/*!
 * jQuery JavaScript Library v1.12.4
 * http://jquery.com/
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2016-05-20T17:17Z
 */

(function( global, factory ) {

	if ( typeof module === "object" && typeof module.exports === "object" ) {
		// For CommonJS and CommonJS-like environments where a proper `window`
		// is present, execute the factory and get jQuery.
		// For environments that do not have a `window` with a `document`
		// (such as Node.js), expose a factory as module.exports.
		// This accentuates the need for the creation of a real `window`.
		// e.g. var jQuery = require("jquery")(window);
		// See ticket #14549 for more info.
		module.exports = global.document ?
			factory( global, true ) :
			function( w ) {
				if ( !w.document ) {
					throw new Error( "jQuery requires a window with a document" );
				}
				return factory( w );
			};
	} else {
		factory( global );
	}

// Pass this if window is not defined yet
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {

// Support: Firefox 18+
// Can't be in strict mode, several libs including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if
// you try to trace through "use strict" call chains. (#13335)
//"use strict";
var deletedIds = [];

var document = window.document;

var slice = deletedIds.slice;

var concat = deletedIds.concat;

var push = deletedIds.push;

var indexOf = deletedIds.indexOf;

var class2type = {};

var toString = class2type.toString;

var hasOwn = class2type.hasOwnProperty;

var support = {};



var
	version = "1.12.4",

	// Define a local copy of jQuery
	jQuery = function( selector, context ) {

		// The jQuery object is actually just the init constructor 'enhanced'
		// Need init if jQuery is called (just allow error to be thrown if not included)
		return new jQuery.fn.init( selector, context );
	},

	// Support: Android<4.1, IE<9
	// Make sure we trim BOM and NBSP
	rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,

	// Matches dashed string for camelizing
	rmsPrefix = /^-ms-/,
	rdashAlpha = /-([\da-z])/gi,

	// Used by jQuery.camelCase as callback to replace()
	fcamelCase = function( all, letter ) {
		return letter.toUpperCase();
	};

jQuery.fn = jQuery.prototype = {

	// The current version of jQuery being used
	jquery: version,

	constructor: jQuery,

	// Start with an empty selector
	selector: "",

	// The default length of a jQuery object is 0
	length: 0,

	toArray: function() {
		return slice.call( this );
	},

	// Get the Nth element in the matched element set OR
	// Get the whole matched element set as a clean array
	get: function( num ) {
		return num != null ?

			// Return just the one element from the set
			( num < 0 ? this[ num + this.length ] : this[ num ] ) :

			// Return all the elements in a clean array
			slice.call( this );
	},

	// Take an array of elements and push it onto the stack
	// (returning the new matched element set)
	pushStack: function( elems ) {

		// Build a new jQuery matched element set
		var ret = jQuery.merge( this.constructor(), elems );

		// Add the old object onto the stack (as a reference)
		ret.prevObject = this;
		ret.context = this.context;

		// Return the newly-formed element set
		return ret;
	},

	// Execute a callback for every element in the matched set.
	each: function( callback ) {
		return jQuery.each( this, callback );
	},

	map: function( callback ) {
		return this.pushStack( jQuery.map( this, function( elem, i ) {
			return callback.call( elem, i, elem );
		} ) );
	},

	slice: function() {
		return this.pushStack( slice.apply( this, arguments ) );
	},

	first: function() {
		return this.eq( 0 );
	},

	last: function() {
		return this.eq( -1 );
	},

	eq: function( i ) {
		var len = this.length,
			j = +i + ( i < 0 ? len : 0 );
		return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
	},

	end: function() {
		return this.prevObject || this.constructor();
	},

	// For internal use only.
	// Behaves like an Array's method, not like a jQuery method.
	push: push,
	sort: deletedIds.sort,
	splice: deletedIds.splice
};

jQuery.extend = jQuery.fn.extend = function() {
	var src, copyIsArray, copy, name, options, clone,
		target = arguments[ 0 ] || {},
		i = 1,
		length = arguments.length,
		deep = false;

	// Handle a deep copy situation
	if ( typeof target === "boolean" ) {
		deep = target;

		// skip the boolean and the target
		target = arguments[ i ] || {};
		i++;
	}

	// Handle case when target is a string or something (possible in deep copy)
	if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
		target = {};
	}

	// extend jQuery itself if only one argument is passed
	if ( i === length ) {
		target = this;
		i--;
	}

	for ( ; i < length; i++ ) {

		// Only deal with non-null/undefined values
		if ( ( options = arguments[ i ] ) != null ) {

			// Extend the base object
			for ( name in options ) {
				src = target[ name ];
				copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy ) {
					continue;
				}

				// Recurse if we're merging plain objects or arrays
				if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
					( copyIsArray = jQuery.isArray( copy ) ) ) ) {

					if ( copyIsArray ) {
						copyIsArray = false;
						clone = src && jQuery.isArray( src ) ? src : [];

					} else {
						clone = src && jQuery.isPlainObject( src ) ? src : {};
					}

					// Never move original objects, clone them
					target[ name ] = jQuery.extend( deep, clone, copy );

				// Don't bring in undefined values
				} else if ( copy !== undefined ) {
					target[ name ] = copy;
				}
			}
		}
	}

	// Return the modified object
	return target;
};

jQuery.extend( {

	// Unique for each copy of jQuery on the page
	expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),

	// Assume jQuery is ready without the ready module
	isReady: true,

	error: function( msg ) {
		throw new Error( msg );
	},

	noop: function() {},

	// See test/unit/core.js for details concerning isFunction.
	// Since version 1.3, DOM methods and functions like alert
	// aren't supported. They return false on IE (#2968).
	isFunction: function( obj ) {
		return jQuery.type( obj ) === "function";
	},

	isArray: Array.isArray || function( obj ) {
		return jQuery.type( obj ) === "array";
	},

	isWindow: function( obj ) {
		/* jshint eqeqeq: false */
		return obj != null && obj == obj.window;
	},

	isNumeric: function( obj ) {

		// parseFloat NaNs numeric-cast false positives (null|true|false|"")
		// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
		// subtraction forces infinities to NaN
		// adding 1 corrects loss of precision from parseFloat (#15100)
		var realStringObj = obj && obj.toString();
		return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
	},

	isEmptyObject: function( obj ) {
		var name;
		for ( name in obj ) {
			return false;
		}
		return true;
	},

	isPlainObject: function( obj ) {
		var key;

		// Must be an Object.
		// Because of IE, we also have to check the presence of the constructor property.
		// Make sure that DOM nodes and window objects don't pass through, as well
		if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
			return false;
		}

		try {

			// Not own constructor property must be Object
			if ( obj.constructor &&
				!hasOwn.call( obj, "constructor" ) &&
				!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
				return false;
			}
		} catch ( e ) {

			// IE8,9 Will throw exceptions on certain host objects #9897
			return false;
		}

		// Support: IE<9
		// Handle iteration over inherited properties before own properties.
		if ( !support.ownFirst ) {
			for ( key in obj ) {
				return hasOwn.call( obj, key );
			}
		}

		// Own properties are enumerated firstly, so to speed up,
		// if last one is own, then all properties are own.
		for ( key in obj ) {}

		return key === undefined || hasOwn.call( obj, key );
	},

	type: function( obj ) {
		if ( obj == null ) {
			return obj + "";
		}
		return typeof obj === "object" || typeof obj === "function" ?
			class2type[ toString.call( obj ) ] || "object" :
			typeof obj;
	},

	// Workarounds based on findings by Jim Driscoll
	// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
	globalEval: function( data ) {
		if ( data && jQuery.trim( data ) ) {

			// We use execScript on Internet Explorer
			// We use an anonymous function so that context is window
			// rather than jQuery in Firefox
			( window.execScript || function( data ) {
				window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
			} )( data );
		}
	},

	// Convert dashed to camelCase; used by the css and data modules
	// Microsoft forgot to hump their vendor prefix (#9572)
	camelCase: function( string ) {
		return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
	},

	nodeName: function( elem, name ) {
		return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
	},

	each: function( obj, callback ) {
		var length, i = 0;

		if ( isArrayLike( obj ) ) {
			length = obj.length;
			for ( ; i < length; i++ ) {
				if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
					break;
				}
			}
		} else {
			for ( i in obj ) {
				if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
					break;
				}
			}
		}

		return obj;
	},

	// Support: Android<4.1, IE<9
	trim: function( text ) {
		return text == null ?
			"" :
			( text + "" ).replace( rtrim, "" );
	},

	// results is for internal usage only
	makeArray: function( arr, results ) {
		var ret = results || [];

		if ( arr != null ) {
			if ( isArrayLike( Object( arr ) ) ) {
				jQuery.merge( ret,
					typeof arr === "string" ?
					[ arr ] : arr
				);
			} else {
				push.call( ret, arr );
			}
		}

		return ret;
	},

	inArray: function( elem, arr, i ) {
		var len;

		if ( arr ) {
			if ( indexOf ) {
				return indexOf.call( arr, elem, i );
			}

			len = arr.length;
			i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;

			for ( ; i < len; i++ ) {

				// Skip accessing in sparse arrays
				if ( i in arr && arr[ i ] === elem ) {
					return i;
				}
			}
		}

		return -1;
	},

	merge: function( first, second ) {
		var len = +second.length,
			j = 0,
			i = first.length;

		while ( j < len ) {
			first[ i++ ] = second[ j++ ];
		}

		// Support: IE<9
		// Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
		if ( len !== len ) {
			while ( second[ j ] !== undefined ) {
				first[ i++ ] = second[ j++ ];
			}
		}

		first.length = i;

		return first;
	},

	grep: function( elems, callback, invert ) {
		var callbackInverse,
			matches = [],
			i = 0,
			length = elems.length,
			callbackExpect = !invert;

		// Go through the array, only saving the items
		// that pass the validator function
		for ( ; i < length; i++ ) {
			callbackInverse = !callback( elems[ i ], i );
			if ( callbackInverse !== callbackExpect ) {
				matches.push( elems[ i ] );
			}
		}

		return matches;
	},

	// arg is for internal usage only
	map: function( elems, callback, arg ) {
		var length, value,
			i = 0,
			ret = [];

		// Go through the array, translating each of the items to their new values
		if ( isArrayLike( elems ) ) {
			length = elems.length;
			for ( ; i < length; i++ ) {
				value = callback( elems[ i ], i, arg );

				if ( value != null ) {
					ret.push( value );
				}
			}

		// Go through every key on the object,
		} else {
			for ( i in elems ) {
				value = callback( elems[ i ], i, arg );

				if ( value != null ) {
					ret.push( value );
				}
			}
		}

		// Flatten any nested arrays
		return concat.apply( [], ret );
	},

	// A global GUID counter for objects
	guid: 1,

	// Bind a function to a context, optionally partially applying any
	// arguments.
	proxy: function( fn, context ) {
		var args, proxy, tmp;

		if ( typeof context === "string" ) {
			tmp = fn[ context ];
			context = fn;
			fn = tmp;
		}

		// Quick check to determine if target is callable, in the spec
		// this throws a TypeError, but we will just return undefined.
		if ( !jQuery.isFunction( fn ) ) {
			return undefined;
		}

		// Simulated bind
		args = slice.call( arguments, 2 );
		proxy = function() {
			return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
		};

		// Set the guid of unique handler to the same of original handler, so it can be removed
		proxy.guid = fn.guid = fn.guid || jQuery.guid++;

		return proxy;
	},

	now: function() {
		return +( new Date() );
	},

	// jQuery.support is not used in Core but other projects attach their
	// properties to it so it needs to exist.
	support: support
} );

// JSHint would error on this code due to the Symbol not being defined in ES5.
// Defining this global in .jshintrc would create a danger of using the global
// unguarded in another place, it seems safer to just disable JSHint for these
// three lines.
/* jshint ignore: start */
if ( typeof Symbol === "function" ) {
	jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
}
/* jshint ignore: end */

// Populate the class2type map
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
function( i, name ) {
	class2type[ "[object " + name + "]" ] = name.toLowerCase();
} );

function isArrayLike( obj ) {

	// Support: iOS 8.2 (not reproducible in simulator)
	// `in` check used to prevent JIT error (gh-2145)
	// hasOwn isn't used here due to false negatives
	// regarding Nodelist length in IE
	var length = !!obj && "length" in obj && obj.length,
		type = jQuery.type( obj );

	if ( type === "function" || jQuery.isWindow( obj ) ) {
		return false;
	}

	return type === "array" || length === 0 ||
		typeof length === "number" && length > 0 && ( length - 1 ) in obj;
}
var Sizzle =
/*!
 * Sizzle CSS Selector Engine v2.2.1
 * http://sizzlejs.com/
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2015-10-17
 */
(function( window ) {

var i,
	support,
	Expr,
	getText,
	isXML,
	tokenize,
	compile,
	select,
	outermostContext,
	sortInput,
	hasDuplicate,

	// Local document vars
	setDocument,
	document,
	docElem,
	documentIsHTML,
	rbuggyQSA,
	rbuggyMatches,
	matches,
	contains,

	// Instance-specific data
	expando = "sizzle" + 1 * new Date(),
	preferredDoc = window.document,
	dirruns = 0,
	done = 0,
	classCache = createCache(),
	tokenCache = createCache(),
	compilerCache = createCache(),
	sortOrder = function( a, b ) {
		if ( a === b ) {
			hasDuplicate = true;
		}
		return 0;
	},

	// General-purpose constants
	MAX_NEGATIVE = 1 << 31,

	// Instance methods
	hasOwn = ({}).hasOwnProperty,
	arr = [],
	pop = arr.pop,
	push_native = arr.push,
	push = arr.push,
	slice = arr.slice,
	// Use a stripped-down indexOf as it's faster than native
	// http://jsperf.com/thor-indexof-vs-for/5
	indexOf = function( list, elem ) {
		var i = 0,
			len = list.length;
		for ( ; i < len; i++ ) {
			if ( list[i] === elem ) {
				return i;
			}
		}
		return -1;
	},

	booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",

	// Regular expressions

	// http://www.w3.org/TR/css3-selectors/#whitespace
	whitespace = "[\\x20\\t\\r\\n\\f]",

	// http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
	identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",

	// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
	attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
		// Operator (capture 2)
		"*([*^$|!~]?=)" + whitespace +
		// "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
		"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
		"*\\]",

	pseudos = ":(" + identifier + ")(?:\\((" +
		// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
		// 1. quoted (capture 3; capture 4 or capture 5)
		"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
		// 2. simple (capture 6)
		"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
		// 3. anything else (capture 2)
		".*" +
		")\\)|)",

	// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
	rwhitespace = new RegExp( whitespace + "+", "g" ),
	rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),

	rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
	rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),

	rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),

	rpseudo = new RegExp( pseudos ),
	ridentifier = new RegExp( "^" + identifier + "$" ),

	matchExpr = {
		"ID": new RegExp( "^#(" + identifier + ")" ),
		"CLASS": new RegExp( "^\\.(" + identifier + ")" ),
		"TAG": new RegExp( "^(" + identifier + "|[*])" ),
		"ATTR": new RegExp( "^" + attributes ),
		"PSEUDO": new RegExp( "^" + pseudos ),
		"CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
			"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
			"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
		"bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
		// For use in libraries implementing .is()
		// We use this for POS matching in `select`
		"needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
			whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
	},

	rinputs = /^(?:input|select|textarea|button)$/i,
	rheader = /^h\d$/i,

	rnative = /^[^{]+\{\s*\[native \w/,

	// Easily-parseable/retrievable ID or TAG or CLASS selectors
	rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,

	rsibling = /[+~]/,
	rescape = /'|\\/g,

	// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
	runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
	funescape = function( _, escaped, escapedWhitespace ) {
		var high = "0x" + escaped - 0x10000;
		// NaN means non-codepoint
		// Support: Firefox<24
		// Workaround erroneous numeric interpretation of +"0x"
		return high !== high || escapedWhitespace ?
			escaped :
			high < 0 ?
				// BMP codepoint
				String.fromCharCode( high + 0x10000 ) :
				// Supplemental Plane codepoint (surrogate pair)
				String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
	},

	// Used for iframes
	// See setDocument()
	// Removing the function wrapper causes a "Permission Denied"
	// error in IE
	unloadHandler = function() {
		setDocument();
	};

// Optimize for push.apply( _, NodeList )
try {
	push.apply(
		(arr = slice.call( preferredDoc.childNodes )),
		preferredDoc.childNodes
	);
	// Support: Android<4.0
	// Detect silently failing push.apply
	arr[ preferredDoc.childNodes.length ].nodeType;
} catch ( e ) {
	push = { apply: arr.length ?

		// Leverage slice if possible
		function( target, els ) {
			push_native.apply( target, slice.call(els) );
		} :

		// Support: IE<9
		// Otherwise append directly
		function( target, els ) {
			var j = target.length,
				i = 0;
			// Can't trust NodeList.length
			while ( (target[j++] = els[i++]) ) {}
			target.length = j - 1;
		}
	};
}

function Sizzle( selector, context, results, seed ) {
	var m, i, elem, nid, nidselect, match, groups, newSelector,
		newContext = context && context.ownerDocument,

		// nodeType defaults to 9, since context defaults to document
		nodeType = context ? context.nodeType : 9;

	results = results || [];

	// Return early from calls with invalid selector or context
	if ( typeof selector !== "string" || !selector ||
		nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {

		return results;
	}

	// Try to shortcut find operations (as opposed to filters) in HTML documents
	if ( !seed ) {

		if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
			setDocument( context );
		}
		context = context || document;

		if ( documentIsHTML ) {

			// If the selector is sufficiently simple, try using a "get*By*" DOM method
			// (excepting DocumentFragment context, where the methods don't exist)
			if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {

				// ID selector
				if ( (m = match[1]) ) {

					// Document context
					if ( nodeType === 9 ) {
						if ( (elem = context.getElementById( m )) ) {

							// Support: IE, Opera, Webkit
							// TODO: identify versions
							// getElementById can match elements by name instead of ID
							if ( elem.id === m ) {
								results.push( elem );
								return results;
							}
						} else {
							return results;
						}

					// Element context
					} else {

						// Support: IE, Opera, Webkit
						// TODO: identify versions
						// getElementById can match elements by name instead of ID
						if ( newContext && (elem = newContext.getElementById( m )) &&
							contains( context, elem ) &&
							elem.id === m ) {

							results.push( elem );
							return results;
						}
					}

				// Type selector
				} else if ( match[2] ) {
					push.apply( results, context.getElementsByTagName( selector ) );
					return results;

				// Class selector
				} else if ( (m = match[3]) && support.getElementsByClassName &&
					context.getElementsByClassName ) {

					push.apply( results, context.getElementsByClassName( m ) );
					return results;
				}
			}

			// Take advantage of querySelectorAll
			if ( support.qsa &&
				!compilerCache[ selector + " " ] &&
				(!rbuggyQSA || !rbuggyQSA.test( selector )) ) {

				if ( nodeType !== 1 ) {
					newContext = context;
					newSelector = selector;

				// qSA looks outside Element context, which is not what we want
				// Thanks to Andrew Dupont for this workaround technique
				// Support: IE <=8
				// Exclude object elements
				} else if ( context.nodeName.toLowerCase() !== "object" ) {

					// Capture the context ID, setting it first if necessary
					if ( (nid = context.getAttribute( "id" )) ) {
						nid = nid.replace( rescape, "\\$&" );
					} else {
						context.setAttribute( "id", (nid = expando) );
					}

					// Prefix every selector in the list
					groups = tokenize( selector );
					i = groups.length;
					nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
					while ( i-- ) {
						groups[i] = nidselect + " " + toSelector( groups[i] );
					}
					newSelector = groups.join( "," );

					// Expand context for sibling selectors
					newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
						context;
				}

				if ( newSelector ) {
					try {
						push.apply( results,
							newContext.querySelectorAll( newSelector )
						);
						return results;
					} catch ( qsaError ) {
					} finally {
						if ( nid === expando ) {
							context.removeAttribute( "id" );
						}
					}
				}
			}
		}
	}

	// All others
	return select( selector.replace( rtrim, "$1" ), context, results, seed );
}

/**
 * Create key-value caches of limited size
 * @returns {function(string, object)} Returns the Object data after storing it on itself with
 *	property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
 *	deleting the oldest entry
 */
function createCache() {
	var keys = [];

	function cache( key, value ) {
		// Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
		if ( keys.push( key + " " ) > Expr.cacheLength ) {
			// Only keep the most recent entries
			delete cache[ keys.shift() ];
		}
		return (cache[ key + " " ] = value);
	}
	return cache;
}

/**
 * Mark a function for special use by Sizzle
 * @param {Function} fn The function to mark
 */
function markFunction( fn ) {
	fn[ expando ] = true;
	return fn;
}

/**
 * Support testing using an element
 * @param {Function} fn Passed the created div and expects a boolean result
 */
function assert( fn ) {
	var div = document.createElement("div");

	try {
		return !!fn( div );
	} catch (e) {
		return false;
	} finally {
		// Remove from its parent by default
		if ( div.parentNode ) {
			div.parentNode.removeChild( div );
		}
		// release memory in IE
		div = null;
	}
}

/**
 * Adds the same handler for all of the specified attrs
 * @param {String} attrs Pipe-separated list of attributes
 * @param {Function} handler The method that will be applied
 */
function addHandle( attrs, handler ) {
	var arr = attrs.split("|"),
		i = arr.length;

	while ( i-- ) {
		Expr.attrHandle[ arr[i] ] = handler;
	}
}

/**
 * Checks document order of two siblings
 * @param {Element} a
 * @param {Element} b
 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
 */
function siblingCheck( a, b ) {
	var cur = b && a,
		diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
			( ~b.sourceIndex || MAX_NEGATIVE ) -
			( ~a.sourceIndex || MAX_NEGATIVE );

	// Use IE sourceIndex if available on both nodes
	if ( diff ) {
		return diff;
	}

	// Check if b follows a
	if ( cur ) {
		while ( (cur = cur.nextSibling) ) {
			if ( cur === b ) {
				return -1;
			}
		}
	}

	return a ? 1 : -1;
}

/**
 * Returns a function to use in pseudos for input types
 * @param {String} type
 */
function createInputPseudo( type ) {
	return function( elem ) {
		var name = elem.nodeName.toLowerCase();
		return name === "input" && elem.type === type;
	};
}

/**
 * Returns a function to use in pseudos for buttons
 * @param {String} type
 */
function createButtonPseudo( type ) {
	return function( elem ) {
		var name = elem.nodeName.toLowerCase();
		return (name === "input" || name === "button") && elem.type === type;
	};
}

/**
 * Returns a function to use in pseudos for positionals
 * @param {Function} fn
 */
function createPositionalPseudo( fn ) {
	return markFunction(function( argument ) {
		argument = +argument;
		return markFunction(function( seed, matches ) {
			var j,
				matchIndexes = fn( [], seed.length, argument ),
				i = matchIndexes.length;

			// Match elements found at the specified indexes
			while ( i-- ) {
				if ( seed[ (j = matchIndexes[i]) ] ) {
					seed[j] = !(matches[j] = seed[j]);
				}
			}
		});
	});
}

/**
 * Checks a node for validity as a Sizzle context
 * @param {Element|Object=} context
 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
 */
function testContext( context ) {
	return context && typeof context.getElementsByTagName !== "undefined" && context;
}

// Expose support vars for convenience
support = Sizzle.support = {};

/**
 * Detects XML nodes
 * @param {Element|Object} elem An element or a document
 * @returns {Boolean} True iff elem is a non-HTML XML node
 */
isXML = Sizzle.isXML = function( elem ) {
	// documentElement is verified for cases where it doesn't yet exist
	// (such as loading iframes in IE - #4833)
	var documentElement = elem && (elem.ownerDocument || elem).documentElement;
	return documentElement ? documentElement.nodeName !== "HTML" : false;
};

/**
 * Sets document-related variables once based on the current document
 * @param {Element|Object} [doc] An element or document object to use to set the document
 * @returns {Object} Returns the current document
 */
setDocument = Sizzle.setDocument = function( node ) {
	var hasCompare, parent,
		doc = node ? node.ownerDocument || node : preferredDoc;

	// Return early if doc is invalid or already selected
	if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
		return document;
	}

	// Update global variables
	document = doc;
	docElem = document.documentElement;
	documentIsHTML = !isXML( document );

	// Support: IE 9-11, Edge
	// Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
	if ( (parent = document.defaultView) && parent.top !== parent ) {
		// Support: IE 11
		if ( parent.addEventListener ) {
			parent.addEventListener( "unload", unloadHandler, false );

		// Support: IE 9 - 10 only
		} else if ( parent.attachEvent ) {
			parent.attachEvent( "onunload", unloadHandler );
		}
	}

	/* Attributes
	---------------------------------------------------------------------- */

	// Support: IE<8
	// Verify that getAttribute really returns attributes and not properties
	// (excepting IE8 booleans)
	support.attributes = assert(function( div ) {
		div.className = "i";
		return !div.getAttribute("className");
	});

	/* getElement(s)By*
	---------------------------------------------------------------------- */

	// Check if getElementsByTagName("*") returns only elements
	support.getElementsByTagName = assert(function( div ) {
		div.appendChild( document.createComment("") );
		return !div.getElementsByTagName("*").length;
	});

	// Support: IE<9
	support.getElementsByClassName = rnative.test( document.getElementsByClassName );

	// Support: IE<10
	// Check if getElementById returns elements by name
	// The broken getElementById methods don't pick up programatically-set names,
	// so use a roundabout getElementsByName test
	support.getById = assert(function( div ) {
		docElem.appendChild( div ).id = expando;
		return !document.getElementsByName || !document.getElementsByName( expando ).length;
	});

	// ID find and filter
	if ( support.getById ) {
		Expr.find["ID"] = function( id, context ) {
			if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
				var m = context.getElementById( id );
				return m ? [ m ] : [];
			}
		};
		Expr.filter["ID"] = function( id ) {
			var attrId = id.replace( runescape, funescape );
			return function( elem ) {
				return elem.getAttribute("id") === attrId;
			};
		};
	} else {
		// Support: IE6/7
		// getElementById is not reliable as a find shortcut
		delete Expr.find["ID"];

		Expr.filter["ID"] =  function( id ) {
			var attrId = id.replace( runescape, funescape );
			return function( elem ) {
				var node = typeof elem.getAttributeNode !== "undefined" &&
					elem.getAttributeNode("id");
				return node && node.value === attrId;
			};
		};
	}

	// Tag
	Expr.find["TAG"] = support.getElementsByTagName ?
		function( tag, context ) {
			if ( typeof context.getElementsByTagName !== "undefined" ) {
				return context.getElementsByTagName( tag );

			// DocumentFragment nodes don't have gEBTN
			} else if ( support.qsa ) {
				return context.querySelectorAll( tag );
			}
		} :

		function( tag, context ) {
			var elem,
				tmp = [],
				i = 0,
				// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
				results = context.getElementsByTagName( tag );

			// Filter out possible comments
			if ( tag === "*" ) {
				while ( (elem = results[i++]) ) {
					if ( elem.nodeType === 1 ) {
						tmp.push( elem );
					}
				}

				return tmp;
			}
			return results;
		};

	// Class
	Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
		if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
			return context.getElementsByClassName( className );
		}
	};

	/* QSA/matchesSelector
	---------------------------------------------------------------------- */

	// QSA and matchesSelector support

	// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
	rbuggyMatches = [];

	// qSa(:focus) reports false when true (Chrome 21)
	// We allow this because of a bug in IE8/9 that throws an error
	// whenever `document.activeElement` is accessed on an iframe
	// So, we allow :focus to pass through QSA all the time to avoid the IE error
	// See http://bugs.jquery.com/ticket/13378
	rbuggyQSA = [];

	if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
		// Build QSA regex
		// Regex strategy adopted from Diego Perini
		assert(function( div ) {
			// Select is set to empty string on purpose
			// This is to test IE's treatment of not explicitly
			// setting a boolean content attribute,
			// since its presence should be enough
			// http://bugs.jquery.com/ticket/12359
			docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
				"<select id='" + expando + "-\r\\' msallowcapture=''>" +
				"<option selected=''></option></select>";

			// Support: IE8, Opera 11-12.16
			// Nothing should be selected when empty strings follow ^= or $= or *=
			// The test attribute must be unknown in Opera but "safe" for WinRT
			// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
			if ( div.querySelectorAll("[msallowcapture^='']").length ) {
				rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
			}

			// Support: IE8
			// Boolean attributes and "value" are not treated correctly
			if ( !div.querySelectorAll("[selected]").length ) {
				rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
			}

			// Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
			if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
				rbuggyQSA.push("~=");
			}

			// Webkit/Opera - :checked should return selected option elements
			// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
			// IE8 throws error here and will not see later tests
			if ( !div.querySelectorAll(":checked").length ) {
				rbuggyQSA.push(":checked");
			}

			// Support: Safari 8+, iOS 8+
			// https://bugs.webkit.org/show_bug.cgi?id=136851
			// In-page `selector#id sibing-combinator selector` fails
			if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
				rbuggyQSA.push(".#.+[+~]");
			}
		});

		assert(function( div ) {
			// Support: Windows 8 Native Apps
			// The type and name attributes are restricted during .innerHTML assignment
			var input = document.createElement("input");
			input.setAttribute( "type", "hidden" );
			div.appendChild( input ).setAttribute( "name", "D" );

			// Support: IE8
			// Enforce case-sensitivity of name attribute
			if ( div.querySelectorAll("[name=d]").length ) {
				rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
			}

			// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
			// IE8 throws error here and will not see later tests
			if ( !div.querySelectorAll(":enabled").length ) {
				rbuggyQSA.push( ":enabled", ":disabled" );
			}

			// Opera 10-11 does not throw on post-comma invalid pseudos
			div.querySelectorAll("*,:x");
			rbuggyQSA.push(",.*:");
		});
	}

	if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
		docElem.webkitMatchesSelector ||
		docElem.mozMatchesSelector ||
		docElem.oMatchesSelector ||
		docElem.msMatchesSelector) )) ) {

		assert(function( div ) {
			// Check to see if it's possible to do matchesSelector
			// on a disconnected node (IE 9)
			support.disconnectedMatch = matches.call( div, "div" );

			// This should fail with an exception
			// Gecko does not error, returns false instead
			matches.call( div, "[s!='']:x" );
			rbuggyMatches.push( "!=", pseudos );
		});
	}

	rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
	rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );

	/* Contains
	---------------------------------------------------------------------- */
	hasCompare = rnative.test( docElem.compareDocumentPosition );

	// Element contains another
	// Purposefully self-exclusive
	// As in, an element does not contain itself
	contains = hasCompare || rnative.test( docElem.contains ) ?
		function( a, b ) {
			var adown = a.nodeType === 9 ? a.documentElement : a,
				bup = b && b.parentNode;
			return a === bup || !!( bup && bup.nodeType === 1 && (
				adown.contains ?
					adown.contains( bup ) :
					a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
			));
		} :
		function( a, b ) {
			if ( b ) {
				while ( (b = b.parentNode) ) {
					if ( b === a ) {
						return true;
					}
				}
			}
			return false;
		};

	/* Sorting
	---------------------------------------------------------------------- */

	// Document order sorting
	sortOrder = hasCompare ?
	function( a, b ) {

		// Flag for duplicate removal
		if ( a === b ) {
			hasDuplicate = true;
			return 0;
		}

		// Sort on method existence if only one input has compareDocumentPosition
		var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
		if ( compare ) {
			return compare;
		}

		// Calculate position if both inputs belong to the same document
		compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
			a.compareDocumentPosition( b ) :

			// Otherwise we know they are disconnected
			1;

		// Disconnected nodes
		if ( compare & 1 ||
			(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {

			// Choose the first element that is related to our preferred document
			if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
				return -1;
			}
			if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
				return 1;
			}

			// Maintain original order
			return sortInput ?
				( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
				0;
		}

		return compare & 4 ? -1 : 1;
	} :
	function( a, b ) {
		// Exit early if the nodes are identical
		if ( a === b ) {
			hasDuplicate = true;
			return 0;
		}

		var cur,
			i = 0,
			aup = a.parentNode,
			bup = b.parentNode,
			ap = [ a ],
			bp = [ b ];

		// Parentless nodes are either documents or disconnected
		if ( !aup || !bup ) {
			return a === document ? -1 :
				b === document ? 1 :
				aup ? -1 :
				bup ? 1 :
				sortInput ?
				( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
				0;

		// If the nodes are siblings, we can do a quick check
		} else if ( aup === bup ) {
			return siblingCheck( a, b );
		}

		// Otherwise we need full lists of their ancestors for comparison
		cur = a;
		while ( (cur = cur.parentNode) ) {
			ap.unshift( cur );
		}
		cur = b;
		while ( (cur = cur.parentNode) ) {
			bp.unshift( cur );
		}

		// Walk down the tree looking for a discrepancy
		while ( ap[i] === bp[i] ) {
			i++;
		}

		return i ?
			// Do a sibling check if the nodes have a common ancestor
			siblingCheck( ap[i], bp[i] ) :

			// Otherwise nodes in our document sort first
			ap[i] === preferredDoc ? -1 :
			bp[i] === preferredDoc ? 1 :
			0;
	};

	return document;
};

Sizzle.matches = function( expr, elements ) {
	return Sizzle( expr, null, null, elements );
};

Sizzle.matchesSelector = function( elem, expr ) {
	// Set document vars if needed
	if ( ( elem.ownerDocument || elem ) !== document ) {
		setDocument( elem );
	}

	// Make sure that attribute selectors are quoted
	expr = expr.replace( rattributeQuotes, "='$1']" );

	if ( support.matchesSelector && documentIsHTML &&
		!compilerCache[ expr + " " ] &&
		( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
		( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {

		try {
			var ret = matches.call( elem, expr );

			// IE 9's matchesSelector returns false on disconnected nodes
			if ( ret || support.disconnectedMatch ||
					// As well, disconnected nodes are said to be in a document
					// fragment in IE 9
					elem.document && elem.document.nodeType !== 11 ) {
				return ret;
			}
		} catch (e) {}
	}

	return Sizzle( expr, document, null, [ elem ] ).length > 0;
};

Sizzle.contains = function( context, elem ) {
	// Set document vars if needed
	if ( ( context.ownerDocument || context ) !== document ) {
		setDocument( context );
	}
	return contains( context, elem );
};

Sizzle.attr = function( elem, name ) {
	// Set document vars if needed
	if ( ( elem.ownerDocument || elem ) !== document ) {
		setDocument( elem );
	}

	var fn = Expr.attrHandle[ name.toLowerCase() ],
		// Don't get fooled by Object.prototype properties (jQuery #13807)
		val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
			fn( elem, name, !documentIsHTML ) :
			undefined;

	return val !== undefined ?
		val :
		support.attributes || !documentIsHTML ?
			elem.getAttribute( name ) :
			(val = elem.getAttributeNode(name)) && val.specified ?
				val.value :
				null;
};

Sizzle.error = function( msg ) {
	throw new Error( "Syntax error, unrecognized expression: " + msg );
};

/**
 * Document sorting and removing duplicates
 * @param {ArrayLike} results
 */
Sizzle.uniqueSort = function( results ) {
	var elem,
		duplicates = [],
		j = 0,
		i = 0;

	// Unless we *know* we can detect duplicates, assume their presence
	hasDuplicate = !support.detectDuplicates;
	sortInput = !support.sortStable && results.slice( 0 );
	results.sort( sortOrder );

	if ( hasDuplicate ) {
		while ( (elem = results[i++]) ) {
			if ( elem === results[ i ] ) {
				j = duplicates.push( i );
			}
		}
		while ( j-- ) {
			results.splice( duplicates[ j ], 1 );
		}
	}

	// Clear input after sorting to release objects
	// See https://github.com/jquery/sizzle/pull/225
	sortInput = null;

	return results;
};

/**
 * Utility function for retrieving the text value of an array of DOM nodes
 * @param {Array|Element} elem
 */
getText = Sizzle.getText = function( elem ) {
	var node,
		ret = "",
		i = 0,
		nodeType = elem.nodeType;

	if ( !nodeType ) {
		// If no nodeType, this is expected to be an array
		while ( (node = elem[i++]) ) {
			// Do not traverse comment nodes
			ret += getText( node );
		}
	} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
		// Use textContent for elements
		// innerText usage removed for consistency of new lines (jQuery #11153)
		if ( typeof elem.textContent === "string" ) {
			return elem.textContent;
		} else {
			// Traverse its children
			for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
				ret += getText( elem );
			}
		}
	} else if ( nodeType === 3 || nodeType === 4 ) {
		return elem.nodeValue;
	}
	// Do not include comment or processing instruction nodes

	return ret;
};

Expr = Sizzle.selectors = {

	// Can be adjusted by the user
	cacheLength: 50,

	createPseudo: markFunction,

	match: matchExpr,

	attrHandle: {},

	find: {},

	relative: {
		">": { dir: "parentNode", first: true },
		" ": { dir: "parentNode" },
		"+": { dir: "previousSibling", first: true },
		"~": { dir: "previousSibling" }
	},

	preFilter: {
		"ATTR": function( match ) {
			match[1] = match[1].replace( runescape, funescape );

			// Move the given value to match[3] whether quoted or unquoted
			match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );

			if ( match[2] === "~=" ) {
				match[3] = " " + match[3] + " ";
			}

			return match.slice( 0, 4 );
		},

		"CHILD": function( match ) {
			/* matches from matchExpr["CHILD"]
				1 type (only|nth|...)
				2 what (child|of-type)
				3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
				4 xn-component of xn+y argument ([+-]?\d*n|)
				5 sign of xn-component
				6 x of xn-component
				7 sign of y-component
				8 y of y-component
			*/
			match[1] = match[1].toLowerCase();

			if ( match[1].slice( 0, 3 ) === "nth" ) {
				// nth-* requires argument
				if ( !match[3] ) {
					Sizzle.error( match[0] );
				}

				// numeric x and y parameters for Expr.filter.CHILD
				// remember that false/true cast respectively to 0/1
				match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
				match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );

			// other types prohibit arguments
			} else if ( match[3] ) {
				Sizzle.error( match[0] );
			}

			return match;
		},

		"PSEUDO": function( match ) {
			var excess,
				unquoted = !match[6] && match[2];

			if ( matchExpr["CHILD"].test( match[0] ) ) {
				return null;
			}

			// Accept quoted arguments as-is
			if ( match[3] ) {
				match[2] = match[4] || match[5] || "";

			// Strip excess characters from unquoted arguments
			} else if ( unquoted && rpseudo.test( unquoted ) &&
				// Get excess from tokenize (recursively)
				(excess = tokenize( unquoted, true )) &&
				// advance to the next closing parenthesis
				(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {

				// excess is a negative index
				match[0] = match[0].slice( 0, excess );
				match[2] = unquoted.slice( 0, excess );
			}

			// Return only captures needed by the pseudo filter method (type and argument)
			return match.slice( 0, 3 );
		}
	},

	filter: {

		"TAG": function( nodeNameSelector ) {
			var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
			return nodeNameSelector === "*" ?
				function() { return true; } :
				function( elem ) {
					return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
				};
		},

		"CLASS": function( className ) {
			var pattern = classCache[ className + " " ];

			return pattern ||
				(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
				classCache( className, function( elem ) {
					return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
				});
		},

		"ATTR": function( name, operator, check ) {
			return function( elem ) {
				var result = Sizzle.attr( elem, name );

				if ( result == null ) {
					return operator === "!=";
				}
				if ( !operator ) {
					return true;
				}

				result += "";

				return operator === "=" ? result === check :
					operator === "!=" ? result !== check :
					operator === "^=" ? check && result.indexOf( check ) === 0 :
					operator === "*=" ? check && result.indexOf( check ) > -1 :
					operator === "$=" ? check && result.slice( -check.length ) === check :
					operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
					operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
					false;
			};
		},

		"CHILD": function( type, what, argument, first, last ) {
			var simple = type.slice( 0, 3 ) !== "nth",
				forward = type.slice( -4 ) !== "last",
				ofType = what === "of-type";

			return first === 1 && last === 0 ?

				// Shortcut for :nth-*(n)
				function( elem ) {
					return !!elem.parentNode;
				} :

				function( elem, context, xml ) {
					var cache, uniqueCache, outerCache, node, nodeIndex, start,
						dir = simple !== forward ? "nextSibling" : "previousSibling",
						parent = elem.parentNode,
						name = ofType && elem.nodeName.toLowerCase(),
						useCache = !xml && !ofType,
						diff = false;

					if ( parent ) {

						// :(first|last|only)-(child|of-type)
						if ( simple ) {
							while ( dir ) {
								node = elem;
								while ( (node = node[ dir ]) ) {
									if ( ofType ?
										node.nodeName.toLowerCase() === name :
										node.nodeType === 1 ) {

										return false;
									}
								}
								// Reverse direction for :only-* (if we haven't yet done so)
								start = dir = type === "only" && !start && "nextSibling";
							}
							return true;
						}

						start = [ forward ? parent.firstChild : parent.lastChild ];

						// non-xml :nth-child(...) stores cache data on `parent`
						if ( forward && useCache ) {

							// Seek `elem` from a previously-cached index

							// ...in a gzip-friendly way
							node = parent;
							outerCache = node[ expando ] || (node[ expando ] = {});

							// Support: IE <9 only
							// Defend against cloned attroperties (jQuery gh-1709)
							uniqueCache = outerCache[ node.uniqueID ] ||
								(outerCache[ node.uniqueID ] = {});

							cache = uniqueCache[ type ] || [];
							nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
							diff = nodeIndex && cache[ 2 ];
							node = nodeIndex && parent.childNodes[ nodeIndex ];

							while ( (node = ++nodeIndex && node && node[ dir ] ||

								// Fallback to seeking `elem` from the start
								(diff = nodeIndex = 0) || start.pop()) ) {

								// When found, cache indexes on `parent` and break
								if ( node.nodeType === 1 && ++diff && node === elem ) {
									uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
									break;
								}
							}

						} else {
							// Use previously-cached element index if available
							if ( useCache ) {
								// ...in a gzip-friendly way
								node = elem;
								outerCache = node[ expando ] || (node[ expando ] = {});

								// Support: IE <9 only
								// Defend against cloned attroperties (jQuery gh-1709)
								uniqueCache = outerCache[ node.uniqueID ] ||
									(outerCache[ node.uniqueID ] = {});

								cache = uniqueCache[ type ] || [];
								nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
								diff = nodeIndex;
							}

							// xml :nth-child(...)
							// or :nth-last-child(...) or :nth(-last)?-of-type(...)
							if ( diff === false ) {
								// Use the same loop as above to seek `elem` from the start
								while ( (node = ++nodeIndex && node && node[ dir ] ||
									(diff = nodeIndex = 0) || start.pop()) ) {

									if ( ( ofType ?
										node.nodeName.toLowerCase() === name :
										node.nodeType === 1 ) &&
										++diff ) {

										// Cache the index of each encountered element
										if ( useCache ) {
											outerCache = node[ expando ] || (node[ expando ] = {});

											// Support: IE <9 only
											// Defend against cloned attroperties (jQuery gh-1709)
											uniqueCache = outerCache[ node.uniqueID ] ||
												(outerCache[ node.uniqueID ] = {});

											uniqueCache[ type ] = [ dirruns, diff ];
										}

										if ( node === elem ) {
											break;
										}
									}
								}
							}
						}

						// Incorporate the offset, then check against cycle size
						diff -= last;
						return diff === first || ( diff % first === 0 && diff / first >= 0 );
					}
				};
		},

		"PSEUDO": function( pseudo, argument ) {
			// pseudo-class names are case-insensitive
			// http://www.w3.org/TR/selectors/#pseudo-classes
			// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
			// Remember that setFilters inherits from pseudos
			var args,
				fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
					Sizzle.error( "unsupported pseudo: " + pseudo );

			// The user may use createPseudo to indicate that
			// arguments are needed to create the filter function
			// just as Sizzle does
			if ( fn[ expando ] ) {
				return fn( argument );
			}

			// But maintain support for old signatures
			if ( fn.length > 1 ) {
				args = [ pseudo, pseudo, "", argument ];
				return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
					markFunction(function( seed, matches ) {
						var idx,
							matched = fn( seed, argument ),
							i = matched.length;
						while ( i-- ) {
							idx = indexOf( seed, matched[i] );
							seed[ idx ] = !( matches[ idx ] = matched[i] );
						}
					}) :
					function( elem ) {
						return fn( elem, 0, args );
					};
			}

			return fn;
		}
	},

	pseudos: {
		// Potentially complex pseudos
		"not": markFunction(function( selector ) {
			// Trim the selector passed to compile
			// to avoid treating leading and trailing
			// spaces as combinators
			var input = [],
				results = [],
				matcher = compile( selector.replace( rtrim, "$1" ) );

			return matcher[ expando ] ?
				markFunction(function( seed, matches, context, xml ) {
					var elem,
						unmatched = matcher( seed, null, xml, [] ),
						i = seed.length;

					// Match elements unmatched by `matcher`
					while ( i-- ) {
						if ( (elem = unmatched[i]) ) {
							seed[i] = !(matches[i] = elem);
						}
					}
				}) :
				function( elem, context, xml ) {
					input[0] = elem;
					matcher( input, null, xml, results );
					// Don't keep the element (issue #299)
					input[0] = null;
					return !results.pop();
				};
		}),

		"has": markFunction(function( selector ) {
			return function( elem ) {
				return Sizzle( selector, elem ).length > 0;
			};
		}),

		"contains": markFunction(function( text ) {
			text = text.replace( runescape, funescape );
			return function( elem ) {
				return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
			};
		}),

		// "Whether an element is represented by a :lang() selector
		// is based solely on the element's language value
		// being equal to the identifier C,
		// or beginning with the identifier C immediately followed by "-".
		// The matching of C against the element's language value is performed case-insensitively.
		// The identifier C does not have to be a valid language name."
		// http://www.w3.org/TR/selectors/#lang-pseudo
		"lang": markFunction( function( lang ) {
			// lang value must be a valid identifier
			if ( !ridentifier.test(lang || "") ) {
				Sizzle.error( "unsupported lang: " + lang );
			}
			lang = lang.replace( runescape, funescape ).toLowerCase();
			return function( elem ) {
				var elemLang;
				do {
					if ( (elemLang = documentIsHTML ?
						elem.lang :
						elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {

						elemLang = elemLang.toLowerCase();
						return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
					}
				} while ( (elem = elem.parentNode) && elem.nodeType === 1 );
				return false;
			};
		}),

		// Miscellaneous
		"target": function( elem ) {
			var hash = window.location && window.location.hash;
			return hash && hash.slice( 1 ) === elem.id;
		},

		"root": function( elem ) {
			return elem === docElem;
		},

		"focus": function( elem ) {
			return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
		},

		// Boolean properties
		"enabled": function( elem ) {
			return elem.disabled === false;
		},

		"disabled": function( elem ) {
			return elem.disabled === true;
		},

		"checked": function( elem ) {
			// In CSS3, :checked should return both checked and selected elements
			// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
			var nodeName = elem.nodeName.toLowerCase();
			return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
		},

		"selected": function( elem ) {
			// Accessing this property makes selected-by-default
			// options in Safari work properly
			if ( elem.parentNode ) {
				elem.parentNode.selectedIndex;
			}

			return elem.selected === true;
		},

		// Contents
		"empty": function( elem ) {
			// http://www.w3.org/TR/selectors/#empty-pseudo
			// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
			//   but not by others (comment: 8; processing instruction: 7; etc.)
			// nodeType < 6 works because attributes (2) do not appear as children
			for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
				if ( elem.nodeType < 6 ) {
					return false;
				}
			}
			return true;
		},

		"parent": function( elem ) {
			return !Expr.pseudos["empty"]( elem );
		},

		// Element/input types
		"header": function( elem ) {
			return rheader.test( elem.nodeName );
		},

		"input": function( elem ) {
			return rinputs.test( elem.nodeName );
		},

		"button": function( elem ) {
			var name = elem.nodeName.toLowerCase();
			return name === "input" && elem.type === "button" || name === "button";
		},

		"text": function( elem ) {
			var attr;
			return elem.nodeName.toLowerCase() === "input" &&
				elem.type === "text" &&

				// Support: IE<8
				// New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
				( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
		},

		// Position-in-collection
		"first": createPositionalPseudo(function() {
			return [ 0 ];
		}),

		"last": createPositionalPseudo(function( matchIndexes, length ) {
			return [ length - 1 ];
		}),

		"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
			return [ argument < 0 ? argument + length : argument ];
		}),

		"even": createPositionalPseudo(function( matchIndexes, length ) {
			var i = 0;
			for ( ; i < length; i += 2 ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		}),

		"odd": createPositionalPseudo(function( matchIndexes, length ) {
			var i = 1;
			for ( ; i < length; i += 2 ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		}),

		"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
			var i = argument < 0 ? argument + length : argument;
			for ( ; --i >= 0; ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		}),

		"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
			var i = argument < 0 ? argument + length : argument;
			for ( ; ++i < length; ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		})
	}
};

Expr.pseudos["nth"] = Expr.pseudos["eq"];

// Add button/input type pseudos
for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
	Expr.pseudos[ i ] = createInputPseudo( i );
}
for ( i in { submit: true, reset: true } ) {
	Expr.pseudos[ i ] = createButtonPseudo( i );
}

// Easy API for creating new setFilters
function setFilters() {}
setFilters.prototype = Expr.filters = Expr.pseudos;
Expr.setFilters = new setFilters();

tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
	var matched, match, tokens, type,
		soFar, groups, preFilters,
		cached = tokenCache[ selector + " " ];

	if ( cached ) {
		return parseOnly ? 0 : cached.slice( 0 );
	}

	soFar = selector;
	groups = [];
	preFilters = Expr.preFilter;

	while ( soFar ) {

		// Comma and first run
		if ( !matched || (match = rcomma.exec( soFar )) ) {
			if ( match ) {
				// Don't consume trailing commas as valid
				soFar = soFar.slice( match[0].length ) || soFar;
			}
			groups.push( (tokens = []) );
		}

		matched = false;

		// Combinators
		if ( (match = rcombinators.exec( soFar )) ) {
			matched = match.shift();
			tokens.push({
				value: matched,
				// Cast descendant combinators to space
				type: match[0].replace( rtrim, " " )
			});
			soFar = soFar.slice( matched.length );
		}

		// Filters
		for ( type in Expr.filter ) {
			if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
				(match = preFilters[ type ]( match ))) ) {
				matched = match.shift();
				tokens.push({
					value: matched,
					type: type,
					matches: match
				});
				soFar = soFar.slice( matched.length );
			}
		}

		if ( !matched ) {
			break;
		}
	}

	// Return the length of the invalid excess
	// if we're just parsing
	// Otherwise, throw an error or return tokens
	return parseOnly ?
		soFar.length :
		soFar ?
			Sizzle.error( selector ) :
			// Cache the tokens
			tokenCache( selector, groups ).slice( 0 );
};

function toSelector( tokens ) {
	var i = 0,
		len = tokens.length,
		selector = "";
	for ( ; i < len; i++ ) {
		selector += tokens[i].value;
	}
	return selector;
}

function addCombinator( matcher, combinator, base ) {
	var dir = combinator.dir,
		checkNonElements = base && dir === "parentNode",
		doneName = done++;

	return combinator.first ?
		// Check against closest ancestor/preceding element
		function( elem, context, xml ) {
			while ( (elem = elem[ dir ]) ) {
				if ( elem.nodeType === 1 || checkNonElements ) {
					return matcher( elem, context, xml );
				}
			}
		} :

		// Check against all ancestor/preceding elements
		function( elem, context, xml ) {
			var oldCache, uniqueCache, outerCache,
				newCache = [ dirruns, doneName ];

			// We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
			if ( xml ) {
				while ( (elem = elem[ dir ]) ) {
					if ( elem.nodeType === 1 || checkNonElements ) {
						if ( matcher( elem, context, xml ) ) {
							return true;
						}
					}
				}
			} else {
				while ( (elem = elem[ dir ]) ) {
					if ( elem.nodeType === 1 || checkNonElements ) {
						outerCache = elem[ expando ] || (elem[ expando ] = {});

						// Support: IE <9 only
						// Defend against cloned attroperties (jQuery gh-1709)
						uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});

						if ( (oldCache = uniqueCache[ dir ]) &&
							oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {

							// Assign to newCache so results back-propagate to previous elements
							return (newCache[ 2 ] = oldCache[ 2 ]);
						} else {
							// Reuse newcache so results back-propagate to previous elements
							uniqueCache[ dir ] = newCache;

							// A match means we're done; a fail means we have to keep checking
							if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
								return true;
							}
						}
					}
				}
			}
		};
}

function elementMatcher( matchers ) {
	return matchers.length > 1 ?
		function( elem, context, xml ) {
			var i = matchers.length;
			while ( i-- ) {
				if ( !matchers[i]( elem, context, xml ) ) {
					return false;
				}
			}
			return true;
		} :
		matchers[0];
}

function multipleContexts( selector, contexts, results ) {
	var i = 0,
		len = contexts.length;
	for ( ; i < len; i++ ) {
		Sizzle( selector, contexts[i], results );
	}
	return results;
}

function condense( unmatched, map, filter, context, xml ) {
	var elem,
		newUnmatched = [],
		i = 0,
		len = unmatched.length,
		mapped = map != null;

	for ( ; i < len; i++ ) {
		if ( (elem = unmatched[i]) ) {
			if ( !filter || filter( elem, context, xml ) ) {
				newUnmatched.push( elem );
				if ( mapped ) {
					map.push( i );
				}
			}
		}
	}

	return newUnmatched;
}

function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
	if ( postFilter && !postFilter[ expando ] ) {
		postFilter = setMatcher( postFilter );
	}
	if ( postFinder && !postFinder[ expando ] ) {
		postFinder = setMatcher( postFinder, postSelector );
	}
	return markFunction(function( seed, results, context, xml ) {
		var temp, i, elem,
			preMap = [],
			postMap = [],
			preexisting = results.length,

			// Get initial elements from seed or context
			elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),

			// Prefilter to get matcher input, preserving a map for seed-results synchronization
			matcherIn = preFilter && ( seed || !selector ) ?
				condense( elems, preMap, preFilter, context, xml ) :
				elems,

			matcherOut = matcher ?
				// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
				postFinder || ( seed ? preFilter : preexisting || postFilter ) ?

					// ...intermediate processing is necessary
					[] :

					// ...otherwise use results directly
					results :
				matcherIn;

		// Find primary matches
		if ( matcher ) {
			matcher( matcherIn, matcherOut, context, xml );
		}

		// Apply postFilter
		if ( postFilter ) {
			temp = condense( matcherOut, postMap );
			postFilter( temp, [], context, xml );

			// Un-match failing elements by moving them back to matcherIn
			i = temp.length;
			while ( i-- ) {
				if ( (elem = temp[i]) ) {
					matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
				}
			}
		}

		if ( seed ) {
			if ( postFinder || preFilter ) {
				if ( postFinder ) {
					// Get the final matcherOut by condensing this intermediate into postFinder contexts
					temp = [];
					i = matcherOut.length;
					while ( i-- ) {
						if ( (elem = matcherOut[i]) ) {
							// Restore matcherIn since elem is not yet a final match
							temp.push( (matcherIn[i] = elem) );
						}
					}
					postFinder( null, (matcherOut = []), temp, xml );
				}

				// Move matched elements from seed to results to keep them synchronized
				i = matcherOut.length;
				while ( i-- ) {
					if ( (elem = matcherOut[i]) &&
						(temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {

						seed[temp] = !(results[temp] = elem);
					}
				}
			}

		// Add elements to results, through postFinder if defined
		} else {
			matcherOut = condense(
				matcherOut === results ?
					matcherOut.splice( preexisting, matcherOut.length ) :
					matcherOut
			);
			if ( postFinder ) {
				postFinder( null, results, matcherOut, xml );
			} else {
				push.apply( results, matcherOut );
			}
		}
	});
}

function matcherFromTokens( tokens ) {
	var checkContext, matcher, j,
		len = tokens.length,
		leadingRelative = Expr.relative[ tokens[0].type ],
		implicitRelative = leadingRelative || Expr.relative[" "],
		i = leadingRelative ? 1 : 0,

		// The foundational matcher ensures that elements are reachable from top-level context(s)
		matchContext = addCombinator( function( elem ) {
			return elem === checkContext;
		}, implicitRelative, true ),
		matchAnyContext = addCombinator( function( elem ) {
			return indexOf( checkContext, elem ) > -1;
		}, implicitRelative, true ),
		matchers = [ function( elem, context, xml ) {
			var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
				(checkContext = context).nodeType ?
					matchContext( elem, context, xml ) :
					matchAnyContext( elem, context, xml ) );
			// Avoid hanging onto element (issue #299)
			checkContext = null;
			return ret;
		} ];

	for ( ; i < len; i++ ) {
		if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
			matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
		} else {
			matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );

			// Return special upon seeing a positional matcher
			if ( matcher[ expando ] ) {
				// Find the next relative operator (if any) for proper handling
				j = ++i;
				for ( ; j < len; j++ ) {
					if ( Expr.relative[ tokens[j].type ] ) {
						break;
					}
				}
				return setMatcher(
					i > 1 && elementMatcher( matchers ),
					i > 1 && toSelector(
						// If the preceding token was a descendant combinator, insert an implicit any-element `*`
						tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
					).replace( rtrim, "$1" ),
					matcher,
					i < j && matcherFromTokens( tokens.slice( i, j ) ),
					j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
					j < len && toSelector( tokens )
				);
			}
			matchers.push( matcher );
		}
	}

	return elementMatcher( matchers );
}

function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
	var bySet = setMatchers.length > 0,
		byElement = elementMatchers.length > 0,
		superMatcher = function( seed, context, xml, results, outermost ) {
			var elem, j, matcher,
				matchedCount = 0,
				i = "0",
				unmatched = seed && [],
				setMatched = [],
				contextBackup = outermostContext,
				// We must always have either seed elements or outermost context
				elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
				// Use integer dirruns iff this is the outermost matcher
				dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
				len = elems.length;

			if ( outermost ) {
				outermostContext = context === document || context || outermost;
			}

			// Add elements passing elementMatchers directly to results
			// Support: IE<9, Safari
			// Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
			for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
				if ( byElement && elem ) {
					j = 0;
					if ( !context && elem.ownerDocument !== document ) {
						setDocument( elem );
						xml = !documentIsHTML;
					}
					while ( (matcher = elementMatchers[j++]) ) {
						if ( matcher( elem, context || document, xml) ) {
							results.push( elem );
							break;
						}
					}
					if ( outermost ) {
						dirruns = dirrunsUnique;
					}
				}

				// Track unmatched elements for set filters
				if ( bySet ) {
					// They will have gone through all possible matchers
					if ( (elem = !matcher && elem) ) {
						matchedCount--;
					}

					// Lengthen the array for every element, matched or not
					if ( seed ) {
						unmatched.push( elem );
					}
				}
			}

			// `i` is now the count of elements visited above, and adding it to `matchedCount`
			// makes the latter nonnegative.
			matchedCount += i;

			// Apply set filters to unmatched elements
			// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
			// equals `i`), unless we didn't visit _any_ elements in the above loop because we have
			// no element matchers and no seed.
			// Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
			// case, which will result in a "00" `matchedCount` that differs from `i` but is also
			// numerically zero.
			if ( bySet && i !== matchedCount ) {
				j = 0;
				while ( (matcher = setMatchers[j++]) ) {
					matcher( unmatched, setMatched, context, xml );
				}

				if ( seed ) {
					// Reintegrate element matches to eliminate the need for sorting
					if ( matchedCount > 0 ) {
						while ( i-- ) {
							if ( !(unmatched[i] || setMatched[i]) ) {
								setMatched[i] = pop.call( results );
							}
						}
					}

					// Discard index placeholder values to get only actual matches
					setMatched = condense( setMatched );
				}

				// Add matches to results
				push.apply( results, setMatched );

				// Seedless set matches succeeding multiple successful matchers stipulate sorting
				if ( outermost && !seed && setMatched.length > 0 &&
					( matchedCount + setMatchers.length ) > 1 ) {

					Sizzle.uniqueSort( results );
				}
			}

			// Override manipulation of globals by nested matchers
			if ( outermost ) {
				dirruns = dirrunsUnique;
				outermostContext = contextBackup;
			}

			return unmatched;
		};

	return bySet ?
		markFunction( superMatcher ) :
		superMatcher;
}

compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
	var i,
		setMatchers = [],
		elementMatchers = [],
		cached = compilerCache[ selector + " " ];

	if ( !cached ) {
		// Generate a function of recursive functions that can be used to check each element
		if ( !match ) {
			match = tokenize( selector );
		}
		i = match.length;
		while ( i-- ) {
			cached = matcherFromTokens( match[i] );
			if ( cached[ expando ] ) {
				setMatchers.push( cached );
			} else {
				elementMatchers.push( cached );
			}
		}

		// Cache the compiled function
		cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );

		// Save selector and tokenization
		cached.selector = selector;
	}
	return cached;
};

/**
 * A low-level selection function that works with Sizzle's compiled
 *  selector functions
 * @param {String|Function} selector A selector or a pre-compiled
 *  selector function built with Sizzle.compile
 * @param {Element} context
 * @param {Array} [results]
 * @param {Array} [seed] A set of elements to match against
 */
select = Sizzle.select = function( selector, context, results, seed ) {
	var i, tokens, token, type, find,
		compiled = typeof selector === "function" && selector,
		match = !seed && tokenize( (selector = compiled.selector || selector) );

	results = results || [];

	// Try to minimize operations if there is only one selector in the list and no seed
	// (the latter of which guarantees us context)
	if ( match.length === 1 ) {

		// Reduce context if the leading compound selector is an ID
		tokens = match[0] = match[0].slice( 0 );
		if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
				support.getById && context.nodeType === 9 && documentIsHTML &&
				Expr.relative[ tokens[1].type ] ) {

			context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
			if ( !context ) {
				return results;

			// Precompiled matchers will still verify ancestry, so step up a level
			} else if ( compiled ) {
				context = context.parentNode;
			}

			selector = selector.slice( tokens.shift().value.length );
		}

		// Fetch a seed set for right-to-left matching
		i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
		while ( i-- ) {
			token = tokens[i];

			// Abort if we hit a combinator
			if ( Expr.relative[ (type = token.type) ] ) {
				break;
			}
			if ( (find = Expr.find[ type ]) ) {
				// Search, expanding context for leading sibling combinators
				if ( (seed = find(
					token.matches[0].replace( runescape, funescape ),
					rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
				)) ) {

					// If seed is empty or no tokens remain, we can return early
					tokens.splice( i, 1 );
					selector = seed.length && toSelector( tokens );
					if ( !selector ) {
						push.apply( results, seed );
						return results;
					}

					break;
				}
			}
		}
	}

	// Compile and execute a filtering function if one is not provided
	// Provide `match` to avoid retokenization if we modified the selector above
	( compiled || compile( selector, match ) )(
		seed,
		context,
		!documentIsHTML,
		results,
		!context || rsibling.test( selector ) && testContext( context.parentNode ) || context
	);
	return results;
};

// One-time assignments

// Sort stability
support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;

// Support: Chrome 14-35+
// Always assume duplicates if they aren't passed to the comparison function
support.detectDuplicates = !!hasDuplicate;

// Initialize against the default document
setDocument();

// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
// Detached nodes confoundingly follow *each other*
support.sortDetached = assert(function( div1 ) {
	// Should return 1, but returns 4 (following)
	return div1.compareDocumentPosition( document.createElement("div") ) & 1;
});

// Support: IE<8
// Prevent attribute/property "interpolation"
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
if ( !assert(function( div ) {
	div.innerHTML = "<a href='#'></a>";
	return div.firstChild.getAttribute("href") === "#" ;
}) ) {
	addHandle( "type|href|height|width", function( elem, name, isXML ) {
		if ( !isXML ) {
			return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
		}
	});
}

// Support: IE<9
// Use defaultValue in place of getAttribute("value")
if ( !support.attributes || !assert(function( div ) {
	div.innerHTML = "<input/>";
	div.firstChild.setAttribute( "value", "" );
	return div.firstChild.getAttribute( "value" ) === "";
}) ) {
	addHandle( "value", function( elem, name, isXML ) {
		if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
			return elem.defaultValue;
		}
	});
}

// Support: IE<9
// Use getAttributeNode to fetch booleans when getAttribute lies
if ( !assert(function( div ) {
	return div.getAttribute("disabled") == null;
}) ) {
	addHandle( booleans, function( elem, name, isXML ) {
		var val;
		if ( !isXML ) {
			return elem[ name ] === true ? name.toLowerCase() :
					(val = elem.getAttributeNode( name )) && val.specified ?
					val.value :
				null;
		}
	});
}

return Sizzle;

})( window );



jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
jQuery.expr[ ":" ] = jQuery.expr.pseudos;
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains;



var dir = function( elem, dir, until ) {
	var matched = [],
		truncate = until !== undefined;

	while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
		if ( elem.nodeType === 1 ) {
			if ( truncate && jQuery( elem ).is( until ) ) {
				break;
			}
			matched.push( elem );
		}
	}
	return matched;
};


var siblings = function( n, elem ) {
	var matched = [];

	for ( ; n; n = n.nextSibling ) {
		if ( n.nodeType === 1 && n !== elem ) {
			matched.push( n );
		}
	}

	return matched;
};


var rneedsContext = jQuery.expr.match.needsContext;

var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );



var risSimple = /^.[^:#\[\.,]*$/;

// Implement the identical functionality for filter and not
function winnow( elements, qualifier, not ) {
	if ( jQuery.isFunction( qualifier ) ) {
		return jQuery.grep( elements, function( elem, i ) {
			/* jshint -W018 */
			return !!qualifier.call( elem, i, elem ) !== not;
		} );

	}

	if ( qualifier.nodeType ) {
		return jQuery.grep( elements, function( elem ) {
			return ( elem === qualifier ) !== not;
		} );

	}

	if ( typeof qualifier === "string" ) {
		if ( risSimple.test( qualifier ) ) {
			return jQuery.filter( qualifier, elements, not );
		}

		qualifier = jQuery.filter( qualifier, elements );
	}

	return jQuery.grep( elements, function( elem ) {
		return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
	} );
}

jQuery.filter = function( expr, elems, not ) {
	var elem = elems[ 0 ];

	if ( not ) {
		expr = ":not(" + expr + ")";
	}

	return elems.length === 1 && elem.nodeType === 1 ?
		jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
		jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
			return elem.nodeType === 1;
		} ) );
};

jQuery.fn.extend( {
	find: function( selector ) {
		var i,
			ret = [],
			self = this,
			len = self.length;

		if ( typeof selector !== "string" ) {
			return this.pushStack( jQuery( selector ).filter( function() {
				for ( i = 0; i < len; i++ ) {
					if ( jQuery.contains( self[ i ], this ) ) {
						return true;
					}
				}
			} ) );
		}

		for ( i = 0; i < len; i++ ) {
			jQuery.find( selector, self[ i ], ret );
		}

		// Needed because $( selector, context ) becomes $( context ).find( selector )
		ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
		ret.selector = this.selector ? this.selector + " " + selector : selector;
		return ret;
	},
	filter: function( selector ) {
		return this.pushStack( winnow( this, selector || [], false ) );
	},
	not: function( selector ) {
		return this.pushStack( winnow( this, selector || [], true ) );
	},
	is: function( selector ) {
		return !!winnow(
			this,

			// If this is a positional/relative selector, check membership in the returned set
			// so $("p:first").is("p:last") won't return true for a doc with two "p".
			typeof selector === "string" && rneedsContext.test( selector ) ?
				jQuery( selector ) :
				selector || [],
			false
		).length;
	}
} );


// Initialize a jQuery object


// A central reference to the root jQuery(document)
var rootjQuery,

	// A simple way to check for HTML strings
	// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
	// Strict HTML recognition (#11290: must start with <)
	rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,

	init = jQuery.fn.init = function( selector, context, root ) {
		var match, elem;

		// HANDLE: $(""), $(null), $(undefined), $(false)
		if ( !selector ) {
			return this;
		}

		// init accepts an alternate rootjQuery
		// so migrate can support jQuery.sub (gh-2101)
		root = root || rootjQuery;

		// Handle HTML strings
		if ( typeof selector === "string" ) {
			if ( selector.charAt( 0 ) === "<" &&
				selector.charAt( selector.length - 1 ) === ">" &&
				selector.length >= 3 ) {

				// Assume that strings that start and end with <> are HTML and skip the regex check
				match = [ null, selector, null ];

			} else {
				match = rquickExpr.exec( selector );
			}

			// Match html or make sure no context is specified for #id
			if ( match && ( match[ 1 ] || !context ) ) {

				// HANDLE: $(html) -> $(array)
				if ( match[ 1 ] ) {
					context = context instanceof jQuery ? context[ 0 ] : context;

					// scripts is true for back-compat
					// Intentionally let the error be thrown if parseHTML is not present
					jQuery.merge( this, jQuery.parseHTML(
						match[ 1 ],
						context && context.nodeType ? context.ownerDocument || context : document,
						true
					) );

					// HANDLE: $(html, props)
					if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
						for ( match in context ) {

							// Properties of context are called as methods if possible
							if ( jQuery.isFunction( this[ match ] ) ) {
								this[ match ]( context[ match ] );

							// ...and otherwise set as attributes
							} else {
								this.attr( match, context[ match ] );
							}
						}
					}

					return this;

				// HANDLE: $(#id)
				} else {
					elem = document.getElementById( match[ 2 ] );

					// Check parentNode to catch when Blackberry 4.6 returns
					// nodes that are no longer in the document #6963
					if ( elem && elem.parentNode ) {

						// Handle the case where IE and Opera return items
						// by name instead of ID
						if ( elem.id !== match[ 2 ] ) {
							return rootjQuery.find( selector );
						}

						// Otherwise, we inject the element directly into the jQuery object
						this.length = 1;
						this[ 0 ] = elem;
					}

					this.context = document;
					this.selector = selector;
					return this;
				}

			// HANDLE: $(expr, $(...))
			} else if ( !context || context.jquery ) {
				return ( context || root ).find( selector );

			// HANDLE: $(expr, context)
			// (which is just equivalent to: $(context).find(expr)
			} else {
				return this.constructor( context ).find( selector );
			}

		// HANDLE: $(DOMElement)
		} else if ( selector.nodeType ) {
			this.context = this[ 0 ] = selector;
			this.length = 1;
			return this;

		// HANDLE: $(function)
		// Shortcut for document ready
		} else if ( jQuery.isFunction( selector ) ) {
			return typeof root.ready !== "undefined" ?
				root.ready( selector ) :

				// Execute immediately if ready is not present
				selector( jQuery );
		}

		if ( selector.selector !== undefined ) {
			this.selector = selector.selector;
			this.context = selector.context;
		}

		return jQuery.makeArray( selector, this );
	};

// Give the init function the jQuery prototype for later instantiation
init.prototype = jQuery.fn;

// Initialize central reference
rootjQuery = jQuery( document );


var rparentsprev = /^(?:parents|prev(?:Until|All))/,

	// methods guaranteed to produce a unique set when starting from a unique set
	guaranteedUnique = {
		children: true,
		contents: true,
		next: true,
		prev: true
	};

jQuery.fn.extend( {
	has: function( target ) {
		var i,
			targets = jQuery( target, this ),
			len = targets.length;

		return this.filter( function() {
			for ( i = 0; i < len; i++ ) {
				if ( jQuery.contains( this, targets[ i ] ) ) {
					return true;
				}
			}
		} );
	},

	closest: function( selectors, context ) {
		var cur,
			i = 0,
			l = this.length,
			matched = [],
			pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
				jQuery( selectors, context || this.context ) :
				0;

		for ( ; i < l; i++ ) {
			for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {

				// Always skip document fragments
				if ( cur.nodeType < 11 && ( pos ?
					pos.index( cur ) > -1 :

					// Don't pass non-elements to Sizzle
					cur.nodeType === 1 &&
						jQuery.find.matchesSelector( cur, selectors ) ) ) {

					matched.push( cur );
					break;
				}
			}
		}

		return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
	},

	// Determine the position of an element within
	// the matched set of elements
	index: function( elem ) {

		// No argument, return index in parent
		if ( !elem ) {
			return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
		}

		// index in selector
		if ( typeof elem === "string" ) {
			return jQuery.inArray( this[ 0 ], jQuery( elem ) );
		}

		// Locate the position of the desired element
		return jQuery.inArray(

			// If it receives a jQuery object, the first element is used
			elem.jquery ? elem[ 0 ] : elem, this );
	},

	add: function( selector, context ) {
		return this.pushStack(
			jQuery.uniqueSort(
				jQuery.merge( this.get(), jQuery( selector, context ) )
			)
		);
	},

	addBack: function( selector ) {
		return this.add( selector == null ?
			this.prevObject : this.prevObject.filter( selector )
		);
	}
} );

function sibling( cur, dir ) {
	do {
		cur = cur[ dir ];
	} while ( cur && cur.nodeType !== 1 );

	return cur;
}

jQuery.each( {
	parent: function( elem ) {
		var parent = elem.parentNode;
		return parent && parent.nodeType !== 11 ? parent : null;
	},
	parents: function( elem ) {
		return dir( elem, "parentNode" );
	},
	parentsUntil: function( elem, i, until ) {
		return dir( elem, "parentNode", until );
	},
	next: function( elem ) {
		return sibling( elem, "nextSibling" );
	},
	prev: function( elem ) {
		return sibling( elem, "previousSibling" );
	},
	nextAll: function( elem ) {
		return dir( elem, "nextSibling" );
	},
	prevAll: function( elem ) {
		return dir( elem, "previousSibling" );
	},
	nextUntil: function( elem, i, until ) {
		return dir( elem, "nextSibling", until );
	},
	prevUntil: function( elem, i, until ) {
		return dir( elem, "previousSibling", until );
	},
	siblings: function( elem ) {
		return siblings( ( elem.parentNode || {} ).firstChild, elem );
	},
	children: function( elem ) {
		return siblings( elem.firstChild );
	},
	contents: function( elem ) {
		return jQuery.nodeName( elem, "iframe" ) ?
			elem.contentDocument || elem.contentWindow.document :
			jQuery.merge( [], elem.childNodes );
	}
}, function( name, fn ) {
	jQuery.fn[ name ] = function( until, selector ) {
		var ret = jQuery.map( this, fn, until );

		if ( name.slice( -5 ) !== "Until" ) {
			selector = until;
		}

		if ( selector && typeof selector === "string" ) {
			ret = jQuery.filter( selector, ret );
		}

		if ( this.length > 1 ) {

			// Remove duplicates
			if ( !guaranteedUnique[ name ] ) {
				ret = jQuery.uniqueSort( ret );
			}

			// Reverse order for parents* and prev-derivatives
			if ( rparentsprev.test( name ) ) {
				ret = ret.reverse();
			}
		}

		return this.pushStack( ret );
	};
} );
var rnotwhite = ( /\S+/g );



// Convert String-formatted options into Object-formatted ones
function createOptions( options ) {
	var object = {};
	jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
		object[ flag ] = true;
	} );
	return object;
}

/*
 * Create a callback list using the following parameters:
 *
 *	options: an optional list of space-separated options that will change how
 *			the callback list behaves or a more traditional option object
 *
 * By default a callback list will act like an event callback list and can be
 * "fired" multiple times.
 *
 * Possible options:
 *
 *	once:			will ensure the callback list can only be fired once (like a Deferred)
 *
 *	memory:			will keep track of previous values and will call any callback added
 *					after the list has been fired right away with the latest "memorized"
 *					values (like a Deferred)
 *
 *	unique:			will ensure a callback can only be added once (no duplicate in the list)
 *
 *	stopOnFalse:	interrupt callings when a callback returns false
 *
 */
jQuery.Callbacks = function( options ) {

	// Convert options from String-formatted to Object-formatted if needed
	// (we check in cache first)
	options = typeof options === "string" ?
		createOptions( options ) :
		jQuery.extend( {}, options );

	var // Flag to know if list is currently firing
		firing,

		// Last fire value for non-forgettable lists
		memory,

		// Flag to know if list was already fired
		fired,

		// Flag to prevent firing
		locked,

		// Actual callback list
		list = [],

		// Queue of execution data for repeatable lists
		queue = [],

		// Index of currently firing callback (modified by add/remove as needed)
		firingIndex = -1,

		// Fire callbacks
		fire = function() {

			// Enforce single-firing
			locked = options.once;

			// Execute callbacks for all pending executions,
			// respecting firingIndex overrides and runtime changes
			fired = firing = true;
			for ( ; queue.length; firingIndex = -1 ) {
				memory = queue.shift();
				while ( ++firingIndex < list.length ) {

					// Run callback and check for early termination
					if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
						options.stopOnFalse ) {

						// Jump to end and forget the data so .add doesn't re-fire
						firingIndex = list.length;
						memory = false;
					}
				}
			}

			// Forget the data if we're done with it
			if ( !options.memory ) {
				memory = false;
			}

			firing = false;

			// Clean up if we're done firing for good
			if ( locked ) {

				// Keep an empty list if we have data for future add calls
				if ( memory ) {
					list = [];

				// Otherwise, this object is spent
				} else {
					list = "";
				}
			}
		},

		// Actual Callbacks object
		self = {

			// Add a callback or a collection of callbacks to the list
			add: function() {
				if ( list ) {

					// If we have memory from a past run, we should fire after adding
					if ( memory && !firing ) {
						firingIndex = list.length - 1;
						queue.push( memory );
					}

					( function add( args ) {
						jQuery.each( args, function( _, arg ) {
							if ( jQuery.isFunction( arg ) ) {
								if ( !options.unique || !self.has( arg ) ) {
									list.push( arg );
								}
							} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {

								// Inspect recursively
								add( arg );
							}
						} );
					} )( arguments );

					if ( memory && !firing ) {
						fire();
					}
				}
				return this;
			},

			// Remove a callback from the list
			remove: function() {
				jQuery.each( arguments, function( _, arg ) {
					var index;
					while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
						list.splice( index, 1 );

						// Handle firing indexes
						if ( index <= firingIndex ) {
							firingIndex--;
						}
					}
				} );
				return this;
			},

			// Check if a given callback is in the list.
			// If no argument is given, return whether or not list has callbacks attached.
			has: function( fn ) {
				return fn ?
					jQuery.inArray( fn, list ) > -1 :
					list.length > 0;
			},

			// Remove all callbacks from the list
			empty: function() {
				if ( list ) {
					list = [];
				}
				return this;
			},

			// Disable .fire and .add
			// Abort any current/pending executions
			// Clear all callbacks and values
			disable: function() {
				locked = queue = [];
				list = memory = "";
				return this;
			},
			disabled: function() {
				return !list;
			},

			// Disable .fire
			// Also disable .add unless we have memory (since it would have no effect)
			// Abort any pending executions
			lock: function() {
				locked = true;
				if ( !memory ) {
					self.disable();
				}
				return this;
			},
			locked: function() {
				return !!locked;
			},

			// Call all callbacks with the given context and arguments
			fireWith: function( context, args ) {
				if ( !locked ) {
					args = args || [];
					args = [ context, args.slice ? args.slice() : args ];
					queue.push( args );
					if ( !firing ) {
						fire();
					}
				}
				return this;
			},

			// Call all the callbacks with the given arguments
			fire: function() {
				self.fireWith( this, arguments );
				return this;
			},

			// To know if the callbacks have already been called at least once
			fired: function() {
				return !!fired;
			}
		};

	return self;
};


jQuery.extend( {

	Deferred: function( func ) {
		var tuples = [

				// action, add listener, listener list, final state
				[ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
				[ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
				[ "notify", "progress", jQuery.Callbacks( "memory" ) ]
			],
			state = "pending",
			promise = {
				state: function() {
					return state;
				},
				always: function() {
					deferred.done( arguments ).fail( arguments );
					return this;
				},
				then: function( /* fnDone, fnFail, fnProgress */ ) {
					var fns = arguments;
					return jQuery.Deferred( function( newDefer ) {
						jQuery.each( tuples, function( i, tuple ) {
							var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];

							// deferred[ done | fail | progress ] for forwarding actions to newDefer
							deferred[ tuple[ 1 ] ]( function() {
								var returned = fn && fn.apply( this, arguments );
								if ( returned && jQuery.isFunction( returned.promise ) ) {
									returned.promise()
										.progress( newDefer.notify )
										.done( newDefer.resolve )
										.fail( newDefer.reject );
								} else {
									newDefer[ tuple[ 0 ] + "With" ](
										this === promise ? newDefer.promise() : this,
										fn ? [ returned ] : arguments
									);
								}
							} );
						} );
						fns = null;
					} ).promise();
				},

				// Get a promise for this deferred
				// If obj is provided, the promise aspect is added to the object
				promise: function( obj ) {
					return obj != null ? jQuery.extend( obj, promise ) : promise;
				}
			},
			deferred = {};

		// Keep pipe for back-compat
		promise.pipe = promise.then;

		// Add list-specific methods
		jQuery.each( tuples, function( i, tuple ) {
			var list = tuple[ 2 ],
				stateString = tuple[ 3 ];

			// promise[ done | fail | progress ] = list.add
			promise[ tuple[ 1 ] ] = list.add;

			// Handle state
			if ( stateString ) {
				list.add( function() {

					// state = [ resolved | rejected ]
					state = stateString;

				// [ reject_list | resolve_list ].disable; progress_list.lock
				}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
			}

			// deferred[ resolve | reject | notify ]
			deferred[ tuple[ 0 ] ] = function() {
				deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
				return this;
			};
			deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
		} );

		// Make the deferred a promise
		promise.promise( deferred );

		// Call given func if any
		if ( func ) {
			func.call( deferred, deferred );
		}

		// All done!
		return deferred;
	},

	// Deferred helper
	when: function( subordinate /* , ..., subordinateN */ ) {
		var i = 0,
			resolveValues = slice.call( arguments ),
			length = resolveValues.length,

			// the count of uncompleted subordinates
			remaining = length !== 1 ||
				( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,

			// the master Deferred.
			// If resolveValues consist of only a single Deferred, just use that.
			deferred = remaining === 1 ? subordinate : jQuery.Deferred(),

			// Update function for both resolve and progress values
			updateFunc = function( i, contexts, values ) {
				return function( value ) {
					contexts[ i ] = this;
					values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
					if ( values === progressValues ) {
						deferred.notifyWith( contexts, values );

					} else if ( !( --remaining ) ) {
						deferred.resolveWith( contexts, values );
					}
				};
			},

			progressValues, progressContexts, resolveContexts;

		// add listeners to Deferred subordinates; treat others as resolved
		if ( length > 1 ) {
			progressValues = new Array( length );
			progressContexts = new Array( length );
			resolveContexts = new Array( length );
			for ( ; i < length; i++ ) {
				if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
					resolveValues[ i ].promise()
						.progress( updateFunc( i, progressContexts, progressValues ) )
						.done( updateFunc( i, resolveContexts, resolveValues ) )
						.fail( deferred.reject );
				} else {
					--remaining;
				}
			}
		}

		// if we're not waiting on anything, resolve the master
		if ( !remaining ) {
			deferred.resolveWith( resolveContexts, resolveValues );
		}

		return deferred.promise();
	}
} );


// The deferred used on DOM ready
var readyList;

jQuery.fn.ready = function( fn ) {

	// Add the callback
	jQuery.ready.promise().done( fn );

	return this;
};

jQuery.extend( {

	// Is the DOM ready to be used? Set to true once it occurs.
	isReady: false,

	// A counter to track how many items to wait for before
	// the ready event fires. See #6781
	readyWait: 1,

	// Hold (or release) the ready event
	holdReady: function( hold ) {
		if ( hold ) {
			jQuery.readyWait++;
		} else {
			jQuery.ready( true );
		}
	},

	// Handle when the DOM is ready
	ready: function( wait ) {

		// Abort if there are pending holds or we're already ready
		if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
			return;
		}

		// Remember that the DOM is ready
		jQuery.isReady = true;

		// If a normal DOM Ready event fired, decrement, and wait if need be
		if ( wait !== true && --jQuery.readyWait > 0 ) {
			return;
		}

		// If there are functions bound, to execute
		readyList.resolveWith( document, [ jQuery ] );

		// Trigger any bound ready events
		if ( jQuery.fn.triggerHandler ) {
			jQuery( document ).triggerHandler( "ready" );
			jQuery( document ).off( "ready" );
		}
	}
} );

/**
 * Clean-up method for dom ready events
 */
function detach() {
	if ( document.addEventListener ) {
		document.removeEventListener( "DOMContentLoaded", completed );
		window.removeEventListener( "load", completed );

	} else {
		document.detachEvent( "onreadystatechange", completed );
		window.detachEvent( "onload", completed );
	}
}

/**
 * The ready event handler and self cleanup method
 */
function completed() {

	// readyState === "complete" is good enough for us to call the dom ready in oldIE
	if ( document.addEventListener ||
		window.event.type === "load" ||
		document.readyState === "complete" ) {

		detach();
		jQuery.ready();
	}
}

jQuery.ready.promise = function( obj ) {
	if ( !readyList ) {

		readyList = jQuery.Deferred();

		// Catch cases where $(document).ready() is called
		// after the browser event has already occurred.
		// Support: IE6-10
		// Older IE sometimes signals "interactive" too soon
		if ( document.readyState === "complete" ||
			( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {

			// Handle it asynchronously to allow scripts the opportunity to delay ready
			window.setTimeout( jQuery.ready );

		// Standards-based browsers support DOMContentLoaded
		} else if ( document.addEventListener ) {

			// Use the handy event callback
			document.addEventListener( "DOMContentLoaded", completed );

			// A fallback to window.onload, that will always work
			window.addEventListener( "load", completed );

		// If IE event model is used
		} else {

			// Ensure firing before onload, maybe late but safe also for iframes
			document.attachEvent( "onreadystatechange", completed );

			// A fallback to window.onload, that will always work
			window.attachEvent( "onload", completed );

			// If IE and not a frame
			// continually check to see if the document is ready
			var top = false;

			try {
				top = window.frameElement == null && document.documentElement;
			} catch ( e ) {}

			if ( top && top.doScroll ) {
				( function doScrollCheck() {
					if ( !jQuery.isReady ) {

						try {

							// Use the trick by Diego Perini
							// http://javascript.nwbox.com/IEContentLoaded/
							top.doScroll( "left" );
						} catch ( e ) {
							return window.setTimeout( doScrollCheck, 50 );
						}

						// detach all dom ready events
						detach();

						// and execute any waiting functions
						jQuery.ready();
					}
				} )();
			}
		}
	}
	return readyList.promise( obj );
};

// Kick off the DOM ready check even if the user does not
jQuery.ready.promise();




// Support: IE<9
// Iteration over object's inherited properties before its own
var i;
for ( i in jQuery( support ) ) {
	break;
}
support.ownFirst = i === "0";

// Note: most support tests are defined in their respective modules.
// false until the test is run
support.inlineBlockNeedsLayout = false;

// Execute ASAP in case we need to set body.style.zoom
jQuery( function() {

	// Minified: var a,b,c,d
	var val, div, body, container;

	body = document.getElementsByTagName( "body" )[ 0 ];
	if ( !body || !body.style ) {

		// Return for frameset docs that don't have a body
		return;
	}

	// Setup
	div = document.createElement( "div" );
	container = document.createElement( "div" );
	container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
	body.appendChild( container ).appendChild( div );

	if ( typeof div.style.zoom !== "undefined" ) {

		// Support: IE<8
		// Check if natively block-level elements act like inline-block
		// elements when setting their display to 'inline' and giving
		// them layout
		div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";

		support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
		if ( val ) {

			// Prevent IE 6 from affecting layout for positioned elements #11048
			// Prevent IE from shrinking the body in IE 7 mode #12869
			// Support: IE<8
			body.style.zoom = 1;
		}
	}

	body.removeChild( container );
} );


( function() {
	var div = document.createElement( "div" );

	// Support: IE<9
	support.deleteExpando = true;
	try {
		delete div.test;
	} catch ( e ) {
		support.deleteExpando = false;
	}

	// Null elements to avoid leaks in IE.
	div = null;
} )();
var acceptData = function( elem ) {
	var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
		nodeType = +elem.nodeType || 1;

	// Do not set data on non-element DOM nodes because it will not be cleared (#8335).
	return nodeType !== 1 && nodeType !== 9 ?
		false :

		// Nodes accept data unless otherwise specified; rejection can be conditional
		!noData || noData !== true && elem.getAttribute( "classid" ) === noData;
};




var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
	rmultiDash = /([A-Z])/g;

function dataAttr( elem, key, data ) {

	// If nothing was found internally, try to fetch any
	// data from the HTML5 data-* attribute
	if ( data === undefined && elem.nodeType === 1 ) {

		var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();

		data = elem.getAttribute( name );

		if ( typeof data === "string" ) {
			try {
				data = data === "true" ? true :
					data === "false" ? false :
					data === "null" ? null :

					// Only convert to a number if it doesn't change the string
					+data + "" === data ? +data :
					rbrace.test( data ) ? jQuery.parseJSON( data ) :
					data;
			} catch ( e ) {}

			// Make sure we set the data so it isn't changed later
			jQuery.data( elem, key, data );

		} else {
			data = undefined;
		}
	}

	return data;
}

// checks a cache object for emptiness
function isEmptyDataObject( obj ) {
	var name;
	for ( name in obj ) {

		// if the public data object is empty, the private is still empty
		if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
			continue;
		}
		if ( name !== "toJSON" ) {
			return false;
		}
	}

	return true;
}

function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
	if ( !acceptData( elem ) ) {
		return;
	}

	var ret, thisCache,
		internalKey = jQuery.expando,

		// We have to handle DOM nodes and JS objects differently because IE6-7
		// can't GC object references properly across the DOM-JS boundary
		isNode = elem.nodeType,

		// Only DOM nodes need the global jQuery cache; JS object data is
		// attached directly to the object so GC can occur automatically
		cache = isNode ? jQuery.cache : elem,

		// Only defining an ID for JS objects if its cache already exists allows
		// the code to shortcut on the same path as a DOM node with no cache
		id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;

	// Avoid doing any more work than we need to when trying to get data on an
	// object that has no data at all
	if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
		data === undefined && typeof name === "string" ) {
		return;
	}

	if ( !id ) {

		// Only DOM nodes need a new unique ID for each element since their data
		// ends up in the global cache
		if ( isNode ) {
			id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
		} else {
			id = internalKey;
		}
	}

	if ( !cache[ id ] ) {

		// Avoid exposing jQuery metadata on plain JS objects when the object
		// is serialized using JSON.stringify
		cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
	}

	// An object can be passed to jQuery.data instead of a key/value pair; this gets
	// shallow copied over onto the existing cache
	if ( typeof name === "object" || typeof name === "function" ) {
		if ( pvt ) {
			cache[ id ] = jQuery.extend( cache[ id ], name );
		} else {
			cache[ id ].data = jQuery.extend( cache[ id ].data, name );
		}
	}

	thisCache = cache[ id ];

	// jQuery data() is stored in a separate object inside the object's internal data
	// cache in order to avoid key collisions between internal data and user-defined
	// data.
	if ( !pvt ) {
		if ( !thisCache.data ) {
			thisCache.data = {};
		}

		thisCache = thisCache.data;
	}

	if ( data !== undefined ) {
		thisCache[ jQuery.camelCase( name ) ] = data;
	}

	// Check for both converted-to-camel and non-converted data property names
	// If a data property was specified
	if ( typeof name === "string" ) {

		// First Try to find as-is property data
		ret = thisCache[ name ];

		// Test for null|undefined property data
		if ( ret == null ) {

			// Try to find the camelCased property
			ret = thisCache[ jQuery.camelCase( name ) ];
		}
	} else {
		ret = thisCache;
	}

	return ret;
}

function internalRemoveData( elem, name, pvt ) {
	if ( !acceptData( elem ) ) {
		return;
	}

	var thisCache, i,
		isNode = elem.nodeType,

		// See jQuery.data for more information
		cache = isNode ? jQuery.cache : elem,
		id = isNode ? elem[ jQuery.expando ] : jQuery.expando;

	// If there is already no cache entry for this object, there is no
	// purpose in continuing
	if ( !cache[ id ] ) {
		return;
	}

	if ( name ) {

		thisCache = pvt ? cache[ id ] : cache[ id ].data;

		if ( thisCache ) {

			// Support array or space separated string names for data keys
			if ( !jQuery.isArray( name ) ) {

				// try the string as a key before any manipulation
				if ( name in thisCache ) {
					name = [ name ];
				} else {

					// split the camel cased version by spaces unless a key with the spaces exists
					name = jQuery.camelCase( name );
					if ( name in thisCache ) {
						name = [ name ];
					} else {
						name = name.split( " " );
					}
				}
			} else {

				// If "name" is an array of keys...
				// When data is initially created, via ("key", "val") signature,
				// keys will be converted to camelCase.
				// Since there is no way to tell _how_ a key was added, remove
				// both plain key and camelCase key. #12786
				// This will only penalize the array argument path.
				name = name.concat( jQuery.map( name, jQuery.camelCase ) );
			}

			i = name.length;
			while ( i-- ) {
				delete thisCache[ name[ i ] ];
			}

			// If there is no data left in the cache, we want to continue
			// and let the cache object itself get destroyed
			if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
				return;
			}
		}
	}

	// See jQuery.data for more information
	if ( !pvt ) {
		delete cache[ id ].data;

		// Don't destroy the parent cache unless the internal data object
		// had been the only thing left in it
		if ( !isEmptyDataObject( cache[ id ] ) ) {
			return;
		}
	}

	// Destroy the cache
	if ( isNode ) {
		jQuery.cleanData( [ elem ], true );

	// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
	/* jshint eqeqeq: false */
	} else if ( support.deleteExpando || cache != cache.window ) {
		/* jshint eqeqeq: true */
		delete cache[ id ];

	// When all else fails, undefined
	} else {
		cache[ id ] = undefined;
	}
}

jQuery.extend( {
	cache: {},

	// The following elements (space-suffixed to avoid Object.prototype collisions)
	// throw uncatchable exceptions if you attempt to set expando properties
	noData: {
		"applet ": true,
		"embed ": true,

		// ...but Flash objects (which have this classid) *can* handle expandos
		"object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
	},

	hasData: function( elem ) {
		elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
		return !!elem && !isEmptyDataObject( elem );
	},

	data: function( elem, name, data ) {
		return internalData( elem, name, data );
	},

	removeData: function( elem, name ) {
		return internalRemoveData( elem, name );
	},

	// For internal use only.
	_data: function( elem, name, data ) {
		return internalData( elem, name, data, true );
	},

	_removeData: function( elem, name ) {
		return internalRemoveData( elem, name, true );
	}
} );

jQuery.fn.extend( {
	data: function( key, value ) {
		var i, name, data,
			elem = this[ 0 ],
			attrs = elem && elem.attributes;

		// Special expections of .data basically thwart jQuery.access,
		// so implement the relevant behavior ourselves

		// Gets all values
		if ( key === undefined ) {
			if ( this.length ) {
				data = jQuery.data( elem );

				if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
					i = attrs.length;
					while ( i-- ) {

						// Support: IE11+
						// The attrs elements can be null (#14894)
						if ( attrs[ i ] ) {
							name = attrs[ i ].name;
							if ( name.indexOf( "data-" ) === 0 ) {
								name = jQuery.camelCase( name.slice( 5 ) );
								dataAttr( elem, name, data[ name ] );
							}
						}
					}
					jQuery._data( elem, "parsedAttrs", true );
				}
			}

			return data;
		}

		// Sets multiple values
		if ( typeof key === "object" ) {
			return this.each( function() {
				jQuery.data( this, key );
			} );
		}

		return arguments.length > 1 ?

			// Sets one value
			this.each( function() {
				jQuery.data( this, key, value );
			} ) :

			// Gets one value
			// Try to fetch any internally stored data first
			elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
	},

	removeData: function( key ) {
		return this.each( function() {
			jQuery.removeData( this, key );
		} );
	}
} );


jQuery.extend( {
	queue: function( elem, type, data ) {
		var queue;

		if ( elem ) {
			type = ( type || "fx" ) + "queue";
			queue = jQuery._data( elem, type );

			// Speed up dequeue by getting out quickly if this is just a lookup
			if ( data ) {
				if ( !queue || jQuery.isArray( data ) ) {
					queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
				} else {
					queue.push( data );
				}
			}
			return queue || [];
		}
	},

	dequeue: function( elem, type ) {
		type = type || "fx";

		var queue = jQuery.queue( elem, type ),
			startLength = queue.length,
			fn = queue.shift(),
			hooks = jQuery._queueHooks( elem, type ),
			next = function() {
				jQuery.dequeue( elem, type );
			};

		// If the fx queue is dequeued, always remove the progress sentinel
		if ( fn === "inprogress" ) {
			fn = queue.shift();
			startLength--;
		}

		if ( fn ) {

			// Add a progress sentinel to prevent the fx queue from being
			// automatically dequeued
			if ( type === "fx" ) {
				queue.unshift( "inprogress" );
			}

			// clear up the last queue stop function
			delete hooks.stop;
			fn.call( elem, next, hooks );
		}

		if ( !startLength && hooks ) {
			hooks.empty.fire();
		}
	},

	// not intended for public consumption - generates a queueHooks object,
	// or returns the current one
	_queueHooks: function( elem, type ) {
		var key = type + "queueHooks";
		return jQuery._data( elem, key ) || jQuery._data( elem, key, {
			empty: jQuery.Callbacks( "once memory" ).add( function() {
				jQuery._removeData( elem, type + "queue" );
				jQuery._removeData( elem, key );
			} )
		} );
	}
} );

jQuery.fn.extend( {
	queue: function( type, data ) {
		var setter = 2;

		if ( typeof type !== "string" ) {
			data = type;
			type = "fx";
			setter--;
		}

		if ( arguments.length < setter ) {
			return jQuery.queue( this[ 0 ], type );
		}

		return data === undefined ?
			this :
			this.each( function() {
				var queue = jQuery.queue( this, type, data );

				// ensure a hooks for this queue
				jQuery._queueHooks( this, type );

				if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
					jQuery.dequeue( this, type );
				}
			} );
	},
	dequeue: function( type ) {
		return this.each( function() {
			jQuery.dequeue( this, type );
		} );
	},
	clearQueue: function( type ) {
		return this.queue( type || "fx", [] );
	},

	// Get a promise resolved when queues of a certain type
	// are emptied (fx is the type by default)
	promise: function( type, obj ) {
		var tmp,
			count = 1,
			defer = jQuery.Deferred(),
			elements = this,
			i = this.length,
			resolve = function() {
				if ( !( --count ) ) {
					defer.resolveWith( elements, [ elements ] );
				}
			};

		if ( typeof type !== "string" ) {
			obj = type;
			type = undefined;
		}
		type = type || "fx";

		while ( i-- ) {
			tmp = jQuery._data( elements[ i ], type + "queueHooks" );
			if ( tmp && tmp.empty ) {
				count++;
				tmp.empty.add( resolve );
			}
		}
		resolve();
		return defer.promise( obj );
	}
} );


( function() {
	var shrinkWrapBlocksVal;

	support.shrinkWrapBlocks = function() {
		if ( shrinkWrapBlocksVal != null ) {
			return shrinkWrapBlocksVal;
		}

		// Will be changed later if needed.
		shrinkWrapBlocksVal = false;

		// Minified: var b,c,d
		var div, body, container;

		body = document.getElementsByTagName( "body" )[ 0 ];
		if ( !body || !body.style ) {

			// Test fired too early or in an unsupported environment, exit.
			return;
		}

		// Setup
		div = document.createElement( "div" );
		container = document.createElement( "div" );
		container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
		body.appendChild( container ).appendChild( div );

		// Support: IE6
		// Check if elements with layout shrink-wrap their children
		if ( typeof div.style.zoom !== "undefined" ) {

			// Reset CSS: box-sizing; display; margin; border
			div.style.cssText =

				// Support: Firefox<29, Android 2.3
				// Vendor-prefix box-sizing
				"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
				"box-sizing:content-box;display:block;margin:0;border:0;" +
				"padding:1px;width:1px;zoom:1";
			div.appendChild( document.createElement( "div" ) ).style.width = "5px";
			shrinkWrapBlocksVal = div.offsetWidth !== 3;
		}

		body.removeChild( container );

		return shrinkWrapBlocksVal;
	};

} )();
var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;

var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );


var cssExpand = [ "Top", "Right", "Bottom", "Left" ];

var isHidden = function( elem, el ) {

		// isHidden might be called from jQuery#filter function;
		// in that case, element will be second argument
		elem = el || elem;
		return jQuery.css( elem, "display" ) === "none" ||
			!jQuery.contains( elem.ownerDocument, elem );
	};



function adjustCSS( elem, prop, valueParts, tween ) {
	var adjusted,
		scale = 1,
		maxIterations = 20,
		currentValue = tween ?
			function() { return tween.cur(); } :
			function() { return jQuery.css( elem, prop, "" ); },
		initial = currentValue(),
		unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),

		// Starting value computation is required for potential unit mismatches
		initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
			rcssNum.exec( jQuery.css( elem, prop ) );

	if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {

		// Trust units reported by jQuery.css
		unit = unit || initialInUnit[ 3 ];

		// Make sure we update the tween properties later on
		valueParts = valueParts || [];

		// Iteratively approximate from a nonzero starting point
		initialInUnit = +initial || 1;

		do {

			// If previous iteration zeroed out, double until we get *something*.
			// Use string for doubling so we don't accidentally see scale as unchanged below
			scale = scale || ".5";

			// Adjust and apply
			initialInUnit = initialInUnit / scale;
			jQuery.style( elem, prop, initialInUnit + unit );

		// Update scale, tolerating zero or NaN from tween.cur()
		// Break the loop if scale is unchanged or perfect, or if we've just had enough.
		} while (
			scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
		);
	}

	if ( valueParts ) {
		initialInUnit = +initialInUnit || +initial || 0;

		// Apply relative offset (+=/-=) if specified
		adjusted = valueParts[ 1 ] ?
			initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
			+valueParts[ 2 ];
		if ( tween ) {
			tween.unit = unit;
			tween.start = initialInUnit;
			tween.end = adjusted;
		}
	}
	return adjusted;
}


// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
	var i = 0,
		length = elems.length,
		bulk = key == null;

	// Sets many values
	if ( jQuery.type( key ) === "object" ) {
		chainable = true;
		for ( i in key ) {
			access( elems, fn, i, key[ i ], true, emptyGet, raw );
		}

	// Sets one value
	} else if ( value !== undefined ) {
		chainable = true;

		if ( !jQuery.isFunction( value ) ) {
			raw = true;
		}

		if ( bulk ) {

			// Bulk operations run against the entire set
			if ( raw ) {
				fn.call( elems, value );
				fn = null;

			// ...except when executing function values
			} else {
				bulk = fn;
				fn = function( elem, key, value ) {
					return bulk.call( jQuery( elem ), value );
				};
			}
		}

		if ( fn ) {
			for ( ; i < length; i++ ) {
				fn(
					elems[ i ],
					key,
					raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
				);
			}
		}
	}

	return chainable ?
		elems :

		// Gets
		bulk ?
			fn.call( elems ) :
			length ? fn( elems[ 0 ], key ) : emptyGet;
};
var rcheckableType = ( /^(?:checkbox|radio)$/i );

var rtagName = ( /<([\w:-]+)/ );

var rscriptType = ( /^$|\/(?:java|ecma)script/i );

var rleadingWhitespace = ( /^\s+/ );

var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
		"details|dialog|figcaption|figure|footer|header|hgroup|main|" +
		"mark|meter|nav|output|picture|progress|section|summary|template|time|video";



function createSafeFragment( document ) {
	var list = nodeNames.split( "|" ),
		safeFrag = document.createDocumentFragment();

	if ( safeFrag.createElement ) {
		while ( list.length ) {
			safeFrag.createElement(
				list.pop()
			);
		}
	}
	return safeFrag;
}


( function() {
	var div = document.createElement( "div" ),
		fragment = document.createDocumentFragment(),
		input = document.createElement( "input" );

	// Setup
	div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";

	// IE strips leading whitespace when .innerHTML is used
	support.leadingWhitespace = div.firstChild.nodeType === 3;

	// Make sure that tbody elements aren't automatically inserted
	// IE will insert them into empty tables
	support.tbody = !div.getElementsByTagName( "tbody" ).length;

	// Make sure that link elements get serialized correctly by innerHTML
	// This requires a wrapper element in IE
	support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;

	// Makes sure cloning an html5 element does not cause problems
	// Where outerHTML is undefined, this still works
	support.html5Clone =
		document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";

	// Check if a disconnected checkbox will retain its checked
	// value of true after appended to the DOM (IE6/7)
	input.type = "checkbox";
	input.checked = true;
	fragment.appendChild( input );
	support.appendChecked = input.checked;

	// Make sure textarea (and checkbox) defaultValue is properly cloned
	// Support: IE6-IE11+
	div.innerHTML = "<textarea>x</textarea>";
	support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;

	// #11217 - WebKit loses check when the name is after the checked attribute
	fragment.appendChild( div );

	// Support: Windows Web Apps (WWA)
	// `name` and `type` must use .setAttribute for WWA (#14901)
	input = document.createElement( "input" );
	input.setAttribute( "type", "radio" );
	input.setAttribute( "checked", "checked" );
	input.setAttribute( "name", "t" );

	div.appendChild( input );

	// Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
	// old WebKit doesn't clone checked state correctly in fragments
	support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;

	// Support: IE<9
	// Cloned elements keep attachEvent handlers, we use addEventListener on IE9+
	support.noCloneEvent = !!div.addEventListener;

	// Support: IE<9
	// Since attributes and properties are the same in IE,
	// cleanData must set properties to undefined rather than use removeAttribute
	div[ jQuery.expando ] = 1;
	support.attributes = !div.getAttribute( jQuery.expando );
} )();


// We have to close these tags to support XHTML (#13200)
var wrapMap = {
	option: [ 1, "<select multiple='multiple'>", "</select>" ],
	legend: [ 1, "<fieldset>", "</fieldset>" ],
	area: [ 1, "<map>", "</map>" ],

	// Support: IE8
	param: [ 1, "<object>", "</object>" ],
	thead: [ 1, "<table>", "</table>" ],
	tr: [ 2, "<table><tbody>", "</tbody></table>" ],
	col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
	td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],

	// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
	// unless wrapped in a div with non-breaking characters in front of it.
	_default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
};

// Support: IE8-IE9
wrapMap.optgroup = wrapMap.option;

wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;


function getAll( context, tag ) {
	var elems, elem,
		i = 0,
		found = typeof context.getElementsByTagName !== "undefined" ?
			context.getElementsByTagName( tag || "*" ) :
			typeof context.querySelectorAll !== "undefined" ?
				context.querySelectorAll( tag || "*" ) :
				undefined;

	if ( !found ) {
		for ( found = [], elems = context.childNodes || context;
			( elem = elems[ i ] ) != null;
			i++
		) {
			if ( !tag || jQuery.nodeName( elem, tag ) ) {
				found.push( elem );
			} else {
				jQuery.merge( found, getAll( elem, tag ) );
			}
		}
	}

	return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
		jQuery.merge( [ context ], found ) :
		found;
}


// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
	var elem,
		i = 0;
	for ( ; ( elem = elems[ i ] ) != null; i++ ) {
		jQuery._data(
			elem,
			"globalEval",
			!refElements || jQuery._data( refElements[ i ], "globalEval" )
		);
	}
}


var rhtml = /<|&#?\w+;/,
	rtbody = /<tbody/i;

function fixDefaultChecked( elem ) {
	if ( rcheckableType.test( elem.type ) ) {
		elem.defaultChecked = elem.checked;
	}
}

function buildFragment( elems, context, scripts, selection, ignored ) {
	var j, elem, contains,
		tmp, tag, tbody, wrap,
		l = elems.length,

		// Ensure a safe fragment
		safe = createSafeFragment( context ),

		nodes = [],
		i = 0;

	for ( ; i < l; i++ ) {
		elem = elems[ i ];

		if ( elem || elem === 0 ) {

			// Add nodes directly
			if ( jQuery.type( elem ) === "object" ) {
				jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );

			// Convert non-html into a text node
			} else if ( !rhtml.test( elem ) ) {
				nodes.push( context.createTextNode( elem ) );

			// Convert html into DOM nodes
			} else {
				tmp = tmp || safe.appendChild( context.createElement( "div" ) );

				// Deserialize a standard representation
				tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
				wrap = wrapMap[ tag ] || wrapMap._default;

				tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];

				// Descend through wrappers to the right content
				j = wrap[ 0 ];
				while ( j-- ) {
					tmp = tmp.lastChild;
				}

				// Manually add leading whitespace removed by IE
				if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
					nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
				}

				// Remove IE's autoinserted <tbody> from table fragments
				if ( !support.tbody ) {

					// String was a <table>, *may* have spurious <tbody>
					elem = tag === "table" && !rtbody.test( elem ) ?
						tmp.firstChild :

						// String was a bare <thead> or <tfoot>
						wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
							tmp :
							0;

					j = elem && elem.childNodes.length;
					while ( j-- ) {
						if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
							!tbody.childNodes.length ) {

							elem.removeChild( tbody );
						}
					}
				}

				jQuery.merge( nodes, tmp.childNodes );

				// Fix #12392 for WebKit and IE > 9
				tmp.textContent = "";

				// Fix #12392 for oldIE
				while ( tmp.firstChild ) {
					tmp.removeChild( tmp.firstChild );
				}

				// Remember the top-level container for proper cleanup
				tmp = safe.lastChild;
			}
		}
	}

	// Fix #11356: Clear elements from fragment
	if ( tmp ) {
		safe.removeChild( tmp );
	}

	// Reset defaultChecked for any radios and checkboxes
	// about to be appended to the DOM in IE 6/7 (#8060)
	if ( !support.appendChecked ) {
		jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
	}

	i = 0;
	while ( ( elem = nodes[ i++ ] ) ) {

		// Skip elements already in the context collection (trac-4087)
		if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
			if ( ignored ) {
				ignored.push( elem );
			}

			continue;
		}

		contains = jQuery.contains( elem.ownerDocument, elem );

		// Append to fragment
		tmp = getAll( safe.appendChild( elem ), "script" );

		// Preserve script evaluation history
		if ( contains ) {
			setGlobalEval( tmp );
		}

		// Capture executables
		if ( scripts ) {
			j = 0;
			while ( ( elem = tmp[ j++ ] ) ) {
				if ( rscriptType.test( elem.type || "" ) ) {
					scripts.push( elem );
				}
			}
		}
	}

	tmp = null;

	return safe;
}


( function() {
	var i, eventName,
		div = document.createElement( "div" );

	// Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
	for ( i in { submit: true, change: true, focusin: true } ) {
		eventName = "on" + i;

		if ( !( support[ i ] = eventName in window ) ) {

			// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
			div.setAttribute( eventName, "t" );
			support[ i ] = div.attributes[ eventName ].expando === false;
		}
	}

	// Null elements to avoid leaks in IE.
	div = null;
} )();


var rformElems = /^(?:input|select|textarea)$/i,
	rkeyEvent = /^key/,
	rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
	rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
	rtypenamespace = /^([^.]*)(?:\.(.+)|)/;

function returnTrue() {
	return true;
}

function returnFalse() {
	return false;
}

// Support: IE9
// See #13393 for more info
function safeActiveElement() {
	try {
		return document.activeElement;
	} catch ( err ) { }
}

function on( elem, types, selector, data, fn, one ) {
	var origFn, type;

	// Types can be a map of types/handlers
	if ( typeof types === "object" ) {

		// ( types-Object, selector, data )
		if ( typeof selector !== "string" ) {

			// ( types-Object, data )
			data = data || selector;
			selector = undefined;
		}
		for ( type in types ) {
			on( elem, type, selector, data, types[ type ], one );
		}
		return elem;
	}

	if ( data == null && fn == null ) {

		// ( types, fn )
		fn = selector;
		data = selector = undefined;
	} else if ( fn == null ) {
		if ( typeof selector === "string" ) {

			// ( types, selector, fn )
			fn = data;
			data = undefined;
		} else {

			// ( types, data, fn )
			fn = data;
			data = selector;
			selector = undefined;
		}
	}
	if ( fn === false ) {
		fn = returnFalse;
	} else if ( !fn ) {
		return elem;
	}

	if ( one === 1 ) {
		origFn = fn;
		fn = function( event ) {

			// Can use an empty set, since event contains the info
			jQuery().off( event );
			return origFn.apply( this, arguments );
		};

		// Use same guid so caller can remove using origFn
		fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
	}
	return elem.each( function() {
		jQuery.event.add( this, types, fn, data, selector );
	} );
}

/*
 * Helper functions for managing events -- not part of the public interface.
 * Props to Dean Edwards' addEvent library for many of the ideas.
 */
jQuery.event = {

	global: {},

	add: function( elem, types, handler, data, selector ) {
		var tmp, events, t, handleObjIn,
			special, eventHandle, handleObj,
			handlers, type, namespaces, origType,
			elemData = jQuery._data( elem );

		// Don't attach events to noData or text/comment nodes (but allow plain objects)
		if ( !elemData ) {
			return;
		}

		// Caller can pass in an object of custom data in lieu of the handler
		if ( handler.handler ) {
			handleObjIn = handler;
			handler = handleObjIn.handler;
			selector = handleObjIn.selector;
		}

		// Make sure that the handler has a unique ID, used to find/remove it later
		if ( !handler.guid ) {
			handler.guid = jQuery.guid++;
		}

		// Init the element's event structure and main handler, if this is the first
		if ( !( events = elemData.events ) ) {
			events = elemData.events = {};
		}
		if ( !( eventHandle = elemData.handle ) ) {
			eventHandle = elemData.handle = function( e ) {

				// Discard the second event of a jQuery.event.trigger() and
				// when an event is called after a page has unloaded
				return typeof jQuery !== "undefined" &&
					( !e || jQuery.event.triggered !== e.type ) ?
					jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
					undefined;
			};

			// Add elem as a property of the handle fn to prevent a memory leak
			// with IE non-native events
			eventHandle.elem = elem;
		}

		// Handle multiple events separated by a space
		types = ( types || "" ).match( rnotwhite ) || [ "" ];
		t = types.length;
		while ( t-- ) {
			tmp = rtypenamespace.exec( types[ t ] ) || [];
			type = origType = tmp[ 1 ];
			namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();

			// There *must* be a type, no attaching namespace-only handlers
			if ( !type ) {
				continue;
			}

			// If event changes its type, use the special event handlers for the changed type
			special = jQuery.event.special[ type ] || {};

			// If selector defined, determine special event api type, otherwise given type
			type = ( selector ? special.delegateType : special.bindType ) || type;

			// Update special based on newly reset type
			special = jQuery.event.special[ type ] || {};

			// handleObj is passed to all event handlers
			handleObj = jQuery.extend( {
				type: type,
				origType: origType,
				data: data,
				handler: handler,
				guid: handler.guid,
				selector: selector,
				needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
				namespace: namespaces.join( "." )
			}, handleObjIn );

			// Init the event handler queue if we're the first
			if ( !( handlers = events[ type ] ) ) {
				handlers = events[ type ] = [];
				handlers.delegateCount = 0;

				// Only use addEventListener/attachEvent if the special events handler returns false
				if ( !special.setup ||
					special.setup.call( elem, data, namespaces, eventHandle ) === false ) {

					// Bind the global event handler to the element
					if ( elem.addEventListener ) {
						elem.addEventListener( type, eventHandle, false );

					} else if ( elem.attachEvent ) {
						elem.attachEvent( "on" + type, eventHandle );
					}
				}
			}

			if ( special.add ) {
				special.add.call( elem, handleObj );

				if ( !handleObj.handler.guid ) {
					handleObj.handler.guid = handler.guid;
				}
			}

			// Add to the element's handler list, delegates in front
			if ( selector ) {
				handlers.splice( handlers.delegateCount++, 0, handleObj );
			} else {
				handlers.push( handleObj );
			}

			// Keep track of which events have ever been used, for event optimization
			jQuery.event.global[ type ] = true;
		}

		// Nullify elem to prevent memory leaks in IE
		elem = null;
	},

	// Detach an event or set of events from an element
	remove: function( elem, types, handler, selector, mappedTypes ) {
		var j, handleObj, tmp,
			origCount, t, events,
			special, handlers, type,
			namespaces, origType,
			elemData = jQuery.hasData( elem ) && jQuery._data( elem );

		if ( !elemData || !( events = elemData.events ) ) {
			return;
		}

		// Once for each type.namespace in types; type may be omitted
		types = ( types || "" ).match( rnotwhite ) || [ "" ];
		t = types.length;
		while ( t-- ) {
			tmp = rtypenamespace.exec( types[ t ] ) || [];
			type = origType = tmp[ 1 ];
			namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();

			// Unbind all events (on this namespace, if provided) for the element
			if ( !type ) {
				for ( type in events ) {
					jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
				}
				continue;
			}

			special = jQuery.event.special[ type ] || {};
			type = ( selector ? special.delegateType : special.bindType ) || type;
			handlers = events[ type ] || [];
			tmp = tmp[ 2 ] &&
				new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );

			// Remove matching events
			origCount = j = handlers.length;
			while ( j-- ) {
				handleObj = handlers[ j ];

				if ( ( mappedTypes || origType === handleObj.origType ) &&
					( !handler || handler.guid === handleObj.guid ) &&
					( !tmp || tmp.test( handleObj.namespace ) ) &&
					( !selector || selector === handleObj.selector ||
						selector === "**" && handleObj.selector ) ) {
					handlers.splice( j, 1 );

					if ( handleObj.selector ) {
						handlers.delegateCount--;
					}
					if ( special.remove ) {
						special.remove.call( elem, handleObj );
					}
				}
			}

			// Remove generic event handler if we removed something and no more handlers exist
			// (avoids potential for endless recursion during removal of special event handlers)
			if ( origCount && !handlers.length ) {
				if ( !special.teardown ||
					special.teardown.call( elem, namespaces, elemData.handle ) === false ) {

					jQuery.removeEvent( elem, type, elemData.handle );
				}

				delete events[ type ];
			}
		}

		// Remove the expando if it's no longer used
		if ( jQuery.isEmptyObject( events ) ) {
			delete elemData.handle;

			// removeData also checks for emptiness and clears the expando if empty
			// so use it instead of delete
			jQuery._removeData( elem, "events" );
		}
	},

	trigger: function( event, data, elem, onlyHandlers ) {
		var handle, ontype, cur,
			bubbleType, special, tmp, i,
			eventPath = [ elem || document ],
			type = hasOwn.call( event, "type" ) ? event.type : event,
			namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];

		cur = tmp = elem = elem || document;

		// Don't do events on text and comment nodes
		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
			return;
		}

		// focus/blur morphs to focusin/out; ensure we're not firing them right now
		if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
			return;
		}

		if ( type.indexOf( "." ) > -1 ) {

			// Namespaced trigger; create a regexp to match event type in handle()
			namespaces = type.split( "." );
			type = namespaces.shift();
			namespaces.sort();
		}
		ontype = type.indexOf( ":" ) < 0 && "on" + type;

		// Caller can pass in a jQuery.Event object, Object, or just an event type string
		event = event[ jQuery.expando ] ?
			event :
			new jQuery.Event( type, typeof event === "object" && event );

		// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
		event.isTrigger = onlyHandlers ? 2 : 3;
		event.namespace = namespaces.join( "." );
		event.rnamespace = event.namespace ?
			new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
			null;

		// Clean up the event in case it is being reused
		event.result = undefined;
		if ( !event.target ) {
			event.target = elem;
		}

		// Clone any incoming data and prepend the event, creating the handler arg list
		data = data == null ?
			[ event ] :
			jQuery.makeArray( data, [ event ] );

		// Allow special events to draw outside the lines
		special = jQuery.event.special[ type ] || {};
		if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
			return;
		}

		// Determine event propagation path in advance, per W3C events spec (#9951)
		// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
		if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {

			bubbleType = special.delegateType || type;
			if ( !rfocusMorph.test( bubbleType + type ) ) {
				cur = cur.parentNode;
			}
			for ( ; cur; cur = cur.parentNode ) {
				eventPath.push( cur );
				tmp = cur;
			}

			// Only add window if we got to document (e.g., not plain obj or detached DOM)
			if ( tmp === ( elem.ownerDocument || document ) ) {
				eventPath.push( tmp.defaultView || tmp.parentWindow || window );
			}
		}

		// Fire handlers on the event path
		i = 0;
		while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {

			event.type = i > 1 ?
				bubbleType :
				special.bindType || type;

			// jQuery handler
			handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
				jQuery._data( cur, "handle" );

			if ( handle ) {
				handle.apply( cur, data );
			}

			// Native handler
			handle = ontype && cur[ ontype ];
			if ( handle && handle.apply && acceptData( cur ) ) {
				event.result = handle.apply( cur, data );
				if ( event.result === false ) {
					event.preventDefault();
				}
			}
		}
		event.type = type;

		// If nobody prevented the default action, do it now
		if ( !onlyHandlers && !event.isDefaultPrevented() ) {

			if (
				( !special._default ||
				 special._default.apply( eventPath.pop(), data ) === false
				) && acceptData( elem )
			) {

				// Call a native DOM method on the target with the same name name as the event.
				// Can't use an .isFunction() check here because IE6/7 fails that test.
				// Don't do default actions on window, that's where global variables be (#6170)
				if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {

					// Don't re-trigger an onFOO event when we call its FOO() method
					tmp = elem[ ontype ];

					if ( tmp ) {
						elem[ ontype ] = null;
					}

					// Prevent re-triggering of the same event, since we already bubbled it above
					jQuery.event.triggered = type;
					try {
						elem[ type ]();
					} catch ( e ) {

						// IE<9 dies on focus/blur to hidden element (#1486,#12518)
						// only reproducible on winXP IE8 native, not IE9 in IE8 mode
					}
					jQuery.event.triggered = undefined;

					if ( tmp ) {
						elem[ ontype ] = tmp;
					}
				}
			}
		}

		return event.result;
	},

	dispatch: function( event ) {

		// Make a writable jQuery.Event from the native event object
		event = jQuery.event.fix( event );

		var i, j, ret, matched, handleObj,
			handlerQueue = [],
			args = slice.call( arguments ),
			handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
			special = jQuery.event.special[ event.type ] || {};

		// Use the fix-ed jQuery.Event rather than the (read-only) native event
		args[ 0 ] = event;
		event.delegateTarget = this;

		// Call the preDispatch hook for the mapped type, and let it bail if desired
		if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
			return;
		}

		// Determine handlers
		handlerQueue = jQuery.event.handlers.call( this, event, handlers );

		// Run delegates first; they may want to stop propagation beneath us
		i = 0;
		while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
			event.currentTarget = matched.elem;

			j = 0;
			while ( ( handleObj = matched.handlers[ j++ ] ) &&
				!event.isImmediatePropagationStopped() ) {

				// Triggered event must either 1) have no namespace, or 2) have namespace(s)
				// a subset or equal to those in the bound event (both can have no namespace).
				if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {

					event.handleObj = handleObj;
					event.data = handleObj.data;

					ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
						handleObj.handler ).apply( matched.elem, args );

					if ( ret !== undefined ) {
						if ( ( event.result = ret ) === false ) {
							event.preventDefault();
							event.stopPropagation();
						}
					}
				}
			}
		}

		// Call the postDispatch hook for the mapped type
		if ( special.postDispatch ) {
			special.postDispatch.call( this, event );
		}

		return event.result;
	},

	handlers: function( event, handlers ) {
		var i, matches, sel, handleObj,
			handlerQueue = [],
			delegateCount = handlers.delegateCount,
			cur = event.target;

		// Support (at least): Chrome, IE9
		// Find delegate handlers
		// Black-hole SVG <use> instance trees (#13180)
		//
		// Support: Firefox<=42+
		// Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
		if ( delegateCount && cur.nodeType &&
			( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {

			/* jshint eqeqeq: false */
			for ( ; cur != this; cur = cur.parentNode || this ) {
				/* jshint eqeqeq: true */

				// Don't check non-elements (#13208)
				// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
				if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
					matches = [];
					for ( i = 0; i < delegateCount; i++ ) {
						handleObj = handlers[ i ];

						// Don't conflict with Object.prototype properties (#13203)
						sel = handleObj.selector + " ";

						if ( matches[ sel ] === undefined ) {
							matches[ sel ] = handleObj.needsContext ?
								jQuery( sel, this ).index( cur ) > -1 :
								jQuery.find( sel, this, null, [ cur ] ).length;
						}
						if ( matches[ sel ] ) {
							matches.push( handleObj );
						}
					}
					if ( matches.length ) {
						handlerQueue.push( { elem: cur, handlers: matches } );
					}
				}
			}
		}

		// Add the remaining (directly-bound) handlers
		if ( delegateCount < handlers.length ) {
			handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
		}

		return handlerQueue;
	},

	fix: function( event ) {
		if ( event[ jQuery.expando ] ) {
			return event;
		}

		// Create a writable copy of the event object and normalize some properties
		var i, prop, copy,
			type = event.type,
			originalEvent = event,
			fixHook = this.fixHooks[ type ];

		if ( !fixHook ) {
			this.fixHooks[ type ] = fixHook =
				rmouseEvent.test( type ) ? this.mouseHooks :
				rkeyEvent.test( type ) ? this.keyHooks :
				{};
		}
		copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;

		event = new jQuery.Event( originalEvent );

		i = copy.length;
		while ( i-- ) {
			prop = copy[ i ];
			event[ prop ] = originalEvent[ prop ];
		}

		// Support: IE<9
		// Fix target property (#1925)
		if ( !event.target ) {
			event.target = originalEvent.srcElement || document;
		}

		// Support: Safari 6-8+
		// Target should not be a text node (#504, #13143)
		if ( event.target.nodeType === 3 ) {
			event.target = event.target.parentNode;
		}

		// Support: IE<9
		// For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
		event.metaKey = !!event.metaKey;

		return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
	},

	// Includes some event props shared by KeyEvent and MouseEvent
	props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
		"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),

	fixHooks: {},

	keyHooks: {
		props: "char charCode key keyCode".split( " " ),
		filter: function( event, original ) {

			// Add which for key events
			if ( event.which == null ) {
				event.which = original.charCode != null ? original.charCode : original.keyCode;
			}

			return event;
		}
	},

	mouseHooks: {
		props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
			"pageX pageY screenX screenY toElement" ).split( " " ),
		filter: function( event, original ) {
			var body, eventDoc, doc,
				button = original.button,
				fromElement = original.fromElement;

			// Calculate pageX/Y if missing and clientX/Y available
			if ( event.pageX == null && original.clientX != null ) {
				eventDoc = event.target.ownerDocument || document;
				doc = eventDoc.documentElement;
				body = eventDoc.body;

				event.pageX = original.clientX +
					( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
					( doc && doc.clientLeft || body && body.clientLeft || 0 );
				event.pageY = original.clientY +
					( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) -
					( doc && doc.clientTop  || body && body.clientTop  || 0 );
			}

			// Add relatedTarget, if necessary
			if ( !event.relatedTarget && fromElement ) {
				event.relatedTarget = fromElement === event.target ?
					original.toElement :
					fromElement;
			}

			// Add which for click: 1 === left; 2 === middle; 3 === right
			// Note: button is not normalized, so don't use it
			if ( !event.which && button !== undefined ) {
				event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
			}

			return event;
		}
	},

	special: {
		load: {

			// Prevent triggered image.load events from bubbling to window.load
			noBubble: true
		},
		focus: {

			// Fire native event if possible so blur/focus sequence is correct
			trigger: function() {
				if ( this !== safeActiveElement() && this.focus ) {
					try {
						this.focus();
						return false;
					} catch ( e ) {

						// Support: IE<9
						// If we error on focus to hidden element (#1486, #12518),
						// let .trigger() run the handlers
					}
				}
			},
			delegateType: "focusin"
		},
		blur: {
			trigger: function() {
				if ( this === safeActiveElement() && this.blur ) {
					this.blur();
					return false;
				}
			},
			delegateType: "focusout"
		},
		click: {

			// For checkbox, fire native event so checked state will be right
			trigger: function() {
				if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
					this.click();
					return false;
				}
			},

			// For cross-browser consistency, don't fire native .click() on links
			_default: function( event ) {
				return jQuery.nodeName( event.target, "a" );
			}
		},

		beforeunload: {
			postDispatch: function( event ) {

				// Support: Firefox 20+
				// Firefox doesn't alert if the returnValue field is not set.
				if ( event.result !== undefined && event.originalEvent ) {
					event.originalEvent.returnValue = event.result;
				}
			}
		}
	},

	// Piggyback on a donor event to simulate a different one
	simulate: function( type, elem, event ) {
		var e = jQuery.extend(
			new jQuery.Event(),
			event,
			{
				type: type,
				isSimulated: true

				// Previously, `originalEvent: {}` was set here, so stopPropagation call
				// would not be triggered on donor event, since in our own
				// jQuery.event.stopPropagation function we had a check for existence of
				// originalEvent.stopPropagation method, so, consequently it would be a noop.
				//
				// Guard for simulated events was moved to jQuery.event.stopPropagation function
				// since `originalEvent` should point to the original event for the
				// constancy with other events and for more focused logic
			}
		);

		jQuery.event.trigger( e, null, elem );

		if ( e.isDefaultPrevented() ) {
			event.preventDefault();
		}
	}
};

jQuery.removeEvent = document.removeEventListener ?
	function( elem, type, handle ) {

		// This "if" is needed for plain objects
		if ( elem.removeEventListener ) {
			elem.removeEventListener( type, handle );
		}
	} :
	function( elem, type, handle ) {
		var name = "on" + type;

		if ( elem.detachEvent ) {

			// #8545, #7054, preventing memory leaks for custom events in IE6-8
			// detachEvent needed property on element, by name of that event,
			// to properly expose it to GC
			if ( typeof elem[ name ] === "undefined" ) {
				elem[ name ] = null;
			}

			elem.detachEvent( name, handle );
		}
	};

jQuery.Event = function( src, props ) {

	// Allow instantiation without the 'new' keyword
	if ( !( this instanceof jQuery.Event ) ) {
		return new jQuery.Event( src, props );
	}

	// Event object
	if ( src && src.type ) {
		this.originalEvent = src;
		this.type = src.type;

		// Events bubbling up the document may have been marked as prevented
		// by a handler lower down the tree; reflect the correct value.
		this.isDefaultPrevented = src.defaultPrevented ||
				src.defaultPrevented === undefined &&

				// Support: IE < 9, Android < 4.0
				src.returnValue === false ?
			returnTrue :
			returnFalse;

	// Event type
	} else {
		this.type = src;
	}

	// Put explicitly provided properties onto the event object
	if ( props ) {
		jQuery.extend( this, props );
	}

	// Create a timestamp if incoming event doesn't have one
	this.timeStamp = src && src.timeStamp || jQuery.now();

	// Mark it as fixed
	this[ jQuery.expando ] = true;
};

// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
jQuery.Event.prototype = {
	constructor: jQuery.Event,
	isDefaultPrevented: returnFalse,
	isPropagationStopped: returnFalse,
	isImmediatePropagationStopped: returnFalse,

	preventDefault: function() {
		var e = this.originalEvent;

		this.isDefaultPrevented = returnTrue;
		if ( !e ) {
			return;
		}

		// If preventDefault exists, run it on the original event
		if ( e.preventDefault ) {
			e.preventDefault();

		// Support: IE
		// Otherwise set the returnValue property of the original event to false
		} else {
			e.returnValue = false;
		}
	},
	stopPropagation: function() {
		var e = this.originalEvent;

		this.isPropagationStopped = returnTrue;

		if ( !e || this.isSimulated ) {
			return;
		}

		// If stopPropagation exists, run it on the original event
		if ( e.stopPropagation ) {
			e.stopPropagation();
		}

		// Support: IE
		// Set the cancelBubble property of the original event to true
		e.cancelBubble = true;
	},
	stopImmediatePropagation: function() {
		var e = this.originalEvent;

		this.isImmediatePropagationStopped = returnTrue;

		if ( e && e.stopImmediatePropagation ) {
			e.stopImmediatePropagation();
		}

		this.stopPropagation();
	}
};

// Create mouseenter/leave events using mouseover/out and event-time checks
// so that event delegation works in jQuery.
// Do the same for pointerenter/pointerleave and pointerover/pointerout
//
// Support: Safari 7 only
// Safari sends mouseenter too often; see:
// https://code.google.com/p/chromium/issues/detail?id=470258
// for the description of the bug (it existed in older Chrome versions as well).
jQuery.each( {
	mouseenter: "mouseover",
	mouseleave: "mouseout",
	pointerenter: "pointerover",
	pointerleave: "pointerout"
}, function( orig, fix ) {
	jQuery.event.special[ orig ] = {
		delegateType: fix,
		bindType: fix,

		handle: function( event ) {
			var ret,
				target = this,
				related = event.relatedTarget,
				handleObj = event.handleObj;

			// For mouseenter/leave call the handler if related is outside the target.
			// NB: No relatedTarget if the mouse left/entered the browser window
			if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
				event.type = handleObj.origType;
				ret = handleObj.handler.apply( this, arguments );
				event.type = fix;
			}
			return ret;
		}
	};
} );

// IE submit delegation
if ( !support.submit ) {

	jQuery.event.special.submit = {
		setup: function() {

			// Only need this for delegated form submit events
			if ( jQuery.nodeName( this, "form" ) ) {
				return false;
			}

			// Lazy-add a submit handler when a descendant form may potentially be submitted
			jQuery.event.add( this, "click._submit keypress._submit", function( e ) {

				// Node name check avoids a VML-related crash in IE (#9807)
				var elem = e.target,
					form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?

						// Support: IE <=8
						// We use jQuery.prop instead of elem.form
						// to allow fixing the IE8 delegated submit issue (gh-2332)
						// by 3rd party polyfills/workarounds.
						jQuery.prop( elem, "form" ) :
						undefined;

				if ( form && !jQuery._data( form, "submit" ) ) {
					jQuery.event.add( form, "submit._submit", function( event ) {
						event._submitBubble = true;
					} );
					jQuery._data( form, "submit", true );
				}
			} );

			// return undefined since we don't need an event listener
		},

		postDispatch: function( event ) {

			// If form was submitted by the user, bubble the event up the tree
			if ( event._submitBubble ) {
				delete event._submitBubble;
				if ( this.parentNode && !event.isTrigger ) {
					jQuery.event.simulate( "submit", this.parentNode, event );
				}
			}
		},

		teardown: function() {

			// Only need this for delegated form submit events
			if ( jQuery.nodeName( this, "form" ) ) {
				return false;
			}

			// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
			jQuery.event.remove( this, "._submit" );
		}
	};
}

// IE change delegation and checkbox/radio fix
if ( !support.change ) {

	jQuery.event.special.change = {

		setup: function() {

			if ( rformElems.test( this.nodeName ) ) {

				// IE doesn't fire change on a check/radio until blur; trigger it on click
				// after a propertychange. Eat the blur-change in special.change.handle.
				// This still fires onchange a second time for check/radio after blur.
				if ( this.type === "checkbox" || this.type === "radio" ) {
					jQuery.event.add( this, "propertychange._change", function( event ) {
						if ( event.originalEvent.propertyName === "checked" ) {
							this._justChanged = true;
						}
					} );
					jQuery.event.add( this, "click._change", function( event ) {
						if ( this._justChanged && !event.isTrigger ) {
							this._justChanged = false;
						}

						// Allow triggered, simulated change events (#11500)
						jQuery.event.simulate( "change", this, event );
					} );
				}
				return false;
			}

			// Delegated event; lazy-add a change handler on descendant inputs
			jQuery.event.add( this, "beforeactivate._change", function( e ) {
				var elem = e.target;

				if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
					jQuery.event.add( elem, "change._change", function( event ) {
						if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
							jQuery.event.simulate( "change", this.parentNode, event );
						}
					} );
					jQuery._data( elem, "change", true );
				}
			} );
		},

		handle: function( event ) {
			var elem = event.target;

			// Swallow native change events from checkbox/radio, we already triggered them above
			if ( this !== elem || event.isSimulated || event.isTrigger ||
				( elem.type !== "radio" && elem.type !== "checkbox" ) ) {

				return event.handleObj.handler.apply( this, arguments );
			}
		},

		teardown: function() {
			jQuery.event.remove( this, "._change" );

			return !rformElems.test( this.nodeName );
		}
	};
}

// Support: Firefox
// Firefox doesn't have focus(in | out) events
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
//
// Support: Chrome, Safari
// focus(in | out) events fire after focus & blur events,
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
if ( !support.focusin ) {
	jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {

		// Attach a single capturing handler on the document while someone wants focusin/focusout
		var handler = function( event ) {
			jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
		};

		jQuery.event.special[ fix ] = {
			setup: function() {
				var doc = this.ownerDocument || this,
					attaches = jQuery._data( doc, fix );

				if ( !attaches ) {
					doc.addEventListener( orig, handler, true );
				}
				jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
			},
			teardown: function() {
				var doc = this.ownerDocument || this,
					attaches = jQuery._data( doc, fix ) - 1;

				if ( !attaches ) {
					doc.removeEventListener( orig, handler, true );
					jQuery._removeData( doc, fix );
				} else {
					jQuery._data( doc, fix, attaches );
				}
			}
		};
	} );
}

jQuery.fn.extend( {

	on: function( types, selector, data, fn ) {
		return on( this, types, selector, data, fn );
	},
	one: function( types, selector, data, fn ) {
		return on( this, types, selector, data, fn, 1 );
	},
	off: function( types, selector, fn ) {
		var handleObj, type;
		if ( types && types.preventDefault && types.handleObj ) {

			// ( event )  dispatched jQuery.Event
			handleObj = types.handleObj;
			jQuery( types.delegateTarget ).off(
				handleObj.namespace ?
					handleObj.origType + "." + handleObj.namespace :
					handleObj.origType,
				handleObj.selector,
				handleObj.handler
			);
			return this;
		}
		if ( typeof types === "object" ) {

			// ( types-object [, selector] )
			for ( type in types ) {
				this.off( type, selector, types[ type ] );
			}
			return this;
		}
		if ( selector === false || typeof selector === "function" ) {

			// ( types [, fn] )
			fn = selector;
			selector = undefined;
		}
		if ( fn === false ) {
			fn = returnFalse;
		}
		return this.each( function() {
			jQuery.event.remove( this, types, fn, selector );
		} );
	},

	trigger: function( type, data ) {
		return this.each( function() {
			jQuery.event.trigger( type, data, this );
		} );
	},
	triggerHandler: function( type, data ) {
		var elem = this[ 0 ];
		if ( elem ) {
			return jQuery.event.trigger( type, data, elem, true );
		}
	}
} );


var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
	rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
	rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,

	// Support: IE 10-11, Edge 10240+
	// In IE/Edge using regex groups here causes severe slowdowns.
	// See https://connect.microsoft.com/IE/feedback/details/1736512/
	rnoInnerhtml = /<script|<style|<link/i,

	// checked="checked" or checked
	rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
	rscriptTypeMasked = /^true\/(.*)/,
	rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
	safeFragment = createSafeFragment( document ),
	fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );

// Support: IE<8
// Manipulating tables requires a tbody
function manipulationTarget( elem, content ) {
	return jQuery.nodeName( elem, "table" ) &&
		jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?

		elem.getElementsByTagName( "tbody" )[ 0 ] ||
			elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
		elem;
}

// Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) {
	elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
	return elem;
}
function restoreScript( elem ) {
	var match = rscriptTypeMasked.exec( elem.type );
	if ( match ) {
		elem.type = match[ 1 ];
	} else {
		elem.removeAttribute( "type" );
	}
	return elem;
}

function cloneCopyEvent( src, dest ) {
	if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
		return;
	}

	var type, i, l,
		oldData = jQuery._data( src ),
		curData = jQuery._data( dest, oldData ),
		events = oldData.events;

	if ( events ) {
		delete curData.handle;
		curData.events = {};

		for ( type in events ) {
			for ( i = 0, l = events[ type ].length; i < l; i++ ) {
				jQuery.event.add( dest, type, events[ type ][ i ] );
			}
		}
	}

	// make the cloned public data object a copy from the original
	if ( curData.data ) {
		curData.data = jQuery.extend( {}, curData.data );
	}
}

function fixCloneNodeIssues( src, dest ) {
	var nodeName, e, data;

	// We do not need to do anything for non-Elements
	if ( dest.nodeType !== 1 ) {
		return;
	}

	nodeName = dest.nodeName.toLowerCase();

	// IE6-8 copies events bound via attachEvent when using cloneNode.
	if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
		data = jQuery._data( dest );

		for ( e in data.events ) {
			jQuery.removeEvent( dest, e, data.handle );
		}

		// Event data gets referenced instead of copied if the expando gets copied too
		dest.removeAttribute( jQuery.expando );
	}

	// IE blanks contents when cloning scripts, and tries to evaluate newly-set text
	if ( nodeName === "script" && dest.text !== src.text ) {
		disableScript( dest ).text = src.text;
		restoreScript( dest );

	// IE6-10 improperly clones children of object elements using classid.
	// IE10 throws NoModificationAllowedError if parent is null, #12132.
	} else if ( nodeName === "object" ) {
		if ( dest.parentNode ) {
			dest.outerHTML = src.outerHTML;
		}

		// This path appears unavoidable for IE9. When cloning an object
		// element in IE9, the outerHTML strategy above is not sufficient.
		// If the src has innerHTML and the destination does not,
		// copy the src.innerHTML into the dest.innerHTML. #10324
		if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
			dest.innerHTML = src.innerHTML;
		}

	} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {

		// IE6-8 fails to persist the checked state of a cloned checkbox
		// or radio button. Worse, IE6-7 fail to give the cloned element
		// a checked appearance if the defaultChecked value isn't also set

		dest.defaultChecked = dest.checked = src.checked;

		// IE6-7 get confused and end up setting the value of a cloned
		// checkbox/radio button to an empty string instead of "on"
		if ( dest.value !== src.value ) {
			dest.value = src.value;
		}

	// IE6-8 fails to return the selected option to the default selected
	// state when cloning options
	} else if ( nodeName === "option" ) {
		dest.defaultSelected = dest.selected = src.defaultSelected;

	// IE6-8 fails to set the defaultValue to the correct value when
	// cloning other types of input fields
	} else if ( nodeName === "input" || nodeName === "textarea" ) {
		dest.defaultValue = src.defaultValue;
	}
}

function domManip( collection, args, callback, ignored ) {

	// Flatten any nested arrays
	args = concat.apply( [], args );

	var first, node, hasScripts,
		scripts, doc, fragment,
		i = 0,
		l = collection.length,
		iNoClone = l - 1,
		value = args[ 0 ],
		isFunction = jQuery.isFunction( value );

	// We can't cloneNode fragments that contain checked, in WebKit
	if ( isFunction ||
			( l > 1 && typeof value === "string" &&
				!support.checkClone && rchecked.test( value ) ) ) {
		return collection.each( function( index ) {
			var self = collection.eq( index );
			if ( isFunction ) {
				args[ 0 ] = value.call( this, index, self.html() );
			}
			domManip( self, args, callback, ignored );
		} );
	}

	if ( l ) {
		fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
		first = fragment.firstChild;

		if ( fragment.childNodes.length === 1 ) {
			fragment = first;
		}

		// Require either new content or an interest in ignored elements to invoke the callback
		if ( first || ignored ) {
			scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
			hasScripts = scripts.length;

			// Use the original fragment for the last item
			// instead of the first because it can end up
			// being emptied incorrectly in certain situations (#8070).
			for ( ; i < l; i++ ) {
				node = fragment;

				if ( i !== iNoClone ) {
					node = jQuery.clone( node, true, true );

					// Keep references to cloned scripts for later restoration
					if ( hasScripts ) {

						// Support: Android<4.1, PhantomJS<2
						// push.apply(_, arraylike) throws on ancient WebKit
						jQuery.merge( scripts, getAll( node, "script" ) );
					}
				}

				callback.call( collection[ i ], node, i );
			}

			if ( hasScripts ) {
				doc = scripts[ scripts.length - 1 ].ownerDocument;

				// Reenable scripts
				jQuery.map( scripts, restoreScript );

				// Evaluate executable scripts on first document insertion
				for ( i = 0; i < hasScripts; i++ ) {
					node = scripts[ i ];
					if ( rscriptType.test( node.type || "" ) &&
						!jQuery._data( node, "globalEval" ) &&
						jQuery.contains( doc, node ) ) {

						if ( node.src ) {

							// Optional AJAX dependency, but won't run scripts if not present
							if ( jQuery._evalUrl ) {
								jQuery._evalUrl( node.src );
							}
						} else {
							jQuery.globalEval(
								( node.text || node.textContent || node.innerHTML || "" )
									.replace( rcleanScript, "" )
							);
						}
					}
				}
			}

			// Fix #11809: Avoid leaking memory
			fragment = first = null;
		}
	}

	return collection;
}

function remove( elem, selector, keepData ) {
	var node,
		elems = selector ? jQuery.filter( selector, elem ) : elem,
		i = 0;

	for ( ; ( node = elems[ i ] ) != null; i++ ) {

		if ( !keepData && node.nodeType === 1 ) {
			jQuery.cleanData( getAll( node ) );
		}

		if ( node.parentNode ) {
			if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
				setGlobalEval( getAll( node, "script" ) );
			}
			node.parentNode.removeChild( node );
		}
	}

	return elem;
}

jQuery.extend( {
	htmlPrefilter: function( html ) {
		return html.replace( rxhtmlTag, "<$1></$2>" );
	},

	clone: function( elem, dataAndEvents, deepDataAndEvents ) {
		var destElements, node, clone, i, srcElements,
			inPage = jQuery.contains( elem.ownerDocument, elem );

		if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
			!rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {

			clone = elem.cloneNode( true );

		// IE<=8 does not properly clone detached, unknown element nodes
		} else {
			fragmentDiv.innerHTML = elem.outerHTML;
			fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
		}

		if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
				( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {

			// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
			destElements = getAll( clone );
			srcElements = getAll( elem );

			// Fix all IE cloning issues
			for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {

				// Ensure that the destination node is not null; Fixes #9587
				if ( destElements[ i ] ) {
					fixCloneNodeIssues( node, destElements[ i ] );
				}
			}
		}

		// Copy the events from the original to the clone
		if ( dataAndEvents ) {
			if ( deepDataAndEvents ) {
				srcElements = srcElements || getAll( elem );
				destElements = destElements || getAll( clone );

				for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
					cloneCopyEvent( node, destElements[ i ] );
				}
			} else {
				cloneCopyEvent( elem, clone );
			}
		}

		// Preserve script evaluation history
		destElements = getAll( clone, "script" );
		if ( destElements.length > 0 ) {
			setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
		}

		destElements = srcElements = node = null;

		// Return the cloned set
		return clone;
	},

	cleanData: function( elems, /* internal */ forceAcceptData ) {
		var elem, type, id, data,
			i = 0,
			internalKey = jQuery.expando,
			cache = jQuery.cache,
			attributes = support.attributes,
			special = jQuery.event.special;

		for ( ; ( elem = elems[ i ] ) != null; i++ ) {
			if ( forceAcceptData || acceptData( elem ) ) {

				id = elem[ internalKey ];
				data = id && cache[ id ];

				if ( data ) {
					if ( data.events ) {
						for ( type in data.events ) {
							if ( special[ type ] ) {
								jQuery.event.remove( elem, type );

							// This is a shortcut to avoid jQuery.event.remove's overhead
							} else {
								jQuery.removeEvent( elem, type, data.handle );
							}
						}
					}

					// Remove cache only if it was not already removed by jQuery.event.remove
					if ( cache[ id ] ) {

						delete cache[ id ];

						// Support: IE<9
						// IE does not allow us to delete expando properties from nodes
						// IE creates expando attributes along with the property
						// IE does not have a removeAttribute function on Document nodes
						if ( !attributes && typeof elem.removeAttribute !== "undefined" ) {
							elem.removeAttribute( internalKey );

						// Webkit & Blink performance suffers when deleting properties
						// from DOM nodes, so set to undefined instead
						// https://code.google.com/p/chromium/issues/detail?id=378607
						} else {
							elem[ internalKey ] = undefined;
						}

						deletedIds.push( id );
					}
				}
			}
		}
	}
} );

jQuery.fn.extend( {

	// Keep domManip exposed until 3.0 (gh-2225)
	domManip: domManip,

	detach: function( selector ) {
		return remove( this, selector, true );
	},

	remove: function( selector ) {
		return remove( this, selector );
	},

	text: function( value ) {
		return access( this, function( value ) {
			return value === undefined ?
				jQuery.text( this ) :
				this.empty().append(
					( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
				);
		}, null, value, arguments.length );
	},

	append: function() {
		return domManip( this, arguments, function( elem ) {
			if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
				var target = manipulationTarget( this, elem );
				target.appendChild( elem );
			}
		} );
	},

	prepend: function() {
		return domManip( this, arguments, function( elem ) {
			if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
				var target = manipulationTarget( this, elem );
				target.insertBefore( elem, target.firstChild );
			}
		} );
	},

	before: function() {
		return domManip( this, arguments, function( elem ) {
			if ( this.parentNode ) {
				this.parentNode.insertBefore( elem, this );
			}
		} );
	},

	after: function() {
		return domManip( this, arguments, function( elem ) {
			if ( this.parentNode ) {
				this.parentNode.insertBefore( elem, this.nextSibling );
			}
		} );
	},

	empty: function() {
		var elem,
			i = 0;

		for ( ; ( elem = this[ i ] ) != null; i++ ) {

			// Remove element nodes and prevent memory leaks
			if ( elem.nodeType === 1 ) {
				jQuery.cleanData( getAll( elem, false ) );
			}

			// Remove any remaining nodes
			while ( elem.firstChild ) {
				elem.removeChild( elem.firstChild );
			}

			// If this is a select, ensure that it displays empty (#12336)
			// Support: IE<9
			if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
				elem.options.length = 0;
			}
		}

		return this;
	},

	clone: function( dataAndEvents, deepDataAndEvents ) {
		dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
		deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;

		return this.map( function() {
			return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
		} );
	},

	html: function( value ) {
		return access( this, function( value ) {
			var elem = this[ 0 ] || {},
				i = 0,
				l = this.length;

			if ( value === undefined ) {
				return elem.nodeType === 1 ?
					elem.innerHTML.replace( rinlinejQuery, "" ) :
					undefined;
			}

			// See if we can take a shortcut and just use innerHTML
			if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
				( support.htmlSerialize || !rnoshimcache.test( value )  ) &&
				( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
				!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {

				value = jQuery.htmlPrefilter( value );

				try {
					for ( ; i < l; i++ ) {

						// Remove element nodes and prevent memory leaks
						elem = this[ i ] || {};
						if ( elem.nodeType === 1 ) {
							jQuery.cleanData( getAll( elem, false ) );
							elem.innerHTML = value;
						}
					}

					elem = 0;

				// If using innerHTML throws an exception, use the fallback method
				} catch ( e ) {}
			}

			if ( elem ) {
				this.empty().append( value );
			}
		}, null, value, arguments.length );
	},

	replaceWith: function() {
		var ignored = [];

		// Make the changes, replacing each non-ignored context element with the new content
		return domManip( this, arguments, function( elem ) {
			var parent = this.parentNode;

			if ( jQuery.inArray( this, ignored ) < 0 ) {
				jQuery.cleanData( getAll( this ) );
				if ( parent ) {
					parent.replaceChild( elem, this );
				}
			}

		// Force callback invocation
		}, ignored );
	}
} );

jQuery.each( {
	appendTo: "append",
	prependTo: "prepend",
	insertBefore: "before",
	insertAfter: "after",
	replaceAll: "replaceWith"
}, function( name, original ) {
	jQuery.fn[ name ] = function( selector ) {
		var elems,
			i = 0,
			ret = [],
			insert = jQuery( selector ),
			last = insert.length - 1;

		for ( ; i <= last; i++ ) {
			elems = i === last ? this : this.clone( true );
			jQuery( insert[ i ] )[ original ]( elems );

			// Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
			push.apply( ret, elems.get() );
		}

		return this.pushStack( ret );
	};
} );


var iframe,
	elemdisplay = {

		// Support: Firefox
		// We have to pre-define these values for FF (#10227)
		HTML: "block",
		BODY: "block"
	};

/**
 * Retrieve the actual display of a element
 * @param {String} name nodeName of the element
 * @param {Object} doc Document object
 */

// Called only from within defaultDisplay
function actualDisplay( name, doc ) {
	var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),

		display = jQuery.css( elem[ 0 ], "display" );

	// We don't have any data stored on the element,
	// so use "detach" method as fast way to get rid of the element
	elem.detach();

	return display;
}

/**
 * Try to determine the default display value of an element
 * @param {String} nodeName
 */
function defaultDisplay( nodeName ) {
	var doc = document,
		display = elemdisplay[ nodeName ];

	if ( !display ) {
		display = actualDisplay( nodeName, doc );

		// If the simple way fails, read from inside an iframe
		if ( display === "none" || !display ) {

			// Use the already-created iframe if possible
			iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
				.appendTo( doc.documentElement );

			// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
			doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;

			// Support: IE
			doc.write();
			doc.close();

			display = actualDisplay( nodeName, doc );
			iframe.detach();
		}

		// Store the correct default display
		elemdisplay[ nodeName ] = display;
	}

	return display;
}
var rmargin = ( /^margin/ );

var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );

var swap = function( elem, options, callback, args ) {
	var ret, name,
		old = {};

	// Remember the old values, and insert the new ones
	for ( name in options ) {
		old[ name ] = elem.style[ name ];
		elem.style[ name ] = options[ name ];
	}

	ret = callback.apply( elem, args || [] );

	// Revert the old values
	for ( name in options ) {
		elem.style[ name ] = old[ name ];
	}

	return ret;
};


var documentElement = document.documentElement;



( function() {
	var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
		reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
		container = document.createElement( "div" ),
		div = document.createElement( "div" );

	// Finish early in limited (non-browser) environments
	if ( !div.style ) {
		return;
	}

	div.style.cssText = "float:left;opacity:.5";

	// Support: IE<9
	// Make sure that element opacity exists (as opposed to filter)
	support.opacity = div.style.opacity === "0.5";

	// Verify style float existence
	// (IE uses styleFloat instead of cssFloat)
	support.cssFloat = !!div.style.cssFloat;

	div.style.backgroundClip = "content-box";
	div.cloneNode( true ).style.backgroundClip = "";
	support.clearCloneStyle = div.style.backgroundClip === "content-box";

	container = document.createElement( "div" );
	container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
		"padding:0;margin-top:1px;position:absolute";
	div.innerHTML = "";
	container.appendChild( div );

	// Support: Firefox<29, Android 2.3
	// Vendor-prefix box-sizing
	support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" ||
		div.style.WebkitBoxSizing === "";

	jQuery.extend( support, {
		reliableHiddenOffsets: function() {
			if ( pixelPositionVal == null ) {
				computeStyleTests();
			}
			return reliableHiddenOffsetsVal;
		},

		boxSizingReliable: function() {

			// We're checking for pixelPositionVal here instead of boxSizingReliableVal
			// since that compresses better and they're computed together anyway.
			if ( pixelPositionVal == null ) {
				computeStyleTests();
			}
			return boxSizingReliableVal;
		},

		pixelMarginRight: function() {

			// Support: Android 4.0-4.3
			if ( pixelPositionVal == null ) {
				computeStyleTests();
			}
			return pixelMarginRightVal;
		},

		pixelPosition: function() {
			if ( pixelPositionVal == null ) {
				computeStyleTests();
			}
			return pixelPositionVal;
		},

		reliableMarginRight: function() {

			// Support: Android 2.3
			if ( pixelPositionVal == null ) {
				computeStyleTests();
			}
			return reliableMarginRightVal;
		},

		reliableMarginLeft: function() {

			// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
			if ( pixelPositionVal == null ) {
				computeStyleTests();
			}
			return reliableMarginLeftVal;
		}
	} );

	function computeStyleTests() {
		var contents, divStyle,
			documentElement = document.documentElement;

		// Setup
		documentElement.appendChild( container );

		div.style.cssText =

			// Support: Android 2.3
			// Vendor-prefix box-sizing
			"-webkit-box-sizing:border-box;box-sizing:border-box;" +
			"position:relative;display:block;" +
			"margin:auto;border:1px;padding:1px;" +
			"top:1%;width:50%";

		// Support: IE<9
		// Assume reasonable values in the absence of getComputedStyle
		pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false;
		pixelMarginRightVal = reliableMarginRightVal = true;

		// Check for getComputedStyle so that this code is not run in IE<9.
		if ( window.getComputedStyle ) {
			divStyle = window.getComputedStyle( div );
			pixelPositionVal = ( divStyle || {} ).top !== "1%";
			reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px";
			boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px";

			// Support: Android 4.0 - 4.3 only
			// Some styles come back with percentage values, even though they shouldn't
			div.style.marginRight = "50%";
			pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px";

			// Support: Android 2.3 only
			// Div with explicit width and no margin-right incorrectly
			// gets computed margin-right based on width of container (#3333)
			// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
			contents = div.appendChild( document.createElement( "div" ) );

			// Reset CSS: box-sizing; display; margin; border; padding
			contents.style.cssText = div.style.cssText =

				// Support: Android 2.3
				// Vendor-prefix box-sizing
				"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
				"box-sizing:content-box;display:block;margin:0;border:0;padding:0";
			contents.style.marginRight = contents.style.width = "0";
			div.style.width = "1px";

			reliableMarginRightVal =
				!parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );

			div.removeChild( contents );
		}

		// Support: IE6-8
		// First check that getClientRects works as expected
		// Check if table cells still have offsetWidth/Height when they are set
		// to display:none and there are still other visible table cells in a
		// table row; if so, offsetWidth/Height are not reliable for use when
		// determining if an element has been hidden directly using
		// display:none (it is still safe to use offsets if a parent element is
		// hidden; don safety goggles and see bug #4512 for more information).
		div.style.display = "none";
		reliableHiddenOffsetsVal = div.getClientRects().length === 0;
		if ( reliableHiddenOffsetsVal ) {
			div.style.display = "";
			div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
			div.childNodes[ 0 ].style.borderCollapse = "separate";
			contents = div.getElementsByTagName( "td" );
			contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
			reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
			if ( reliableHiddenOffsetsVal ) {
				contents[ 0 ].style.display = "";
				contents[ 1 ].style.display = "none";
				reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
			}
		}

		// Teardown
		documentElement.removeChild( container );
	}

} )();


var getStyles, curCSS,
	rposition = /^(top|right|bottom|left)$/;

if ( window.getComputedStyle ) {
	getStyles = function( elem ) {

		// Support: IE<=11+, Firefox<=30+ (#15098, #14150)
		// IE throws on elements created in popups
		// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
		var view = elem.ownerDocument.defaultView;

		if ( !view || !view.opener ) {
			view = window;
		}

		return view.getComputedStyle( elem );
	};

	curCSS = function( elem, name, computed ) {
		var width, minWidth, maxWidth, ret,
			style = elem.style;

		computed = computed || getStyles( elem );

		// getPropertyValue is only needed for .css('filter') in IE9, see #12537
		ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;

		// Support: Opera 12.1x only
		// Fall back to style even without computed
		// computed is undefined for elems on document fragments
		if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
			ret = jQuery.style( elem, name );
		}

		if ( computed ) {

			// A tribute to the "awesome hack by Dean Edwards"
			// Chrome < 17 and Safari 5.0 uses "computed value"
			// instead of "used value" for margin-right
			// Safari 5.1.7 (at least) returns percentage for a larger set of values,
			// but width seems to be reliably pixels
			// this is against the CSSOM draft spec:
			// http://dev.w3.org/csswg/cssom/#resolved-values
			if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {

				// Remember the original values
				width = style.width;
				minWidth = style.minWidth;
				maxWidth = style.maxWidth;

				// Put in the new values to get a computed value out
				style.minWidth = style.maxWidth = style.width = ret;
				ret = computed.width;

				// Revert the changed values
				style.width = width;
				style.minWidth = minWidth;
				style.maxWidth = maxWidth;
			}
		}

		// Support: IE
		// IE returns zIndex value as an integer.
		return ret === undefined ?
			ret :
			ret + "";
	};
} else if ( documentElement.currentStyle ) {
	getStyles = function( elem ) {
		return elem.currentStyle;
	};

	curCSS = function( elem, name, computed ) {
		var left, rs, rsLeft, ret,
			style = elem.style;

		computed = computed || getStyles( elem );
		ret = computed ? computed[ name ] : undefined;

		// Avoid setting ret to empty string here
		// so we don't default to auto
		if ( ret == null && style && style[ name ] ) {
			ret = style[ name ];
		}

		// From the awesome hack by Dean Edwards
		// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291

		// If we're not dealing with a regular pixel number
		// but a number that has a weird ending, we need to convert it to pixels
		// but not position css attributes, as those are
		// proportional to the parent element instead
		// and we can't measure the parent instead because it
		// might trigger a "stacking dolls" problem
		if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {

			// Remember the original values
			left = style.left;
			rs = elem.runtimeStyle;
			rsLeft = rs && rs.left;

			// Put in the new values to get a computed value out
			if ( rsLeft ) {
				rs.left = elem.currentStyle.left;
			}
			style.left = name === "fontSize" ? "1em" : ret;
			ret = style.pixelLeft + "px";

			// Revert the changed values
			style.left = left;
			if ( rsLeft ) {
				rs.left = rsLeft;
			}
		}

		// Support: IE
		// IE returns zIndex value as an integer.
		return ret === undefined ?
			ret :
			ret + "" || "auto";
	};
}




function addGetHookIf( conditionFn, hookFn ) {

	// Define the hook, we'll check on the first run if it's really needed.
	return {
		get: function() {
			if ( conditionFn() ) {

				// Hook not needed (or it's not possible to use it due
				// to missing dependency), remove it.
				delete this.get;
				return;
			}

			// Hook needed; redefine it so that the support test is not executed again.
			return ( this.get = hookFn ).apply( this, arguments );
		}
	};
}


var

		ralpha = /alpha\([^)]*\)/i,
	ropacity = /opacity\s*=\s*([^)]*)/i,

	// swappable if display is none or starts with table except
	// "table", "table-cell", or "table-caption"
	// see here for display values:
	// https://developer.mozilla.org/en-US/docs/CSS/display
	rdisplayswap = /^(none|table(?!-c[ea]).+)/,
	rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),

	cssShow = { position: "absolute", visibility: "hidden", display: "block" },
	cssNormalTransform = {
		letterSpacing: "0",
		fontWeight: "400"
	},

	cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
	emptyStyle = document.createElement( "div" ).style;


// return a css property mapped to a potentially vendor prefixed property
function vendorPropName( name ) {

	// shortcut for names that are not vendor prefixed
	if ( name in emptyStyle ) {
		return name;
	}

	// check for vendor prefixed names
	var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ),
		i = cssPrefixes.length;

	while ( i-- ) {
		name = cssPrefixes[ i ] + capName;
		if ( name in emptyStyle ) {
			return name;
		}
	}
}

function showHide( elements, show ) {
	var display, elem, hidden,
		values = [],
		index = 0,
		length = elements.length;

	for ( ; index < length; index++ ) {
		elem = elements[ index ];
		if ( !elem.style ) {
			continue;
		}

		values[ index ] = jQuery._data( elem, "olddisplay" );
		display = elem.style.display;
		if ( show ) {

			// Reset the inline display of this element to learn if it is
			// being hidden by cascaded rules or not
			if ( !values[ index ] && display === "none" ) {
				elem.style.display = "";
			}

			// Set elements which have been overridden with display: none
			// in a stylesheet to whatever the default browser style is
			// for such an element
			if ( elem.style.display === "" && isHidden( elem ) ) {
				values[ index ] =
					jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) );
			}
		} else {
			hidden = isHidden( elem );

			if ( display && display !== "none" || !hidden ) {
				jQuery._data(
					elem,
					"olddisplay",
					hidden ? display : jQuery.css( elem, "display" )
				);
			}
		}
	}

	// Set the display of most of the elements in a second loop
	// to avoid the constant reflow
	for ( index = 0; index < length; index++ ) {
		elem = elements[ index ];
		if ( !elem.style ) {
			continue;
		}
		if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
			elem.style.display = show ? values[ index ] || "" : "none";
		}
	}

	return elements;
}

function setPositiveNumber( elem, value, subtract ) {
	var matches = rnumsplit.exec( value );
	return matches ?

		// Guard against undefined "subtract", e.g., when used as in cssHooks
		Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
		value;
}

function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
	var i = extra === ( isBorderBox ? "border" : "content" ) ?

		// If we already have the right measurement, avoid augmentation
		4 :

		// Otherwise initialize for horizontal or vertical properties
		name === "width" ? 1 : 0,

		val = 0;

	for ( ; i < 4; i += 2 ) {

		// both box models exclude margin, so add it if we want it
		if ( extra === "margin" ) {
			val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
		}

		if ( isBorderBox ) {

			// border-box includes padding, so remove it if we want content
			if ( extra === "content" ) {
				val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
			}

			// at this point, extra isn't border nor margin, so remove border
			if ( extra !== "margin" ) {
				val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
			}
		} else {

			// at this point, extra isn't content, so add padding
			val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );

			// at this point, extra isn't content nor padding, so add border
			if ( extra !== "padding" ) {
				val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
			}
		}
	}

	return val;
}

function getWidthOrHeight( elem, name, extra ) {

	// Start with offset property, which is equivalent to the border-box value
	var valueIsBorderBox = true,
		val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
		styles = getStyles( elem ),
		isBorderBox = support.boxSizing &&
			jQuery.css( elem, "boxSizing", false, styles ) === "border-box";

	// some non-html elements return undefined for offsetWidth, so check for null/undefined
	// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
	// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
	if ( val <= 0 || val == null ) {

		// Fall back to computed then uncomputed css if necessary
		val = curCSS( elem, name, styles );
		if ( val < 0 || val == null ) {
			val = elem.style[ name ];
		}

		// Computed unit is not pixels. Stop here and return.
		if ( rnumnonpx.test( val ) ) {
			return val;
		}

		// we need the check for style in case a browser which returns unreliable values
		// for getComputedStyle silently falls back to the reliable elem.style
		valueIsBorderBox = isBorderBox &&
			( support.boxSizingReliable() || val === elem.style[ name ] );

		// Normalize "", auto, and prepare for extra
		val = parseFloat( val ) || 0;
	}

	// use the active box-sizing model to add/subtract irrelevant styles
	return ( val +
		augmentWidthOrHeight(
			elem,
			name,
			extra || ( isBorderBox ? "border" : "content" ),
			valueIsBorderBox,
			styles
		)
	) + "px";
}

jQuery.extend( {

	// Add in style property hooks for overriding the default
	// behavior of getting and setting a style property
	cssHooks: {
		opacity: {
			get: function( elem, computed ) {
				if ( computed ) {

					// We should always get a number back from opacity
					var ret = curCSS( elem, "opacity" );
					return ret === "" ? "1" : ret;
				}
			}
		}
	},

	// Don't automatically add "px" to these possibly-unitless properties
	cssNumber: {
		"animationIterationCount": true,
		"columnCount": true,
		"fillOpacity": true,
		"flexGrow": true,
		"flexShrink": true,
		"fontWeight": true,
		"lineHeight": true,
		"opacity": true,
		"order": true,
		"orphans": true,
		"widows": true,
		"zIndex": true,
		"zoom": true
	},

	// Add in properties whose names you wish to fix before
	// setting or getting the value
	cssProps: {

		// normalize float css property
		"float": support.cssFloat ? "cssFloat" : "styleFloat"
	},

	// Get and set the style property on a DOM Node
	style: function( elem, name, value, extra ) {

		// Don't set styles on text and comment nodes
		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
			return;
		}

		// Make sure that we're working with the right name
		var ret, type, hooks,
			origName = jQuery.camelCase( name ),
			style = elem.style;

		name = jQuery.cssProps[ origName ] ||
			( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );

		// gets hook for the prefixed version
		// followed by the unprefixed version
		hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];

		// Check if we're setting a value
		if ( value !== undefined ) {
			type = typeof value;

			// Convert "+=" or "-=" to relative numbers (#7345)
			if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
				value = adjustCSS( elem, name, ret );

				// Fixes bug #9237
				type = "number";
			}

			// Make sure that null and NaN values aren't set. See: #7116
			if ( value == null || value !== value ) {
				return;
			}

			// If a number was passed in, add the unit (except for certain CSS properties)
			if ( type === "number" ) {
				value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
			}

			// Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
			// but it would mean to define eight
			// (for every problematic property) identical functions
			if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
				style[ name ] = "inherit";
			}

			// If a hook was provided, use that value, otherwise just set the specified value
			if ( !hooks || !( "set" in hooks ) ||
				( value = hooks.set( elem, value, extra ) ) !== undefined ) {

				// Support: IE
				// Swallow errors from 'invalid' CSS values (#5509)
				try {
					style[ name ] = value;
				} catch ( e ) {}
			}

		} else {

			// If a hook was provided get the non-computed value from there
			if ( hooks && "get" in hooks &&
				( ret = hooks.get( elem, false, extra ) ) !== undefined ) {

				return ret;
			}

			// Otherwise just get the value from the style object
			return style[ name ];
		}
	},

	css: function( elem, name, extra, styles ) {
		var num, val, hooks,
			origName = jQuery.camelCase( name );

		// Make sure that we're working with the right name
		name = jQuery.cssProps[ origName ] ||
			( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );

		// gets hook for the prefixed version
		// followed by the unprefixed version
		hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];

		// If a hook was provided get the computed value from there
		if ( hooks && "get" in hooks ) {
			val = hooks.get( elem, true, extra );
		}

		// Otherwise, if a way to get the computed value exists, use that
		if ( val === undefined ) {
			val = curCSS( elem, name, styles );
		}

		//convert "normal" to computed value
		if ( val === "normal" && name in cssNormalTransform ) {
			val = cssNormalTransform[ name ];
		}

		// Return, converting to number if forced or a qualifier was provided and val looks numeric
		if ( extra === "" || extra ) {
			num = parseFloat( val );
			return extra === true || isFinite( num ) ? num || 0 : val;
		}
		return val;
	}
} );

jQuery.each( [ "height", "width" ], function( i, name ) {
	jQuery.cssHooks[ name ] = {
		get: function( elem, computed, extra ) {
			if ( computed ) {

				// certain elements can have dimension info if we invisibly show them
				// however, it must have a current display style that would benefit from this
				return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
					elem.offsetWidth === 0 ?
						swap( elem, cssShow, function() {
							return getWidthOrHeight( elem, name, extra );
						} ) :
						getWidthOrHeight( elem, name, extra );
			}
		},

		set: function( elem, value, extra ) {
			var styles = extra && getStyles( elem );
			return setPositiveNumber( elem, value, extra ?
				augmentWidthOrHeight(
					elem,
					name,
					extra,
					support.boxSizing &&
						jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
					styles
				) : 0
			);
		}
	};
} );

if ( !support.opacity ) {
	jQuery.cssHooks.opacity = {
		get: function( elem, computed ) {

			// IE uses filters for opacity
			return ropacity.test( ( computed && elem.currentStyle ?
				elem.currentStyle.filter :
				elem.style.filter ) || "" ) ?
					( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
					computed ? "1" : "";
		},

		set: function( elem, value ) {
			var style = elem.style,
				currentStyle = elem.currentStyle,
				opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
				filter = currentStyle && currentStyle.filter || style.filter || "";

			// IE has trouble with opacity if it does not have layout
			// Force it by setting the zoom level
			style.zoom = 1;

			// if setting opacity to 1, and no other filters exist -
			// attempt to remove filter attribute #6652
			// if value === "", then remove inline opacity #12685
			if ( ( value >= 1 || value === "" ) &&
					jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
					style.removeAttribute ) {

				// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
				// if "filter:" is present at all, clearType is disabled, we want to avoid this
				// style.removeAttribute is IE Only, but so apparently is this code path...
				style.removeAttribute( "filter" );

				// if there is no filter style applied in a css rule
				// or unset inline opacity, we are done
				if ( value === "" || currentStyle && !currentStyle.filter ) {
					return;
				}
			}

			// otherwise, set new filter values
			style.filter = ralpha.test( filter ) ?
				filter.replace( ralpha, opacity ) :
				filter + " " + opacity;
		}
	};
}

jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
	function( elem, computed ) {
		if ( computed ) {
			return swap( elem, { "display": "inline-block" },
				curCSS, [ elem, "marginRight" ] );
		}
	}
);

jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
	function( elem, computed ) {
		if ( computed ) {
			return (
				parseFloat( curCSS( elem, "marginLeft" ) ) ||

				// Support: IE<=11+
				// Running getBoundingClientRect on a disconnected node in IE throws an error
				// Support: IE8 only
				// getClientRects() errors on disconnected elems
				( jQuery.contains( elem.ownerDocument, elem ) ?
					elem.getBoundingClientRect().left -
						swap( elem, { marginLeft: 0 }, function() {
							return elem.getBoundingClientRect().left;
						} ) :
					0
				)
			) + "px";
		}
	}
);

// These hooks are used by animate to expand properties
jQuery.each( {
	margin: "",
	padding: "",
	border: "Width"
}, function( prefix, suffix ) {
	jQuery.cssHooks[ prefix + suffix ] = {
		expand: function( value ) {
			var i = 0,
				expanded = {},

				// assumes a single number if not a string
				parts = typeof value === "string" ? value.split( " " ) : [ value ];

			for ( ; i < 4; i++ ) {
				expanded[ prefix + cssExpand[ i ] + suffix ] =
					parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
			}

			return expanded;
		}
	};

	if ( !rmargin.test( prefix ) ) {
		jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
	}
} );

jQuery.fn.extend( {
	css: function( name, value ) {
		return access( this, function( elem, name, value ) {
			var styles, len,
				map = {},
				i = 0;

			if ( jQuery.isArray( name ) ) {
				styles = getStyles( elem );
				len = name.length;

				for ( ; i < len; i++ ) {
					map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
				}

				return map;
			}

			return value !== undefined ?
				jQuery.style( elem, name, value ) :
				jQuery.css( elem, name );
		}, name, value, arguments.length > 1 );
	},
	show: function() {
		return showHide( this, true );
	},
	hide: function() {
		return showHide( this );
	},
	toggle: function( state ) {
		if ( typeof state === "boolean" ) {
			return state ? this.show() : this.hide();
		}

		return this.each( function() {
			if ( isHidden( this ) ) {
				jQuery( this ).show();
			} else {
				jQuery( this ).hide();
			}
		} );
	}
} );


function Tween( elem, options, prop, end, easing ) {
	return new Tween.prototype.init( elem, options, prop, end, easing );
}
jQuery.Tween = Tween;

Tween.prototype = {
	constructor: Tween,
	init: function( elem, options, prop, end, easing, unit ) {
		this.elem = elem;
		this.prop = prop;
		this.easing = easing || jQuery.easing._default;
		this.options = options;
		this.start = this.now = this.cur();
		this.end = end;
		this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
	},
	cur: function() {
		var hooks = Tween.propHooks[ this.prop ];

		return hooks && hooks.get ?
			hooks.get( this ) :
			Tween.propHooks._default.get( this );
	},
	run: function( percent ) {
		var eased,
			hooks = Tween.propHooks[ this.prop ];

		if ( this.options.duration ) {
			this.pos = eased = jQuery.easing[ this.easing ](
				percent, this.options.duration * percent, 0, 1, this.options.duration
			);
		} else {
			this.pos = eased = percent;
		}
		this.now = ( this.end - this.start ) * eased + this.start;

		if ( this.options.step ) {
			this.options.step.call( this.elem, this.now, this );
		}

		if ( hooks && hooks.set ) {
			hooks.set( this );
		} else {
			Tween.propHooks._default.set( this );
		}
		return this;
	}
};

Tween.prototype.init.prototype = Tween.prototype;

Tween.propHooks = {
	_default: {
		get: function( tween ) {
			var result;

			// Use a property on the element directly when it is not a DOM element,
			// or when there is no matching style property that exists.
			if ( tween.elem.nodeType !== 1 ||
				tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
				return tween.elem[ tween.prop ];
			}

			// passing an empty string as a 3rd parameter to .css will automatically
			// attempt a parseFloat and fallback to a string if the parse fails
			// so, simple values such as "10px" are parsed to Float.
			// complex values such as "rotate(1rad)" are returned as is.
			result = jQuery.css( tween.elem, tween.prop, "" );

			// Empty strings, null, undefined and "auto" are converted to 0.
			return !result || result === "auto" ? 0 : result;
		},
		set: function( tween ) {

			// use step hook for back compat - use cssHook if its there - use .style if its
			// available and use plain properties where available
			if ( jQuery.fx.step[ tween.prop ] ) {
				jQuery.fx.step[ tween.prop ]( tween );
			} else if ( tween.elem.nodeType === 1 &&
				( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
					jQuery.cssHooks[ tween.prop ] ) ) {
				jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
			} else {
				tween.elem[ tween.prop ] = tween.now;
			}
		}
	}
};

// Support: IE <=9
// Panic based approach to setting things on disconnected nodes

Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
	set: function( tween ) {
		if ( tween.elem.nodeType && tween.elem.parentNode ) {
			tween.elem[ tween.prop ] = tween.now;
		}
	}
};

jQuery.easing = {
	linear: function( p ) {
		return p;
	},
	swing: function( p ) {
		return 0.5 - Math.cos( p * Math.PI ) / 2;
	},
	_default: "swing"
};

jQuery.fx = Tween.prototype.init;

// Back Compat <1.8 extension point
jQuery.fx.step = {};




var
	fxNow, timerId,
	rfxtypes = /^(?:toggle|show|hide)$/,
	rrun = /queueHooks$/;

// Animations created synchronously will run synchronously
function createFxNow() {
	window.setTimeout( function() {
		fxNow = undefined;
	} );
	return ( fxNow = jQuery.now() );
}

// Generate parameters to create a standard animation
function genFx( type, includeWidth ) {
	var which,
		attrs = { height: type },
		i = 0;

	// if we include width, step value is 1 to do all cssExpand values,
	// if we don't include width, step value is 2 to skip over Left and Right
	includeWidth = includeWidth ? 1 : 0;
	for ( ; i < 4 ; i += 2 - includeWidth ) {
		which = cssExpand[ i ];
		attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
	}

	if ( includeWidth ) {
		attrs.opacity = attrs.width = type;
	}

	return attrs;
}

function createTween( value, prop, animation ) {
	var tween,
		collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
		index = 0,
		length = collection.length;
	for ( ; index < length; index++ ) {
		if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {

			// we're done with this property
			return tween;
		}
	}
}

function defaultPrefilter( elem, props, opts ) {
	/* jshint validthis: true */
	var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
		anim = this,
		orig = {},
		style = elem.style,
		hidden = elem.nodeType && isHidden( elem ),
		dataShow = jQuery._data( elem, "fxshow" );

	// handle queue: false promises
	if ( !opts.queue ) {
		hooks = jQuery._queueHooks( elem, "fx" );
		if ( hooks.unqueued == null ) {
			hooks.unqueued = 0;
			oldfire = hooks.empty.fire;
			hooks.empty.fire = function() {
				if ( !hooks.unqueued ) {
					oldfire();
				}
			};
		}
		hooks.unqueued++;

		anim.always( function() {

			// doing this makes sure that the complete handler will be called
			// before this completes
			anim.always( function() {
				hooks.unqueued--;
				if ( !jQuery.queue( elem, "fx" ).length ) {
					hooks.empty.fire();
				}
			} );
		} );
	}

	// height/width overflow pass
	if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {

		// Make sure that nothing sneaks out
		// Record all 3 overflow attributes because IE does not
		// change the overflow attribute when overflowX and
		// overflowY are set to the same value
		opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];

		// Set display property to inline-block for height/width
		// animations on inline elements that are having width/height animated
		display = jQuery.css( elem, "display" );

		// Test default display if display is currently "none"
		checkDisplay = display === "none" ?
			jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;

		if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {

			// inline-level elements accept inline-block;
			// block-level elements need to be inline with layout
			if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
				style.display = "inline-block";
			} else {
				style.zoom = 1;
			}
		}
	}

	if ( opts.overflow ) {
		style.overflow = "hidden";
		if ( !support.shrinkWrapBlocks() ) {
			anim.always( function() {
				style.overflow = opts.overflow[ 0 ];
				style.overflowX = opts.overflow[ 1 ];
				style.overflowY = opts.overflow[ 2 ];
			} );
		}
	}

	// show/hide pass
	for ( prop in props ) {
		value = props[ prop ];
		if ( rfxtypes.exec( value ) ) {
			delete props[ prop ];
			toggle = toggle || value === "toggle";
			if ( value === ( hidden ? "hide" : "show" ) ) {

				// If there is dataShow left over from a stopped hide or show
				// and we are going to proceed with show, we should pretend to be hidden
				if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
					hidden = true;
				} else {
					continue;
				}
			}
			orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );

		// Any non-fx value stops us from restoring the original display value
		} else {
			display = undefined;
		}
	}

	if ( !jQuery.isEmptyObject( orig ) ) {
		if ( dataShow ) {
			if ( "hidden" in dataShow ) {
				hidden = dataShow.hidden;
			}
		} else {
			dataShow = jQuery._data( elem, "fxshow", {} );
		}

		// store state if its toggle - enables .stop().toggle() to "reverse"
		if ( toggle ) {
			dataShow.hidden = !hidden;
		}
		if ( hidden ) {
			jQuery( elem ).show();
		} else {
			anim.done( function() {
				jQuery( elem ).hide();
			} );
		}
		anim.done( function() {
			var prop;
			jQuery._removeData( elem, "fxshow" );
			for ( prop in orig ) {
				jQuery.style( elem, prop, orig[ prop ] );
			}
		} );
		for ( prop in orig ) {
			tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );

			if ( !( prop in dataShow ) ) {
				dataShow[ prop ] = tween.start;
				if ( hidden ) {
					tween.end = tween.start;
					tween.start = prop === "width" || prop === "height" ? 1 : 0;
				}
			}
		}

	// If this is a noop like .hide().hide(), restore an overwritten display value
	} else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
		style.display = display;
	}
}

function propFilter( props, specialEasing ) {
	var index, name, easing, value, hooks;

	// camelCase, specialEasing and expand cssHook pass
	for ( index in props ) {
		name = jQuery.camelCase( index );
		easing = specialEasing[ name ];
		value = props[ index ];
		if ( jQuery.isArray( value ) ) {
			easing = value[ 1 ];
			value = props[ index ] = value[ 0 ];
		}

		if ( index !== name ) {
			props[ name ] = value;
			delete props[ index ];
		}

		hooks = jQuery.cssHooks[ name ];
		if ( hooks && "expand" in hooks ) {
			value = hooks.expand( value );
			delete props[ name ];

			// not quite $.extend, this wont overwrite keys already present.
			// also - reusing 'index' from above because we have the correct "name"
			for ( index in value ) {
				if ( !( index in props ) ) {
					props[ index ] = value[ index ];
					specialEasing[ index ] = easing;
				}
			}
		} else {
			specialEasing[ name ] = easing;
		}
	}
}

function Animation( elem, properties, options ) {
	var result,
		stopped,
		index = 0,
		length = Animation.prefilters.length,
		deferred = jQuery.Deferred().always( function() {

			// don't match elem in the :animated selector
			delete tick.elem;
		} ),
		tick = function() {
			if ( stopped ) {
				return false;
			}
			var currentTime = fxNow || createFxNow(),
				remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),

				// Support: Android 2.3
				// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
				temp = remaining / animation.duration || 0,
				percent = 1 - temp,
				index = 0,
				length = animation.tweens.length;

			for ( ; index < length ; index++ ) {
				animation.tweens[ index ].run( percent );
			}

			deferred.notifyWith( elem, [ animation, percent, remaining ] );

			if ( percent < 1 && length ) {
				return remaining;
			} else {
				deferred.resolveWith( elem, [ animation ] );
				return false;
			}
		},
		animation = deferred.promise( {
			elem: elem,
			props: jQuery.extend( {}, properties ),
			opts: jQuery.extend( true, {
				specialEasing: {},
				easing: jQuery.easing._default
			}, options ),
			originalProperties: properties,
			originalOptions: options,
			startTime: fxNow || createFxNow(),
			duration: options.duration,
			tweens: [],
			createTween: function( prop, end ) {
				var tween = jQuery.Tween( elem, animation.opts, prop, end,
						animation.opts.specialEasing[ prop ] || animation.opts.easing );
				animation.tweens.push( tween );
				return tween;
			},
			stop: function( gotoEnd ) {
				var index = 0,

					// if we are going to the end, we want to run all the tweens
					// otherwise we skip this part
					length = gotoEnd ? animation.tweens.length : 0;
				if ( stopped ) {
					return this;
				}
				stopped = true;
				for ( ; index < length ; index++ ) {
					animation.tweens[ index ].run( 1 );
				}

				// resolve when we played the last frame
				// otherwise, reject
				if ( gotoEnd ) {
					deferred.notifyWith( elem, [ animation, 1, 0 ] );
					deferred.resolveWith( elem, [ animation, gotoEnd ] );
				} else {
					deferred.rejectWith( elem, [ animation, gotoEnd ] );
				}
				return this;
			}
		} ),
		props = animation.props;

	propFilter( props, animation.opts.specialEasing );

	for ( ; index < length ; index++ ) {
		result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
		if ( result ) {
			if ( jQuery.isFunction( result.stop ) ) {
				jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
					jQuery.proxy( result.stop, result );
			}
			return result;
		}
	}

	jQuery.map( props, createTween, animation );

	if ( jQuery.isFunction( animation.opts.start ) ) {
		animation.opts.start.call( elem, animation );
	}

	jQuery.fx.timer(
		jQuery.extend( tick, {
			elem: elem,
			anim: animation,
			queue: animation.opts.queue
		} )
	);

	// attach callbacks from options
	return animation.progress( animation.opts.progress )
		.done( animation.opts.done, animation.opts.complete )
		.fail( animation.opts.fail )
		.always( animation.opts.always );
}

jQuery.Animation = jQuery.extend( Animation, {

	tweeners: {
		"*": [ function( prop, value ) {
			var tween = this.createTween( prop, value );
			adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
			return tween;
		} ]
	},

	tweener: function( props, callback ) {
		if ( jQuery.isFunction( props ) ) {
			callback = props;
			props = [ "*" ];
		} else {
			props = props.match( rnotwhite );
		}

		var prop,
			index = 0,
			length = props.length;

		for ( ; index < length ; index++ ) {
			prop = props[ index ];
			Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
			Animation.tweeners[ prop ].unshift( callback );
		}
	},

	prefilters: [ defaultPrefilter ],

	prefilter: function( callback, prepend ) {
		if ( prepend ) {
			Animation.prefilters.unshift( callback );
		} else {
			Animation.prefilters.push( callback );
		}
	}
} );

jQuery.speed = function( speed, easing, fn ) {
	var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
		complete: fn || !fn && easing ||
			jQuery.isFunction( speed ) && speed,
		duration: speed,
		easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
	};

	opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
		opt.duration in jQuery.fx.speeds ?
			jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;

	// normalize opt.queue - true/undefined/null -> "fx"
	if ( opt.queue == null || opt.queue === true ) {
		opt.queue = "fx";
	}

	// Queueing
	opt.old = opt.complete;

	opt.complete = function() {
		if ( jQuery.isFunction( opt.old ) ) {
			opt.old.call( this );
		}

		if ( opt.queue ) {
			jQuery.dequeue( this, opt.queue );
		}
	};

	return opt;
};

jQuery.fn.extend( {
	fadeTo: function( speed, to, easing, callback ) {

		// show any hidden elements after setting opacity to 0
		return this.filter( isHidden ).css( "opacity", 0 ).show()

			// animate to the value specified
			.end().animate( { opacity: to }, speed, easing, callback );
	},
	animate: function( prop, speed, easing, callback ) {
		var empty = jQuery.isEmptyObject( prop ),
			optall = jQuery.speed( speed, easing, callback ),
			doAnimation = function() {

				// Operate on a copy of prop so per-property easing won't be lost
				var anim = Animation( this, jQuery.extend( {}, prop ), optall );

				// Empty animations, or finishing resolves immediately
				if ( empty || jQuery._data( this, "finish" ) ) {
					anim.stop( true );
				}
			};
			doAnimation.finish = doAnimation;

		return empty || optall.queue === false ?
			this.each( doAnimation ) :
			this.queue( optall.queue, doAnimation );
	},
	stop: function( type, clearQueue, gotoEnd ) {
		var stopQueue = function( hooks ) {
			var stop = hooks.stop;
			delete hooks.stop;
			stop( gotoEnd );
		};

		if ( typeof type !== "string" ) {
			gotoEnd = clearQueue;
			clearQueue = type;
			type = undefined;
		}
		if ( clearQueue && type !== false ) {
			this.queue( type || "fx", [] );
		}

		return this.each( function() {
			var dequeue = true,
				index = type != null && type + "queueHooks",
				timers = jQuery.timers,
				data = jQuery._data( this );

			if ( index ) {
				if ( data[ index ] && data[ index ].stop ) {
					stopQueue( data[ index ] );
				}
			} else {
				for ( index in data ) {
					if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
						stopQueue( data[ index ] );
					}
				}
			}

			for ( index = timers.length; index--; ) {
				if ( timers[ index ].elem === this &&
					( type == null || timers[ index ].queue === type ) ) {

					timers[ index ].anim.stop( gotoEnd );
					dequeue = false;
					timers.splice( index, 1 );
				}
			}

			// start the next in the queue if the last step wasn't forced
			// timers currently will call their complete callbacks, which will dequeue
			// but only if they were gotoEnd
			if ( dequeue || !gotoEnd ) {
				jQuery.dequeue( this, type );
			}
		} );
	},
	finish: function( type ) {
		if ( type !== false ) {
			type = type || "fx";
		}
		return this.each( function() {
			var index,
				data = jQuery._data( this ),
				queue = data[ type + "queue" ],
				hooks = data[ type + "queueHooks" ],
				timers = jQuery.timers,
				length = queue ? queue.length : 0;

			// enable finishing flag on private data
			data.finish = true;

			// empty the queue first
			jQuery.queue( this, type, [] );

			if ( hooks && hooks.stop ) {
				hooks.stop.call( this, true );
			}

			// look for any active animations, and finish them
			for ( index = timers.length; index--; ) {
				if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
					timers[ index ].anim.stop( true );
					timers.splice( index, 1 );
				}
			}

			// look for any animations in the old queue and finish them
			for ( index = 0; index < length; index++ ) {
				if ( queue[ index ] && queue[ index ].finish ) {
					queue[ index ].finish.call( this );
				}
			}

			// turn off finishing flag
			delete data.finish;
		} );
	}
} );

jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
	var cssFn = jQuery.fn[ name ];
	jQuery.fn[ name ] = function( speed, easing, callback ) {
		return speed == null || typeof speed === "boolean" ?
			cssFn.apply( this, arguments ) :
			this.animate( genFx( name, true ), speed, easing, callback );
	};
} );

// Generate shortcuts for custom animations
jQuery.each( {
	slideDown: genFx( "show" ),
	slideUp: genFx( "hide" ),
	slideToggle: genFx( "toggle" ),
	fadeIn: { opacity: "show" },
	fadeOut: { opacity: "hide" },
	fadeToggle: { opacity: "toggle" }
}, function( name, props ) {
	jQuery.fn[ name ] = function( speed, easing, callback ) {
		return this.animate( props, speed, easing, callback );
	};
} );

jQuery.timers = [];
jQuery.fx.tick = function() {
	var timer,
		timers = jQuery.timers,
		i = 0;

	fxNow = jQuery.now();

	for ( ; i < timers.length; i++ ) {
		timer = timers[ i ];

		// Checks the timer has not already been removed
		if ( !timer() && timers[ i ] === timer ) {
			timers.splice( i--, 1 );
		}
	}

	if ( !timers.length ) {
		jQuery.fx.stop();
	}
	fxNow = undefined;
};

jQuery.fx.timer = function( timer ) {
	jQuery.timers.push( timer );
	if ( timer() ) {
		jQuery.fx.start();
	} else {
		jQuery.timers.pop();
	}
};

jQuery.fx.interval = 13;

jQuery.fx.start = function() {
	if ( !timerId ) {
		timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
	}
};

jQuery.fx.stop = function() {
	window.clearInterval( timerId );
	timerId = null;
};

jQuery.fx.speeds = {
	slow: 600,
	fast: 200,

	// Default speed
	_default: 400
};


// Based off of the plugin by Clint Helfers, with permission.
// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
jQuery.fn.delay = function( time, type ) {
	time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
	type = type || "fx";

	return this.queue( type, function( next, hooks ) {
		var timeout = window.setTimeout( next, time );
		hooks.stop = function() {
			window.clearTimeout( timeout );
		};
	} );
};


( function() {
	var a,
		input = document.createElement( "input" ),
		div = document.createElement( "div" ),
		select = document.createElement( "select" ),
		opt = select.appendChild( document.createElement( "option" ) );

	// Setup
	div = document.createElement( "div" );
	div.setAttribute( "className", "t" );
	div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
	a = div.getElementsByTagName( "a" )[ 0 ];

	// Support: Windows Web Apps (WWA)
	// `type` must use .setAttribute for WWA (#14901)
	input.setAttribute( "type", "checkbox" );
	div.appendChild( input );

	a = div.getElementsByTagName( "a" )[ 0 ];

	// First batch of tests.
	a.style.cssText = "top:1px";

	// Test setAttribute on camelCase class.
	// If it works, we need attrFixes when doing get/setAttribute (ie6/7)
	support.getSetAttribute = div.className !== "t";

	// Get the style information from getAttribute
	// (IE uses .cssText instead)
	support.style = /top/.test( a.getAttribute( "style" ) );

	// Make sure that URLs aren't manipulated
	// (IE normalizes it by default)
	support.hrefNormalized = a.getAttribute( "href" ) === "/a";

	// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
	support.checkOn = !!input.value;

	// Make sure that a selected-by-default option has a working selected property.
	// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
	support.optSelected = opt.selected;

	// Tests for enctype support on a form (#6743)
	support.enctype = !!document.createElement( "form" ).enctype;

	// Make sure that the options inside disabled selects aren't marked as disabled
	// (WebKit marks them as disabled)
	select.disabled = true;
	support.optDisabled = !opt.disabled;

	// Support: IE8 only
	// Check if we can trust getAttribute("value")
	input = document.createElement( "input" );
	input.setAttribute( "value", "" );
	support.input = input.getAttribute( "value" ) === "";

	// Check if an input maintains its value after becoming a radio
	input.value = "t";
	input.setAttribute( "type", "radio" );
	support.radioValue = input.value === "t";
} )();


var rreturn = /\r/g,
	rspaces = /[\x20\t\r\n\f]+/g;

jQuery.fn.extend( {
	val: function( value ) {
		var hooks, ret, isFunction,
			elem = this[ 0 ];

		if ( !arguments.length ) {
			if ( elem ) {
				hooks = jQuery.valHooks[ elem.type ] ||
					jQuery.valHooks[ elem.nodeName.toLowerCase() ];

				if (
					hooks &&
					"get" in hooks &&
					( ret = hooks.get( elem, "value" ) ) !== undefined
				) {
					return ret;
				}

				ret = elem.value;

				return typeof ret === "string" ?

					// handle most common string cases
					ret.replace( rreturn, "" ) :

					// handle cases where value is null/undef or number
					ret == null ? "" : ret;
			}

			return;
		}

		isFunction = jQuery.isFunction( value );

		return this.each( function( i ) {
			var val;

			if ( this.nodeType !== 1 ) {
				return;
			}

			if ( isFunction ) {
				val = value.call( this, i, jQuery( this ).val() );
			} else {
				val = value;
			}

			// Treat null/undefined as ""; convert numbers to string
			if ( val == null ) {
				val = "";
			} else if ( typeof val === "number" ) {
				val += "";
			} else if ( jQuery.isArray( val ) ) {
				val = jQuery.map( val, function( value ) {
					return value == null ? "" : value + "";
				} );
			}

			hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];

			// If set returns undefined, fall back to normal setting
			if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
				this.value = val;
			}
		} );
	}
} );

jQuery.extend( {
	valHooks: {
		option: {
			get: function( elem ) {
				var val = jQuery.find.attr( elem, "value" );
				return val != null ?
					val :

					// Support: IE10-11+
					// option.text throws exceptions (#14686, #14858)
					// Strip and collapse whitespace
					// https://html.spec.whatwg.org/#strip-and-collapse-whitespace
					jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " );
			}
		},
		select: {
			get: function( elem ) {
				var value, option,
					options = elem.options,
					index = elem.selectedIndex,
					one = elem.type === "select-one" || index < 0,
					values = one ? null : [],
					max = one ? index + 1 : options.length,
					i = index < 0 ?
						max :
						one ? index : 0;

				// Loop through all the selected options
				for ( ; i < max; i++ ) {
					option = options[ i ];

					// oldIE doesn't update selected after form reset (#2551)
					if ( ( option.selected || i === index ) &&

							// Don't return options that are disabled or in a disabled optgroup
							( support.optDisabled ?
								!option.disabled :
								option.getAttribute( "disabled" ) === null ) &&
							( !option.parentNode.disabled ||
								!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {

						// Get the specific value for the option
						value = jQuery( option ).val();

						// We don't need an array for one selects
						if ( one ) {
							return value;
						}

						// Multi-Selects return an array
						values.push( value );
					}
				}

				return values;
			},

			set: function( elem, value ) {
				var optionSet, option,
					options = elem.options,
					values = jQuery.makeArray( value ),
					i = options.length;

				while ( i-- ) {
					option = options[ i ];

					if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) {

						// Support: IE6
						// When new option element is added to select box we need to
						// force reflow of newly added node in order to workaround delay
						// of initialization properties
						try {
							option.selected = optionSet = true;

						} catch ( _ ) {

							// Will be executed only in IE6
							option.scrollHeight;
						}

					} else {
						option.selected = false;
					}
				}

				// Force browsers to behave consistently when non-matching value is set
				if ( !optionSet ) {
					elem.selectedIndex = -1;
				}

				return options;
			}
		}
	}
} );

// Radios and checkboxes getter/setter
jQuery.each( [ "radio", "checkbox" ], function() {
	jQuery.valHooks[ this ] = {
		set: function( elem, value ) {
			if ( jQuery.isArray( value ) ) {
				return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
			}
		}
	};
	if ( !support.checkOn ) {
		jQuery.valHooks[ this ].get = function( elem ) {
			return elem.getAttribute( "value" ) === null ? "on" : elem.value;
		};
	}
} );




var nodeHook, boolHook,
	attrHandle = jQuery.expr.attrHandle,
	ruseDefault = /^(?:checked|selected)$/i,
	getSetAttribute = support.getSetAttribute,
	getSetInput = support.input;

jQuery.fn.extend( {
	attr: function( name, value ) {
		return access( this, jQuery.attr, name, value, arguments.length > 1 );
	},

	removeAttr: function( name ) {
		return this.each( function() {
			jQuery.removeAttr( this, name );
		} );
	}
} );

jQuery.extend( {
	attr: function( elem, name, value ) {
		var ret, hooks,
			nType = elem.nodeType;

		// Don't get/set attributes on text, comment and attribute nodes
		if ( nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

		// Fallback to prop when attributes are not supported
		if ( typeof elem.getAttribute === "undefined" ) {
			return jQuery.prop( elem, name, value );
		}

		// All attributes are lowercase
		// Grab necessary hook if one is defined
		if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
			name = name.toLowerCase();
			hooks = jQuery.attrHooks[ name ] ||
				( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
		}

		if ( value !== undefined ) {
			if ( value === null ) {
				jQuery.removeAttr( elem, name );
				return;
			}

			if ( hooks && "set" in hooks &&
				( ret = hooks.set( elem, value, name ) ) !== undefined ) {
				return ret;
			}

			elem.setAttribute( name, value + "" );
			return value;
		}

		if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
			return ret;
		}

		ret = jQuery.find.attr( elem, name );

		// Non-existent attributes return null, we normalize to undefined
		return ret == null ? undefined : ret;
	},

	attrHooks: {
		type: {
			set: function( elem, value ) {
				if ( !support.radioValue && value === "radio" &&
					jQuery.nodeName( elem, "input" ) ) {

					// Setting the type on a radio button after the value resets the value in IE8-9
					// Reset value to default in case type is set after value during creation
					var val = elem.value;
					elem.setAttribute( "type", value );
					if ( val ) {
						elem.value = val;
					}
					return value;
				}
			}
		}
	},

	removeAttr: function( elem, value ) {
		var name, propName,
			i = 0,
			attrNames = value && value.match( rnotwhite );

		if ( attrNames && elem.nodeType === 1 ) {
			while ( ( name = attrNames[ i++ ] ) ) {
				propName = jQuery.propFix[ name ] || name;

				// Boolean attributes get special treatment (#10870)
				if ( jQuery.expr.match.bool.test( name ) ) {

					// Set corresponding property to false
					if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
						elem[ propName ] = false;

					// Support: IE<9
					// Also clear defaultChecked/defaultSelected (if appropriate)
					} else {
						elem[ jQuery.camelCase( "default-" + name ) ] =
							elem[ propName ] = false;
					}

				// See #9699 for explanation of this approach (setting first, then removal)
				} else {
					jQuery.attr( elem, name, "" );
				}

				elem.removeAttribute( getSetAttribute ? name : propName );
			}
		}
	}
} );

// Hooks for boolean attributes
boolHook = {
	set: function( elem, value, name ) {
		if ( value === false ) {

			// Remove boolean attributes when set to false
			jQuery.removeAttr( elem, name );
		} else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {

			// IE<8 needs the *property* name
			elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );

		} else {

			// Support: IE<9
			// Use defaultChecked and defaultSelected for oldIE
			elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
		}
		return name;
	}
};

jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
	var getter = attrHandle[ name ] || jQuery.find.attr;

	if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
		attrHandle[ name ] = function( elem, name, isXML ) {
			var ret, handle;
			if ( !isXML ) {

				// Avoid an infinite loop by temporarily removing this function from the getter
				handle = attrHandle[ name ];
				attrHandle[ name ] = ret;
				ret = getter( elem, name, isXML ) != null ?
					name.toLowerCase() :
					null;
				attrHandle[ name ] = handle;
			}
			return ret;
		};
	} else {
		attrHandle[ name ] = function( elem, name, isXML ) {
			if ( !isXML ) {
				return elem[ jQuery.camelCase( "default-" + name ) ] ?
					name.toLowerCase() :
					null;
			}
		};
	}
} );

// fix oldIE attroperties
if ( !getSetInput || !getSetAttribute ) {
	jQuery.attrHooks.value = {
		set: function( elem, value, name ) {
			if ( jQuery.nodeName( elem, "input" ) ) {

				// Does not return so that setAttribute is also used
				elem.defaultValue = value;
			} else {

				// Use nodeHook if defined (#1954); otherwise setAttribute is fine
				return nodeHook && nodeHook.set( elem, value, name );
			}
		}
	};
}

// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !getSetAttribute ) {

	// Use this for any attribute in IE6/7
	// This fixes almost every IE6/7 issue
	nodeHook = {
		set: function( elem, value, name ) {

			// Set the existing or create a new attribute node
			var ret = elem.getAttributeNode( name );
			if ( !ret ) {
				elem.setAttributeNode(
					( ret = elem.ownerDocument.createAttribute( name ) )
				);
			}

			ret.value = value += "";

			// Break association with cloned elements by also using setAttribute (#9646)
			if ( name === "value" || value === elem.getAttribute( name ) ) {
				return value;
			}
		}
	};

	// Some attributes are constructed with empty-string values when not defined
	attrHandle.id = attrHandle.name = attrHandle.coords =
		function( elem, name, isXML ) {
			var ret;
			if ( !isXML ) {
				return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ?
					ret.value :
					null;
			}
		};

	// Fixing value retrieval on a button requires this module
	jQuery.valHooks.button = {
		get: function( elem, name ) {
			var ret = elem.getAttributeNode( name );
			if ( ret && ret.specified ) {
				return ret.value;
			}
		},
		set: nodeHook.set
	};

	// Set contenteditable to false on removals(#10429)
	// Setting to empty string throws an error as an invalid value
	jQuery.attrHooks.contenteditable = {
		set: function( elem, value, name ) {
			nodeHook.set( elem, value === "" ? false : value, name );
		}
	};

	// Set width and height to auto instead of 0 on empty string( Bug #8150 )
	// This is for removals
	jQuery.each( [ "width", "height" ], function( i, name ) {
		jQuery.attrHooks[ name ] = {
			set: function( elem, value ) {
				if ( value === "" ) {
					elem.setAttribute( name, "auto" );
					return value;
				}
			}
		};
	} );
}

if ( !support.style ) {
	jQuery.attrHooks.style = {
		get: function( elem ) {

			// Return undefined in the case of empty string
			// Note: IE uppercases css property names, but if we were to .toLowerCase()
			// .cssText, that would destroy case sensitivity in URL's, like in "background"
			return elem.style.cssText || undefined;
		},
		set: function( elem, value ) {
			return ( elem.style.cssText = value + "" );
		}
	};
}




var rfocusable = /^(?:input|select|textarea|button|object)$/i,
	rclickable = /^(?:a|area)$/i;

jQuery.fn.extend( {
	prop: function( name, value ) {
		return access( this, jQuery.prop, name, value, arguments.length > 1 );
	},

	removeProp: function( name ) {
		name = jQuery.propFix[ name ] || name;
		return this.each( function() {

			// try/catch handles cases where IE balks (such as removing a property on window)
			try {
				this[ name ] = undefined;
				delete this[ name ];
			} catch ( e ) {}
		} );
	}
} );

jQuery.extend( {
	prop: function( elem, name, value ) {
		var ret, hooks,
			nType = elem.nodeType;

		// Don't get/set properties on text, comment and attribute nodes
		if ( nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

		if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {

			// Fix name and attach hooks
			name = jQuery.propFix[ name ] || name;
			hooks = jQuery.propHooks[ name ];
		}

		if ( value !== undefined ) {
			if ( hooks && "set" in hooks &&
				( ret = hooks.set( elem, value, name ) ) !== undefined ) {
				return ret;
			}

			return ( elem[ name ] = value );
		}

		if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
			return ret;
		}

		return elem[ name ];
	},

	propHooks: {
		tabIndex: {
			get: function( elem ) {

				// elem.tabIndex doesn't always return the
				// correct value when it hasn't been explicitly set
				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
				// Use proper attribute retrieval(#12072)
				var tabindex = jQuery.find.attr( elem, "tabindex" );

				return tabindex ?
					parseInt( tabindex, 10 ) :
					rfocusable.test( elem.nodeName ) ||
						rclickable.test( elem.nodeName ) && elem.href ?
							0 :
							-1;
			}
		}
	},

	propFix: {
		"for": "htmlFor",
		"class": "className"
	}
} );

// Some attributes require a special call on IE
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
if ( !support.hrefNormalized ) {

	// href/src property should get the full normalized URL (#10299/#12915)
	jQuery.each( [ "href", "src" ], function( i, name ) {
		jQuery.propHooks[ name ] = {
			get: function( elem ) {
				return elem.getAttribute( name, 4 );
			}
		};
	} );
}

// Support: Safari, IE9+
// Accessing the selectedIndex property
// forces the browser to respect setting selected
// on the option
// The getter ensures a default option is selected
// when in an optgroup
if ( !support.optSelected ) {
	jQuery.propHooks.selected = {
		get: function( elem ) {
			var parent = elem.parentNode;

			if ( parent ) {
				parent.selectedIndex;

				// Make sure that it also works with optgroups, see #5701
				if ( parent.parentNode ) {
					parent.parentNode.selectedIndex;
				}
			}
			return null;
		},
		set: function( elem ) {
			var parent = elem.parentNode;
			if ( parent ) {
				parent.selectedIndex;

				if ( parent.parentNode ) {
					parent.parentNode.selectedIndex;
				}
			}
		}
	};
}

jQuery.each( [
	"tabIndex",
	"readOnly",
	"maxLength",
	"cellSpacing",
	"cellPadding",
	"rowSpan",
	"colSpan",
	"useMap",
	"frameBorder",
	"contentEditable"
], function() {
	jQuery.propFix[ this.toLowerCase() ] = this;
} );

// IE6/7 call enctype encoding
if ( !support.enctype ) {
	jQuery.propFix.enctype = "encoding";
}




var rclass = /[\t\r\n\f]/g;

function getClass( elem ) {
	return jQuery.attr( elem, "class" ) || "";
}

jQuery.fn.extend( {
	addClass: function( value ) {
		var classes, elem, cur, curValue, clazz, j, finalValue,
			i = 0;

		if ( jQuery.isFunction( value ) ) {
			return this.each( function( j ) {
				jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
			} );
		}

		if ( typeof value === "string" && value ) {
			classes = value.match( rnotwhite ) || [];

			while ( ( elem = this[ i++ ] ) ) {
				curValue = getClass( elem );
				cur = elem.nodeType === 1 &&
					( " " + curValue + " " ).replace( rclass, " " );

				if ( cur ) {
					j = 0;
					while ( ( clazz = classes[ j++ ] ) ) {
						if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
							cur += clazz + " ";
						}
					}

					// only assign if different to avoid unneeded rendering.
					finalValue = jQuery.trim( cur );
					if ( curValue !== finalValue ) {
						jQuery.attr( elem, "class", finalValue );
					}
				}
			}
		}

		return this;
	},

	removeClass: function( value ) {
		var classes, elem, cur, curValue, clazz, j, finalValue,
			i = 0;

		if ( jQuery.isFunction( value ) ) {
			return this.each( function( j ) {
				jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
			} );
		}

		if ( !arguments.length ) {
			return this.attr( "class", "" );
		}

		if ( typeof value === "string" && value ) {
			classes = value.match( rnotwhite ) || [];

			while ( ( elem = this[ i++ ] ) ) {
				curValue = getClass( elem );

				// This expression is here for better compressibility (see addClass)
				cur = elem.nodeType === 1 &&
					( " " + curValue + " " ).replace( rclass, " " );

				if ( cur ) {
					j = 0;
					while ( ( clazz = classes[ j++ ] ) ) {

						// Remove *all* instances
						while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
							cur = cur.replace( " " + clazz + " ", " " );
						}
					}

					// Only assign if different to avoid unneeded rendering.
					finalValue = jQuery.trim( cur );
					if ( curValue !== finalValue ) {
						jQuery.attr( elem, "class", finalValue );
					}
				}
			}
		}

		return this;
	},

	toggleClass: function( value, stateVal ) {
		var type = typeof value;

		if ( typeof stateVal === "boolean" && type === "string" ) {
			return stateVal ? this.addClass( value ) : this.removeClass( value );
		}

		if ( jQuery.isFunction( value ) ) {
			return this.each( function( i ) {
				jQuery( this ).toggleClass(
					value.call( this, i, getClass( this ), stateVal ),
					stateVal
				);
			} );
		}

		return this.each( function() {
			var className, i, self, classNames;

			if ( type === "string" ) {

				// Toggle individual class names
				i = 0;
				self = jQuery( this );
				classNames = value.match( rnotwhite ) || [];

				while ( ( className = classNames[ i++ ] ) ) {

					// Check each className given, space separated list
					if ( self.hasClass( className ) ) {
						self.removeClass( className );
					} else {
						self.addClass( className );
					}
				}

			// Toggle whole class name
			} else if ( value === undefined || type === "boolean" ) {
				className = getClass( this );
				if ( className ) {

					// store className if set
					jQuery._data( this, "__className__", className );
				}

				// If the element has a class name or if we're passed "false",
				// then remove the whole classname (if there was one, the above saved it).
				// Otherwise bring back whatever was previously saved (if anything),
				// falling back to the empty string if nothing was stored.
				jQuery.attr( this, "class",
					className || value === false ?
					"" :
					jQuery._data( this, "__className__" ) || ""
				);
			}
		} );
	},

	hasClass: function( selector ) {
		var className, elem,
			i = 0;

		className = " " + selector + " ";
		while ( ( elem = this[ i++ ] ) ) {
			if ( elem.nodeType === 1 &&
				( " " + getClass( elem ) + " " ).replace( rclass, " " )
					.indexOf( className ) > -1
			) {
				return true;
			}
		}

		return false;
	}
} );




// Return jQuery for attributes-only inclusion


jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
	"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
	"change select submit keydown keypress keyup error contextmenu" ).split( " " ),
	function( i, name ) {

	// Handle event binding
	jQuery.fn[ name ] = function( data, fn ) {
		return arguments.length > 0 ?
			this.on( name, null, data, fn ) :
			this.trigger( name );
	};
} );

jQuery.fn.extend( {
	hover: function( fnOver, fnOut ) {
		return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
	}
} );


var location = window.location;

var nonce = jQuery.now();

var rquery = ( /\?/ );



var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;

jQuery.parseJSON = function( data ) {

	// Attempt to parse using the native JSON parser first
	if ( window.JSON && window.JSON.parse ) {

		// Support: Android 2.3
		// Workaround failure to string-cast null input
		return window.JSON.parse( data + "" );
	}

	var requireNonComma,
		depth = null,
		str = jQuery.trim( data + "" );

	// Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
	// after removing valid tokens
	return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {

		// Force termination if we see a misplaced comma
		if ( requireNonComma && comma ) {
			depth = 0;
		}

		// Perform no more replacements after returning to outermost depth
		if ( depth === 0 ) {
			return token;
		}

		// Commas must not follow "[", "{", or ","
		requireNonComma = open || comma;

		// Determine new depth
		// array/object open ("[" or "{"): depth += true - false (increment)
		// array/object close ("]" or "}"): depth += false - true (decrement)
		// other cases ("," or primitive): depth += true - true (numeric cast)
		depth += !close - !open;

		// Remove this token
		return "";
	} ) ) ?
		( Function( "return " + str ) )() :
		jQuery.error( "Invalid JSON: " + data );
};


// Cross-browser xml parsing
jQuery.parseXML = function( data ) {
	var xml, tmp;
	if ( !data || typeof data !== "string" ) {
		return null;
	}
	try {
		if ( window.DOMParser ) { // Standard
			tmp = new window.DOMParser();
			xml = tmp.parseFromString( data, "text/xml" );
		} else { // IE
			xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
			xml.async = "false";
			xml.loadXML( data );
		}
	} catch ( e ) {
		xml = undefined;
	}
	if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
		jQuery.error( "Invalid XML: " + data );
	}
	return xml;
};


var
	rhash = /#.*$/,
	rts = /([?&])_=[^&]*/,

	// IE leaves an \r character at EOL
	rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,

	// #7653, #8125, #8152: local protocol detection
	rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
	rnoContent = /^(?:GET|HEAD)$/,
	rprotocol = /^\/\//,
	rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,

	/* Prefilters
	 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
	 * 2) These are called:
	 *    - BEFORE asking for a transport
	 *    - AFTER param serialization (s.data is a string if s.processData is true)
	 * 3) key is the dataType
	 * 4) the catchall symbol "*" can be used
	 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
	 */
	prefilters = {},

	/* Transports bindings
	 * 1) key is the dataType
	 * 2) the catchall symbol "*" can be used
	 * 3) selection will start with transport dataType and THEN go to "*" if needed
	 */
	transports = {},

	// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
	allTypes = "*/".concat( "*" ),

	// Document location
	ajaxLocation = location.href,

	// Segment location into parts
	ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];

// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) {

	// dataTypeExpression is optional and defaults to "*"
	return function( dataTypeExpression, func ) {

		if ( typeof dataTypeExpression !== "string" ) {
			func = dataTypeExpression;
			dataTypeExpression = "*";
		}

		var dataType,
			i = 0,
			dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];

		if ( jQuery.isFunction( func ) ) {

			// For each dataType in the dataTypeExpression
			while ( ( dataType = dataTypes[ i++ ] ) ) {

				// Prepend if requested
				if ( dataType.charAt( 0 ) === "+" ) {
					dataType = dataType.slice( 1 ) || "*";
					( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );

				// Otherwise append
				} else {
					( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
				}
			}
		}
	};
}

// Base inspection function for prefilters and transports
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {

	var inspected = {},
		seekingTransport = ( structure === transports );

	function inspect( dataType ) {
		var selected;
		inspected[ dataType ] = true;
		jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
			var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
			if ( typeof dataTypeOrTransport === "string" &&
				!seekingTransport && !inspected[ dataTypeOrTransport ] ) {

				options.dataTypes.unshift( dataTypeOrTransport );
				inspect( dataTypeOrTransport );
				return false;
			} else if ( seekingTransport ) {
				return !( selected = dataTypeOrTransport );
			}
		} );
		return selected;
	}

	return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
}

// A special extend for ajax options
// that takes "flat" options (not to be deep extended)
// Fixes #9887
function ajaxExtend( target, src ) {
	var deep, key,
		flatOptions = jQuery.ajaxSettings.flatOptions || {};

	for ( key in src ) {
		if ( src[ key ] !== undefined ) {
			( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
		}
	}
	if ( deep ) {
		jQuery.extend( true, target, deep );
	}

	return target;
}

/* Handles responses to an ajax request:
 * - finds the right dataType (mediates between content-type and expected dataType)
 * - returns the corresponding response
 */
function ajaxHandleResponses( s, jqXHR, responses ) {
	var firstDataType, ct, finalDataType, type,
		contents = s.contents,
		dataTypes = s.dataTypes;

	// Remove auto dataType and get content-type in the process
	while ( dataTypes[ 0 ] === "*" ) {
		dataTypes.shift();
		if ( ct === undefined ) {
			ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
		}
	}

	// Check if we're dealing with a known content-type
	if ( ct ) {
		for ( type in contents ) {
			if ( contents[ type ] && contents[ type ].test( ct ) ) {
				dataTypes.unshift( type );
				break;
			}
		}
	}

	// Check to see if we have a response for the expected dataType
	if ( dataTypes[ 0 ] in responses ) {
		finalDataType = dataTypes[ 0 ];
	} else {

		// Try convertible dataTypes
		for ( type in responses ) {
			if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
				finalDataType = type;
				break;
			}
			if ( !firstDataType ) {
				firstDataType = type;
			}
		}

		// Or just use first one
		finalDataType = finalDataType || firstDataType;
	}

	// If we found a dataType
	// We add the dataType to the list if needed
	// and return the corresponding response
	if ( finalDataType ) {
		if ( finalDataType !== dataTypes[ 0 ] ) {
			dataTypes.unshift( finalDataType );
		}
		return responses[ finalDataType ];
	}
}

/* Chain conversions given the request and the original response
 * Also sets the responseXXX fields on the jqXHR instance
 */
function ajaxConvert( s, response, jqXHR, isSuccess ) {
	var conv2, current, conv, tmp, prev,
		converters = {},

		// Work with a copy of dataTypes in case we need to modify it for conversion
		dataTypes = s.dataTypes.slice();

	// Create converters map with lowercased keys
	if ( dataTypes[ 1 ] ) {
		for ( conv in s.converters ) {
			converters[ conv.toLowerCase() ] = s.converters[ conv ];
		}
	}

	current = dataTypes.shift();

	// Convert to each sequential dataType
	while ( current ) {

		if ( s.responseFields[ current ] ) {
			jqXHR[ s.responseFields[ current ] ] = response;
		}

		// Apply the dataFilter if provided
		if ( !prev && isSuccess && s.dataFilter ) {
			response = s.dataFilter( response, s.dataType );
		}

		prev = current;
		current = dataTypes.shift();

		if ( current ) {

			// There's only work to do if current dataType is non-auto
			if ( current === "*" ) {

				current = prev;

			// Convert response if prev dataType is non-auto and differs from current
			} else if ( prev !== "*" && prev !== current ) {

				// Seek a direct converter
				conv = converters[ prev + " " + current ] || converters[ "* " + current ];

				// If none found, seek a pair
				if ( !conv ) {
					for ( conv2 in converters ) {

						// If conv2 outputs current
						tmp = conv2.split( " " );
						if ( tmp[ 1 ] === current ) {

							// If prev can be converted to accepted input
							conv = converters[ prev + " " + tmp[ 0 ] ] ||
								converters[ "* " + tmp[ 0 ] ];
							if ( conv ) {

								// Condense equivalence converters
								if ( conv === true ) {
									conv = converters[ conv2 ];

								// Otherwise, insert the intermediate dataType
								} else if ( converters[ conv2 ] !== true ) {
									current = tmp[ 0 ];
									dataTypes.unshift( tmp[ 1 ] );
								}
								break;
							}
						}
					}
				}

				// Apply converter (if not an equivalence)
				if ( conv !== true ) {

					// Unless errors are allowed to bubble, catch and return them
					if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
						response = conv( response );
					} else {
						try {
							response = conv( response );
						} catch ( e ) {
							return {
								state: "parsererror",
								error: conv ? e : "No conversion from " + prev + " to " + current
							};
						}
					}
				}
			}
		}
	}

	return { state: "success", data: response };
}

jQuery.extend( {

	// Counter for holding the number of active queries
	active: 0,

	// Last-Modified header cache for next request
	lastModified: {},
	etag: {},

	ajaxSettings: {
		url: ajaxLocation,
		type: "GET",
		isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
		global: true,
		processData: true,
		async: true,
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		/*
		timeout: 0,
		data: null,
		dataType: null,
		username: null,
		password: null,
		cache: null,
		throws: false,
		traditional: false,
		headers: {},
		*/

		accepts: {
			"*": allTypes,
			text: "text/plain",
			html: "text/html",
			xml: "application/xml, text/xml",
			json: "application/json, text/javascript"
		},

		contents: {
			xml: /\bxml\b/,
			html: /\bhtml/,
			json: /\bjson\b/
		},

		responseFields: {
			xml: "responseXML",
			text: "responseText",
			json: "responseJSON"
		},

		// Data converters
		// Keys separate source (or catchall "*") and destination types with a single space
		converters: {

			// Convert anything to text
			"* text": String,

			// Text to html (true = no transformation)
			"text html": true,

			// Evaluate text as a json expression
			"text json": jQuery.parseJSON,

			// Parse text as xml
			"text xml": jQuery.parseXML
		},

		// For options that shouldn't be deep extended:
		// you can add your own custom options here if
		// and when you create one that shouldn't be
		// deep extended (see ajaxExtend)
		flatOptions: {
			url: true,
			context: true
		}
	},

	// Creates a full fledged settings object into target
	// with both ajaxSettings and settings fields.
	// If target is omitted, writes into ajaxSettings.
	ajaxSetup: function( target, settings ) {
		return settings ?

			// Building a settings object
			ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :

			// Extending ajaxSettings
			ajaxExtend( jQuery.ajaxSettings, target );
	},

	ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
	ajaxTransport: addToPrefiltersOrTransports( transports ),

	// Main method
	ajax: function( url, options ) {

		// If url is an object, simulate pre-1.5 signature
		if ( typeof url === "object" ) {
			options = url;
			url = undefined;
		}

		// Force options to be an object
		options = options || {};

		var

			// Cross-domain detection vars
			parts,

			// Loop variable
			i,

			// URL without anti-cache param
			cacheURL,

			// Response headers as string
			responseHeadersString,

			// timeout handle
			timeoutTimer,

			// To know if global events are to be dispatched
			fireGlobals,

			transport,

			// Response headers
			responseHeaders,

			// Create the final options object
			s = jQuery.ajaxSetup( {}, options ),

			// Callbacks context
			callbackContext = s.context || s,

			// Context for global events is callbackContext if it is a DOM node or jQuery collection
			globalEventContext = s.context &&
				( callbackContext.nodeType || callbackContext.jquery ) ?
					jQuery( callbackContext ) :
					jQuery.event,

			// Deferreds
			deferred = jQuery.Deferred(),
			completeDeferred = jQuery.Callbacks( "once memory" ),

			// Status-dependent callbacks
			statusCode = s.statusCode || {},

			// Headers (they are sent all at once)
			requestHeaders = {},
			requestHeadersNames = {},

			// The jqXHR state
			state = 0,

			// Default abort message
			strAbort = "canceled",

			// Fake xhr
			jqXHR = {
				readyState: 0,

				// Builds headers hashtable if needed
				getResponseHeader: function( key ) {
					var match;
					if ( state === 2 ) {
						if ( !responseHeaders ) {
							responseHeaders = {};
							while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
								responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
							}
						}
						match = responseHeaders[ key.toLowerCase() ];
					}
					return match == null ? null : match;
				},

				// Raw string
				getAllResponseHeaders: function() {
					return state === 2 ? responseHeadersString : null;
				},

				// Caches the header
				setRequestHeader: function( name, value ) {
					var lname = name.toLowerCase();
					if ( !state ) {
						name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
						requestHeaders[ name ] = value;
					}
					return this;
				},

				// Overrides response content-type header
				overrideMimeType: function( type ) {
					if ( !state ) {
						s.mimeType = type;
					}
					return this;
				},

				// Status-dependent callbacks
				statusCode: function( map ) {
					var code;
					if ( map ) {
						if ( state < 2 ) {
							for ( code in map ) {

								// Lazy-add the new callback in a way that preserves old ones
								statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
							}
						} else {

							// Execute the appropriate callbacks
							jqXHR.always( map[ jqXHR.status ] );
						}
					}
					return this;
				},

				// Cancel the request
				abort: function( statusText ) {
					var finalText = statusText || strAbort;
					if ( transport ) {
						transport.abort( finalText );
					}
					done( 0, finalText );
					return this;
				}
			};

		// Attach deferreds
		deferred.promise( jqXHR ).complete = completeDeferred.add;
		jqXHR.success = jqXHR.done;
		jqXHR.error = jqXHR.fail;

		// Remove hash character (#7531: and string promotion)
		// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
		// Handle falsy url in the settings object (#10093: consistency with old signature)
		// We also use the url parameter if available
		s.url = ( ( url || s.url || ajaxLocation ) + "" )
			.replace( rhash, "" )
			.replace( rprotocol, ajaxLocParts[ 1 ] + "//" );

		// Alias method option to type as per ticket #12004
		s.type = options.method || options.type || s.method || s.type;

		// Extract dataTypes list
		s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];

		// A cross-domain request is in order when we have a protocol:host:port mismatch
		if ( s.crossDomain == null ) {
			parts = rurl.exec( s.url.toLowerCase() );
			s.crossDomain = !!( parts &&
				( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
					( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
						( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
			);
		}

		// Convert data if not already a string
		if ( s.data && s.processData && typeof s.data !== "string" ) {
			s.data = jQuery.param( s.data, s.traditional );
		}

		// Apply prefilters
		inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );

		// If request was aborted inside a prefilter, stop there
		if ( state === 2 ) {
			return jqXHR;
		}

		// We can fire global events as of now if asked to
		// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
		fireGlobals = jQuery.event && s.global;

		// Watch for a new set of requests
		if ( fireGlobals && jQuery.active++ === 0 ) {
			jQuery.event.trigger( "ajaxStart" );
		}

		// Uppercase the type
		s.type = s.type.toUpperCase();

		// Determine if request has content
		s.hasContent = !rnoContent.test( s.type );

		// Save the URL in case we're toying with the If-Modified-Since
		// and/or If-None-Match header later on
		cacheURL = s.url;

		// More options handling for requests with no content
		if ( !s.hasContent ) {

			// If data is available, append data to url
			if ( s.data ) {
				cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );

				// #9682: remove data so that it's not used in an eventual retry
				delete s.data;
			}

			// Add anti-cache in url if needed
			if ( s.cache === false ) {
				s.url = rts.test( cacheURL ) ?

					// If there is already a '_' parameter, set its value
					cacheURL.replace( rts, "$1_=" + nonce++ ) :

					// Otherwise add one to the end
					cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
			}
		}

		// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
		if ( s.ifModified ) {
			if ( jQuery.lastModified[ cacheURL ] ) {
				jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
			}
			if ( jQuery.etag[ cacheURL ] ) {
				jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
			}
		}

		// Set the correct header, if data is being sent
		if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
			jqXHR.setRequestHeader( "Content-Type", s.contentType );
		}

		// Set the Accepts header for the server, depending on the dataType
		jqXHR.setRequestHeader(
			"Accept",
			s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
				s.accepts[ s.dataTypes[ 0 ] ] +
					( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
				s.accepts[ "*" ]
		);

		// Check for headers option
		for ( i in s.headers ) {
			jqXHR.setRequestHeader( i, s.headers[ i ] );
		}

		// Allow custom headers/mimetypes and early abort
		if ( s.beforeSend &&
			( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {

			// Abort if not done already and return
			return jqXHR.abort();
		}

		// aborting is no longer a cancellation
		strAbort = "abort";

		// Install callbacks on deferreds
		for ( i in { success: 1, error: 1, complete: 1 } ) {
			jqXHR[ i ]( s[ i ] );
		}

		// Get transport
		transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );

		// If no transport, we auto-abort
		if ( !transport ) {
			done( -1, "No Transport" );
		} else {
			jqXHR.readyState = 1;

			// Send global event
			if ( fireGlobals ) {
				globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
			}

			// If request was aborted inside ajaxSend, stop there
			if ( state === 2 ) {
				return jqXHR;
			}

			// Timeout
			if ( s.async && s.timeout > 0 ) {
				timeoutTimer = window.setTimeout( function() {
					jqXHR.abort( "timeout" );
				}, s.timeout );
			}

			try {
				state = 1;
				transport.send( requestHeaders, done );
			} catch ( e ) {

				// Propagate exception as error if not done
				if ( state < 2 ) {
					done( -1, e );

				// Simply rethrow otherwise
				} else {
					throw e;
				}
			}
		}

		// Callback for when everything is done
		function done( status, nativeStatusText, responses, headers ) {
			var isSuccess, success, error, response, modified,
				statusText = nativeStatusText;

			// Called once
			if ( state === 2 ) {
				return;
			}

			// State is "done" now
			state = 2;

			// Clear timeout if it exists
			if ( timeoutTimer ) {
				window.clearTimeout( timeoutTimer );
			}

			// Dereference transport for early garbage collection
			// (no matter how long the jqXHR object will be used)
			transport = undefined;

			// Cache response headers
			responseHeadersString = headers || "";

			// Set readyState
			jqXHR.readyState = status > 0 ? 4 : 0;

			// Determine if successful
			isSuccess = status >= 200 && status < 300 || status === 304;

			// Get response data
			if ( responses ) {
				response = ajaxHandleResponses( s, jqXHR, responses );
			}

			// Convert no matter what (that way responseXXX fields are always set)
			response = ajaxConvert( s, response, jqXHR, isSuccess );

			// If successful, handle type chaining
			if ( isSuccess ) {

				// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
				if ( s.ifModified ) {
					modified = jqXHR.getResponseHeader( "Last-Modified" );
					if ( modified ) {
						jQuery.lastModified[ cacheURL ] = modified;
					}
					modified = jqXHR.getResponseHeader( "etag" );
					if ( modified ) {
						jQuery.etag[ cacheURL ] = modified;
					}
				}

				// if no content
				if ( status === 204 || s.type === "HEAD" ) {
					statusText = "nocontent";

				// if not modified
				} else if ( status === 304 ) {
					statusText = "notmodified";

				// If we have data, let's convert it
				} else {
					statusText = response.state;
					success = response.data;
					error = response.error;
					isSuccess = !error;
				}
			} else {

				// We extract error from statusText
				// then normalize statusText and status for non-aborts
				error = statusText;
				if ( status || !statusText ) {
					statusText = "error";
					if ( status < 0 ) {
						status = 0;
					}
				}
			}

			// Set data for the fake xhr object
			jqXHR.status = status;
			jqXHR.statusText = ( nativeStatusText || statusText ) + "";

			// Success/Error
			if ( isSuccess ) {
				deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
			} else {
				deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
			}

			// Status-dependent callbacks
			jqXHR.statusCode( statusCode );
			statusCode = undefined;

			if ( fireGlobals ) {
				globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
					[ jqXHR, s, isSuccess ? success : error ] );
			}

			// Complete
			completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );

			if ( fireGlobals ) {
				globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );

				// Handle the global AJAX counter
				if ( !( --jQuery.active ) ) {
					jQuery.event.trigger( "ajaxStop" );
				}
			}
		}

		return jqXHR;
	},

	getJSON: function( url, data, callback ) {
		return jQuery.get( url, data, callback, "json" );
	},

	getScript: function( url, callback ) {
		return jQuery.get( url, undefined, callback, "script" );
	}
} );

jQuery.each( [ "get", "post" ], function( i, method ) {
	jQuery[ method ] = function( url, data, callback, type ) {

		// shift arguments if data argument was omitted
		if ( jQuery.isFunction( data ) ) {
			type = type || callback;
			callback = data;
			data = undefined;
		}

		// The url can be an options object (which then must have .url)
		return jQuery.ajax( jQuery.extend( {
			url: url,
			type: method,
			dataType: type,
			data: data,
			success: callback
		}, jQuery.isPlainObject( url ) && url ) );
	};
} );


jQuery._evalUrl = function( url ) {
	return jQuery.ajax( {
		url: url,

		// Make this explicit, since user can override this through ajaxSetup (#11264)
		type: "GET",
		dataType: "script",
		cache: true,
		async: false,
		global: false,
		"throws": true
	} );
};


jQuery.fn.extend( {
	wrapAll: function( html ) {
		if ( jQuery.isFunction( html ) ) {
			return this.each( function( i ) {
				jQuery( this ).wrapAll( html.call( this, i ) );
			} );
		}

		if ( this[ 0 ] ) {

			// The elements to wrap the target around
			var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );

			if ( this[ 0 ].parentNode ) {
				wrap.insertBefore( this[ 0 ] );
			}

			wrap.map( function() {
				var elem = this;

				while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
					elem = elem.firstChild;
				}

				return elem;
			} ).append( this );
		}

		return this;
	},

	wrapInner: function( html ) {
		if ( jQuery.isFunction( html ) ) {
			return this.each( function( i ) {
				jQuery( this ).wrapInner( html.call( this, i ) );
			} );
		}

		return this.each( function() {
			var self = jQuery( this ),
				contents = self.contents();

			if ( contents.length ) {
				contents.wrapAll( html );

			} else {
				self.append( html );
			}
		} );
	},

	wrap: function( html ) {
		var isFunction = jQuery.isFunction( html );

		return this.each( function( i ) {
			jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
		} );
	},

	unwrap: function() {
		return this.parent().each( function() {
			if ( !jQuery.nodeName( this, "body" ) ) {
				jQuery( this ).replaceWith( this.childNodes );
			}
		} ).end();
	}
} );


function getDisplay( elem ) {
	return elem.style && elem.style.display || jQuery.css( elem, "display" );
}

function filterHidden( elem ) {

	// Disconnected elements are considered hidden
	if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
		return true;
	}
	while ( elem && elem.nodeType === 1 ) {
		if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
			return true;
		}
		elem = elem.parentNode;
	}
	return false;
}

jQuery.expr.filters.hidden = function( elem ) {

	// Support: Opera <= 12.12
	// Opera reports offsetWidths and offsetHeights less than zero on some elements
	return support.reliableHiddenOffsets() ?
		( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
			!elem.getClientRects().length ) :
			filterHidden( elem );
};

jQuery.expr.filters.visible = function( elem ) {
	return !jQuery.expr.filters.hidden( elem );
};




var r20 = /%20/g,
	rbracket = /\[\]$/,
	rCRLF = /\r?\n/g,
	rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
	rsubmittable = /^(?:input|select|textarea|keygen)/i;

function buildParams( prefix, obj, traditional, add ) {
	var name;

	if ( jQuery.isArray( obj ) ) {

		// Serialize array item.
		jQuery.each( obj, function( i, v ) {
			if ( traditional || rbracket.test( prefix ) ) {

				// Treat each array item as a scalar.
				add( prefix, v );

			} else {

				// Item is non-scalar (array or object), encode its numeric index.
				buildParams(
					prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
					v,
					traditional,
					add
				);
			}
		} );

	} else if ( !traditional && jQuery.type( obj ) === "object" ) {

		// Serialize object item.
		for ( name in obj ) {
			buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
		}

	} else {

		// Serialize scalar item.
		add( prefix, obj );
	}
}

// Serialize an array of form elements or a set of
// key/values into a query string
jQuery.param = function( a, traditional ) {
	var prefix,
		s = [],
		add = function( key, value ) {

			// If value is a function, invoke it and return its value
			value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
			s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
		};

	// Set traditional to true for jQuery <= 1.3.2 behavior.
	if ( traditional === undefined ) {
		traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
	}

	// If an array was passed in, assume that it is an array of form elements.
	if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {

		// Serialize the form elements
		jQuery.each( a, function() {
			add( this.name, this.value );
		} );

	} else {

		// If traditional, encode the "old" way (the way 1.3.2 or older
		// did it), otherwise encode params recursively.
		for ( prefix in a ) {
			buildParams( prefix, a[ prefix ], traditional, add );
		}
	}

	// Return the resulting serialization
	return s.join( "&" ).replace( r20, "+" );
};

jQuery.fn.extend( {
	serialize: function() {
		return jQuery.param( this.serializeArray() );
	},
	serializeArray: function() {
		return this.map( function() {

			// Can add propHook for "elements" to filter or add form elements
			var elements = jQuery.prop( this, "elements" );
			return elements ? jQuery.makeArray( elements ) : this;
		} )
		.filter( function() {
			var type = this.type;

			// Use .is(":disabled") so that fieldset[disabled] works
			return this.name && !jQuery( this ).is( ":disabled" ) &&
				rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
				( this.checked || !rcheckableType.test( type ) );
		} )
		.map( function( i, elem ) {
			var val = jQuery( this ).val();

			return val == null ?
				null :
				jQuery.isArray( val ) ?
					jQuery.map( val, function( val ) {
						return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
					} ) :
					{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
		} ).get();
	}
} );


// Create the request object
// (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?

	// Support: IE6-IE8
	function() {

		// XHR cannot access local files, always use ActiveX for that case
		if ( this.isLocal ) {
			return createActiveXHR();
		}

		// Support: IE 9-11
		// IE seems to error on cross-domain PATCH requests when ActiveX XHR
		// is used. In IE 9+ always use the native XHR.
		// Note: this condition won't catch Edge as it doesn't define
		// document.documentMode but it also doesn't support ActiveX so it won't
		// reach this code.
		if ( document.documentMode > 8 ) {
			return createStandardXHR();
		}

		// Support: IE<9
		// oldIE XHR does not support non-RFC2616 methods (#13240)
		// See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
		// and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
		// Although this check for six methods instead of eight
		// since IE also does not support "trace" and "connect"
		return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
			createStandardXHR() || createActiveXHR();
	} :

	// For all other browsers, use the standard XMLHttpRequest object
	createStandardXHR;

var xhrId = 0,
	xhrCallbacks = {},
	xhrSupported = jQuery.ajaxSettings.xhr();

// Support: IE<10
// Open requests must be manually aborted on unload (#5280)
// See https://support.microsoft.com/kb/2856746 for more info
if ( window.attachEvent ) {
	window.attachEvent( "onunload", function() {
		for ( var key in xhrCallbacks ) {
			xhrCallbacks[ key ]( undefined, true );
		}
	} );
}

// Determine support properties
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
xhrSupported = support.ajax = !!xhrSupported;

// Create transport if the browser can provide an xhr
if ( xhrSupported ) {

	jQuery.ajaxTransport( function( options ) {

		// Cross domain only allowed if supported through XMLHttpRequest
		if ( !options.crossDomain || support.cors ) {

			var callback;

			return {
				send: function( headers, complete ) {
					var i,
						xhr = options.xhr(),
						id = ++xhrId;

					// Open the socket
					xhr.open(
						options.type,
						options.url,
						options.async,
						options.username,
						options.password
					);

					// Apply custom fields if provided
					if ( options.xhrFields ) {
						for ( i in options.xhrFields ) {
							xhr[ i ] = options.xhrFields[ i ];
						}
					}

					// Override mime type if needed
					if ( options.mimeType && xhr.overrideMimeType ) {
						xhr.overrideMimeType( options.mimeType );
					}

					// X-Requested-With header
					// For cross-domain requests, seeing as conditions for a preflight are
					// akin to a jigsaw puzzle, we simply never set it to be sure.
					// (it can always be set on a per-request basis or even using ajaxSetup)
					// For same-domain requests, won't change header if already provided.
					if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
						headers[ "X-Requested-With" ] = "XMLHttpRequest";
					}

					// Set headers
					for ( i in headers ) {

						// Support: IE<9
						// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
						// request header to a null-value.
						//
						// To keep consistent with other XHR implementations, cast the value
						// to string and ignore `undefined`.
						if ( headers[ i ] !== undefined ) {
							xhr.setRequestHeader( i, headers[ i ] + "" );
						}
					}

					// Do send the request
					// This may raise an exception which is actually
					// handled in jQuery.ajax (so no try/catch here)
					xhr.send( ( options.hasContent && options.data ) || null );

					// Listener
					callback = function( _, isAbort ) {
						var status, statusText, responses;

						// Was never called and is aborted or complete
						if ( callback && ( isAbort || xhr.readyState === 4 ) ) {

							// Clean up
							delete xhrCallbacks[ id ];
							callback = undefined;
							xhr.onreadystatechange = jQuery.noop;

							// Abort manually if needed
							if ( isAbort ) {
								if ( xhr.readyState !== 4 ) {
									xhr.abort();
								}
							} else {
								responses = {};
								status = xhr.status;

								// Support: IE<10
								// Accessing binary-data responseText throws an exception
								// (#11426)
								if ( typeof xhr.responseText === "string" ) {
									responses.text = xhr.responseText;
								}

								// Firefox throws an exception when accessing
								// statusText for faulty cross-domain requests
								try {
									statusText = xhr.statusText;
								} catch ( e ) {

									// We normalize with Webkit giving an empty statusText
									statusText = "";
								}

								// Filter status for non standard behaviors

								// If the request is local and we have data: assume a success
								// (success with no data won't get notified, that's the best we
								// can do given current implementations)
								if ( !status && options.isLocal && !options.crossDomain ) {
									status = responses.text ? 200 : 404;

								// IE - #1450: sometimes returns 1223 when it should be 204
								} else if ( status === 1223 ) {
									status = 204;
								}
							}
						}

						// Call complete if needed
						if ( responses ) {
							complete( status, statusText, responses, xhr.getAllResponseHeaders() );
						}
					};

					// Do send the request
					// `xhr.send` may raise an exception, but it will be
					// handled in jQuery.ajax (so no try/catch here)
					if ( !options.async ) {

						// If we're in sync mode we fire the callback
						callback();
					} else if ( xhr.readyState === 4 ) {

						// (IE6 & IE7) if it's in cache and has been
						// retrieved directly we need to fire the callback
						window.setTimeout( callback );
					} else {

						// Register the callback, but delay it in case `xhr.send` throws
						// Add to the list of active xhr callbacks
						xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
					}
				},

				abort: function() {
					if ( callback ) {
						callback( undefined, true );
					}
				}
			};
		}
	} );
}

// Functions to create xhrs
function createStandardXHR() {
	try {
		return new window.XMLHttpRequest();
	} catch ( e ) {}
}

function createActiveXHR() {
	try {
		return new window.ActiveXObject( "Microsoft.XMLHTTP" );
	} catch ( e ) {}
}




// Install script dataType
jQuery.ajaxSetup( {
	accepts: {
		script: "text/javascript, application/javascript, " +
			"application/ecmascript, application/x-ecmascript"
	},
	contents: {
		script: /\b(?:java|ecma)script\b/
	},
	converters: {
		"text script": function( text ) {
			jQuery.globalEval( text );
			return text;
		}
	}
} );

// Handle cache's special case and global
jQuery.ajaxPrefilter( "script", function( s ) {
	if ( s.cache === undefined ) {
		s.cache = false;
	}
	if ( s.crossDomain ) {
		s.type = "GET";
		s.global = false;
	}
} );

// Bind script tag hack transport
jQuery.ajaxTransport( "script", function( s ) {

	// This transport only deals with cross domain requests
	if ( s.crossDomain ) {

		var script,
			head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;

		return {

			send: function( _, callback ) {

				script = document.createElement( "script" );

				script.async = true;

				if ( s.scriptCharset ) {
					script.charset = s.scriptCharset;
				}

				script.src = s.url;

				// Attach handlers for all browsers
				script.onload = script.onreadystatechange = function( _, isAbort ) {

					if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {

						// Handle memory leak in IE
						script.onload = script.onreadystatechange = null;

						// Remove the script
						if ( script.parentNode ) {
							script.parentNode.removeChild( script );
						}

						// Dereference the script
						script = null;

						// Callback if not abort
						if ( !isAbort ) {
							callback( 200, "success" );
						}
					}
				};

				// Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
				// Use native DOM manipulation to avoid our domManip AJAX trickery
				head.insertBefore( script, head.firstChild );
			},

			abort: function() {
				if ( script ) {
					script.onload( undefined, true );
				}
			}
		};
	}
} );




var oldCallbacks = [],
	rjsonp = /(=)\?(?=&|$)|\?\?/;

// Default jsonp settings
jQuery.ajaxSetup( {
	jsonp: "callback",
	jsonpCallback: function() {
		var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
		this[ callback ] = true;
		return callback;
	}
} );

// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {

	var callbackName, overwritten, responseContainer,
		jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
			"url" :
			typeof s.data === "string" &&
				( s.contentType || "" )
					.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
				rjsonp.test( s.data ) && "data"
		);

	// Handle iff the expected data type is "jsonp" or we have a parameter to set
	if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {

		// Get callback name, remembering preexisting value associated with it
		callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
			s.jsonpCallback() :
			s.jsonpCallback;

		// Insert callback into url or form data
		if ( jsonProp ) {
			s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
		} else if ( s.jsonp !== false ) {
			s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
		}

		// Use data converter to retrieve json after script execution
		s.converters[ "script json" ] = function() {
			if ( !responseContainer ) {
				jQuery.error( callbackName + " was not called" );
			}
			return responseContainer[ 0 ];
		};

		// force json dataType
		s.dataTypes[ 0 ] = "json";

		// Install callback
		overwritten = window[ callbackName ];
		window[ callbackName ] = function() {
			responseContainer = arguments;
		};

		// Clean-up function (fires after converters)
		jqXHR.always( function() {

			// If previous value didn't exist - remove it
			if ( overwritten === undefined ) {
				jQuery( window ).removeProp( callbackName );

			// Otherwise restore preexisting value
			} else {
				window[ callbackName ] = overwritten;
			}

			// Save back as free
			if ( s[ callbackName ] ) {

				// make sure that re-using the options doesn't screw things around
				s.jsonpCallback = originalSettings.jsonpCallback;

				// save the callback name for future use
				oldCallbacks.push( callbackName );
			}

			// Call if it was a function and we have a response
			if ( responseContainer && jQuery.isFunction( overwritten ) ) {
				overwritten( responseContainer[ 0 ] );
			}

			responseContainer = overwritten = undefined;
		} );

		// Delegate to script
		return "script";
	}
} );




// data: string of html
// context (optional): If specified, the fragment will be created in this context,
// defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string
jQuery.parseHTML = function( data, context, keepScripts ) {
	if ( !data || typeof data !== "string" ) {
		return null;
	}
	if ( typeof context === "boolean" ) {
		keepScripts = context;
		context = false;
	}
	context = context || document;

	var parsed = rsingleTag.exec( data ),
		scripts = !keepScripts && [];

	// Single tag
	if ( parsed ) {
		return [ context.createElement( parsed[ 1 ] ) ];
	}

	parsed = buildFragment( [ data ], context, scripts );

	if ( scripts && scripts.length ) {
		jQuery( scripts ).remove();
	}

	return jQuery.merge( [], parsed.childNodes );
};


// Keep a copy of the old load method
var _load = jQuery.fn.load;

/**
 * Load a url into a page
 */
jQuery.fn.load = function( url, params, callback ) {
	if ( typeof url !== "string" && _load ) {
		return _load.apply( this, arguments );
	}

	var selector, type, response,
		self = this,
		off = url.indexOf( " " );

	if ( off > -1 ) {
		selector = jQuery.trim( url.slice( off, url.length ) );
		url = url.slice( 0, off );
	}

	// If it's a function
	if ( jQuery.isFunction( params ) ) {

		// We assume that it's the callback
		callback = params;
		params = undefined;

	// Otherwise, build a param string
	} else if ( params && typeof params === "object" ) {
		type = "POST";
	}

	// If we have elements to modify, make the request
	if ( self.length > 0 ) {
		jQuery.ajax( {
			url: url,

			// If "type" variable is undefined, then "GET" method will be used.
			// Make value of this field explicit since
			// user can override it through ajaxSetup method
			type: type || "GET",
			dataType: "html",
			data: params
		} ).done( function( responseText ) {

			// Save response for use in complete callback
			response = arguments;

			self.html( selector ?

				// If a selector was specified, locate the right elements in a dummy div
				// Exclude scripts to avoid IE 'Permission Denied' errors
				jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :

				// Otherwise use the full result
				responseText );

		// If the request succeeds, this function gets "data", "status", "jqXHR"
		// but they are ignored because response was set above.
		// If it fails, this function gets "jqXHR", "status", "error"
		} ).always( callback && function( jqXHR, status ) {
			self.each( function() {
				callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
			} );
		} );
	}

	return this;
};




// Attach a bunch of functions for handling common AJAX events
jQuery.each( [
	"ajaxStart",
	"ajaxStop",
	"ajaxComplete",
	"ajaxError",
	"ajaxSuccess",
	"ajaxSend"
], function( i, type ) {
	jQuery.fn[ type ] = function( fn ) {
		return this.on( type, fn );
	};
} );




jQuery.expr.filters.animated = function( elem ) {
	return jQuery.grep( jQuery.timers, function( fn ) {
		return elem === fn.elem;
	} ).length;
};





/**
 * Gets a window from an element
 */
function getWindow( elem ) {
	return jQuery.isWindow( elem ) ?
		elem :
		elem.nodeType === 9 ?
			elem.defaultView || elem.parentWindow :
			false;
}

jQuery.offset = {
	setOffset: function( elem, options, i ) {
		var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
			position = jQuery.css( elem, "position" ),
			curElem = jQuery( elem ),
			props = {};

		// set position first, in-case top/left are set even on static elem
		if ( position === "static" ) {
			elem.style.position = "relative";
		}

		curOffset = curElem.offset();
		curCSSTop = jQuery.css( elem, "top" );
		curCSSLeft = jQuery.css( elem, "left" );
		calculatePosition = ( position === "absolute" || position === "fixed" ) &&
			jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;

		// need to be able to calculate position if either top or left
		// is auto and position is either absolute or fixed
		if ( calculatePosition ) {
			curPosition = curElem.position();
			curTop = curPosition.top;
			curLeft = curPosition.left;
		} else {
			curTop = parseFloat( curCSSTop ) || 0;
			curLeft = parseFloat( curCSSLeft ) || 0;
		}

		if ( jQuery.isFunction( options ) ) {

			// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
			options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
		}

		if ( options.top != null ) {
			props.top = ( options.top - curOffset.top ) + curTop;
		}
		if ( options.left != null ) {
			props.left = ( options.left - curOffset.left ) + curLeft;
		}

		if ( "using" in options ) {
			options.using.call( elem, props );
		} else {
			curElem.css( props );
		}
	}
};

jQuery.fn.extend( {
	offset: function( options ) {
		if ( arguments.length ) {
			return options === undefined ?
				this :
				this.each( function( i ) {
					jQuery.offset.setOffset( this, options, i );
				} );
		}

		var docElem, win,
			box = { top: 0, left: 0 },
			elem = this[ 0 ],
			doc = elem && elem.ownerDocument;

		if ( !doc ) {
			return;
		}

		docElem = doc.documentElement;

		// Make sure it's not a disconnected DOM node
		if ( !jQuery.contains( docElem, elem ) ) {
			return box;
		}

		// If we don't have gBCR, just use 0,0 rather than error
		// BlackBerry 5, iOS 3 (original iPhone)
		if ( typeof elem.getBoundingClientRect !== "undefined" ) {
			box = elem.getBoundingClientRect();
		}
		win = getWindow( doc );
		return {
			top: box.top  + ( win.pageYOffset || docElem.scrollTop )  - ( docElem.clientTop  || 0 ),
			left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
		};
	},

	position: function() {
		if ( !this[ 0 ] ) {
			return;
		}

		var offsetParent, offset,
			parentOffset = { top: 0, left: 0 },
			elem = this[ 0 ];

		// Fixed elements are offset from window (parentOffset = {top:0, left: 0},
		// because it is its only offset parent
		if ( jQuery.css( elem, "position" ) === "fixed" ) {

			// we assume that getBoundingClientRect is available when computed position is fixed
			offset = elem.getBoundingClientRect();
		} else {

			// Get *real* offsetParent
			offsetParent = this.offsetParent();

			// Get correct offsets
			offset = this.offset();
			if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
				parentOffset = offsetParent.offset();
			}

			// Add offsetParent borders
			parentOffset.top  += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
			parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
		}

		// Subtract parent offsets and element margins
		// note: when an element has margin: auto the offsetLeft and marginLeft
		// are the same in Safari causing offset.left to incorrectly be 0
		return {
			top:  offset.top  - parentOffset.top - jQuery.css( elem, "marginTop", true ),
			left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
		};
	},

	offsetParent: function() {
		return this.map( function() {
			var offsetParent = this.offsetParent;

			while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
				jQuery.css( offsetParent, "position" ) === "static" ) ) {
				offsetParent = offsetParent.offsetParent;
			}
			return offsetParent || documentElement;
		} );
	}
} );

// Create scrollLeft and scrollTop methods
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
	var top = /Y/.test( prop );

	jQuery.fn[ method ] = function( val ) {
		return access( this, function( elem, method, val ) {
			var win = getWindow( elem );

			if ( val === undefined ) {
				return win ? ( prop in win ) ? win[ prop ] :
					win.document.documentElement[ method ] :
					elem[ method ];
			}

			if ( win ) {
				win.scrollTo(
					!top ? val : jQuery( win ).scrollLeft(),
					top ? val : jQuery( win ).scrollTop()
				);

			} else {
				elem[ method ] = val;
			}
		}, method, val, arguments.length, null );
	};
} );

// Support: Safari<7-8+, Chrome<37-44+
// Add the top/left cssHooks using jQuery.fn.position
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// getComputedStyle returns percent when specified for top/left/bottom/right
// rather than make the css module depend on the offset module, we just check for it here
jQuery.each( [ "top", "left" ], function( i, prop ) {
	jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
		function( elem, computed ) {
			if ( computed ) {
				computed = curCSS( elem, prop );

				// if curCSS returns percentage, fallback to offset
				return rnumnonpx.test( computed ) ?
					jQuery( elem ).position()[ prop ] + "px" :
					computed;
			}
		}
	);
} );


// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
	jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
	function( defaultExtra, funcName ) {

		// margin is only for outerHeight, outerWidth
		jQuery.fn[ funcName ] = function( margin, value ) {
			var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
				extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );

			return access( this, function( elem, type, value ) {
				var doc;

				if ( jQuery.isWindow( elem ) ) {

					// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
					// isn't a whole lot we can do. See pull request at this URL for discussion:
					// https://github.com/jquery/jquery/pull/764
					return elem.document.documentElement[ "client" + name ];
				}

				// Get document width or height
				if ( elem.nodeType === 9 ) {
					doc = elem.documentElement;

					// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
					// whichever is greatest
					// unfortunately, this causes bug #3838 in IE6/8 only,
					// but there is currently no good, small way to fix it.
					return Math.max(
						elem.body[ "scroll" + name ], doc[ "scroll" + name ],
						elem.body[ "offset" + name ], doc[ "offset" + name ],
						doc[ "client" + name ]
					);
				}

				return value === undefined ?

					// Get width or height on the element, requesting but not forcing parseFloat
					jQuery.css( elem, type, extra ) :

					// Set width or height on the element
					jQuery.style( elem, type, value, extra );
			}, type, chainable ? margin : undefined, chainable, null );
		};
	} );
} );


jQuery.fn.extend( {

	bind: function( types, data, fn ) {
		return this.on( types, null, data, fn );
	},
	unbind: function( types, fn ) {
		return this.off( types, null, fn );
	},

	delegate: function( selector, types, data, fn ) {
		return this.on( types, selector, data, fn );
	},
	undelegate: function( selector, types, fn ) {

		// ( namespace ) or ( selector, types [, fn] )
		return arguments.length === 1 ?
			this.off( selector, "**" ) :
			this.off( types, selector || "**", fn );
	}
} );

// The number of elements contained in the matched element set
jQuery.fn.size = function() {
	return this.length;
};

jQuery.fn.andSelf = jQuery.fn.addBack;




// Register as a named AMD module, since jQuery can be concatenated with other
// files that may use define, but not via a proper concatenation script that
// understands anonymous AMD modules. A named AMD is safest and most robust
// way to register. Lowercase jquery is used because AMD module names are
// derived from file names, and jQuery is normally delivered in a lowercase
// file name. Do this after creating the global so that if an AMD module wants
// to call noConflict to hide this version of jQuery, it will work.

// Note that for maximum portability, libraries that are not jQuery should
// declare themselves as anonymous modules, and avoid setting a global if an
// AMD loader is present. jQuery is a special case. For more information, see
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon

if ( typeof define === "function" && define.amd ) {
	define( "jquery", [], function() {
		return jQuery;
	} );
}



var

	// Map over jQuery in case of overwrite
	_jQuery = window.jQuery,

	// Map over the $ in case of overwrite
	_$ = window.$;

jQuery.noConflict = function( deep ) {
	if ( window.$ === jQuery ) {
		window.$ = _$;
	}

	if ( deep && window.jQuery === jQuery ) {
		window.jQuery = _jQuery;
	}

	return jQuery;
};

// Expose jQuery and $ identifiers, even in
// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566)
if ( !noGlobal ) {
	window.jQuery = window.$ = jQuery;
}

return jQuery;
}));
/* ========================================================================
 * Bootstrap: affix.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#affix
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // AFFIX CLASS DEFINITION
  // ======================

  var Affix = function (element, options) {
    this.options = $.extend({}, Affix.DEFAULTS, options)

    var target = this.options.target === Affix.DEFAULTS.target ? $(this.options.target) : $(document).find(this.options.target)

    this.$target = target
      .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
      .on('click.bs.affix.data-api',  $.proxy(this.checkPositionWithEventLoop, this))

    this.$element     = $(element)
    this.affixed      = null
    this.unpin        = null
    this.pinnedOffset = null

    this.checkPosition()
  }

  Affix.VERSION  = '3.4.1'

  Affix.RESET    = 'affix affix-top affix-bottom'

  Affix.DEFAULTS = {
    offset: 0,
    target: window
  }

  Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
    var scrollTop    = this.$target.scrollTop()
    var position     = this.$element.offset()
    var targetHeight = this.$target.height()

    if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false

    if (this.affixed == 'bottom') {
      if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
      return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
    }

    var initializing   = this.affixed == null
    var colliderTop    = initializing ? scrollTop : position.top
    var colliderHeight = initializing ? targetHeight : height

    if (offsetTop != null && scrollTop <= offsetTop) return 'top'
    if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'

    return false
  }

  Affix.prototype.getPinnedOffset = function () {
    if (this.pinnedOffset) return this.pinnedOffset
    this.$element.removeClass(Affix.RESET).addClass('affix')
    var scrollTop = this.$target.scrollTop()
    var position  = this.$element.offset()
    return (this.pinnedOffset = position.top - scrollTop)
  }

  Affix.prototype.checkPositionWithEventLoop = function () {
    setTimeout($.proxy(this.checkPosition, this), 1)
  }

  Affix.prototype.checkPosition = function () {
    if (!this.$element.is(':visible')) return

    var height       = this.$element.height()
    var offset       = this.options.offset
    var offsetTop    = offset.top
    var offsetBottom = offset.bottom
    var scrollHeight = Math.max($(document).height(), $(document.body).height())

    if (typeof offset != 'object')         offsetBottom = offsetTop = offset
    if (typeof offsetTop == 'function')    offsetTop    = offset.top(this.$element)
    if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)

    var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)

    if (this.affixed != affix) {
      if (this.unpin != null) this.$element.css('top', '')

      var affixType = 'affix' + (affix ? '-' + affix : '')
      var e         = $.Event(affixType + '.bs.affix')

      this.$element.trigger(e)

      if (e.isDefaultPrevented()) return

      this.affixed = affix
      this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null

      this.$element
        .removeClass(Affix.RESET)
        .addClass(affixType)
        .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
    }

    if (affix == 'bottom') {
      this.$element.offset({
        top: scrollHeight - height - offsetBottom
      })
    }
  }


  // AFFIX PLUGIN DEFINITION
  // =======================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.affix')
      var options = typeof option == 'object' && option

      if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.affix

  $.fn.affix             = Plugin
  $.fn.affix.Constructor = Affix


  // AFFIX NO CONFLICT
  // =================

  $.fn.affix.noConflict = function () {
    $.fn.affix = old
    return this
  }


  // AFFIX DATA-API
  // ==============

  $(window).on('load', function () {
    $('[data-spy="affix"]').each(function () {
      var $spy = $(this)
      var data = $spy.data()

      data.offset = data.offset || {}

      if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
      if (data.offsetTop    != null) data.offset.top    = data.offsetTop

      Plugin.call($spy, data)
    })
  })

}(jQuery);
/* ========================================================================
 * Bootstrap: alert.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#alerts
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // ALERT CLASS DEFINITION
  // ======================

  var dismiss = '[data-dismiss="alert"]'
  var Alert   = function (el) {
    $(el).on('click', dismiss, this.close)
  }

  Alert.VERSION = '3.4.1'

  Alert.TRANSITION_DURATION = 150

  Alert.prototype.close = function (e) {
    var $this    = $(this)
    var selector = $this.attr('data-target')

    if (!selector) {
      selector = $this.attr('href')
      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
    }

    selector    = selector === '#' ? [] : selector
    var $parent = $(document).find(selector)

    if (e) e.preventDefault()

    if (!$parent.length) {
      $parent = $this.closest('.alert')
    }

    $parent.trigger(e = $.Event('close.bs.alert'))

    if (e.isDefaultPrevented()) return

    $parent.removeClass('in')

    function removeElement() {
      // detach from parent, fire event then clean up data
      $parent.detach().trigger('closed.bs.alert').remove()
    }

    $.support.transition && $parent.hasClass('fade') ?
      $parent
        .one('bsTransitionEnd', removeElement)
        .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
      removeElement()
  }


  // ALERT PLUGIN DEFINITION
  // =======================

  function Plugin(option) {
    return this.each(function () {
      var $this = $(this)
      var data  = $this.data('bs.alert')

      if (!data) $this.data('bs.alert', (data = new Alert(this)))
      if (typeof option == 'string') data[option].call($this)
    })
  }

  var old = $.fn.alert

  $.fn.alert             = Plugin
  $.fn.alert.Constructor = Alert


  // ALERT NO CONFLICT
  // =================

  $.fn.alert.noConflict = function () {
    $.fn.alert = old
    return this
  }


  // ALERT DATA-API
  // ==============

  $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)

}(jQuery);
/* ========================================================================
 * Bootstrap: button.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#buttons
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // BUTTON PUBLIC CLASS DEFINITION
  // ==============================

  var Button = function (element, options) {
    this.$element  = $(element)
    this.options   = $.extend({}, Button.DEFAULTS, options)
    this.isLoading = false
  }

  Button.VERSION  = '3.4.1'

  Button.DEFAULTS = {
    loadingText: 'loading...'
  }

  Button.prototype.setState = function (state) {
    var d    = 'disabled'
    var $el  = this.$element
    var val  = $el.is('input') ? 'val' : 'html'
    var data = $el.data()

    state += 'Text'

    if (data.resetText == null) $el.data('resetText', $el[val]())

    // push to event loop to allow forms to submit
    setTimeout($.proxy(function () {
      $el[val](data[state] == null ? this.options[state] : data[state])

      if (state == 'loadingText') {
        this.isLoading = true
        $el.addClass(d).attr(d, d).prop(d, true)
      } else if (this.isLoading) {
        this.isLoading = false
        $el.removeClass(d).removeAttr(d).prop(d, false)
      }
    }, this), 0)
  }

  Button.prototype.toggle = function () {
    var changed = true
    var $parent = this.$element.closest('[data-toggle="buttons"]')

    if ($parent.length) {
      var $input = this.$element.find('input')
      if ($input.prop('type') == 'radio') {
        if ($input.prop('checked')) changed = false
        $parent.find('.active').removeClass('active')
        this.$element.addClass('active')
      } else if ($input.prop('type') == 'checkbox') {
        if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
        this.$element.toggleClass('active')
      }
      $input.prop('checked', this.$element.hasClass('active'))
      if (changed) $input.trigger('change')
    } else {
      this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
      this.$element.toggleClass('active')
    }
  }


  // BUTTON PLUGIN DEFINITION
  // ========================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.button')
      var options = typeof option == 'object' && option

      if (!data) $this.data('bs.button', (data = new Button(this, options)))

      if (option == 'toggle') data.toggle()
      else if (option) data.setState(option)
    })
  }

  var old = $.fn.button

  $.fn.button             = Plugin
  $.fn.button.Constructor = Button


  // BUTTON NO CONFLICT
  // ==================

  $.fn.button.noConflict = function () {
    $.fn.button = old
    return this
  }


  // BUTTON DATA-API
  // ===============

  $(document)
    .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
      var $btn = $(e.target).closest('.btn')
      Plugin.call($btn, 'toggle')
      if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) {
        // Prevent double click on radios, and the double selections (so cancellation) on checkboxes
        e.preventDefault()
        // The target component still receive the focus
        if ($btn.is('input,button')) $btn.trigger('focus')
        else $btn.find('input:visible,button:visible').first().trigger('focus')
      }
    })
    .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
      $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))
    })

}(jQuery);
/* ========================================================================
 * Bootstrap: carousel.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#carousel
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // CAROUSEL CLASS DEFINITION
  // =========================

  var Carousel = function (element, options) {
    this.$element    = $(element)
    this.$indicators = this.$element.find('.carousel-indicators')
    this.options     = options
    this.paused      = null
    this.sliding     = null
    this.interval    = null
    this.$active     = null
    this.$items      = null

    this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))

    this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
      .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
      .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
  }

  Carousel.VERSION  = '3.4.1'

  Carousel.TRANSITION_DURATION = 600

  Carousel.DEFAULTS = {
    interval: 5000,
    pause: 'hover',
    wrap: true,
    keyboard: true
  }

  Carousel.prototype.keydown = function (e) {
    if (/input|textarea/i.test(e.target.tagName)) return
    switch (e.which) {
      case 37: this.prev(); break
      case 39: this.next(); break
      default: return
    }

    e.preventDefault()
  }

  Carousel.prototype.cycle = function (e) {
    e || (this.paused = false)

    this.interval && clearInterval(this.interval)

    this.options.interval
      && !this.paused
      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))

    return this
  }

  Carousel.prototype.getItemIndex = function (item) {
    this.$items = item.parent().children('.item')
    return this.$items.index(item || this.$active)
  }

  Carousel.prototype.getItemForDirection = function (direction, active) {
    var activeIndex = this.getItemIndex(active)
    var willWrap = (direction == 'prev' && activeIndex === 0)
                || (direction == 'next' && activeIndex == (this.$items.length - 1))
    if (willWrap && !this.options.wrap) return active
    var delta = direction == 'prev' ? -1 : 1
    var itemIndex = (activeIndex + delta) % this.$items.length
    return this.$items.eq(itemIndex)
  }

  Carousel.prototype.to = function (pos) {
    var that        = this
    var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))

    if (pos > (this.$items.length - 1) || pos < 0) return

    if (this.sliding)       return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
    if (activeIndex == pos) return this.pause().cycle()

    return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))
  }

  Carousel.prototype.pause = function (e) {
    e || (this.paused = true)

    if (this.$element.find('.next, .prev').length && $.support.transition) {
      this.$element.trigger($.support.transition.end)
      this.cycle(true)
    }

    this.interval = clearInterval(this.interval)

    return this
  }

  Carousel.prototype.next = function () {
    if (this.sliding) return
    return this.slide('next')
  }

  Carousel.prototype.prev = function () {
    if (this.sliding) return
    return this.slide('prev')
  }

  Carousel.prototype.slide = function (type, next) {
    var $active   = this.$element.find('.item.active')
    var $next     = next || this.getItemForDirection(type, $active)
    var isCycling = this.interval
    var direction = type == 'next' ? 'left' : 'right'
    var that      = this

    if ($next.hasClass('active')) return (this.sliding = false)

    var relatedTarget = $next[0]
    var slideEvent = $.Event('slide.bs.carousel', {
      relatedTarget: relatedTarget,
      direction: direction
    })
    this.$element.trigger(slideEvent)
    if (slideEvent.isDefaultPrevented()) return

    this.sliding = true

    isCycling && this.pause()

    if (this.$indicators.length) {
      this.$indicators.find('.active').removeClass('active')
      var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
      $nextIndicator && $nextIndicator.addClass('active')
    }

    var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
    if ($.support.transition && this.$element.hasClass('slide')) {
      $next.addClass(type)
      if (typeof $next === 'object' && $next.length) {
        $next[0].offsetWidth // force reflow
      }
      $active.addClass(direction)
      $next.addClass(direction)
      $active
        .one('bsTransitionEnd', function () {
          $next.removeClass([type, direction].join(' ')).addClass('active')
          $active.removeClass(['active', direction].join(' '))
          that.sliding = false
          setTimeout(function () {
            that.$element.trigger(slidEvent)
          }, 0)
        })
        .emulateTransitionEnd(Carousel.TRANSITION_DURATION)
    } else {
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
      this.$element.trigger(slidEvent)
    }

    isCycling && this.cycle()

    return this
  }


  // CAROUSEL PLUGIN DEFINITION
  // ==========================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.carousel')
      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
      var action  = typeof option == 'string' ? option : options.slide

      if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
      if (typeof option == 'number') data.to(option)
      else if (action) data[action]()
      else if (options.interval) data.pause().cycle()
    })
  }

  var old = $.fn.carousel

  $.fn.carousel             = Plugin
  $.fn.carousel.Constructor = Carousel


  // CAROUSEL NO CONFLICT
  // ====================

  $.fn.carousel.noConflict = function () {
    $.fn.carousel = old
    return this
  }


  // CAROUSEL DATA-API
  // =================

  var clickHandler = function (e) {
    var $this   = $(this)
    var href    = $this.attr('href')
    if (href) {
      href = href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
    }

    var target  = $this.attr('data-target') || href
    var $target = $(document).find(target)

    if (!$target.hasClass('carousel')) return

    var options = $.extend({}, $target.data(), $this.data())
    var slideIndex = $this.attr('data-slide-to')
    if (slideIndex) options.interval = false

    Plugin.call($target, options)

    if (slideIndex) {
      $target.data('bs.carousel').to(slideIndex)
    }

    e.preventDefault()
  }

  $(document)
    .on('click.bs.carousel.data-api', '[data-slide]', clickHandler)
    .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)

  $(window).on('load', function () {
    $('[data-ride="carousel"]').each(function () {
      var $carousel = $(this)
      Plugin.call($carousel, $carousel.data())
    })
  })

}(jQuery);
/* ========================================================================
 * Bootstrap: collapse.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#collapse
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */

/* jshint latedef: false */

+function ($) {
  'use strict';

  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================

  var Collapse = function (element, options) {
    this.$element      = $(element)
    this.options       = $.extend({}, Collapse.DEFAULTS, options)
    this.$trigger      = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
                           '[data-toggle="collapse"][data-target="#' + element.id + '"]')
    this.transitioning = null

    if (this.options.parent) {
      this.$parent = this.getParent()
    } else {
      this.addAriaAndCollapsedClass(this.$element, this.$trigger)
    }

    if (this.options.toggle) this.toggle()
  }

  Collapse.VERSION  = '3.4.1'

  Collapse.TRANSITION_DURATION = 350

  Collapse.DEFAULTS = {
    toggle: true
  }

  Collapse.prototype.dimension = function () {
    var hasWidth = this.$element.hasClass('width')
    return hasWidth ? 'width' : 'height'
  }

  Collapse.prototype.show = function () {
    if (this.transitioning || this.$element.hasClass('in')) return

    var activesData
    var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')

    if (actives && actives.length) {
      activesData = actives.data('bs.collapse')
      if (activesData && activesData.transitioning) return
    }

    var startEvent = $.Event('show.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

    if (actives && actives.length) {
      Plugin.call(actives, 'hide')
      activesData || actives.data('bs.collapse', null)
    }

    var dimension = this.dimension()

    this.$element
      .removeClass('collapse')
      .addClass('collapsing')[dimension](0)
      .attr('aria-expanded', true)

    this.$trigger
      .removeClass('collapsed')
      .attr('aria-expanded', true)

    this.transitioning = 1

    var complete = function () {
      this.$element
        .removeClass('collapsing')
        .addClass('collapse in')[dimension]('')
      this.transitioning = 0
      this.$element
        .trigger('shown.bs.collapse')
    }

    if (!$.support.transition) return complete.call(this)

    var scrollSize = $.camelCase(['scroll', dimension].join('-'))

    this.$element
      .one('bsTransitionEnd', $.proxy(complete, this))
      .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
  }

  Collapse.prototype.hide = function () {
    if (this.transitioning || !this.$element.hasClass('in')) return

    var startEvent = $.Event('hide.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

    var dimension = this.dimension()

    this.$element[dimension](this.$element[dimension]())[0].offsetHeight

    this.$element
      .addClass('collapsing')
      .removeClass('collapse in')
      .attr('aria-expanded', false)

    this.$trigger
      .addClass('collapsed')
      .attr('aria-expanded', false)

    this.transitioning = 1

    var complete = function () {
      this.transitioning = 0
      this.$element
        .removeClass('collapsing')
        .addClass('collapse')
        .trigger('hidden.bs.collapse')
    }

    if (!$.support.transition) return complete.call(this)

    this.$element
      [dimension](0)
      .one('bsTransitionEnd', $.proxy(complete, this))
      .emulateTransitionEnd(Collapse.TRANSITION_DURATION)
  }

  Collapse.prototype.toggle = function () {
    this[this.$element.hasClass('in') ? 'hide' : 'show']()
  }

  Collapse.prototype.getParent = function () {
    return $(document).find(this.options.parent)
      .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
      .each($.proxy(function (i, element) {
        var $element = $(element)
        this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
      }, this))
      .end()
  }

  Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
    var isOpen = $element.hasClass('in')

    $element.attr('aria-expanded', isOpen)
    $trigger
      .toggleClass('collapsed', !isOpen)
      .attr('aria-expanded', isOpen)
  }

  function getTargetFromTrigger($trigger) {
    var href
    var target = $trigger.attr('data-target')
      || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7

    return $(document).find(target)
  }


  // COLLAPSE PLUGIN DEFINITION
  // ==========================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.collapse')
      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)

      if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.collapse

  $.fn.collapse             = Plugin
  $.fn.collapse.Constructor = Collapse


  // COLLAPSE NO CONFLICT
  // ====================

  $.fn.collapse.noConflict = function () {
    $.fn.collapse = old
    return this
  }


  // COLLAPSE DATA-API
  // =================

  $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
    var $this   = $(this)

    if (!$this.attr('data-target')) e.preventDefault()

    var $target = getTargetFromTrigger($this)
    var data    = $target.data('bs.collapse')
    var option  = data ? 'toggle' : $this.data()

    Plugin.call($target, option)
  })

}(jQuery);
/* ========================================================================
 * Bootstrap: dropdown.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#dropdowns
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // DROPDOWN CLASS DEFINITION
  // =========================

  var backdrop = '.dropdown-backdrop'
  var toggle   = '[data-toggle="dropdown"]'
  var Dropdown = function (element) {
    $(element).on('click.bs.dropdown', this.toggle)
  }

  Dropdown.VERSION = '3.4.1'

  function getParent($this) {
    var selector = $this.attr('data-target')

    if (!selector) {
      selector = $this.attr('href')
      selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
    }

    var $parent = selector !== '#' ? $(document).find(selector) : null

    return $parent && $parent.length ? $parent : $this.parent()
  }

  function clearMenus(e) {
    if (e && e.which === 3) return
    $(backdrop).remove()
    $(toggle).each(function () {
      var $this         = $(this)
      var $parent       = getParent($this)
      var relatedTarget = { relatedTarget: this }

      if (!$parent.hasClass('open')) return

      if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return

      $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))

      if (e.isDefaultPrevented()) return

      $this.attr('aria-expanded', 'false')
      $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
    })
  }

  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)

    if ($this.is('.disabled, :disabled')) return

    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')

    clearMenus()

    if (!isActive) {
      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
        // if mobile we use a backdrop because click events don't delegate
        $(document.createElement('div'))
          .addClass('dropdown-backdrop')
          .insertAfter($(this))
          .on('click', clearMenus)
      }

      var relatedTarget = { relatedTarget: this }
      $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))

      if (e.isDefaultPrevented()) return

      $this
        .trigger('focus')
        .attr('aria-expanded', 'true')

      $parent
        .toggleClass('open')
        .trigger($.Event('shown.bs.dropdown', relatedTarget))
    }

    return false
  }

  Dropdown.prototype.keydown = function (e) {
    if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return

    var $this = $(this)

    e.preventDefault()
    e.stopPropagation()

    if ($this.is('.disabled, :disabled')) return

    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')

    if (!isActive && e.which != 27 || isActive && e.which == 27) {
      if (e.which == 27) $parent.find(toggle).trigger('focus')
      return $this.trigger('click')
    }

    var desc = ' li:not(.disabled):visible a'
    var $items = $parent.find('.dropdown-menu' + desc)

    if (!$items.length) return

    var index = $items.index(e.target)

    if (e.which == 38 && index > 0)                 index--         // up
    if (e.which == 40 && index < $items.length - 1) index++         // down
    if (!~index)                                    index = 0

    $items.eq(index).trigger('focus')
  }


  // DROPDOWN PLUGIN DEFINITION
  // ==========================

  function Plugin(option) {
    return this.each(function () {
      var $this = $(this)
      var data  = $this.data('bs.dropdown')

      if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
      if (typeof option == 'string') data[option].call($this)
    })
  }

  var old = $.fn.dropdown

  $.fn.dropdown             = Plugin
  $.fn.dropdown.Constructor = Dropdown


  // DROPDOWN NO CONFLICT
  // ====================

  $.fn.dropdown.noConflict = function () {
    $.fn.dropdown = old
    return this
  }


  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

  $(document)
    .on('click.bs.dropdown.data-api', clearMenus)
    .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
    .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
    .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
    .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)

}(jQuery);
/* ========================================================================
 * Bootstrap: modal.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#modals
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // MODAL CLASS DEFINITION
  // ======================

  var Modal = function (element, options) {
    this.options = options
    this.$body = $(document.body)
    this.$element = $(element)
    this.$dialog = this.$element.find('.modal-dialog')
    this.$backdrop = null
    this.isShown = null
    this.originalBodyPad = null
    this.scrollbarWidth = 0
    this.ignoreBackdropClick = false
    this.fixedContent = '.navbar-fixed-top, .navbar-fixed-bottom'

    if (this.options.remote) {
      this.$element
        .find('.modal-content')
        .load(this.options.remote, $.proxy(function () {
          this.$element.trigger('loaded.bs.modal')
        }, this))
    }
  }

  Modal.VERSION = '3.4.1'

  Modal.TRANSITION_DURATION = 300
  Modal.BACKDROP_TRANSITION_DURATION = 150

  Modal.DEFAULTS = {
    backdrop: true,
    keyboard: true,
    show: true
  }

  Modal.prototype.toggle = function (_relatedTarget) {
    return this.isShown ? this.hide() : this.show(_relatedTarget)
  }

  Modal.prototype.show = function (_relatedTarget) {
    var that = this
    var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })

    this.$element.trigger(e)

    if (this.isShown || e.isDefaultPrevented()) return

    this.isShown = true

    this.checkScrollbar()
    this.setScrollbar()
    this.$body.addClass('modal-open')

    this.escape()
    this.resize()

    this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))

    this.$dialog.on('mousedown.dismiss.bs.modal', function () {
      that.$element.one('mouseup.dismiss.bs.modal', function (e) {
        if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
      })
    })

    this.backdrop(function () {
      var transition = $.support.transition && that.$element.hasClass('fade')

      if (!that.$element.parent().length) {
        that.$element.appendTo(that.$body) // don't move modals dom position
      }

      that.$element
        .show()
        .scrollTop(0)

      that.adjustDialog()

      if (transition) {
        that.$element[0].offsetWidth // force reflow
      }

      that.$element.addClass('in')

      that.enforceFocus()

      var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })

      transition ?
        that.$dialog // wait for modal to slide in
          .one('bsTransitionEnd', function () {
            that.$element.trigger('focus').trigger(e)
          })
          .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
        that.$element.trigger('focus').trigger(e)
    })
  }

  Modal.prototype.hide = function (e) {
    if (e) e.preventDefault()

    e = $.Event('hide.bs.modal')

    this.$element.trigger(e)

    if (!this.isShown || e.isDefaultPrevented()) return

    this.isShown = false

    this.escape()
    this.resize()

    $(document).off('focusin.bs.modal')

    this.$element
      .removeClass('in')
      .off('click.dismiss.bs.modal')
      .off('mouseup.dismiss.bs.modal')

    this.$dialog.off('mousedown.dismiss.bs.modal')

    $.support.transition && this.$element.hasClass('fade') ?
      this.$element
        .one('bsTransitionEnd', $.proxy(this.hideModal, this))
        .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
      this.hideModal()
  }

  Modal.prototype.enforceFocus = function () {
    $(document)
      .off('focusin.bs.modal') // guard against infinite focus loop
      .on('focusin.bs.modal', $.proxy(function (e) {
        if (document !== e.target &&
          this.$element[0] !== e.target &&
          !this.$element.has(e.target).length) {
          this.$element.trigger('focus')
        }
      }, this))
  }

  Modal.prototype.escape = function () {
    if (this.isShown && this.options.keyboard) {
      this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
        e.which == 27 && this.hide()
      }, this))
    } else if (!this.isShown) {
      this.$element.off('keydown.dismiss.bs.modal')
    }
  }

  Modal.prototype.resize = function () {
    if (this.isShown) {
      $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
    } else {
      $(window).off('resize.bs.modal')
    }
  }

  Modal.prototype.hideModal = function () {
    var that = this
    this.$element.hide()
    this.backdrop(function () {
      that.$body.removeClass('modal-open')
      that.resetAdjustments()
      that.resetScrollbar()
      that.$element.trigger('hidden.bs.modal')
    })
  }

  Modal.prototype.removeBackdrop = function () {
    this.$backdrop && this.$backdrop.remove()
    this.$backdrop = null
  }

  Modal.prototype.backdrop = function (callback) {
    var that = this
    var animate = this.$element.hasClass('fade') ? 'fade' : ''

    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate

      this.$backdrop = $(document.createElement('div'))
        .addClass('modal-backdrop ' + animate)
        .appendTo(this.$body)

      this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
        if (this.ignoreBackdropClick) {
          this.ignoreBackdropClick = false
          return
        }
        if (e.target !== e.currentTarget) return
        this.options.backdrop == 'static'
          ? this.$element[0].focus()
          : this.hide()
      }, this))

      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow

      this.$backdrop.addClass('in')

      if (!callback) return

      doAnimate ?
        this.$backdrop
          .one('bsTransitionEnd', callback)
          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
        callback()

    } else if (!this.isShown && this.$backdrop) {
      this.$backdrop.removeClass('in')

      var callbackRemove = function () {
        that.removeBackdrop()
        callback && callback()
      }
      $.support.transition && this.$element.hasClass('fade') ?
        this.$backdrop
          .one('bsTransitionEnd', callbackRemove)
          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
        callbackRemove()

    } else if (callback) {
      callback()
    }
  }

  // these following methods are used to handle overflowing modals

  Modal.prototype.handleUpdate = function () {
    this.adjustDialog()
  }

  Modal.prototype.adjustDialog = function () {
    var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight

    this.$element.css({
      paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
      paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
    })
  }

  Modal.prototype.resetAdjustments = function () {
    this.$element.css({
      paddingLeft: '',
      paddingRight: ''
    })
  }

  Modal.prototype.checkScrollbar = function () {
    var fullWindowWidth = window.innerWidth
    if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
      var documentElementRect = document.documentElement.getBoundingClientRect()
      fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
    }
    this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
    this.scrollbarWidth = this.measureScrollbar()
  }

  Modal.prototype.setScrollbar = function () {
    var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
    this.originalBodyPad = document.body.style.paddingRight || ''
    var scrollbarWidth = this.scrollbarWidth
    if (this.bodyIsOverflowing) {
      this.$body.css('padding-right', bodyPad + scrollbarWidth)
      $(this.fixedContent).each(function (index, element) {
        var actualPadding = element.style.paddingRight
        var calculatedPadding = $(element).css('padding-right')
        $(element)
          .data('padding-right', actualPadding)
          .css('padding-right', parseFloat(calculatedPadding) + scrollbarWidth + 'px')
      })
    }
  }

  Modal.prototype.resetScrollbar = function () {
    this.$body.css('padding-right', this.originalBodyPad)
    $(this.fixedContent).each(function (index, element) {
      var padding = $(element).data('padding-right')
      $(element).removeData('padding-right')
      element.style.paddingRight = padding ? padding : ''
    })
  }

  Modal.prototype.measureScrollbar = function () { // thx walsh
    var scrollDiv = document.createElement('div')
    scrollDiv.className = 'modal-scrollbar-measure'
    this.$body.append(scrollDiv)
    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
    this.$body[0].removeChild(scrollDiv)
    return scrollbarWidth
  }


  // MODAL PLUGIN DEFINITION
  // =======================

  function Plugin(option, _relatedTarget) {
    return this.each(function () {
      var $this = $(this)
      var data = $this.data('bs.modal')
      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)

      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
      if (typeof option == 'string') data[option](_relatedTarget)
      else if (options.show) data.show(_relatedTarget)
    })
  }

  var old = $.fn.modal

  $.fn.modal = Plugin
  $.fn.modal.Constructor = Modal


  // MODAL NO CONFLICT
  // =================

  $.fn.modal.noConflict = function () {
    $.fn.modal = old
    return this
  }


  // MODAL DATA-API
  // ==============

  $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
    var $this = $(this)
    var href = $this.attr('href')
    var target = $this.attr('data-target') ||
      (href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7

    var $target = $(document).find(target)
    var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())

    if ($this.is('a')) e.preventDefault()

    $target.one('show.bs.modal', function (showEvent) {
      if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
      $target.one('hidden.bs.modal', function () {
        $this.is(':visible') && $this.trigger('focus')
      })
    })
    Plugin.call($target, option, this)
  })

}(jQuery);
/* ========================================================================
 * Bootstrap: scrollspy.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#scrollspy
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // SCROLLSPY CLASS DEFINITION
  // ==========================

  function ScrollSpy(element, options) {
    this.$body          = $(document.body)
    this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
    this.options        = $.extend({}, ScrollSpy.DEFAULTS, options)
    this.selector       = (this.options.target || '') + ' .nav li > a'
    this.offsets        = []
    this.targets        = []
    this.activeTarget   = null
    this.scrollHeight   = 0

    this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
    this.refresh()
    this.process()
  }

  ScrollSpy.VERSION  = '3.4.1'

  ScrollSpy.DEFAULTS = {
    offset: 10
  }

  ScrollSpy.prototype.getScrollHeight = function () {
    return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
  }

  ScrollSpy.prototype.refresh = function () {
    var that          = this
    var offsetMethod  = 'offset'
    var offsetBase    = 0

    this.offsets      = []
    this.targets      = []
    this.scrollHeight = this.getScrollHeight()

    if (!$.isWindow(this.$scrollElement[0])) {
      offsetMethod = 'position'
      offsetBase   = this.$scrollElement.scrollTop()
    }

    this.$body
      .find(this.selector)
      .map(function () {
        var $el   = $(this)
        var href  = $el.data('target') || $el.attr('href')
        var $href = /^#./.test(href) && $(href)

        return ($href
          && $href.length
          && $href.is(':visible')
          && [[$href[offsetMethod]().top + offsetBase, href]]) || null
      })
      .sort(function (a, b) { return a[0] - b[0] })
      .each(function () {
        that.offsets.push(this[0])
        that.targets.push(this[1])
      })
  }

  ScrollSpy.prototype.process = function () {
    var scrollTop    = this.$scrollElement.scrollTop() + this.options.offset
    var scrollHeight = this.getScrollHeight()
    var maxScroll    = this.options.offset + scrollHeight - this.$scrollElement.height()
    var offsets      = this.offsets
    var targets      = this.targets
    var activeTarget = this.activeTarget
    var i

    if (this.scrollHeight != scrollHeight) {
      this.refresh()
    }

    if (scrollTop >= maxScroll) {
      return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
    }

    if (activeTarget && scrollTop < offsets[0]) {
      this.activeTarget = null
      return this.clear()
    }

    for (i = offsets.length; i--;) {
      activeTarget != targets[i]
        && scrollTop >= offsets[i]
        && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])
        && this.activate(targets[i])
    }
  }

  ScrollSpy.prototype.activate = function (target) {
    this.activeTarget = target

    this.clear()

    var selector = this.selector +
      '[data-target="' + target + '"],' +
      this.selector + '[href="' + target + '"]'

    var active = $(selector)
      .parents('li')
      .addClass('active')

    if (active.parent('.dropdown-menu').length) {
      active = active
        .closest('li.dropdown')
        .addClass('active')
    }

    active.trigger('activate.bs.scrollspy')
  }

  ScrollSpy.prototype.clear = function () {
    $(this.selector)
      .parentsUntil(this.options.target, '.active')
      .removeClass('active')
  }


  // SCROLLSPY PLUGIN DEFINITION
  // ===========================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.scrollspy')
      var options = typeof option == 'object' && option

      if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.scrollspy

  $.fn.scrollspy             = Plugin
  $.fn.scrollspy.Constructor = ScrollSpy


  // SCROLLSPY NO CONFLICT
  // =====================

  $.fn.scrollspy.noConflict = function () {
    $.fn.scrollspy = old
    return this
  }


  // SCROLLSPY DATA-API
  // ==================

  $(window).on('load.bs.scrollspy.data-api', function () {
    $('[data-spy="scroll"]').each(function () {
      var $spy = $(this)
      Plugin.call($spy, $spy.data())
    })
  })

}(jQuery);
/* ========================================================================
 * Bootstrap: tab.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#tabs
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // TAB CLASS DEFINITION
  // ====================

  var Tab = function (element) {
    // jscs:disable requireDollarBeforejQueryAssignment
    this.element = $(element)
    // jscs:enable requireDollarBeforejQueryAssignment
  }

  Tab.VERSION = '3.4.1'

  Tab.TRANSITION_DURATION = 150

  Tab.prototype.show = function () {
    var $this    = this.element
    var $ul      = $this.closest('ul:not(.dropdown-menu)')
    var selector = $this.data('target')

    if (!selector) {
      selector = $this.attr('href')
      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
    }

    if ($this.parent('li').hasClass('active')) return

    var $previous = $ul.find('.active:last a')
    var hideEvent = $.Event('hide.bs.tab', {
      relatedTarget: $this[0]
    })
    var showEvent = $.Event('show.bs.tab', {
      relatedTarget: $previous[0]
    })

    $previous.trigger(hideEvent)
    $this.trigger(showEvent)

    if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return

    var $target = $(document).find(selector)

    this.activate($this.closest('li'), $ul)
    this.activate($target, $target.parent(), function () {
      $previous.trigger({
        type: 'hidden.bs.tab',
        relatedTarget: $this[0]
      })
      $this.trigger({
        type: 'shown.bs.tab',
        relatedTarget: $previous[0]
      })
    })
  }

  Tab.prototype.activate = function (element, container, callback) {
    var $active    = container.find('> .active')
    var transition = callback
      && $.support.transition
      && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)

    function next() {
      $active
        .removeClass('active')
        .find('> .dropdown-menu > .active')
        .removeClass('active')
        .end()
        .find('[data-toggle="tab"]')
        .attr('aria-expanded', false)

      element
        .addClass('active')
        .find('[data-toggle="tab"]')
        .attr('aria-expanded', true)

      if (transition) {
        element[0].offsetWidth // reflow for transition
        element.addClass('in')
      } else {
        element.removeClass('fade')
      }

      if (element.parent('.dropdown-menu').length) {
        element
          .closest('li.dropdown')
          .addClass('active')
          .end()
          .find('[data-toggle="tab"]')
          .attr('aria-expanded', true)
      }

      callback && callback()
    }

    $active.length && transition ?
      $active
        .one('bsTransitionEnd', next)
        .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
      next()

    $active.removeClass('in')
  }


  // TAB PLUGIN DEFINITION
  // =====================

  function Plugin(option) {
    return this.each(function () {
      var $this = $(this)
      var data  = $this.data('bs.tab')

      if (!data) $this.data('bs.tab', (data = new Tab(this)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.tab

  $.fn.tab             = Plugin
  $.fn.tab.Constructor = Tab


  // TAB NO CONFLICT
  // ===============

  $.fn.tab.noConflict = function () {
    $.fn.tab = old
    return this
  }


  // TAB DATA-API
  // ============

  var clickHandler = function (e) {
    e.preventDefault()
    Plugin.call($(this), 'show')
  }

  $(document)
    .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
    .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)

}(jQuery);
/* ========================================================================
 * Bootstrap: transition.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#transitions
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // CSS TRANSITION SUPPORT (Shoutout: https://modernizr.com/)
  // ============================================================

  function transitionEnd() {
    var el = document.createElement('bootstrap')

    var transEndEventNames = {
      WebkitTransition : 'webkitTransitionEnd',
      MozTransition    : 'transitionend',
      OTransition      : 'oTransitionEnd otransitionend',
      transition       : 'transitionend'
    }

    for (var name in transEndEventNames) {
      if (el.style[name] !== undefined) {
        return { end: transEndEventNames[name] }
      }
    }

    return false // explicit for ie8 (  ._.)
  }

  // https://blog.alexmaccaw.com/css-transitions
  $.fn.emulateTransitionEnd = function (duration) {
    var called = false
    var $el = this
    $(this).one('bsTransitionEnd', function () { called = true })
    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
    setTimeout(callback, duration)
    return this
  }

  $(function () {
    $.support.transition = transitionEnd()

    if (!$.support.transition) return

    $.event.special.bsTransitionEnd = {
      bindType: $.support.transition.end,
      delegateType: $.support.transition.end,
      handle: function (e) {
        if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
      }
    }
  })

}(jQuery);
/* ========================================================================
 * Bootstrap: tooltip.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#tooltip
 * Inspired by the original jQuery.tipsy by Jason Frame
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */

+function ($) {
  'use strict';

  var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']

  var uriAttrs = [
    'background',
    'cite',
    'href',
    'itemtype',
    'longdesc',
    'poster',
    'src',
    'xlink:href'
  ]

  var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i

  var DefaultWhitelist = {
    // Global attributes allowed on any supplied element below.
    '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
    a: ['target', 'href', 'title', 'rel'],
    area: [],
    b: [],
    br: [],
    col: [],
    code: [],
    div: [],
    em: [],
    hr: [],
    h1: [],
    h2: [],
    h3: [],
    h4: [],
    h5: [],
    h6: [],
    i: [],
    img: ['src', 'alt', 'title', 'width', 'height'],
    li: [],
    ol: [],
    p: [],
    pre: [],
    s: [],
    small: [],
    span: [],
    sub: [],
    sup: [],
    strong: [],
    u: [],
    ul: []
  }

  /**
   * A pattern that recognizes a commonly useful subset of URLs that are safe.
   *
   * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
   */
  var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi

  /**
   * A pattern that matches safe data URLs. Only matches image, video and audio types.
   *
   * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
   */
  var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i

  function allowedAttribute(attr, allowedAttributeList) {
    var attrName = attr.nodeName.toLowerCase()

    if ($.inArray(attrName, allowedAttributeList) !== -1) {
      if ($.inArray(attrName, uriAttrs) !== -1) {
        return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
      }

      return true
    }

    var regExp = $(allowedAttributeList).filter(function (index, value) {
      return value instanceof RegExp
    })

    // Check if a regular expression validates the attribute.
    for (var i = 0, l = regExp.length; i < l; i++) {
      if (attrName.match(regExp[i])) {
        return true
      }
    }

    return false
  }

  function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
    if (unsafeHtml.length === 0) {
      return unsafeHtml
    }

    if (sanitizeFn && typeof sanitizeFn === 'function') {
      return sanitizeFn(unsafeHtml)
    }

    // IE 8 and below don't support createHTMLDocument
    if (!document.implementation || !document.implementation.createHTMLDocument) {
      return unsafeHtml
    }

    var createdDocument = document.implementation.createHTMLDocument('sanitization')
    createdDocument.body.innerHTML = unsafeHtml

    var whitelistKeys = $.map(whiteList, function (el, i) { return i })
    var elements = $(createdDocument.body).find('*')

    for (var i = 0, len = elements.length; i < len; i++) {
      var el = elements[i]
      var elName = el.nodeName.toLowerCase()

      if ($.inArray(elName, whitelistKeys) === -1) {
        el.parentNode.removeChild(el)

        continue
      }

      var attributeList = $.map(el.attributes, function (el) { return el })
      var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])

      for (var j = 0, len2 = attributeList.length; j < len2; j++) {
        if (!allowedAttribute(attributeList[j], whitelistedAttributes)) {
          el.removeAttribute(attributeList[j].nodeName)
        }
      }
    }

    return createdDocument.body.innerHTML
  }

  // TOOLTIP PUBLIC CLASS DEFINITION
  // ===============================

  var Tooltip = function (element, options) {
    this.type       = null
    this.options    = null
    this.enabled    = null
    this.timeout    = null
    this.hoverState = null
    this.$element   = null
    this.inState    = null

    this.init('tooltip', element, options)
  }

  Tooltip.VERSION  = '3.4.1'

  Tooltip.TRANSITION_DURATION = 150

  Tooltip.DEFAULTS = {
    animation: true,
    placement: 'top',
    selector: false,
    template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    container: false,
    viewport: {
      selector: 'body',
      padding: 0
    },
    sanitize : true,
    sanitizeFn : null,
    whiteList : DefaultWhitelist
  }

  Tooltip.prototype.init = function (type, element, options) {
    this.enabled   = true
    this.type      = type
    this.$element  = $(element)
    this.options   = this.getOptions(options)
    this.$viewport = this.options.viewport && $(document).find($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
    this.inState   = { click: false, hover: false, focus: false }

    if (this.$element[0] instanceof document.constructor && !this.options.selector) {
      throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
    }

    var triggers = this.options.trigger.split(' ')

    for (var i = triggers.length; i--;) {
      var trigger = triggers[i]

      if (trigger == 'click') {
        this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
      } else if (trigger != 'manual') {
        var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focusin'
        var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'

        this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
        this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
      }
    }

    this.options.selector ?
      (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
      this.fixTitle()
  }

  Tooltip.prototype.getDefaults = function () {
    return Tooltip.DEFAULTS
  }

  Tooltip.prototype.getOptions = function (options) {
    var dataAttributes = this.$element.data()

    for (var dataAttr in dataAttributes) {
      if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) {
        delete dataAttributes[dataAttr]
      }
    }

    options = $.extend({}, this.getDefaults(), dataAttributes, options)

    if (options.delay && typeof options.delay == 'number') {
      options.delay = {
        show: options.delay,
        hide: options.delay
      }
    }

    if (options.sanitize) {
      options.template = sanitizeHtml(options.template, options.whiteList, options.sanitizeFn)
    }

    return options
  }

  Tooltip.prototype.getDelegateOptions = function () {
    var options  = {}
    var defaults = this.getDefaults()

    this._options && $.each(this._options, function (key, value) {
      if (defaults[key] != value) options[key] = value
    })

    return options
  }

  Tooltip.prototype.enter = function (obj) {
    var self = obj instanceof this.constructor ?
      obj : $(obj.currentTarget).data('bs.' + this.type)

    if (!self) {
      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
      $(obj.currentTarget).data('bs.' + this.type, self)
    }

    if (obj instanceof $.Event) {
      self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
    }

    if (self.tip().hasClass('in') || self.hoverState == 'in') {
      self.hoverState = 'in'
      return
    }

    clearTimeout(self.timeout)

    self.hoverState = 'in'

    if (!self.options.delay || !self.options.delay.show) return self.show()

    self.timeout = setTimeout(function () {
      if (self.hoverState == 'in') self.show()
    }, self.options.delay.show)
  }

  Tooltip.prototype.isInStateTrue = function () {
    for (var key in this.inState) {
      if (this.inState[key]) return true
    }

    return false
  }

  Tooltip.prototype.leave = function (obj) {
    var self = obj instanceof this.constructor ?
      obj : $(obj.currentTarget).data('bs.' + this.type)

    if (!self) {
      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
      $(obj.currentTarget).data('bs.' + this.type, self)
    }

    if (obj instanceof $.Event) {
      self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
    }

    if (self.isInStateTrue()) return

    clearTimeout(self.timeout)

    self.hoverState = 'out'

    if (!self.options.delay || !self.options.delay.hide) return self.hide()

    self.timeout = setTimeout(function () {
      if (self.hoverState == 'out') self.hide()
    }, self.options.delay.hide)
  }

  Tooltip.prototype.show = function () {
    var e = $.Event('show.bs.' + this.type)

    if (this.hasContent() && this.enabled) {
      this.$element.trigger(e)

      var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
      if (e.isDefaultPrevented() || !inDom) return
      var that = this

      var $tip = this.tip()

      var tipId = this.getUID(this.type)

      this.setContent()
      $tip.attr('id', tipId)
      this.$element.attr('aria-describedby', tipId)

      if (this.options.animation) $tip.addClass('fade')

      var placement = typeof this.options.placement == 'function' ?
        this.options.placement.call(this, $tip[0], this.$element[0]) :
        this.options.placement

      var autoToken = /\s?auto?\s?/i
      var autoPlace = autoToken.test(placement)
      if (autoPlace) placement = placement.replace(autoToken, '') || 'top'

      $tip
        .detach()
        .css({ top: 0, left: 0, display: 'block' })
        .addClass(placement)
        .data('bs.' + this.type, this)

      this.options.container ? $tip.appendTo($(document).find(this.options.container)) : $tip.insertAfter(this.$element)
      this.$element.trigger('inserted.bs.' + this.type)

      var pos          = this.getPosition()
      var actualWidth  = $tip[0].offsetWidth
      var actualHeight = $tip[0].offsetHeight

      if (autoPlace) {
        var orgPlacement = placement
        var viewportDim = this.getPosition(this.$viewport)

        placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top'    :
                    placement == 'top'    && pos.top    - actualHeight < viewportDim.top    ? 'bottom' :
                    placement == 'right'  && pos.right  + actualWidth  > viewportDim.width  ? 'left'   :
                    placement == 'left'   && pos.left   - actualWidth  < viewportDim.left   ? 'right'  :
                    placement

        $tip
          .removeClass(orgPlacement)
          .addClass(placement)
      }

      var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)

      this.applyPlacement(calculatedOffset, placement)

      var complete = function () {
        var prevHoverState = that.hoverState
        that.$element.trigger('shown.bs.' + that.type)
        that.hoverState = null

        if (prevHoverState == 'out') that.leave(that)
      }

      $.support.transition && this.$tip.hasClass('fade') ?
        $tip
          .one('bsTransitionEnd', complete)
          .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
        complete()
    }
  }

  Tooltip.prototype.applyPlacement = function (offset, placement) {
    var $tip   = this.tip()
    var width  = $tip[0].offsetWidth
    var height = $tip[0].offsetHeight

    // manually read margins because getBoundingClientRect includes difference
    var marginTop = parseInt($tip.css('margin-top'), 10)
    var marginLeft = parseInt($tip.css('margin-left'), 10)

    // we must check for NaN for ie 8/9
    if (isNaN(marginTop))  marginTop  = 0
    if (isNaN(marginLeft)) marginLeft = 0

    offset.top  += marginTop
    offset.left += marginLeft

    // $.fn.offset doesn't round pixel values
    // so we use setOffset directly with our own function B-0
    $.offset.setOffset($tip[0], $.extend({
      using: function (props) {
        $tip.css({
          top: Math.round(props.top),
          left: Math.round(props.left)
        })
      }
    }, offset), 0)

    $tip.addClass('in')

    // check to see if placing tip in new offset caused the tip to resize itself
    var actualWidth  = $tip[0].offsetWidth
    var actualHeight = $tip[0].offsetHeight

    if (placement == 'top' && actualHeight != height) {
      offset.top = offset.top + height - actualHeight
    }

    var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)

    if (delta.left) offset.left += delta.left
    else offset.top += delta.top

    var isVertical          = /top|bottom/.test(placement)
    var arrowDelta          = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
    var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'

    $tip.offset(offset)
    this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
  }

  Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
    this.arrow()
      .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
      .css(isVertical ? 'top' : 'left', '')
  }

  Tooltip.prototype.setContent = function () {
    var $tip  = this.tip()
    var title = this.getTitle()

    if (this.options.html) {
      if (this.options.sanitize) {
        title = sanitizeHtml(title, this.options.whiteList, this.options.sanitizeFn)
      }

      $tip.find('.tooltip-inner').html(title)
    } else {
      $tip.find('.tooltip-inner').text(title)
    }

    $tip.removeClass('fade in top bottom left right')
  }

  Tooltip.prototype.hide = function (callback) {
    var that = this
    var $tip = $(this.$tip)
    var e    = $.Event('hide.bs.' + this.type)

    function complete() {
      if (that.hoverState != 'in') $tip.detach()
      if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
        that.$element
          .removeAttr('aria-describedby')
          .trigger('hidden.bs.' + that.type)
      }
      callback && callback()
    }

    this.$element.trigger(e)

    if (e.isDefaultPrevented()) return

    $tip.removeClass('in')

    $.support.transition && $tip.hasClass('fade') ?
      $tip
        .one('bsTransitionEnd', complete)
        .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
      complete()

    this.hoverState = null

    return this
  }

  Tooltip.prototype.fixTitle = function () {
    var $e = this.$element
    if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
      $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
    }
  }

  Tooltip.prototype.hasContent = function () {
    return this.getTitle()
  }

  Tooltip.prototype.getPosition = function ($element) {
    $element   = $element || this.$element

    var el     = $element[0]
    var isBody = el.tagName == 'BODY'

    var elRect    = el.getBoundingClientRect()
    if (elRect.width == null) {
      // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
      elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
    }
    var isSvg = window.SVGElement && el instanceof window.SVGElement
    // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
    // See https://github.com/twbs/bootstrap/issues/20280
    var elOffset  = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
    var scroll    = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
    var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null

    return $.extend({}, elRect, scroll, outerDims, elOffset)
  }

  Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
    return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2 } :
           placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
           placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
        /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }

  }

  Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
    var delta = { top: 0, left: 0 }
    if (!this.$viewport) return delta

    var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
    var viewportDimensions = this.getPosition(this.$viewport)

    if (/right|left/.test(placement)) {
      var topEdgeOffset    = pos.top - viewportPadding - viewportDimensions.scroll
      var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
      if (topEdgeOffset < viewportDimensions.top) { // top overflow
        delta.top = viewportDimensions.top - topEdgeOffset
      } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
        delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
      }
    } else {
      var leftEdgeOffset  = pos.left - viewportPadding
      var rightEdgeOffset = pos.left + viewportPadding + actualWidth
      if (leftEdgeOffset < viewportDimensions.left) { // left overflow
        delta.left = viewportDimensions.left - leftEdgeOffset
      } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
        delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
      }
    }

    return delta
  }

  Tooltip.prototype.getTitle = function () {
    var title
    var $e = this.$element
    var o  = this.options

    title = $e.attr('data-original-title')
      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)

    return title
  }

  Tooltip.prototype.getUID = function (prefix) {
    do prefix += ~~(Math.random() * 1000000)
    while (document.getElementById(prefix))
    return prefix
  }

  Tooltip.prototype.tip = function () {
    if (!this.$tip) {
      this.$tip = $(this.options.template)
      if (this.$tip.length != 1) {
        throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
      }
    }
    return this.$tip
  }

  Tooltip.prototype.arrow = function () {
    return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
  }

  Tooltip.prototype.enable = function () {
    this.enabled = true
  }

  Tooltip.prototype.disable = function () {
    this.enabled = false
  }

  Tooltip.prototype.toggleEnabled = function () {
    this.enabled = !this.enabled
  }

  Tooltip.prototype.toggle = function (e) {
    var self = this
    if (e) {
      self = $(e.currentTarget).data('bs.' + this.type)
      if (!self) {
        self = new this.constructor(e.currentTarget, this.getDelegateOptions())
        $(e.currentTarget).data('bs.' + this.type, self)
      }
    }

    if (e) {
      self.inState.click = !self.inState.click
      if (self.isInStateTrue()) self.enter(self)
      else self.leave(self)
    } else {
      self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
    }
  }

  Tooltip.prototype.destroy = function () {
    var that = this
    clearTimeout(this.timeout)
    this.hide(function () {
      that.$element.off('.' + that.type).removeData('bs.' + that.type)
      if (that.$tip) {
        that.$tip.detach()
      }
      that.$tip = null
      that.$arrow = null
      that.$viewport = null
      that.$element = null
    })
  }

  Tooltip.prototype.sanitizeHtml = function (unsafeHtml) {
    return sanitizeHtml(unsafeHtml, this.options.whiteList, this.options.sanitizeFn)
  }

  // TOOLTIP PLUGIN DEFINITION
  // =========================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.tooltip')
      var options = typeof option == 'object' && option

      if (!data && /destroy|hide/.test(option)) return
      if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.tooltip

  $.fn.tooltip             = Plugin
  $.fn.tooltip.Constructor = Tooltip


  // TOOLTIP NO CONFLICT
  // ===================

  $.fn.tooltip.noConflict = function () {
    $.fn.tooltip = old
    return this
  }

}(jQuery);
/* ========================================================================
 * Bootstrap: popover.js v3.4.1
 * https://getbootstrap.com/docs/3.4/javascript/#popovers
 * ========================================================================
 * Copyright 2011-2019 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // POPOVER PUBLIC CLASS DEFINITION
  // ===============================

  var Popover = function (element, options) {
    this.init('popover', element, options)
  }

  if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')

  Popover.VERSION  = '3.4.1'

  Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
    placement: 'right',
    trigger: 'click',
    content: '',
    template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  })


  // NOTE: POPOVER EXTENDS tooltip.js
  // ================================

  Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)

  Popover.prototype.constructor = Popover

  Popover.prototype.getDefaults = function () {
    return Popover.DEFAULTS
  }

  Popover.prototype.setContent = function () {
    var $tip    = this.tip()
    var title   = this.getTitle()
    var content = this.getContent()

    if (this.options.html) {
      var typeContent = typeof content

      if (this.options.sanitize) {
        title = this.sanitizeHtml(title)

        if (typeContent === 'string') {
          content = this.sanitizeHtml(content)
        }
      }

      $tip.find('.popover-title').html(title)
      $tip.find('.popover-content').children().detach().end()[
        typeContent === 'string' ? 'html' : 'append'
      ](content)
    } else {
      $tip.find('.popover-title').text(title)
      $tip.find('.popover-content').children().detach().end().text(content)
    }

    $tip.removeClass('fade top bottom left right in')

    // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
    // this manually by checking the contents.
    if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  }

  Popover.prototype.hasContent = function () {
    return this.getTitle() || this.getContent()
  }

  Popover.prototype.getContent = function () {
    var $e = this.$element
    var o  = this.options

    return $e.attr('data-content')
      || (typeof o.content == 'function' ?
        o.content.call($e[0]) :
        o.content)
  }

  Popover.prototype.arrow = function () {
    return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  }


  // POPOVER PLUGIN DEFINITION
  // =========================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.popover')
      var options = typeof option == 'object' && option

      if (!data && /destroy|hide/.test(option)) return
      if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.popover

  $.fn.popover             = Plugin
  $.fn.popover.Constructor = Popover


  // POPOVER NO CONFLICT
  // ===================

  $.fn.popover.noConflict = function () {
    $.fn.popover = old
    return this
  }

}(jQuery);












/*
Copyright 2012 Igor Vaynberg

Version: 3.4.8 Timestamp: Thu May  1 09:50:32 EDT 2014

This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
General Public License version 2 (the "GPL License"). You may choose either license to govern your
use of this software only upon the condition that you accept all of the terms of either the Apache
License or the GPL License.

You may obtain a copy of the Apache License and the GPL License at:

    http://www.apache.org/licenses/LICENSE-2.0
    http://www.gnu.org/licenses/gpl-2.0.html

Unless required by applicable law or agreed to in writing, software distributed under the
Apache License or the GPL License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the Apache License and the GPL License for
the specific language governing permissions and limitations under the Apache License and the GPL License.
*/
(function ($) {
    if(typeof $.fn.each2 == "undefined") {
        $.extend($.fn, {
            /*
            * 4-10 times faster .each replacement
            * use it carefully, as it overrides jQuery context of element on each iteration
            */
            each2 : function (c) {
                var j = $([0]), i = -1, l = this.length;
                while (
                    ++i < l
                    && (j.context = j[0] = this[i])
                    && c.call(j[0], i, j) !== false //"this"=DOM, i=index, j=jQuery object
                );
                return this;
            }
        });
    }
})(jQuery);

(function ($, undefined) {
    "use strict";
    /*global document, window, jQuery, console */

    if (window.Select2 !== undefined) {
        return;
    }

    var KEY, AbstractSelect2, SingleSelect2, MultiSelect2, nextUid, sizer,
        lastMousePosition={x:0,y:0}, $document, scrollBarDimensions,

    KEY = {
        TAB: 9,
        ENTER: 13,
        ESC: 27,
        SPACE: 32,
        LEFT: 37,
        UP: 38,
        RIGHT: 39,
        DOWN: 40,
        SHIFT: 16,
        CTRL: 17,
        ALT: 18,
        PAGE_UP: 33,
        PAGE_DOWN: 34,
        HOME: 36,
        END: 35,
        BACKSPACE: 8,
        DELETE: 46,
        isArrow: function (k) {
            k = k.which ? k.which : k;
            switch (k) {
            case KEY.LEFT:
            case KEY.RIGHT:
            case KEY.UP:
            case KEY.DOWN:
                return true;
            }
            return false;
        },
        isControl: function (e) {
            var k = e.which;
            switch (k) {
            case KEY.SHIFT:
            case KEY.CTRL:
            case KEY.ALT:
                return true;
            }

            if (e.metaKey) return true;

            return false;
        },
        isFunctionKey: function (k) {
            k = k.which ? k.which : k;
            return k >= 112 && k <= 123;
        }
    },
    MEASURE_SCROLLBAR_TEMPLATE = "<div class='select2-measure-scrollbar'></div>",

    DIACRITICS = {"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE","\u01FC":"AE","\u01E2":"AE","\uA734":"AO","\uA736":"AU","\uA738":"AV","\uA73A":"AV","\uA73C":"AY","\u24B7":"B","\uFF22":"B","\u1E02":"B","\u1E04":"B","\u1E06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24B8":"C","\uFF23":"C","\u0106":"C","\u0108":"C","\u010A":"C","\u010C":"C","\u00C7":"C","\u1E08":"C","\u0187":"C","\u023B":"C","\uA73E":"C","\u24B9":"D","\uFF24":"D","\u1E0A":"D","\u010E":"D","\u1E0C":"D","\u1E10":"D","\u1E12":"D","\u1E0E":"D","\u0110":"D","\u018B":"D","\u018A":"D","\u0189":"D","\uA779":"D","\u01F1":"DZ","\u01C4":"DZ","\u01F2":"Dz","\u01C5":"Dz","\u24BA":"E","\uFF25":"E","\u00C8":"E","\u00C9":"E","\u00CA":"E","\u1EC0":"E","\u1EBE":"E","\u1EC4":"E","\u1EC2":"E","\u1EBC":"E","\u0112":"E","\u1E14":"E","\u1E16":"E","\u0114":"E","\u0116":"E","\u00CB":"E","\u1EBA":"E","\u011A":"E","\u0204":"E","\u0206":"E","\u1EB8":"E","\u1EC6":"E","\u0228":"E","\u1E1C":"E","\u0118":"E","\u1E18":"E","\u1E1A":"E","\u0190":"E","\u018E":"E","\u24BB":"F","\uFF26":"F","\u1E1E":"F","\u0191":"F","\uA77B":"F","\u24BC":"G","\uFF27":"G","\u01F4":"G","\u011C":"G","\u1E20":"G","\u011E":"G","\u0120":"G","\u01E6":"G","\u0122":"G","\u01E4":"G","\u0193":"G","\uA7A0":"G","\uA77D":"G","\uA77E":"G","\u24BD":"H","\uFF28":"H","\u0124":"H","\u1E22":"H","\u1E26":"H","\u021E":"H","\u1E24":"H","\u1E28":"H","\u1E2A":"H","\u0126":"H","\u2C67":"H","\u2C75":"H","\uA78D":"H","\u24BE":"I","\uFF29":"I","\u00CC":"I","\u00CD":"I","\u00CE":"I","\u0128":"I","\u012A":"I","\u012C":"I","\u0130":"I","\u00CF":"I","\u1E2E":"I","\u1EC8":"I","\u01CF":"I","\u0208":"I","\u020A":"I","\u1ECA":"I","\u012E":"I","\u1E2C":"I","\u0197":"I","\u24BF":"J","\uFF2A":"J","\u0134":"J","\u0248":"J","\u24C0":"K","\uFF2B":"K","\u1E30":"K","\u01E8":"K","\u1E32":"K","\u0136":"K","\u1E34":"K","\u0198":"K","\u2C69":"K","\uA740":"K","\uA742":"K","\uA744":"K","\uA7A2":"K","\u24C1":"L","\uFF2C":"L","\u013F":"L","\u0139":"L","\u013D":"L","\u1E36":"L","\u1E38":"L","\u013B":"L","\u1E3C":"L","\u1E3A":"L","\u0141":"L","\u023D":"L","\u2C62":"L","\u2C60":"L","\uA748":"L","\uA746":"L","\uA780":"L","\u01C7":"LJ","\u01C8":"Lj","\u24C2":"M","\uFF2D":"M","\u1E3E":"M","\u1E40":"M","\u1E42":"M","\u2C6E":"M","\u019C":"M","\u24C3":"N","\uFF2E":"N","\u01F8":"N","\u0143":"N","\u00D1":"N","\u1E44":"N","\u0147":"N","\u1E46":"N","\u0145":"N","\u1E4A":"N","\u1E48":"N","\u0220":"N","\u019D":"N","\uA790":"N","\uA7A4":"N","\u01CA":"NJ","\u01CB":"Nj","\u24C4":"O","\uFF2F":"O","\u00D2":"O","\u00D3":"O","\u00D4":"O","\u1ED2":"O","\u1ED0":"O","\u1ED6":"O","\u1ED4":"O","\u00D5":"O","\u1E4C":"O","\u022C":"O","\u1E4E":"O","\u014C":"O","\u1E50":"O","\u1E52":"O","\u014E":"O","\u022E":"O","\u0230":"O","\u00D6":"O","\u022A":"O","\u1ECE":"O","\u0150":"O","\u01D1":"O","\u020C":"O","\u020E":"O","\u01A0":"O","\u1EDC":"O","\u1EDA":"O","\u1EE0":"O","\u1EDE":"O","\u1EE2":"O","\u1ECC":"O","\u1ED8":"O","\u01EA":"O","\u01EC":"O","\u00D8":"O","\u01FE":"O","\u0186":"O","\u019F":"O","\uA74A":"O","\uA74C":"O","\u01A2":"OI","\uA74E":"OO","\u0222":"OU","\u24C5":"P","\uFF30":"P","\u1E54":"P","\u1E56":"P","\u01A4":"P","\u2C63":"P","\uA750":"P","\uA752":"P","\uA754":"P","\u24C6":"Q","\uFF31":"Q","\uA756":"Q","\uA758":"Q","\u024A":"Q","\u24C7":"R","\uFF32":"R","\u0154":"R","\u1E58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1E5A":"R","\u1E5C":"R","\u0156":"R","\u1E5E":"R","\u024C":"R","\u2C64":"R","\uA75A":"R","\uA7A6":"R","\uA782":"R","\u24C8":"S","\uFF33":"S","\u1E9E":"S","\u015A":"S","\u1E64":"S","\u015C":"S","\u1E60":"S","\u0160":"S","\u1E66":"S","\u1E62":"S","\u1E68":"S","\u0218":"S","\u015E":"S","\u2C7E":"S","\uA7A8":"S","\uA784":"S","\u24C9":"T","\uFF34":"T","\u1E6A":"T","\u0164":"T","\u1E6C":"T","\u021A":"T","\u0162":"T","\u1E70":"T","\u1E6E":"T","\u0166":"T","\u01AC":"T","\u01AE":"T","\u023E":"T","\uA786":"T","\uA728":"TZ","\u24CA":"U","\uFF35":"U","\u00D9":"U","\u00DA":"U","\u00DB":"U","\u0168":"U","\u1E78":"U","\u016A":"U","\u1E7A":"U","\u016C":"U","\u00DC":"U","\u01DB":"U","\u01D7":"U","\u01D5":"U","\u01D9":"U","\u1EE6":"U","\u016E":"U","\u0170":"U","\u01D3":"U","\u0214":"U","\u0216":"U","\u01AF":"U","\u1EEA":"U","\u1EE8":"U","\u1EEE":"U","\u1EEC":"U","\u1EF0":"U","\u1EE4":"U","\u1E72":"U","\u0172":"U","\u1E76":"U","\u1E74":"U","\u0244":"U","\u24CB":"V","\uFF36":"V","\u1E7C":"V","\u1E7E":"V","\u01B2":"V","\uA75E":"V","\u0245":"V","\uA760":"VY","\u24CC":"W","\uFF37":"W","\u1E80":"W","\u1E82":"W","\u0174":"W","\u1E86":"W","\u1E84":"W","\u1E88":"W","\u2C72":"W","\u24CD":"X","\uFF38":"X","\u1E8A":"X","\u1E8C":"X","\u24CE":"Y","\uFF39":"Y","\u1EF2":"Y","\u00DD":"Y","\u0176":"Y","\u1EF8":"Y","\u0232":"Y","\u1E8E":"Y","\u0178":"Y","\u1EF6":"Y","\u1EF4":"Y","\u01B3":"Y","\u024E":"Y","\u1EFE":"Y","\u24CF":"Z","\uFF3A":"Z","\u0179":"Z","\u1E90":"Z","\u017B":"Z","\u017D":"Z","\u1E92":"Z","\u1E94":"Z","\u01B5":"Z","\u0224":"Z","\u2C7F":"Z","\u2C6B":"Z","\uA762":"Z","\u24D0":"a","\uFF41":"a","\u1E9A":"a","\u00E0":"a","\u00E1":"a","\u00E2":"a","\u1EA7":"a","\u1EA5":"a","\u1EAB":"a","\u1EA9":"a","\u00E3":"a","\u0101":"a","\u0103":"a","\u1EB1":"a","\u1EAF":"a","\u1EB5":"a","\u1EB3":"a","\u0227":"a","\u01E1":"a","\u00E4":"a","\u01DF":"a","\u1EA3":"a","\u00E5":"a","\u01FB":"a","\u01CE":"a","\u0201":"a","\u0203":"a","\u1EA1":"a","\u1EAD":"a","\u1EB7":"a","\u1E01":"a","\u0105":"a","\u2C65":"a","\u0250":"a","\uA733":"aa","\u00E6":"ae","\u01FD":"ae","\u01E3":"ae","\uA735":"ao","\uA737":"au","\uA739":"av","\uA73B":"av","\uA73D":"ay","\u24D1":"b","\uFF42":"b","\u1E03":"b","\u1E05":"b","\u1E07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24D2":"c","\uFF43":"c","\u0107":"c","\u0109":"c","\u010B":"c","\u010D":"c","\u00E7":"c","\u1E09":"c","\u0188":"c","\u023C":"c","\uA73F":"c","\u2184":"c","\u24D3":"d","\uFF44":"d","\u1E0B":"d","\u010F":"d","\u1E0D":"d","\u1E11":"d","\u1E13":"d","\u1E0F":"d","\u0111":"d","\u018C":"d","\u0256":"d","\u0257":"d","\uA77A":"d","\u01F3":"dz","\u01C6":"dz","\u24D4":"e","\uFF45":"e","\u00E8":"e","\u00E9":"e","\u00EA":"e","\u1EC1":"e","\u1EBF":"e","\u1EC5":"e","\u1EC3":"e","\u1EBD":"e","\u0113":"e","\u1E15":"e","\u1E17":"e","\u0115":"e","\u0117":"e","\u00EB":"e","\u1EBB":"e","\u011B":"e","\u0205":"e","\u0207":"e","\u1EB9":"e","\u1EC7":"e","\u0229":"e","\u1E1D":"e","\u0119":"e","\u1E19":"e","\u1E1B":"e","\u0247":"e","\u025B":"e","\u01DD":"e","\u24D5":"f","\uFF46":"f","\u1E1F":"f","\u0192":"f","\uA77C":"f","\u24D6":"g","\uFF47":"g","\u01F5":"g","\u011D":"g","\u1E21":"g","\u011F":"g","\u0121":"g","\u01E7":"g","\u0123":"g","\u01E5":"g","\u0260":"g","\uA7A1":"g","\u1D79":"g","\uA77F":"g","\u24D7":"h","\uFF48":"h","\u0125":"h","\u1E23":"h","\u1E27":"h","\u021F":"h","\u1E25":"h","\u1E29":"h","\u1E2B":"h","\u1E96":"h","\u0127":"h","\u2C68":"h","\u2C76":"h","\u0265":"h","\u0195":"hv","\u24D8":"i","\uFF49":"i","\u00EC":"i","\u00ED":"i","\u00EE":"i","\u0129":"i","\u012B":"i","\u012D":"i","\u00EF":"i","\u1E2F":"i","\u1EC9":"i","\u01D0":"i","\u0209":"i","\u020B":"i","\u1ECB":"i","\u012F":"i","\u1E2D":"i","\u0268":"i","\u0131":"i","\u24D9":"j","\uFF4A":"j","\u0135":"j","\u01F0":"j","\u0249":"j","\u24DA":"k","\uFF4B":"k","\u1E31":"k","\u01E9":"k","\u1E33":"k","\u0137":"k","\u1E35":"k","\u0199":"k","\u2C6A":"k","\uA741":"k","\uA743":"k","\uA745":"k","\uA7A3":"k","\u24DB":"l","\uFF4C":"l","\u0140":"l","\u013A":"l","\u013E":"l","\u1E37":"l","\u1E39":"l","\u013C":"l","\u1E3D":"l","\u1E3B":"l","\u017F":"l","\u0142":"l","\u019A":"l","\u026B":"l","\u2C61":"l","\uA749":"l","\uA781":"l","\uA747":"l","\u01C9":"lj","\u24DC":"m","\uFF4D":"m","\u1E3F":"m","\u1E41":"m","\u1E43":"m","\u0271":"m","\u026F":"m","\u24DD":"n","\uFF4E":"n","\u01F9":"n","\u0144":"n","\u00F1":"n","\u1E45":"n","\u0148":"n","\u1E47":"n","\u0146":"n","\u1E4B":"n","\u1E49":"n","\u019E":"n","\u0272":"n","\u0149":"n","\uA791":"n","\uA7A5":"n","\u01CC":"nj","\u24DE":"o","\uFF4F":"o","\u00F2":"o","\u00F3":"o","\u00F4":"o","\u1ED3":"o","\u1ED1":"o","\u1ED7":"o","\u1ED5":"o","\u00F5":"o","\u1E4D":"o","\u022D":"o","\u1E4F":"o","\u014D":"o","\u1E51":"o","\u1E53":"o","\u014F":"o","\u022F":"o","\u0231":"o","\u00F6":"o","\u022B":"o","\u1ECF":"o","\u0151":"o","\u01D2":"o","\u020D":"o","\u020F":"o","\u01A1":"o","\u1EDD":"o","\u1EDB":"o","\u1EE1":"o","\u1EDF":"o","\u1EE3":"o","\u1ECD":"o","\u1ED9":"o","\u01EB":"o","\u01ED":"o","\u00F8":"o","\u01FF":"o","\u0254":"o","\uA74B":"o","\uA74D":"o","\u0275":"o","\u01A3":"oi","\u0223":"ou","\uA74F":"oo","\u24DF":"p","\uFF50":"p","\u1E55":"p","\u1E57":"p","\u01A5":"p","\u1D7D":"p","\uA751":"p","\uA753":"p","\uA755":"p","\u24E0":"q","\uFF51":"q","\u024B":"q","\uA757":"q","\uA759":"q","\u24E1":"r","\uFF52":"r","\u0155":"r","\u1E59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1E5B":"r","\u1E5D":"r","\u0157":"r","\u1E5F":"r","\u024D":"r","\u027D":"r","\uA75B":"r","\uA7A7":"r","\uA783":"r","\u24E2":"s","\uFF53":"s","\u00DF":"s","\u015B":"s","\u1E65":"s","\u015D":"s","\u1E61":"s","\u0161":"s","\u1E67":"s","\u1E63":"s","\u1E69":"s","\u0219":"s","\u015F":"s","\u023F":"s","\uA7A9":"s","\uA785":"s","\u1E9B":"s","\u24E3":"t","\uFF54":"t","\u1E6B":"t","\u1E97":"t","\u0165":"t","\u1E6D":"t","\u021B":"t","\u0163":"t","\u1E71":"t","\u1E6F":"t","\u0167":"t","\u01AD":"t","\u0288":"t","\u2C66":"t","\uA787":"t","\uA729":"tz","\u24E4":"u","\uFF55":"u","\u00F9":"u","\u00FA":"u","\u00FB":"u","\u0169":"u","\u1E79":"u","\u016B":"u","\u1E7B":"u","\u016D":"u","\u00FC":"u","\u01DC":"u","\u01D8":"u","\u01D6":"u","\u01DA":"u","\u1EE7":"u","\u016F":"u","\u0171":"u","\u01D4":"u","\u0215":"u","\u0217":"u","\u01B0":"u","\u1EEB":"u","\u1EE9":"u","\u1EEF":"u","\u1EED":"u","\u1EF1":"u","\u1EE5":"u","\u1E73":"u","\u0173":"u","\u1E77":"u","\u1E75":"u","\u0289":"u","\u24E5":"v","\uFF56":"v","\u1E7D":"v","\u1E7F":"v","\u028B":"v","\uA75F":"v","\u028C":"v","\uA761":"vy","\u24E6":"w","\uFF57":"w","\u1E81":"w","\u1E83":"w","\u0175":"w","\u1E87":"w","\u1E85":"w","\u1E98":"w","\u1E89":"w","\u2C73":"w","\u24E7":"x","\uFF58":"x","\u1E8B":"x","\u1E8D":"x","\u24E8":"y","\uFF59":"y","\u1EF3":"y","\u00FD":"y","\u0177":"y","\u1EF9":"y","\u0233":"y","\u1E8F":"y","\u00FF":"y","\u1EF7":"y","\u1E99":"y","\u1EF5":"y","\u01B4":"y","\u024F":"y","\u1EFF":"y","\u24E9":"z","\uFF5A":"z","\u017A":"z","\u1E91":"z","\u017C":"z","\u017E":"z","\u1E93":"z","\u1E95":"z","\u01B6":"z","\u0225":"z","\u0240":"z","\u2C6C":"z","\uA763":"z"};

    $document = $(document);

    nextUid=(function() { var counter=1; return function() { return counter++; }; }());


    function reinsertElement(element) {
        var placeholder = $(document.createTextNode(''));

        element.before(placeholder);
        placeholder.before(element);
        placeholder.remove();
    }

    function stripDiacritics(str) {
        // Used 'uni range + named function' from http://jsperf.com/diacritics/18
        function match(a) {
            return DIACRITICS[a] || a;
        }

        return str.replace(/[^\u0000-\u007E]/g, match);
    }

    function indexOf(value, array) {
        var i = 0, l = array.length;
        for (; i < l; i = i + 1) {
            if (equal(value, array[i])) return i;
        }
        return -1;
    }

    function measureScrollbar () {
        var $template = $( MEASURE_SCROLLBAR_TEMPLATE );
        $template.appendTo('body');

        var dim = {
            width: $template.width() - $template[0].clientWidth,
            height: $template.height() - $template[0].clientHeight
        };
        $template.remove();

        return dim;
    }

    /**
     * Compares equality of a and b
     * @param a
     * @param b
     */
    function equal(a, b) {
        if (a === b) return true;
        if (a === undefined || b === undefined) return false;
        if (a === null || b === null) return false;
        // Check whether 'a' or 'b' is a string (primitive or object).
        // The concatenation of an empty string (+'') converts its argument to a string's primitive.
        if (a.constructor === String) return a+'' === b+''; // a+'' - in case 'a' is a String object
        if (b.constructor === String) return b+'' === a+''; // b+'' - in case 'b' is a String object
        return false;
    }

    /**
     * Splits the string into an array of values, trimming each value. An empty array is returned for nulls or empty
     * strings
     * @param string
     * @param separator
     */
    function splitVal(string, separator) {
        var val, i, l;
        if (string === null || string.length < 1) return [];
        val = string.split(separator);
        for (i = 0, l = val.length; i < l; i = i + 1) val[i] = $.trim(val[i]);
        return val;
    }

    function getSideBorderPadding(element) {
        return element.outerWidth(false) - element.width();
    }

    function installKeyUpChangeEvent(element) {
        var key="keyup-change-value";
        element.on("keydown", function () {
            if ($.data(element, key) === undefined) {
                $.data(element, key, element.val());
            }
        });
        element.on("keyup", function () {
            var val= $.data(element, key);
            if (val !== undefined && element.val() !== val) {
                $.removeData(element, key);
                element.trigger("keyup-change");
            }
        });
    }

    $document.on("mousemove", function (e) {
        lastMousePosition.x = e.pageX;
        lastMousePosition.y = e.pageY;
    });

    /**
     * filters mouse events so an event is fired only if the mouse moved.
     *
     * filters out mouse events that occur when mouse is stationary but
     * the elements under the pointer are scrolled.
     */
    function installFilteredMouseMove(element) {
        element.on("mousemove", function (e) {
            var lastpos = lastMousePosition;
            if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) {
                $(e.target).trigger("mousemove-filtered", e);
            }
        });
    }

    /**
     * Debounces a function. Returns a function that calls the original fn function only if no invocations have been made
     * within the last quietMillis milliseconds.
     *
     * @param quietMillis number of milliseconds to wait before invoking fn
     * @param fn function to be debounced
     * @param ctx object to be used as this reference within fn
     * @return debounced version of fn
     */
    function debounce(quietMillis, fn, ctx) {
        ctx = ctx || undefined;
        var timeout;
        return function () {
            var args = arguments;
            window.clearTimeout(timeout);
            timeout = window.setTimeout(function() {
                fn.apply(ctx, args);
            }, quietMillis);
        };
    }

    function installDebouncedScroll(threshold, element) {
        var notify = debounce(threshold, function (e) { element.trigger("scroll-debounced", e);});
        element.on("scroll", function (e) {
            if (indexOf(e.target, element.get()) >= 0) notify(e);
        });
    }

    function focus($el) {
        if ($el[0] === document.activeElement) return;

        /* set the focus in a 0 timeout - that way the focus is set after the processing
            of the current event has finished - which seems like the only reliable way
            to set focus */
        window.setTimeout(function() {
            var el=$el[0], pos=$el.val().length, range;

            $el.focus();

            /* make sure el received focus so we do not error out when trying to manipulate the caret.
                sometimes modals or others listeners may steal it after its set */
            var isVisible = (el.offsetWidth > 0 || el.offsetHeight > 0);
            if (isVisible && el === document.activeElement) {

                /* after the focus is set move the caret to the end, necessary when we val()
                    just before setting focus */
                if(el.setSelectionRange)
                {
                    el.setSelectionRange(pos, pos);
                }
                else if (el.createTextRange) {
                    range = el.createTextRange();
                    range.collapse(false);
                    range.select();
                }
            }
        }, 0);
    }

    function getCursorInfo(el) {
        el = $(el)[0];
        var offset = 0;
        var length = 0;
        if ('selectionStart' in el) {
            offset = el.selectionStart;
            length = el.selectionEnd - offset;
        } else if ('selection' in document) {
            el.focus();
            var sel = document.selection.createRange();
            length = document.selection.createRange().text.length;
            sel.moveStart('character', -el.value.length);
            offset = sel.text.length - length;
        }
        return { offset: offset, length: length };
    }

    function killEvent(event) {
        event.preventDefault();
        event.stopPropagation();
    }
    function killEventImmediately(event) {
        event.preventDefault();
        event.stopImmediatePropagation();
    }

    function measureTextWidth(e) {
        if (!sizer){
            var style = e[0].currentStyle || window.getComputedStyle(e[0], null);
            sizer = $(document.createElement("div")).css({
                position: "absolute",
                left: "-10000px",
                top: "-10000px",
                display: "none",
                fontSize: style.fontSize,
                fontFamily: style.fontFamily,
                fontStyle: style.fontStyle,
                fontWeight: style.fontWeight,
                letterSpacing: style.letterSpacing,
                textTransform: style.textTransform,
                whiteSpace: "nowrap"
            });
            sizer.attr("class","select2-sizer");
            $("body").append(sizer);
        }
        sizer.text(e.val());
        return sizer.width();
    }

    function syncCssClasses(dest, src, adapter) {
        var classes, replacements = [], adapted;

        classes = dest.attr("class");
        if (classes) {
            classes = '' + classes; // for IE which returns object
            $(classes.split(" ")).each2(function() {
                if (this.indexOf("select2-") === 0) {
                    replacements.push(this);
                }
            });
        }
        classes = src.attr("class");
        if (classes) {
            classes = '' + classes; // for IE which returns object
            $(classes.split(" ")).each2(function() {
                if (this.indexOf("select2-") !== 0) {
                    adapted = adapter(this);
                    if (adapted) {
                        replacements.push(adapted);
                    }
                }
            });
        }
        dest.attr("class", replacements.join(" "));
    }


    function markMatch(text, term, markup, escapeMarkup) {
        var match=stripDiacritics(text.toUpperCase()).indexOf(stripDiacritics(term.toUpperCase())),
            tl=term.length;

        if (match<0) {
            markup.push(escapeMarkup(text));
            return;
        }

        markup.push(escapeMarkup(text.substring(0, match)));
        markup.push("<span class='select2-match'>");
        markup.push(escapeMarkup(text.substring(match, match + tl)));
        markup.push("</span>");
        markup.push(escapeMarkup(text.substring(match + tl, text.length)));
    }

    function defaultEscapeMarkup(markup) {
        var replace_map = {
            '\\': '&#92;',
            '&': '&amp;',
            '<': '&lt;',
            '>': '&gt;',
            '"': '&quot;',
            "'": '&#39;',
            "/": '&#47;'
        };

        return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
            return replace_map[match];
        });
    }

    /**
     * Produces an ajax-based query function
     *
     * @param options object containing configuration parameters
     * @param options.params parameter map for the transport ajax call, can contain such options as cache, jsonpCallback, etc. see $.ajax
     * @param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax
     * @param options.url url for the data
     * @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url.
     * @param options.dataType request data type: ajax, jsonp, other datatypes supported by jQuery's $.ajax function or the transport function if specified
     * @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
     * @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2.
     *      The expected format is an object containing the following keys:
     *      results array of objects that will be used as choices
     *      more (optional) boolean indicating whether there are more results available
     *      Example: {results:[{id:1, text:'Red'},{id:2, text:'Blue'}], more:true}
     */
    function ajax(options) {
        var timeout, // current scheduled but not yet executed request
            handler = null,
            quietMillis = options.quietMillis || 100,
            ajaxUrl = options.url,
            self = this;

        return function (query) {
            window.clearTimeout(timeout);
            timeout = window.setTimeout(function () {
                var data = options.data, // ajax data function
                    url = ajaxUrl, // ajax url string or function
                    transport = options.transport || $.fn.select2.ajaxDefaults.transport,
                    // deprecated - to be removed in 4.0  - use params instead
                    deprecated = {
                        type: options.type || 'GET', // set type of request (GET or POST)
                        cache: options.cache || false,
                        jsonpCallback: options.jsonpCallback||undefined,
                        dataType: options.dataType||"json"
                    },
                    params = $.extend({}, $.fn.select2.ajaxDefaults.params, deprecated);

                data = data ? data.call(self, query.term, query.page, query.context) : null;
                url = (typeof url === 'function') ? url.call(self, query.term, query.page, query.context) : url;

                if (handler && typeof handler.abort === "function") { handler.abort(); }

                if (options.params) {
                    if ($.isFunction(options.params)) {
                        $.extend(params, options.params.call(self));
                    } else {
                        $.extend(params, options.params);
                    }
                }

                $.extend(params, {
                    url: url,
                    dataType: options.dataType,
                    data: data,
                    success: function (data) {
                        // TODO - replace query.page with query so users have access to term, page, etc.
                        var results = options.results(data, query.page);
                        query.callback(results);
                    }
                });
                handler = transport.call(self, params);
            }, quietMillis);
        };
    }

    /**
     * Produces a query function that works with a local array
     *
     * @param options object containing configuration parameters. The options parameter can either be an array or an
     * object.
     *
     * If the array form is used it is assumed that it contains objects with 'id' and 'text' keys.
     *
     * If the object form is used it is assumed that it contains 'data' and 'text' keys. The 'data' key should contain
     * an array of objects that will be used as choices. These objects must contain at least an 'id' key. The 'text'
     * key can either be a String in which case it is expected that each element in the 'data' array has a key with the
     * value of 'text' which will be used to match choices. Alternatively, text can be a function(item) that can extract
     * the text.
     */
    function local(options) {
        var data = options, // data elements
            dataText,
            tmp,
            text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search

         if ($.isArray(data)) {
            tmp = data;
            data = { results: tmp };
        }

         if ($.isFunction(data) === false) {
            tmp = data;
            data = function() { return tmp; };
        }

        var dataItem = data();
        if (dataItem.text) {
            text = dataItem.text;
            // if text is not a function we assume it to be a key name
            if (!$.isFunction(text)) {
                dataText = dataItem.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
                text = function (item) { return item[dataText]; };
            }
        }

        return function (query) {
            var t = query.term, filtered = { results: [] }, process;
            if (t === "") {
                query.callback(data());
                return;
            }

            process = function(datum, collection) {
                var group, attr;
                datum = datum[0];
                if (datum.children) {
                    group = {};
                    for (attr in datum) {
                        if (datum.hasOwnProperty(attr)) group[attr]=datum[attr];
                    }
                    group.children=[];
                    $(datum.children).each2(function(i, childDatum) { process(childDatum, group.children); });
                    if (group.children.length || query.matcher(t, text(group), datum)) {
                        collection.push(group);
                    }
                } else {
                    if (query.matcher(t, text(datum), datum)) {
                        collection.push(datum);
                    }
                }
            };

            $(data().results).each2(function(i, datum) { process(datum, filtered.results); });
            query.callback(filtered);
        };
    }

    // TODO javadoc
    function tags(data) {
        var isFunc = $.isFunction(data);
        return function (query) {
            var t = query.term, filtered = {results: []};
            var result = isFunc ? data(query) : data;
            if ($.isArray(result)) {
                $(result).each(function () {
                    var isObject = this.text !== undefined,
                        text = isObject ? this.text : this;
                    if (t === "" || query.matcher(t, text)) {
                        filtered.results.push(isObject ? this : {id: this, text: this});
                    }
                });
                query.callback(filtered);
            }
        };
    }

    /**
     * Checks if the formatter function should be used.
     *
     * Throws an error if it is not a function. Returns true if it should be used,
     * false if no formatting should be performed.
     *
     * @param formatter
     */
    function checkFormatter(formatter, formatterName) {
        if ($.isFunction(formatter)) return true;
        if (!formatter) return false;
        if (typeof(formatter) === 'string') return true;
        throw new Error(formatterName +" must be a string, function, or falsy value");
    }

    function evaluate(val) {
        if ($.isFunction(val)) {
            var args = Array.prototype.slice.call(arguments, 1);
            return val.apply(null, args);
        }
        return val;
    }

    function countResults(results) {
        var count = 0;
        $.each(results, function(i, item) {
            if (item.children) {
                count += countResults(item.children);
            } else {
                count++;
            }
        });
        return count;
    }

    /**
     * Default tokenizer. This function uses breaks the input on substring match of any string from the
     * opts.tokenSeparators array and uses opts.createSearchChoice to create the choice object. Both of those
     * two options have to be defined in order for the tokenizer to work.
     *
     * @param input text user has typed so far or pasted into the search field
     * @param selection currently selected choices
     * @param selectCallback function(choice) callback tho add the choice to selection
     * @param opts select2's opts
     * @return undefined/null to leave the current input unchanged, or a string to change the input to the returned value
     */
    function defaultTokenizer(input, selection, selectCallback, opts) {
        var original = input, // store the original so we can compare and know if we need to tell the search to update its text
            dupe = false, // check for whether a token we extracted represents a duplicate selected choice
            token, // token
            index, // position at which the separator was found
            i, l, // looping variables
            separator; // the matched separator

        if (!opts.createSearchChoice || !opts.tokenSeparators || opts.tokenSeparators.length < 1) return undefined;

        while (true) {
            index = -1;

            for (i = 0, l = opts.tokenSeparators.length; i < l; i++) {
                separator = opts.tokenSeparators[i];
                index = input.indexOf(separator);
                if (index >= 0) break;
            }

            if (index < 0) break; // did not find any token separator in the input string, bail

            token = input.substring(0, index);
            input = input.substring(index + separator.length);

            if (token.length > 0) {
                token = opts.createSearchChoice.call(this, token, selection);
                if (token !== undefined && token !== null && opts.id(token) !== undefined && opts.id(token) !== null) {
                    dupe = false;
                    for (i = 0, l = selection.length; i < l; i++) {
                        if (equal(opts.id(token), opts.id(selection[i]))) {
                            dupe = true; break;
                        }
                    }

                    if (!dupe) selectCallback(token);
                }
            }
        }

        if (original!==input) return input;
    }

    function cleanupJQueryElements() {
        var self = this;

        Array.prototype.forEach.call(arguments, function (element) {
            self[element].remove();
            self[element] = null;
        });
    }

    /**
     * Creates a new class
     *
     * @param superClass
     * @param methods
     */
    function clazz(SuperClass, methods) {
        var constructor = function () {};
        constructor.prototype = new SuperClass;
        constructor.prototype.constructor = constructor;
        constructor.prototype.parent = SuperClass.prototype;
        constructor.prototype = $.extend(constructor.prototype, methods);
        return constructor;
    }

    AbstractSelect2 = clazz(Object, {

        // abstract
        bind: function (func) {
            var self = this;
            return function () {
                func.apply(self, arguments);
            };
        },

        // abstract
        init: function (opts) {
            var results, search, resultsSelector = ".select2-results";

            // prepare options
            this.opts = opts = this.prepareOpts(opts);

            this.id=opts.id;

            // destroy if called on an existing component
            if (opts.element.data("select2") !== undefined &&
                opts.element.data("select2") !== null) {
                opts.element.data("select2").destroy();
            }

            this.container = this.createContainer();

            this.liveRegion = $("<span>", {
                    role: "status",
                    "aria-live": "polite"
                })
                .addClass("select2-hidden-accessible")
                .appendTo(document.body);

            this.containerId="s2id_"+(opts.element.attr("id") || "autogen"+nextUid());
            this.containerEventName= this.containerId
                .replace(/([.])/g, '_')
                .replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
            this.container.attr("id", this.containerId);

            this.container.attr("title", opts.element.attr("title"));

            this.body = $("body");

            syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);

            this.container.attr("style", opts.element.attr("style"));
            this.container.css(evaluate(opts.containerCss));
            this.container.addClass(evaluate(opts.containerCssClass));

            this.elementTabIndex = this.opts.element.attr("tabindex");

            // swap container for the element
            this.opts.element
                .data("select2", this)
                .attr("tabindex", "-1")
                .before(this.container)
                .on("click.select2", killEvent); // do not leak click events

            this.container.data("select2", this);

            this.dropdown = this.container.find(".select2-drop");

            syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);

            this.dropdown.addClass(evaluate(opts.dropdownCssClass));
            this.dropdown.data("select2", this);
            this.dropdown.on("click", killEvent);

            this.results = results = this.container.find(resultsSelector);
            this.search = search = this.container.find("input.select2-input");

            this.queryCount = 0;
            this.resultsPage = 0;
            this.context = null;

            // initialize the container
            this.initContainer();

            this.container.on("click", killEvent);

            installFilteredMouseMove(this.results);

            this.dropdown.on("mousemove-filtered", resultsSelector, this.bind(this.highlightUnderEvent));
            this.dropdown.on("touchstart touchmove touchend", resultsSelector, this.bind(function (event) {
                this._touchEvent = true;
                this.highlightUnderEvent(event);
            }));
            this.dropdown.on("touchmove", resultsSelector, this.bind(this.touchMoved));
            this.dropdown.on("touchstart touchend", resultsSelector, this.bind(this.clearTouchMoved));

            // Waiting for a click event on touch devices to select option and hide dropdown
            // otherwise click will be triggered on an underlying element
            this.dropdown.on('click', this.bind(function (event) {
                if (this._touchEvent) {
                    this._touchEvent = false;
                    this.selectHighlighted();
                }
            }));

            installDebouncedScroll(80, this.results);
            this.dropdown.on("scroll-debounced", resultsSelector, this.bind(this.loadMoreIfNeeded));

            // do not propagate change event from the search field out of the component
            $(this.container).on("change", ".select2-input", function(e) {e.stopPropagation();});
            $(this.dropdown).on("change", ".select2-input", function(e) {e.stopPropagation();});

            // if jquery.mousewheel plugin is installed we can prevent out-of-bounds scrolling of results via mousewheel
            if ($.fn.mousewheel) {
                results.mousewheel(function (e, delta, deltaX, deltaY) {
                    var top = results.scrollTop();
                    if (deltaY > 0 && top - deltaY <= 0) {
                        results.scrollTop(0);
                        killEvent(e);
                    } else if (deltaY < 0 && results.get(0).scrollHeight - results.scrollTop() + deltaY <= results.height()) {
                        results.scrollTop(results.get(0).scrollHeight - results.height());
                        killEvent(e);
                    }
                });
            }

            installKeyUpChangeEvent(search);
            search.on("keyup-change input paste", this.bind(this.updateResults));
            search.on("focus", function () { search.addClass("select2-focused"); });
            search.on("blur", function () { search.removeClass("select2-focused");});

            this.dropdown.on("mouseup", resultsSelector, this.bind(function (e) {
                if ($(e.target).closest(".select2-result-selectable").length > 0) {
                    this.highlightUnderEvent(e);
                    this.selectHighlighted(e);
                }
            }));

            // trap all mouse events from leaving the dropdown. sometimes there may be a modal that is listening
            // for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's
            // dom it will trigger the popup close, which is not what we want
            // focusin can cause focus wars between modals and select2 since the dropdown is outside the modal.
            this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); });

            this.nextSearchTerm = undefined;

            if ($.isFunction(this.opts.initSelection)) {
                // initialize selection based on the current value of the source element
                this.initSelection();

                // if the user has provided a function that can set selection based on the value of the source element
                // we monitor the change event on the element and trigger it, allowing for two way synchronization
                this.monitorSource();
            }

            if (opts.maximumInputLength !== null) {
                this.search.attr("maxlength", opts.maximumInputLength);
            }

            var disabled = opts.element.prop("disabled");
            if (disabled === undefined) disabled = false;
            this.enable(!disabled);

            var readonly = opts.element.prop("readonly");
            if (readonly === undefined) readonly = false;
            this.readonly(readonly);

            // Calculate size of scrollbar
            scrollBarDimensions = scrollBarDimensions || measureScrollbar();

            this.autofocus = opts.element.prop("autofocus");
            opts.element.prop("autofocus", false);
            if (this.autofocus) this.focus();

            this.search.attr("placeholder", opts.searchInputPlaceholder);
        },

        // abstract
        destroy: function () {
            var element=this.opts.element, select2 = element.data("select2");

            this.close();

            if (this.propertyObserver) {
                this.propertyObserver.disconnect();
                this.propertyObserver = null;
            }

            if (select2 !== undefined) {
                select2.container.remove();
                select2.liveRegion.remove();
                select2.dropdown.remove();
                element
                    .removeClass("select2-offscreen")
                    .removeData("select2")
                    .off(".select2")
                    .prop("autofocus", this.autofocus || false);
                if (this.elementTabIndex) {
                    element.attr({tabindex: this.elementTabIndex});
                } else {
                    element.removeAttr("tabindex");
                }
                element.show();
            }

            cleanupJQueryElements.call(this,
                "container",
                "liveRegion",
                "dropdown",
                "results",
                "search"
            );
        },

        // abstract
        optionToData: function(element) {
            if (element.is("option")) {
                return {
                    id:element.prop("value"),
                    text:element.text(),
                    element: element.get(),
                    css: element.attr("class"),
                    disabled: element.prop("disabled"),
                    locked: equal(element.attr("locked"), "locked") || equal(element.data("locked"), true)
                };
            } else if (element.is("optgroup")) {
                return {
                    text:element.attr("label"),
                    children:[],
                    element: element.get(),
                    css: element.attr("class")
                };
            }
        },

        // abstract
        prepareOpts: function (opts) {
            var element, select, idKey, ajaxUrl, self = this;

            element = opts.element;

            if (element.get(0).tagName.toLowerCase() === "select") {
                this.select = select = opts.element;
            }

            if (select) {
                // these options are not allowed when attached to a select because they are picked up off the element itself
                $.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () {
                    if (this in opts) {
                        throw new Error("Option '" + this + "' is not allowed for Select2 when attached to a <select> element.");
                    }
                });
            }

            opts = $.extend({}, {
                populateResults: function(container, results, query) {
                    var populate, id=this.opts.id, liveRegion=this.liveRegion;

                    populate=function(results, container, depth) {

                        var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted;

                        results = opts.sortResults(results, container, query);

                        for (i = 0, l = results.length; i < l; i = i + 1) {

                            result=results[i];

                            disabled = (result.disabled === true);
                            selectable = (!disabled) && (id(result) !== undefined);

                            compound=result.children && result.children.length > 0;

                            node=$("<li></li>");
                            node.addClass("select2-results-dept-"+depth);
                            node.addClass("select2-result");
                            node.addClass(selectable ? "select2-result-selectable" : "select2-result-unselectable");
                            if (disabled) { node.addClass("select2-disabled"); }
                            if (compound) { node.addClass("select2-result-with-children"); }
                            node.addClass(self.opts.formatResultCssClass(result));
                            node.attr("role", "presentation");

                            label=$(document.createElement("div"));
                            label.addClass("select2-result-label");
                            label.attr("id", "select2-result-label-" + nextUid());
                            label.attr("role", "option");

                            formatted=opts.formatResult(result, label, query, self.opts.escapeMarkup);
                            if (formatted!==undefined) {
                                label.html(formatted);
                                node.append(label);
                            }


                            if (compound) {

                                innerContainer=$("<ul></ul>");
                                innerContainer.addClass("select2-result-sub");
                                populate(result.children, innerContainer, depth+1);
                                node.append(innerContainer);
                            }

                            node.data("select2-data", result);
                            container.append(node);
                        }

                        liveRegion.text(opts.formatMatches(results.length));
                    };

                    populate(results, container, 0);
                }
            }, $.fn.select2.defaults, opts);

            if (typeof(opts.id) !== "function") {
                idKey = opts.id;
                opts.id = function (e) { return e[idKey]; };
            }

            if ($.isArray(opts.element.data("select2Tags"))) {
                if ("tags" in opts) {
                    throw "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " + opts.element.attr("id");
                }
                opts.tags=opts.element.data("select2Tags");
            }

            if (select) {
                opts.query = this.bind(function (query) {
                    var data = { results: [], more: false },
                        term = query.term,
                        children, placeholderOption, process;

                    process=function(element, collection) {
                        var group;
                        if (element.is("option")) {
                            if (query.matcher(term, element.text(), element)) {
                                collection.push(self.optionToData(element));
                            }
                        } else if (element.is("optgroup")) {
                            group=self.optionToData(element);
                            element.children().each2(function(i, elm) { process(elm, group.children); });
                            if (group.children.length>0) {
                                collection.push(group);
                            }
                        }
                    };

                    children=element.children();

                    // ignore the placeholder option if there is one
                    if (this.getPlaceholder() !== undefined && children.length > 0) {
                        placeholderOption = this.getPlaceholderOption();
                        if (placeholderOption) {
                            children=children.not(placeholderOption);
                        }
                    }

                    children.each2(function(i, elm) { process(elm, data.results); });

                    query.callback(data);
                });
                // this is needed because inside val() we construct choices from options and there id is hardcoded
                opts.id=function(e) { return e.id; };
            } else {
                if (!("query" in opts)) {

                    if ("ajax" in opts) {
                        ajaxUrl = opts.element.data("ajax-url");
                        if (ajaxUrl && ajaxUrl.length > 0) {
                            opts.ajax.url = ajaxUrl;
                        }
                        opts.query = ajax.call(opts.element, opts.ajax);
                    } else if ("data" in opts) {
                        opts.query = local(opts.data);
                    } else if ("tags" in opts) {
                        opts.query = tags(opts.tags);
                        if (opts.createSearchChoice === undefined) {
                            opts.createSearchChoice = function (term) { return {id: $.trim(term), text: $.trim(term)}; };
                        }
                        if (opts.initSelection === undefined) {
                            opts.initSelection = function (element, callback) {
                                var data = [];
                                $(splitVal(element.val(), opts.separator)).each(function () {
                                    var obj = { id: this, text: this },
                                        tags = opts.tags;
                                    if ($.isFunction(tags)) tags=tags();
                                    $(tags).each(function() { if (equal(this.id, obj.id)) { obj = this; return false; } });
                                    data.push(obj);
                                });

                                callback(data);
                            };
                        }
                    }
                }
            }
            if (typeof(opts.query) !== "function") {
                throw "query function not defined for Select2 " + opts.element.attr("id");
            }

            if (opts.createSearchChoicePosition === 'top') {
                opts.createSearchChoicePosition = function(list, item) { list.unshift(item); };
            }
            else if (opts.createSearchChoicePosition === 'bottom') {
                opts.createSearchChoicePosition = function(list, item) { list.push(item); };
            }
            else if (typeof(opts.createSearchChoicePosition) !== "function")  {
                throw "invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";
            }

            return opts;
        },

        /**
         * Monitor the original element for changes and update select2 accordingly
         */
        // abstract
        monitorSource: function () {
            var el = this.opts.element, sync, observer;

            el.on("change.select2", this.bind(function (e) {
                if (this.opts.element.data("select2-change-triggered") !== true) {
                    this.initSelection();
                }
            }));

            sync = this.bind(function () {

                // sync enabled state
                var disabled = el.prop("disabled");
                if (disabled === undefined) disabled = false;
                this.enable(!disabled);

                var readonly = el.prop("readonly");
                if (readonly === undefined) readonly = false;
                this.readonly(readonly);

                syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
                this.container.addClass(evaluate(this.opts.containerCssClass));

                syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
                this.dropdown.addClass(evaluate(this.opts.dropdownCssClass));

            });

            // IE8-10 (IE9/10 won't fire propertyChange via attachEventListener)
            if (el.length && el[0].attachEvent) {
                el.each(function() {
                    this.attachEvent("onpropertychange", sync);
                });
            }
            
            // safari, chrome, firefox, IE11
            observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
            if (observer !== undefined) {
                if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
                this.propertyObserver = new observer(function (mutations) {
                    mutations.forEach(sync);
                });
                this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
            }
        },

        // abstract
        triggerSelect: function(data) {
            var evt = $.Event("select2-selecting", { val: this.id(data), object: data });
            this.opts.element.trigger(evt);
            return !evt.isDefaultPrevented();
        },

        /**
         * Triggers the change event on the source element
         */
        // abstract
        triggerChange: function (details) {

            details = details || {};
            details= $.extend({}, details, { type: "change", val: this.val() });
            // prevents recursive triggering
            this.opts.element.data("select2-change-triggered", true);
            this.opts.element.trigger(details);
            this.opts.element.data("select2-change-triggered", false);

            // some validation frameworks ignore the change event and listen instead to keyup, click for selects
            // so here we trigger the click event manually
            this.opts.element.click();

            // ValidationEngine ignores the change event and listens instead to blur
            // so here we trigger the blur event manually if so desired
            if (this.opts.blurOnChange)
                this.opts.element.blur();
        },

        //abstract
        isInterfaceEnabled: function()
        {
            return this.enabledInterface === true;
        },

        // abstract
        enableInterface: function() {
            var enabled = this._enabled && !this._readonly,
                disabled = !enabled;

            if (enabled === this.enabledInterface) return false;

            this.container.toggleClass("select2-container-disabled", disabled);
            this.close();
            this.enabledInterface = enabled;

            return true;
        },

        // abstract
        enable: function(enabled) {
            if (enabled === undefined) enabled = true;
            if (this._enabled === enabled) return;
            this._enabled = enabled;

            this.opts.element.prop("disabled", !enabled);
            this.enableInterface();
        },

        // abstract
        disable: function() {
            this.enable(false);
        },

        // abstract
        readonly: function(enabled) {
            if (enabled === undefined) enabled = false;
            if (this._readonly === enabled) return;
            this._readonly = enabled;

            this.opts.element.prop("readonly", enabled);
            this.enableInterface();
        },

        // abstract
        opened: function () {
            return this.container.hasClass("select2-dropdown-open");
        },

        // abstract
        positionDropdown: function() {
            var $dropdown = this.dropdown,
                offset = this.container.offset(),
                height = this.container.outerHeight(false),
                width = this.container.outerWidth(false),
                dropHeight = $dropdown.outerHeight(false),
                $window = $(window),
                windowWidth = $window.width(),
                windowHeight = $window.height(),
                viewPortRight = $window.scrollLeft() + windowWidth,
                viewportBottom = $window.scrollTop() + windowHeight,
                dropTop = offset.top + height,
                dropLeft = offset.left,
                enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
                enoughRoomAbove = (offset.top - dropHeight) >= $window.scrollTop(),
                dropWidth = $dropdown.outerWidth(false),
                enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
                aboveNow = $dropdown.hasClass("select2-drop-above"),
                bodyOffset,
                above,
                changeDirection,
                css,
                resultsListNode;

            // always prefer the current above/below alignment, unless there is not enough room
            if (aboveNow) {
                above = true;
                if (!enoughRoomAbove && enoughRoomBelow) {
                    changeDirection = true;
                    above = false;
                }
            } else {
                above = false;
                if (!enoughRoomBelow && enoughRoomAbove) {
                    changeDirection = true;
                    above = true;
                }
            }

            //if we are changing direction we need to get positions when dropdown is hidden;
            if (changeDirection) {
                $dropdown.hide();
                offset = this.container.offset();
                height = this.container.outerHeight(false);
                width = this.container.outerWidth(false);
                dropHeight = $dropdown.outerHeight(false);
                viewPortRight = $window.scrollLeft() + windowWidth;
                viewportBottom = $window.scrollTop() + windowHeight;
                dropTop = offset.top + height;
                dropLeft = offset.left;
                dropWidth = $dropdown.outerWidth(false);
                enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
                $dropdown.show();

                // fix so the cursor does not move to the left within the search-textbox in IE
                this.focusSearch();
            }

            if (this.opts.dropdownAutoWidth) {
                resultsListNode = $('.select2-results', $dropdown)[0];
                $dropdown.addClass('select2-drop-auto-width');
                $dropdown.css('width', '');
                // Add scrollbar width to dropdown if vertical scrollbar is present
                dropWidth = $dropdown.outerWidth(false) + (resultsListNode.scrollHeight === resultsListNode.clientHeight ? 0 : scrollBarDimensions.width);
                dropWidth > width ? width = dropWidth : dropWidth = width;
                dropHeight = $dropdown.outerHeight(false);
                enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight;
            }
            else {
                this.container.removeClass('select2-drop-auto-width');
            }

            //console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
            //console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body.scrollTop(), "enough?", enoughRoomAbove);

            // fix positioning when body has an offset and is not position: static
            if (this.body.css('position') !== 'static') {
                bodyOffset = this.body.offset();
                dropTop -= bodyOffset.top;
                dropLeft -= bodyOffset.left;
            }

            if (!enoughRoomOnRight) {
                dropLeft = offset.left + this.container.outerWidth(false) - dropWidth;
            }

            css =  {
                left: dropLeft,
                width: width
            };

            if (above) {
                css.top = offset.top - dropHeight;
                css.bottom = 'auto';
                this.container.addClass("select2-drop-above");
                $dropdown.addClass("select2-drop-above");
            }
            else {
                css.top = dropTop;
                css.bottom = 'auto';
                this.container.removeClass("select2-drop-above");
                $dropdown.removeClass("select2-drop-above");
            }
            css = $.extend(css, evaluate(this.opts.dropdownCss));

            $dropdown.css(css);
        },

        // abstract
        shouldOpen: function() {
            var event;

            if (this.opened()) return false;

            if (this._enabled === false || this._readonly === true) return false;

            event = $.Event("select2-opening");
            this.opts.element.trigger(event);
            return !event.isDefaultPrevented();
        },

        // abstract
        clearDropdownAlignmentPreference: function() {
            // clear the classes used to figure out the preference of where the dropdown should be opened
            this.container.removeClass("select2-drop-above");
            this.dropdown.removeClass("select2-drop-above");
        },

        /**
         * Opens the dropdown
         *
         * @return {Boolean} whether or not dropdown was opened. This method will return false if, for example,
         * the dropdown is already open, or if the 'open' event listener on the element called preventDefault().
         */
        // abstract
        open: function () {

            if (!this.shouldOpen()) return false;

            this.opening();

            return true;
        },

        /**
         * Performs the opening of the dropdown
         */
        // abstract
        opening: function() {
            var cid = this.containerEventName,
                scroll = "scroll." + cid,
                resize = "resize."+cid,
                orient = "orientationchange."+cid,
                mask;

            this.container.addClass("select2-dropdown-open").addClass("select2-container-active");

            this.clearDropdownAlignmentPreference();

            if(this.dropdown[0] !== this.body.children().last()[0]) {
                this.dropdown.detach().appendTo(this.body);
            }

            // create the dropdown mask if doesn't already exist
            mask = $("#select2-drop-mask");
            if (mask.length == 0) {
                mask = $(document.createElement("div"));
                mask.attr("id","select2-drop-mask").attr("class","select2-drop-mask");
                mask.hide();
                mask.appendTo(this.body);
                mask.on("mousedown touchstart click", function (e) {
                    // Prevent IE from generating a click event on the body
                    reinsertElement(mask);

                    var dropdown = $("#select2-drop"), self;
                    if (dropdown.length > 0) {
                        self=dropdown.data("select2");
                        if (self.opts.selectOnBlur) {
                            self.selectHighlighted({noFocus: true});
                        }
                        self.close();
                        e.preventDefault();
                        e.stopPropagation();
                    }
                });
            }

            // ensure the mask is always right before the dropdown
            if (this.dropdown.prev()[0] !== mask[0]) {
                this.dropdown.before(mask);
            }

            // move the global id to the correct dropdown
            $("#select2-drop").removeAttr("id");
            this.dropdown.attr("id", "select2-drop");

            // show the elements
            mask.show();

            this.positionDropdown();
            this.dropdown.show();
            this.positionDropdown();

            this.dropdown.addClass("select2-drop-active");

            // attach listeners to events that can change the position of the container and thus require
            // the position of the dropdown to be updated as well so it does not come unglued from the container
            var that = this;
            this.container.parents().add(window).each(function () {
                $(this).on(resize+" "+scroll+" "+orient, function (e) {
                    if (that.opened()) that.positionDropdown();
                });
            });


        },

        // abstract
        close: function () {
            if (!this.opened()) return;

            var cid = this.containerEventName,
                scroll = "scroll." + cid,
                resize = "resize."+cid,
                orient = "orientationchange."+cid;

            // unbind event listeners
            this.container.parents().add(window).each(function () { $(this).off(scroll).off(resize).off(orient); });

            this.clearDropdownAlignmentPreference();

            $("#select2-drop-mask").hide();
            this.dropdown.removeAttr("id"); // only the active dropdown has the select2-drop id
            this.dropdown.hide();
            this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");
            this.results.empty();


            this.clearSearch();
            this.search.removeClass("select2-active");
            this.opts.element.trigger($.Event("select2-close"));
        },

        /**
         * Opens control, sets input value, and updates results.
         */
        // abstract
        externalSearch: function (term) {
            this.open();
            this.search.val(term);
            this.updateResults(false);
        },

        // abstract
        clearSearch: function () {

        },

        //abstract
        getMaximumSelectionSize: function() {
            return evaluate(this.opts.maximumSelectionSize);
        },

        // abstract
        ensureHighlightVisible: function () {
            var results = this.results, children, index, child, hb, rb, y, more;

            index = this.highlight();

            if (index < 0) return;

            if (index == 0) {

                // if the first element is highlighted scroll all the way to the top,
                // that way any unselectable headers above it will also be scrolled
                // into view

                results.scrollTop(0);
                return;
            }

            children = this.findHighlightableChoices().find('.select2-result-label');

            child = $(children[index]);

            hb = child.offset().top + child.outerHeight(true);

            // if this is the last child lets also make sure select2-more-results is visible
            if (index === children.length - 1) {
                more = results.find("li.select2-more-results");
                if (more.length > 0) {
                    hb = more.offset().top + more.outerHeight(true);
                }
            }

            rb = results.offset().top + results.outerHeight(true);
            if (hb > rb) {
                results.scrollTop(results.scrollTop() + (hb - rb));
            }
            y = child.offset().top - results.offset().top;

            // make sure the top of the element is visible
            if (y < 0 && child.css('display') != 'none' ) {
                results.scrollTop(results.scrollTop() + y); // y is negative
            }
        },

        // abstract
        findHighlightableChoices: function() {
            return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)");
        },

        // abstract
        moveHighlight: function (delta) {
            var choices = this.findHighlightableChoices(),
                index = this.highlight();

            while (index > -1 && index < choices.length) {
                index += delta;
                var choice = $(choices[index]);
                if (choice.hasClass("select2-result-selectable") && !choice.hasClass("select2-disabled") && !choice.hasClass("select2-selected")) {
                    this.highlight(index);
                    break;
                }
            }
        },

        // abstract
        highlight: function (index) {
            var choices = this.findHighlightableChoices(),
                choice,
                data;

            if (arguments.length === 0) {
                return indexOf(choices.filter(".select2-highlighted")[0], choices.get());
            }

            if (index >= choices.length) index = choices.length - 1;
            if (index < 0) index = 0;

            this.removeHighlight();

            choice = $(choices[index]);
            choice.addClass("select2-highlighted");

            // ensure assistive technology can determine the active choice
            this.search.attr("aria-activedescendant", choice.find(".select2-result-label").attr("id"));

            this.ensureHighlightVisible();

            this.liveRegion.text(choice.text());

            data = choice.data("select2-data");
            if (data) {
                this.opts.element.trigger({ type: "select2-highlight", val: this.id(data), choice: data });
            }
        },

        removeHighlight: function() {
            this.results.find(".select2-highlighted").removeClass("select2-highlighted");
        },

        touchMoved: function() {
            this._touchMoved = true;
        },

        clearTouchMoved: function() {
          this._touchMoved = false;
        },

        // abstract
        countSelectableResults: function() {
            return this.findHighlightableChoices().length;
        },

        // abstract
        highlightUnderEvent: function (event) {
            var el = $(event.target).closest(".select2-result-selectable");
            if (el.length > 0 && !el.is(".select2-highlighted")) {
                var choices = this.findHighlightableChoices();
                this.highlight(choices.index(el));
            } else if (el.length == 0) {
                // if we are over an unselectable item remove all highlights
                this.removeHighlight();
            }
        },

        // abstract
        loadMoreIfNeeded: function () {
            var results = this.results,
                more = results.find("li.select2-more-results"),
                below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
                page = this.resultsPage + 1,
                self=this,
                term=this.search.val(),
                context=this.context;

            if (more.length === 0) return;
            below = more.offset().top - results.offset().top - results.height();

            if (below <= this.opts.loadMorePadding) {
                more.addClass("select2-active");
                this.opts.query({
                        element: this.opts.element,
                        term: term,
                        page: page,
                        context: context,
                        matcher: this.opts.matcher,
                        callback: this.bind(function (data) {

                    // ignore a response if the select2 has been closed before it was received
                    if (!self.opened()) return;


                    self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
                    self.postprocessResults(data, false, false);

                    if (data.more===true) {
                        more.detach().appendTo(results).text(evaluate(self.opts.formatLoadMore, page+1));
                        window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
                    } else {
                        more.remove();
                    }
                    self.positionDropdown();
                    self.resultsPage = page;
                    self.context = data.context;
                    this.opts.element.trigger({ type: "select2-loaded", items: data });
                })});
            }
        },

        /**
         * Default tokenizer function which does nothing
         */
        tokenize: function() {

        },

        /**
         * @param initial whether or not this is the call to this method right after the dropdown has been opened
         */
        // abstract
        updateResults: function (initial) {
            var search = this.search,
                results = this.results,
                opts = this.opts,
                data,
                self = this,
                input,
                term = search.val(),
                lastTerm = $.data(this.container, "select2-last-term"),
                // sequence number used to drop out-of-order responses
                queryNumber;

            // prevent duplicate queries against the same term
            if (initial !== true && lastTerm && equal(term, lastTerm)) return;

            $.data(this.container, "select2-last-term", term);

            // if the search is currently hidden we do not alter the results
            if (initial !== true && (this.showSearchInput === false || !this.opened())) {
                return;
            }

            function postRender() {
                search.removeClass("select2-active");
                self.positionDropdown();
                if (results.find('.select2-no-results,.select2-selection-limit,.select2-searching').length) {
                    self.liveRegion.text(results.text());
                }
                else {
                    self.liveRegion.text(self.opts.formatMatches(results.find('.select2-result-selectable').length));
                }
            }

            function render(html) {
                results.html(html);
                postRender();
            }

            queryNumber = ++this.queryCount;

            var maxSelSize = this.getMaximumSelectionSize();
            if (maxSelSize >=1) {
                data = this.data();
                if ($.isArray(data) && data.length >= maxSelSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) {
                    render("<li class='select2-selection-limit'>" + evaluate(opts.formatSelectionTooBig, maxSelSize) + "</li>");
                    return;
                }
            }

            if (search.val().length < opts.minimumInputLength) {
                if (checkFormatter(opts.formatInputTooShort, "formatInputTooShort")) {
                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooShort, search.val(), opts.minimumInputLength) + "</li>");
                } else {
                    render("");
                }
                if (initial && this.showSearch) this.showSearch(true);
                return;
            }

            if (opts.maximumInputLength && search.val().length > opts.maximumInputLength) {
                if (checkFormatter(opts.formatInputTooLong, "formatInputTooLong")) {
                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooLong, search.val(), opts.maximumInputLength) + "</li>");
                } else {
                    render("");
                }
                return;
            }

            if (opts.formatSearching && this.findHighlightableChoices().length === 0) {
                render("<li class='select2-searching'>" + evaluate(opts.formatSearching) + "</li>");
            }

            search.addClass("select2-active");

            this.removeHighlight();

            // give the tokenizer a chance to pre-process the input
            input = this.tokenize();
            if (input != undefined && input != null) {
                search.val(input);
            }

            this.resultsPage = 1;

            opts.query({
                element: opts.element,
                    term: search.val(),
                    page: this.resultsPage,
                    context: null,
                    matcher: opts.matcher,
                    callback: this.bind(function (data) {
                var def; // default choice

                // ignore old responses
                if (queryNumber != this.queryCount) {
                  return;
                }

                // ignore a response if the select2 has been closed before it was received
                if (!this.opened()) {
                    this.search.removeClass("select2-active");
                    return;
                }

                // save context, if any
                this.context = (data.context===undefined) ? null : data.context;
                // create a default choice and prepend it to the list
                if (this.opts.createSearchChoice && search.val() !== "") {
                    def = this.opts.createSearchChoice.call(self, search.val(), data.results);
                    if (def !== undefined && def !== null && self.id(def) !== undefined && self.id(def) !== null) {
                        if ($(data.results).filter(
                            function () {
                                return equal(self.id(this), self.id(def));
                            }).length === 0) {
                            this.opts.createSearchChoicePosition(data.results, def);
                        }
                    }
                }

                if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
                    render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, search.val()) + "</li>");
                    return;
                }

                results.empty();
                self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null});

                if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) {
                    results.append("<li class='select2-more-results'>" + self.opts.escapeMarkup(evaluate(opts.formatLoadMore, this.resultsPage)) + "</li>");
                    window.setTimeout(function() { self.loadMoreIfNeeded(); }, 10);
                }

                this.postprocessResults(data, initial);

                postRender();

                this.opts.element.trigger({ type: "select2-loaded", items: data });
            })});
        },

        // abstract
        cancel: function () {
            this.close();
        },

        // abstract
        blur: function () {
            // if selectOnBlur == true, select the currently highlighted option
            if (this.opts.selectOnBlur)
                this.selectHighlighted({noFocus: true});

            this.close();
            this.container.removeClass("select2-container-active");
            // synonymous to .is(':focus'), which is available in jquery >= 1.6
            if (this.search[0] === document.activeElement) { this.search.blur(); }
            this.clearSearch();
            this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
        },

        // abstract
        focusSearch: function () {
            focus(this.search);
        },

        // abstract
        selectHighlighted: function (options) {
            if (this._touchMoved) {
              this.clearTouchMoved();
              return;
            }
            var index=this.highlight(),
                highlighted=this.results.find(".select2-highlighted"),
                data = highlighted.closest('.select2-result').data("select2-data");

            if (data) {
                this.highlight(index);
                this.onSelect(data, options);
            } else if (options && options.noFocus) {
                this.close();
            }
        },

        // abstract
        getPlaceholder: function () {
            var placeholderOption;
            return this.opts.element.attr("placeholder") ||
                this.opts.element.attr("data-placeholder") || // jquery 1.4 compat
                this.opts.element.data("placeholder") ||
                this.opts.placeholder ||
                ((placeholderOption = this.getPlaceholderOption()) !== undefined ? placeholderOption.text() : undefined);
        },

        // abstract
        getPlaceholderOption: function() {
            if (this.select) {
                var firstOption = this.select.children('option').first();
                if (this.opts.placeholderOption !== undefined ) {
                    //Determine the placeholder option based on the specified placeholderOption setting
                    return (this.opts.placeholderOption === "first" && firstOption) ||
                           (typeof this.opts.placeholderOption === "function" && this.opts.placeholderOption(this.select));
                } else if ($.trim(firstOption.text()) === "" && firstOption.val() === "") {
                    //No explicit placeholder option specified, use the first if it's blank
                    return firstOption;
                }
            }
        },

        /**
         * Get the desired width for the container element.  This is
         * derived first from option `width` passed to select2, then
         * the inline 'style' on the original element, and finally
         * falls back to the jQuery calculated element width.
         */
        // abstract
        initContainerWidth: function () {
            function resolveContainerWidth() {
                var style, attrs, matches, i, l, attr;

                if (this.opts.width === "off") {
                    return null;
                } else if (this.opts.width === "element"){
                    return this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px';
                } else if (this.opts.width === "copy" || this.opts.width === "resolve") {
                    // check if there is inline style on the element that contains width
                    style = this.opts.element.attr('style');
                    if (style !== undefined) {
                        attrs = style.split(';');
                        for (i = 0, l = attrs.length; i < l; i = i + 1) {
                            attr = attrs[i].replace(/\s/g, '');
                            matches = attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i);
                            if (matches !== null && matches.length >= 1)
                                return matches[1];
                        }
                    }

                    if (this.opts.width === "resolve") {
                        // next check if css('width') can resolve a width that is percent based, this is sometimes possible
                        // when attached to input type=hidden or elements hidden via css
                        style = this.opts.element.css('width');
                        if (style.indexOf("%") > 0) return style;

                        // finally, fallback on the calculated width of the element
                        return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
                    }

                    return null;
                } else if ($.isFunction(this.opts.width)) {
                    return this.opts.width();
                } else {
                    return this.opts.width;
               }
            };

            var width = resolveContainerWidth.call(this);
            if (width !== null) {
                this.container.css("width", width);
            }
        }
    });

    SingleSelect2 = clazz(AbstractSelect2, {

        // single

        createContainer: function () {
            var container = $(document.createElement("div")).attr({
                "class": "select2-container"
            }).html([
                "<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>",
                "   <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>",
                "   <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>",
                "</a>",
                "<label for='' class='select2-offscreen'></label>",
                "<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />",
                "<div class='select2-drop select2-display-none'>",
                "   <div class='select2-search'>",
                "       <label for='' class='select2-offscreen'></label>",
                "       <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'",
                "       aria-autocomplete='list' />",
                "   </div>",
                "   <ul class='select2-results' role='listbox'>",
                "   </ul>",
                "</div>"].join(""));
            return container;
        },

        // single
        enableInterface: function() {
            if (this.parent.enableInterface.apply(this, arguments)) {
                this.focusser.prop("disabled", !this.isInterfaceEnabled());
            }
        },

        // single
        opening: function () {
            var el, range, len;

            if (this.opts.minimumResultsForSearch >= 0) {
                this.showSearch(true);
            }

            this.parent.opening.apply(this, arguments);

            if (this.showSearchInput !== false) {
                // IE appends focusser.val() at the end of field :/ so we manually insert it at the beginning using a range
                // all other browsers handle this just fine

                this.search.val(this.focusser.val());
            }
            if (this.opts.shouldFocusInput(this)) {
                this.search.focus();
                // move the cursor to the end after focussing, otherwise it will be at the beginning and
                // new text will appear *before* focusser.val()
                el = this.search.get(0);
                if (el.createTextRange) {
                    range = el.createTextRange();
                    range.collapse(false);
                    range.select();
                } else if (el.setSelectionRange) {
                    len = this.search.val().length;
                    el.setSelectionRange(len, len);
                }
            }

            // initializes search's value with nextSearchTerm (if defined by user)
            // ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
            if(this.search.val() === "") {
                if(this.nextSearchTerm != undefined){
                    this.search.val(this.nextSearchTerm);
                    this.search.select();
                }
            }

            this.focusser.prop("disabled", true).val("");
            this.updateResults(true);
            this.opts.element.trigger($.Event("select2-open"));
        },

        // single
        close: function () {
            if (!this.opened()) return;
            this.parent.close.apply(this, arguments);

            this.focusser.prop("disabled", false);

            if (this.opts.shouldFocusInput(this)) {
                this.focusser.focus();
            }
        },

        // single
        focus: function () {
            if (this.opened()) {
                this.close();
            } else {
                this.focusser.prop("disabled", false);
                if (this.opts.shouldFocusInput(this)) {
                    this.focusser.focus();
                }
            }
        },

        // single
        isFocused: function () {
            return this.container.hasClass("select2-container-active");
        },

        // single
        cancel: function () {
            this.parent.cancel.apply(this, arguments);
            this.focusser.prop("disabled", false);

            if (this.opts.shouldFocusInput(this)) {
                this.focusser.focus();
            }
        },

        // single
        destroy: function() {
            $("label[for='" + this.focusser.attr('id') + "']")
                .attr('for', this.opts.element.attr("id"));
            this.parent.destroy.apply(this, arguments);

            cleanupJQueryElements.call(this,
                "selection",
                "focusser"
            );
        },

        // single
        initContainer: function () {

            var selection,
                container = this.container,
                dropdown = this.dropdown,
                idSuffix = nextUid(),
                elementLabel;

            if (this.opts.minimumResultsForSearch < 0) {
                this.showSearch(false);
            } else {
                this.showSearch(true);
            }

            this.selection = selection = container.find(".select2-choice");

            this.focusser = container.find(".select2-focusser");

            // add aria associations
            selection.find(".select2-chosen").attr("id", "select2-chosen-"+idSuffix);
            this.focusser.attr("aria-labelledby", "select2-chosen-"+idSuffix);
            this.results.attr("id", "select2-results-"+idSuffix);
            this.search.attr("aria-owns", "select2-results-"+idSuffix);

            // rewrite labels from original element to focusser
            this.focusser.attr("id", "s2id_autogen"+idSuffix);

            elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");

            this.focusser.prev()
                .text(elementLabel.text())
                .attr('for', this.focusser.attr('id'));

            // Ensure the original element retains an accessible name
            var originalTitle = this.opts.element.attr("title");
            this.opts.element.attr("title", (originalTitle || elementLabel.text()));

            this.focusser.attr("tabindex", this.elementTabIndex);

            // write label for search field using the label from the focusser element
            this.search.attr("id", this.focusser.attr('id') + '_search');

            this.search.prev()
                .text($("label[for='" + this.focusser.attr('id') + "']").text())
                .attr('for', this.search.attr('id'));

            this.search.on("keydown", this.bind(function (e) {
                if (!this.isInterfaceEnabled()) return;

                if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) {
                    // prevent the page from scrolling
                    killEvent(e);
                    return;
                }

                switch (e.which) {
                    case KEY.UP:
                    case KEY.DOWN:
                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
                        killEvent(e);
                        return;
                    case KEY.ENTER:
                        this.selectHighlighted();
                        killEvent(e);
                        return;
                    case KEY.TAB:
                        this.selectHighlighted({noFocus: true});
                        return;
                    case KEY.ESC:
                        this.cancel(e);
                        killEvent(e);
                        return;
                }
            }));

            this.search.on("blur", this.bind(function(e) {
                // a workaround for chrome to keep the search field focussed when the scroll bar is used to scroll the dropdown.
                // without this the search field loses focus which is annoying
                if (document.activeElement === this.body.get(0)) {
                    window.setTimeout(this.bind(function() {
                        if (this.opened()) {
                            this.search.focus();
                        }
                    }), 0);
                }
            }));

            this.focusser.on("keydown", this.bind(function (e) {
                if (!this.isInterfaceEnabled()) return;

                if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
                    return;
                }

                if (this.opts.openOnEnter === false && e.which === KEY.ENTER) {
                    killEvent(e);
                    return;
                }

                if (e.which == KEY.DOWN || e.which == KEY.UP
                    || (e.which == KEY.ENTER && this.opts.openOnEnter)) {

                    if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) return;

                    this.open();
                    killEvent(e);
                    return;
                }

                if (e.which == KEY.DELETE || e.which == KEY.BACKSPACE) {
                    if (this.opts.allowClear) {
                        this.clear();
                    }
                    killEvent(e);
                    return;
                }
            }));


            installKeyUpChangeEvent(this.focusser);
            this.focusser.on("keyup-change input", this.bind(function(e) {
                if (this.opts.minimumResultsForSearch >= 0) {
                    e.stopPropagation();
                    if (this.opened()) return;
                    this.open();
                }
            }));

            selection.on("mousedown touchstart", "abbr", this.bind(function (e) {
                if (!this.isInterfaceEnabled()) return;
                this.clear();
                killEventImmediately(e);
                this.close();
                this.selection.focus();
            }));

            selection.on("mousedown touchstart", this.bind(function (e) {
                // Prevent IE from generating a click event on the body
                reinsertElement(selection);

                if (!this.container.hasClass("select2-container-active")) {
                    this.opts.element.trigger($.Event("select2-focus"));
                }

                if (this.opened()) {
                    this.close();
                } else if (this.isInterfaceEnabled()) {
                    this.open();
                }

                killEvent(e);
            }));

            dropdown.on("mousedown touchstart", this.bind(function() {
                if (this.opts.shouldFocusInput(this)) {
                    this.search.focus();
                }
            }));

            selection.on("focus", this.bind(function(e) {
                killEvent(e);
            }));

            this.focusser.on("focus", this.bind(function(){
                if (!this.container.hasClass("select2-container-active")) {
                    this.opts.element.trigger($.Event("select2-focus"));
                }
                this.container.addClass("select2-container-active");
            })).on("blur", this.bind(function() {
                if (!this.opened()) {
                    this.container.removeClass("select2-container-active");
                    this.opts.element.trigger($.Event("select2-blur"));
                }
            }));
            this.search.on("focus", this.bind(function(){
                if (!this.container.hasClass("select2-container-active")) {
                    this.opts.element.trigger($.Event("select2-focus"));
                }
                this.container.addClass("select2-container-active");
            }));

            this.initContainerWidth();
            this.opts.element.addClass("select2-offscreen");
            this.setPlaceholder();

        },

        // single
        clear: function(triggerChange) {
            var data=this.selection.data("select2-data");
            if (data) { // guard against queued quick consecutive clicks
                var evt = $.Event("select2-clearing");
                this.opts.element.trigger(evt);
                if (evt.isDefaultPrevented()) {
                    return;
                }
                var placeholderOption = this.getPlaceholderOption();
                this.opts.element.val(placeholderOption ? placeholderOption.val() : "");
                this.selection.find(".select2-chosen").empty();
                this.selection.removeData("select2-data");
                this.setPlaceholder();

                if (triggerChange !== false){
                    this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
                    this.triggerChange({removed:data});
                }
            }
        },

        /**
         * Sets selection based on source element's value
         */
        // single
        initSelection: function () {
            var selected;
            if (this.isPlaceholderOptionSelected()) {
                this.updateSelection(null);
                this.close();
                this.setPlaceholder();
            } else {
                var self = this;
                this.opts.initSelection.call(null, this.opts.element, function(selected){
                    if (selected !== undefined && selected !== null) {
                        self.updateSelection(selected);
                        self.close();
                        self.setPlaceholder();
                        self.nextSearchTerm = self.opts.nextSearchTerm(selected, self.search.val());
                    }
                });
            }
        },

        isPlaceholderOptionSelected: function() {
            var placeholderOption;
            if (this.getPlaceholder() === undefined) return false; // no placeholder specified so no option should be considered
            return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.prop("selected"))
                || (this.opts.element.val() === "")
                || (this.opts.element.val() === undefined)
                || (this.opts.element.val() === null);
        },

        // single
        prepareOpts: function () {
            var opts = this.parent.prepareOpts.apply(this, arguments),
                self=this;

            if (opts.element.get(0).tagName.toLowerCase() === "select") {
                // install the selection initializer
                opts.initSelection = function (element, callback) {
                    var selected = element.find("option").filter(function() { return this.selected && !this.disabled });
                    // a single select box always has a value, no need to null check 'selected'
                    callback(self.optionToData(selected));
                };
            } else if ("data" in opts) {
                // install default initSelection when applied to hidden input and data is local
                opts.initSelection = opts.initSelection || function (element, callback) {
                    var id = element.val();
                    //search in data by id, storing the actual matching item
                    var match = null;
                    opts.query({
                        matcher: function(term, text, el){
                            var is_match = equal(id, opts.id(el));
                            if (is_match) {
                                match = el;
                            }
                            return is_match;
                        },
                        callback: !$.isFunction(callback) ? $.noop : function() {
                            callback(match);
                        }
                    });
                };
            }

            return opts;
        },

        // single
        getPlaceholder: function() {
            // if a placeholder is specified on a single select without a valid placeholder option ignore it
            if (this.select) {
                if (this.getPlaceholderOption() === undefined) {
                    return undefined;
                }
            }

            return this.parent.getPlaceholder.apply(this, arguments);
        },

        // single
        setPlaceholder: function () {
            var placeholder = this.getPlaceholder();

            if (this.isPlaceholderOptionSelected() && placeholder !== undefined) {

                // check for a placeholder option if attached to a select
                if (this.select && this.getPlaceholderOption() === undefined) return;

                this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(placeholder));

                this.selection.addClass("select2-default");

                this.container.removeClass("select2-allowclear");
            }
        },

        // single
        postprocessResults: function (data, initial, noHighlightUpdate) {
            var selected = 0, self = this, showSearchInput = true;

            // find the selected element in the result list

            this.findHighlightableChoices().each2(function (i, elm) {
                if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
                    selected = i;
                    return false;
                }
            });

            // and highlight it
            if (noHighlightUpdate !== false) {
                if (initial === true && selected >= 0) {
                    this.highlight(selected);
                } else {
                    this.highlight(0);
                }
            }

            // hide the search box if this is the first we got the results and there are enough of them for search

            if (initial === true) {
                var min = this.opts.minimumResultsForSearch;
                if (min >= 0) {
                    this.showSearch(countResults(data.results) >= min);
                }
            }
        },

        // single
        showSearch: function(showSearchInput) {
            if (this.showSearchInput === showSearchInput) return;

            this.showSearchInput = showSearchInput;

            this.dropdown.find(".select2-search").toggleClass("select2-search-hidden", !showSearchInput);
            this.dropdown.find(".select2-search").toggleClass("select2-offscreen", !showSearchInput);
            //add "select2-with-searchbox" to the container if search box is shown
            $(this.dropdown, this.container).toggleClass("select2-with-searchbox", showSearchInput);
        },

        // single
        onSelect: function (data, options) {

            if (!this.triggerSelect(data)) { return; }

            var old = this.opts.element.val(),
                oldData = this.data();

            this.opts.element.val(this.id(data));
            this.updateSelection(data);

            this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });

            this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
            this.close();

            if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) {
                this.focusser.focus();
            }

            if (!equal(old, this.id(data))) {
                this.triggerChange({ added: data, removed: oldData });
            }
        },

        // single
        updateSelection: function (data) {

            var container=this.selection.find(".select2-chosen"), formatted, cssClass;

            this.selection.data("select2-data", data);

            container.empty();
            if (data !== null) {
                formatted=this.opts.formatSelection(data, container, this.opts.escapeMarkup);
            }
            if (formatted !== undefined) {
                container.append(formatted);
            }
            cssClass=this.opts.formatSelectionCssClass(data, container);
            if (cssClass !== undefined) {
                container.addClass(cssClass);
            }

            this.selection.removeClass("select2-default");

            if (this.opts.allowClear && this.getPlaceholder() !== undefined) {
                this.container.addClass("select2-allowclear");
            }
        },

        // single
        val: function () {
            var val,
                triggerChange = false,
                data = null,
                self = this,
                oldData = this.data();

            if (arguments.length === 0) {
                return this.opts.element.val();
            }

            val = arguments[0];

            if (arguments.length > 1) {
                triggerChange = arguments[1];
            }

            if (this.select) {
                this.select
                    .val(val)
                    .find("option").filter(function() { return this.selected }).each2(function (i, elm) {
                        data = self.optionToData(elm);
                        return false;
                    });
                this.updateSelection(data);
                this.setPlaceholder();
                if (triggerChange) {
                    this.triggerChange({added: data, removed:oldData});
                }
            } else {
                // val is an id. !val is true for [undefined,null,'',0] - 0 is legal
                if (!val && val !== 0) {
                    this.clear(triggerChange);
                    return;
                }
                if (this.opts.initSelection === undefined) {
                    throw new Error("cannot call val() if initSelection() is not defined");
                }
                this.opts.element.val(val);
                this.opts.initSelection(this.opts.element, function(data){
                    self.opts.element.val(!data ? "" : self.id(data));
                    self.updateSelection(data);
                    self.setPlaceholder();
                    if (triggerChange) {
                        self.triggerChange({added: data, removed:oldData});
                    }
                });
            }
        },

        // single
        clearSearch: function () {
            this.search.val("");
            this.focusser.val("");
        },

        // single
        data: function(value) {
            var data,
                triggerChange = false;

            if (arguments.length === 0) {
                data = this.selection.data("select2-data");
                if (data == undefined) data = null;
                return data;
            } else {
                if (arguments.length > 1) {
                    triggerChange = arguments[1];
                }
                if (!value) {
                    this.clear(triggerChange);
                } else {
                    data = this.data();
                    this.opts.element.val(!value ? "" : this.id(value));
                    this.updateSelection(value);
                    if (triggerChange) {
                        this.triggerChange({added: value, removed:data});
                    }
                }
            }
        }
    });

    MultiSelect2 = clazz(AbstractSelect2, {

        // multi
        createContainer: function () {
            var container = $(document.createElement("div")).attr({
                "class": "select2-container select2-container-multi"
            }).html([
                "<ul class='select2-choices'>",
                "  <li class='select2-search-field'>",
                "    <label for='' class='select2-offscreen'></label>",
                "    <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>",
                "  </li>",
                "</ul>",
                "<div class='select2-drop select2-drop-multi select2-display-none'>",
                "   <ul class='select2-results'>",
                "   </ul>",
                "</div>"].join(""));
            return container;
        },

        // multi
        prepareOpts: function () {
            var opts = this.parent.prepareOpts.apply(this, arguments),
                self=this;

            // TODO validate placeholder is a string if specified

            if (opts.element.get(0).tagName.toLowerCase() === "select") {
                // install the selection initializer
                opts.initSelection = function (element, callback) {

                    var data = [];

                    element.find("option").filter(function() { return this.selected && !this.disabled }).each2(function (i, elm) {
                        data.push(self.optionToData(elm));
                    });
                    callback(data);
                };
            } else if ("data" in opts) {
                // install default initSelection when applied to hidden input and data is local
                opts.initSelection = opts.initSelection || function (element, callback) {
                    var ids = splitVal(element.val(), opts.separator);
                    //search in data by array of ids, storing matching items in a list
                    var matches = [];
                    opts.query({
                        matcher: function(term, text, el){
                            var is_match = $.grep(ids, function(id) {
                                return equal(id, opts.id(el));
                            }).length;
                            if (is_match) {
                                matches.push(el);
                            }
                            return is_match;
                        },
                        callback: !$.isFunction(callback) ? $.noop : function() {
                            // reorder matches based on the order they appear in the ids array because right now
                            // they are in the order in which they appear in data array
                            var ordered = [];
                            for (var i = 0; i < ids.length; i++) {
                                var id = ids[i];
                                for (var j = 0; j < matches.length; j++) {
                                    var match = matches[j];
                                    if (equal(id, opts.id(match))) {
                                        ordered.push(match);
                                        matches.splice(j, 1);
                                        break;
                                    }
                                }
                            }
                            callback(ordered);
                        }
                    });
                };
            }

            return opts;
        },

        // multi
        selectChoice: function (choice) {

            var selected = this.container.find(".select2-search-choice-focus");
            if (selected.length && choice && choice[0] == selected[0]) {

            } else {
                if (selected.length) {
                    this.opts.element.trigger("choice-deselected", selected);
                }
                selected.removeClass("select2-search-choice-focus");
                if (choice && choice.length) {
                    this.close();
                    choice.addClass("select2-search-choice-focus");
                    this.opts.element.trigger("choice-selected", choice);
                }
            }
        },

        // multi
        destroy: function() {
            $("label[for='" + this.search.attr('id') + "']")
                .attr('for', this.opts.element.attr("id"));
            this.parent.destroy.apply(this, arguments);

            cleanupJQueryElements.call(this,
                "searchContainer",
                "selection"
            );
        },

        // multi
        initContainer: function () {

            var selector = ".select2-choices", selection;

            this.searchContainer = this.container.find(".select2-search-field");
            this.selection = selection = this.container.find(selector);

            var _this = this;
            this.selection.on("click", ".select2-search-choice:not(.select2-locked)", function (e) {
                //killEvent(e);
                _this.search[0].focus();
                _this.selectChoice($(this));
            });

            // rewrite labels from original element to focusser
            this.search.attr("id", "s2id_autogen"+nextUid());

            this.search.prev()
                .text($("label[for='" + this.opts.element.attr("id") + "']").text())
                .attr('for', this.search.attr('id'));

            this.search.on("input paste", this.bind(function() {
                if (!this.isInterfaceEnabled()) return;
                if (!this.opened()) {
                    this.open();
                }
            }));

            this.search.attr("tabindex", this.elementTabIndex);

            this.keydowns = 0;
            this.search.on("keydown", this.bind(function (e) {
                if (!this.isInterfaceEnabled()) return;

                ++this.keydowns;
                var selected = selection.find(".select2-search-choice-focus");
                var prev = selected.prev(".select2-search-choice:not(.select2-locked)");
                var next = selected.next(".select2-search-choice:not(.select2-locked)");
                var pos = getCursorInfo(this.search);

                if (selected.length &&
                    (e.which == KEY.LEFT || e.which == KEY.RIGHT || e.which == KEY.BACKSPACE || e.which == KEY.DELETE || e.which == KEY.ENTER)) {
                    var selectedChoice = selected;
                    if (e.which == KEY.LEFT && prev.length) {
                        selectedChoice = prev;
                    }
                    else if (e.which == KEY.RIGHT) {
                        selectedChoice = next.length ? next : null;
                    }
                    else if (e.which === KEY.BACKSPACE) {
                        if (this.unselect(selected.first())) {
                            this.search.width(10);
                            selectedChoice = prev.length ? prev : next;
                        }
                    } else if (e.which == KEY.DELETE) {
                        if (this.unselect(selected.first())) {
                            this.search.width(10);
                            selectedChoice = next.length ? next : null;
                        }
                    } else if (e.which == KEY.ENTER) {
                        selectedChoice = null;
                    }

                    this.selectChoice(selectedChoice);
                    killEvent(e);
                    if (!selectedChoice || !selectedChoice.length) {
                        this.open();
                    }
                    return;
                } else if (((e.which === KEY.BACKSPACE && this.keydowns == 1)
                    || e.which == KEY.LEFT) && (pos.offset == 0 && !pos.length)) {

                    this.selectChoice(selection.find(".select2-search-choice:not(.select2-locked)").last());
                    killEvent(e);
                    return;
                } else {
                    this.selectChoice(null);
                }

                if (this.opened()) {
                    switch (e.which) {
                    case KEY.UP:
                    case KEY.DOWN:
                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
                        killEvent(e);
                        return;
                    case KEY.ENTER:
                        this.selectHighlighted();
                        killEvent(e);
                        return;
                    case KEY.TAB:
                        this.selectHighlighted({noFocus:true});
                        this.close();
                        return;
                    case KEY.ESC:
                        this.cancel(e);
                        killEvent(e);
                        return;
                    }
                }

                if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e)
                 || e.which === KEY.BACKSPACE || e.which === KEY.ESC) {
                    return;
                }

                if (e.which === KEY.ENTER) {
                    if (this.opts.openOnEnter === false) {
                        return;
                    } else if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
                        return;
                    }
                }

                this.open();

                if (e.which === KEY.PAGE_UP || e.which === KEY.PAGE_DOWN) {
                    // prevent the page from scrolling
                    killEvent(e);
                }

                if (e.which === KEY.ENTER) {
                    // prevent form from being submitted
                    killEvent(e);
                }

            }));

            this.search.on("keyup", this.bind(function (e) {
                this.keydowns = 0;
                this.resizeSearch();
            })
            );

            this.search.on("blur", this.bind(function(e) {
                this.container.removeClass("select2-container-active");
                this.search.removeClass("select2-focused");
                this.selectChoice(null);
                if (!this.opened()) this.clearSearch();
                e.stopImmediatePropagation();
                this.opts.element.trigger($.Event("select2-blur"));
            }));

            this.container.on("click", selector, this.bind(function (e) {
                if (!this.isInterfaceEnabled()) return;
                if ($(e.target).closest(".select2-search-choice").length > 0) {
                    // clicked inside a select2 search choice, do not open
                    return;
                }
                this.selectChoice(null);
                this.clearPlaceholder();
                if (!this.container.hasClass("select2-container-active")) {
                    this.opts.element.trigger($.Event("select2-focus"));
                }
                this.open();
                this.focusSearch();
                e.preventDefault();
            }));

            this.container.on("focus", selector, this.bind(function () {
                if (!this.isInterfaceEnabled()) return;
                if (!this.container.hasClass("select2-container-active")) {
                    this.opts.element.trigger($.Event("select2-focus"));
                }
                this.container.addClass("select2-container-active");
                this.dropdown.addClass("select2-drop-active");
                this.clearPlaceholder();
            }));

            this.initContainerWidth();
            this.opts.element.addClass("select2-offscreen");

            // set the placeholder if necessary
            this.clearSearch();
        },

        // multi
        enableInterface: function() {
            if (this.parent.enableInterface.apply(this, arguments)) {
                this.search.prop("disabled", !this.isInterfaceEnabled());
            }
        },

        // multi
        initSelection: function () {
            var data;
            if (this.opts.element.val() === "" && this.opts.element.text() === "") {
                this.updateSelection([]);
                this.close();
                // set the placeholder if necessary
                this.clearSearch();
            }
            if (this.select || this.opts.element.val() !== "") {
                var self = this;
                this.opts.initSelection.call(null, this.opts.element, function(data){
                    if (data !== undefined && data !== null) {
                        self.updateSelection(data);
                        self.close();
                        // set the placeholder if necessary
                        self.clearSearch();
                    }
                });
            }
        },

        // multi
        clearSearch: function () {
            var placeholder = this.getPlaceholder(),
                maxWidth = this.getMaxSearchWidth();

            if (placeholder !== undefined  && this.getVal().length === 0 && this.search.hasClass("select2-focused") === false) {
                this.search.val(placeholder).addClass("select2-default");
                // stretch the search box to full width of the container so as much of the placeholder is visible as possible
                // we could call this.resizeSearch(), but we do not because that requires a sizer and we do not want to create one so early because of a firefox bug, see #944
                this.search.width(maxWidth > 0 ? maxWidth : this.container.css("width"));
            } else {
                this.search.val("").width(10);
            }
        },

        // multi
        clearPlaceholder: function () {
            if (this.search.hasClass("select2-default")) {
                this.search.val("").removeClass("select2-default");
            }
        },

        // multi
        opening: function () {
            this.clearPlaceholder(); // should be done before super so placeholder is not used to search
            this.resizeSearch();

            this.parent.opening.apply(this, arguments);

            this.focusSearch();

            // initializes search's value with nextSearchTerm (if defined by user)
            // ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
            if(this.search.val() === "") {
                if(this.nextSearchTerm != undefined){
                    this.search.val(this.nextSearchTerm);
                    this.search.select();
                }
            }

            this.updateResults(true);
            if (this.opts.shouldFocusInput(this)) {
                this.search.focus();
            }
            this.opts.element.trigger($.Event("select2-open"));
        },

        // multi
        close: function () {
            if (!this.opened()) return;
            this.parent.close.apply(this, arguments);
        },

        // multi
        focus: function () {
            this.close();
            this.search.focus();
        },

        // multi
        isFocused: function () {
            return this.search.hasClass("select2-focused");
        },

        // multi
        updateSelection: function (data) {
            var ids = [], filtered = [], self = this;

            // filter out duplicates
            $(data).each(function () {
                if (indexOf(self.id(this), ids) < 0) {
                    ids.push(self.id(this));
                    filtered.push(this);
                }
            });
            data = filtered;

            this.selection.find(".select2-search-choice").remove();
            $(data).each(function () {
                self.addSelectedChoice(this);
            });
            self.postprocessResults();
        },

        // multi
        tokenize: function() {
            var input = this.search.val();
            input = this.opts.tokenizer.call(this, input, this.data(), this.bind(this.onSelect), this.opts);
            if (input != null && input != undefined) {
                this.search.val(input);
                if (input.length > 0) {
                    this.open();
                }
            }

        },

        // multi
        onSelect: function (data, options) {

            if (!this.triggerSelect(data)) { return; }

            this.addSelectedChoice(data);

            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });

            // keep track of the search's value before it gets cleared
            this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());

            this.clearSearch();
            this.updateResults();

            if (this.select || !this.opts.closeOnSelect) this.postprocessResults(data, false, this.opts.closeOnSelect===true);

            if (this.opts.closeOnSelect) {
                this.close();
                this.search.width(10);
            } else {
                if (this.countSelectableResults()>0) {
                    this.search.width(10);
                    this.resizeSearch();
                    if (this.getMaximumSelectionSize() > 0 && this.val().length >= this.getMaximumSelectionSize()) {
                        // if we reached max selection size repaint the results so choices
                        // are replaced with the max selection reached message
                        this.updateResults(true);
                    } else {
                        // initializes search's value with nextSearchTerm and update search result
                        if(this.nextSearchTerm != undefined){
                            this.search.val(this.nextSearchTerm);
                            this.updateResults();
                            this.search.select();
                        }
                    }
                    this.positionDropdown();
                } else {
                    // if nothing left to select close
                    this.close();
                    this.search.width(10);
                }
            }

            // since its not possible to select an element that has already been
            // added we do not need to check if this is a new element before firing change
            this.triggerChange({ added: data });

            if (!options || !options.noFocus)
                this.focusSearch();
        },

        // multi
        cancel: function () {
            this.close();
            this.focusSearch();
        },

        addSelectedChoice: function (data) {
            var enableChoice = !data.locked,
                enabledItem = $(
                    "<li class='select2-search-choice'>" +
                    "    <div></div>" +
                    "    <a href='#' class='select2-search-choice-close' tabindex='-1'></a>" +
                    "</li>"),
                disabledItem = $(
                    "<li class='select2-search-choice select2-locked'>" +
                    "<div></div>" +
                    "</li>");
            var choice = enableChoice ? enabledItem : disabledItem,
                id = this.id(data),
                val = this.getVal(),
                formatted,
                cssClass;

            formatted=this.opts.formatSelection(data, choice.find("div"), this.opts.escapeMarkup);
            if (formatted != undefined) {
                choice.find("div").replaceWith("<div>"+formatted+"</div>");
            }
            cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
            if (cssClass != undefined) {
                choice.addClass(cssClass);
            }

            if(enableChoice){
              choice.find(".select2-search-choice-close")
                  .on("mousedown", killEvent)
                  .on("click dblclick", this.bind(function (e) {
                  if (!this.isInterfaceEnabled()) return;

                  this.unselect($(e.target));
                  this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");
                  killEvent(e);
                  this.close();
                  this.focusSearch();
              })).on("focus", this.bind(function () {
                  if (!this.isInterfaceEnabled()) return;
                  this.container.addClass("select2-container-active");
                  this.dropdown.addClass("select2-drop-active");
              }));
            }

            choice.data("select2-data", data);
            choice.insertBefore(this.searchContainer);

            val.push(id);
            this.setVal(val);
        },

        // multi
        unselect: function (selected) {
            var val = this.getVal(),
                data,
                index;
            selected = selected.closest(".select2-search-choice");

            if (selected.length === 0) {
                throw "Invalid argument: " + selected + ". Must be .select2-search-choice";
            }

            data = selected.data("select2-data");

            if (!data) {
                // prevent a race condition when the 'x' is clicked really fast repeatedly the event can be queued
                // and invoked on an element already removed
                return;
            }

            var evt = $.Event("select2-removing");
            evt.val = this.id(data);
            evt.choice = data;
            this.opts.element.trigger(evt);

            if (evt.isDefaultPrevented()) {
                return false;
            }

            while((index = indexOf(this.id(data), val)) >= 0) {
                val.splice(index, 1);
                this.setVal(val);
                if (this.select) this.postprocessResults();
            }

            selected.remove();

            this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
            this.triggerChange({ removed: data });

            return true;
        },

        // multi
        postprocessResults: function (data, initial, noHighlightUpdate) {
            var val = this.getVal(),
                choices = this.results.find(".select2-result"),
                compound = this.results.find(".select2-result-with-children"),
                self = this;

            choices.each2(function (i, choice) {
                var id = self.id(choice.data("select2-data"));
                if (indexOf(id, val) >= 0) {
                    // display the selected sports and teams for attendance dropdown
                    if (choice.data("select2-data").disabled !== true) {
                        choice.addClass("select2-selected");
                    }
                    // mark all children of the selected parent as selected
                    choice.find(".select2-result-selectable").addClass("select2-selected");
                }
            });

            compound.each2(function(i, choice) {
                // hide an optgroup if it doesn't have any selectable children
                if (!choice.is('.select2-result-selectable')
                    && choice.find(".select2-result-selectable:not(.select2-selected)").length === 0) {
                    choice.addClass("select2-selected");
                }
            });

            if (this.highlight() == -1 && noHighlightUpdate !== false){
                self.highlight(0);
            }

            //If all results are chosen render formatNoMatches
            if(!this.opts.createSearchChoice && !choices.filter('.select2-result:not(.select2-selected)').length > 0){
                if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) {
                    if (checkFormatter(self.opts.formatNoMatches, "formatNoMatches")) {
                        this.results.append("<li class='select2-no-results'>" + evaluate(self.opts.formatNoMatches, self.search.val()) + "</li>");
                    }
                }
            }

        },

        // multi
        getMaxSearchWidth: function() {
            return this.selection.width() - getSideBorderPadding(this.search);
        },

        // multi
        resizeSearch: function () {
            var minimumWidth, left, maxWidth, containerLeft, searchWidth,
                sideBorderPadding = getSideBorderPadding(this.search);

            minimumWidth = measureTextWidth(this.search) + 10;

            left = this.search.offset().left;

            maxWidth = this.selection.width();
            containerLeft = this.selection.offset().left;

            searchWidth = maxWidth - (left - containerLeft) - sideBorderPadding;

            if (searchWidth < minimumWidth) {
                searchWidth = maxWidth - sideBorderPadding;
            }

            if (searchWidth < 40) {
                searchWidth = maxWidth - sideBorderPadding;
            }

            if (searchWidth <= 0) {
              searchWidth = minimumWidth;
            }

            this.search.width(Math.floor(searchWidth));
        },

        // multi
        getVal: function () {
            var val;
            if (this.select) {
                val = this.select.val();
                return val === null ? [] : val;
            } else {
                val = this.opts.element.val();
                return splitVal(val, this.opts.separator);
            }
        },

        // multi
        setVal: function (val) {
            var unique;
            if (this.select) {
                this.select.val(val);
            } else {
                unique = [];
                // filter out duplicates
                $(val).each(function () {
                    if (indexOf(this, unique) < 0) unique.push(this);
                });
                this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator));
            }
        },

        // multi
        buildChangeDetails: function (old, current) {
            var current = current.slice(0),
                old = old.slice(0);

            // remove intersection from each array
            for (var i = 0; i < current.length; i++) {
                for (var j = 0; j < old.length; j++) {
                    if (equal(this.opts.id(current[i]), this.opts.id(old[j]))) {
                        current.splice(i, 1);
                        if(i>0){
                        	i--;
                        }
                        old.splice(j, 1);
                        j--;
                    }
                }
            }

            return {added: current, removed: old};
        },


        // multi
        val: function (val, triggerChange) {
            var oldData, self=this;

            if (arguments.length === 0) {
                return this.getVal();
            }

            oldData=this.data();
            if (!oldData.length) oldData=[];

            // val is an id. !val is true for [undefined,null,'',0] - 0 is legal
            if (!val && val !== 0) {
                this.opts.element.val("");
                this.updateSelection([]);
                this.clearSearch();
                if (triggerChange) {
                    this.triggerChange({added: this.data(), removed: oldData});
                }
                return;
            }

            // val is a list of ids
            this.setVal(val);

            if (this.select) {
                this.opts.initSelection(this.select, this.bind(this.updateSelection));
                if (triggerChange) {
                    this.triggerChange(this.buildChangeDetails(oldData, this.data()));
                }
            } else {
                if (this.opts.initSelection === undefined) {
                    throw new Error("val() cannot be called if initSelection() is not defined");
                }

                this.opts.initSelection(this.opts.element, function(data){
                    var ids=$.map(data, self.id);
                    self.setVal(ids);
                    self.updateSelection(data);
                    self.clearSearch();
                    if (triggerChange) {
                        self.triggerChange(self.buildChangeDetails(oldData, self.data()));
                    }
                });
            }
            this.clearSearch();
        },

        // multi
        onSortStart: function() {
            if (this.select) {
                throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");
            }

            // collapse search field into 0 width so its container can be collapsed as well
            this.search.width(0);
            // hide the container
            this.searchContainer.hide();
        },

        // multi
        onSortEnd:function() {

            var val=[], self=this;

            // show search and move it to the end of the list
            this.searchContainer.show();
            // make sure the search container is the last item in the list
            this.searchContainer.appendTo(this.searchContainer.parent());
            // since we collapsed the width in dragStarted, we resize it here
            this.resizeSearch();

            // update selection
            this.selection.find(".select2-search-choice").each(function() {
                val.push(self.opts.id($(this).data("select2-data")));
            });
            this.setVal(val);
            this.triggerChange();
        },

        // multi
        data: function(values, triggerChange) {
            var self=this, ids, old;
            if (arguments.length === 0) {
                 return this.selection
                     .children(".select2-search-choice")
                     .map(function() { return $(this).data("select2-data"); })
                     .get();
            } else {
                old = this.data();
                if (!values) { values = []; }
                ids = $.map(values, function(e) { return self.opts.id(e); });
                this.setVal(ids);
                this.updateSelection(values);
                this.clearSearch();
                if (triggerChange) {
                    this.triggerChange(this.buildChangeDetails(old, this.data()));
                }
            }
        }
    });

    $.fn.select2 = function () {

        var args = Array.prototype.slice.call(arguments, 0),
            opts,
            select2,
            method, value, multiple,
            allowedMethods = ["val", "destroy", "opened", "open", "close", "focus", "isFocused", "container", "dropdown", "onSortStart", "onSortEnd", "enable", "disable", "readonly", "positionDropdown", "data", "search"],
            valueMethods = ["opened", "isFocused", "container", "dropdown"],
            propertyMethods = ["val", "data"],
            methodsMap = { search: "externalSearch" };

        this.each(function () {
            if (args.length === 0 || typeof(args[0]) === "object") {
                opts = args.length === 0 ? {} : $.extend({}, args[0]);
                opts.element = $(this);

                if (opts.element.get(0).tagName.toLowerCase() === "select") {
                    multiple = opts.element.prop("multiple");
                } else {
                    multiple = opts.multiple || false;
                    if ("tags" in opts) {opts.multiple = multiple = true;}
                }

                select2 = multiple ? new window.Select2["class"].multi() : new window.Select2["class"].single();
                select2.init(opts);
            } else if (typeof(args[0]) === "string") {

                if (indexOf(args[0], allowedMethods) < 0) {
                    throw "Unknown method: " + args[0];
                }

                value = undefined;
                select2 = $(this).data("select2");
                if (select2 === undefined) return;

                method=args[0];

                if (method === "container") {
                    value = select2.container;
                } else if (method === "dropdown") {
                    value = select2.dropdown;
                } else {
                    if (methodsMap[method]) method = methodsMap[method];

                    value = select2[method].apply(select2, args.slice(1));
                }
                if (indexOf(args[0], valueMethods) >= 0
                    || (indexOf(args[0], propertyMethods) >= 0 && args.length == 1)) {
                    return false; // abort the iteration, ready to return first matched value
                }
            } else {
                throw "Invalid arguments to select2 plugin: " + args;
            }
        });
        return (value === undefined) ? this : value;
    };

    // plugin defaults, accessible to users
    $.fn.select2.defaults = {
        width: "copy",
        loadMorePadding: 0,
        closeOnSelect: true,
        openOnEnter: true,
        containerCss: {},
        dropdownCss: {},
        containerCssClass: "",
        dropdownCssClass: "",
        formatResult: function(result, container, query, escapeMarkup) {
            var markup=[];
            markMatch(result.text, query.term, markup, escapeMarkup);
            return markup.join("");
        },
        formatSelection: function (data, container, escapeMarkup) {
            return data ? escapeMarkup(data.text) : undefined;
        },
        sortResults: function (results, container, query) {
            return results;
        },
        formatResultCssClass: function(data) {return data.css;},
        formatSelectionCssClass: function(data, container) {return undefined;},
        formatMatches: function (matches) { return matches + " results are available, use up and down arrow keys to navigate."; },
        formatNoMatches: function () { return "No matches found"; },
        formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1? "" : "s"); },
        formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); },
        formatSelectionTooBig: function (limit) { return "You can only select " + limit + " item" + (limit == 1 ? "" : "s"); },
        formatLoadMore: function (pageNumber) { return "Loading more results…"; },
        formatSearching: function () { return "Searching…"; },
        minimumResultsForSearch: 0,
        minimumInputLength: 0,
        maximumInputLength: null,
        maximumSelectionSize: 0,
        id: function (e) { return e == undefined ? null : e.id; },
        matcher: function(term, text) {
            return stripDiacritics(''+text).toUpperCase().indexOf(stripDiacritics(''+term).toUpperCase()) >= 0;
        },
        separator: ",",
        tokenSeparators: [],
        tokenizer: defaultTokenizer,
        escapeMarkup: defaultEscapeMarkup,
        blurOnChange: false,
        selectOnBlur: false,
        adaptContainerCssClass: function(c) { return c; },
        adaptDropdownCssClass: function(c) { return null; },
        nextSearchTerm: function(selectedObject, currentSearchTerm) { return undefined; },
        searchInputPlaceholder: '',
        createSearchChoicePosition: 'top',
        shouldFocusInput: function (instance) {
            // Attempt to detect touch devices
            var supportsTouchEvents = (('ontouchstart' in window) ||
                                       (navigator.msMaxTouchPoints > 0));

            // Only devices which support touch events should be special cased
            if (!supportsTouchEvents) {
                return true;
            }

            // Never focus the input if search is disabled
            if (instance.opts.minimumResultsForSearch < 0) {
                return false;
            }

            return true;
        }
    };

    $.fn.select2.ajaxDefaults = {
        transport: $.ajax,
        params: {
            type: "GET",
            cache: false,
            dataType: "json"
        }
    };

    // exports
    window.Select2 = {
        query: {
            ajax: ajax,
            local: local,
            tags: tags
        }, util: {
            debounce: debounce,
            markMatch: markMatch,
            escapeMarkup: defaultEscapeMarkup,
            stripDiacritics: stripDiacritics
        }, "class": {
            "abstract": AbstractSelect2,
            "single": SingleSelect2,
            "multi": MultiSelect2
        }
    };

}(jQuery));
/*
 * DOMParser HTML extension
 * 2012-09-04
 * 
 * By Eli Grey, http://eligrey.com
 * Public domain.
 * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
 */

/*! @source https://gist.github.com/1129031 */
/*global document, DOMParser*/

if (window.DOMParser !== undefined) {
  (function(DOMParser) {
    "use strict";
  
    var
      DOMParser_proto = DOMParser.prototype
    , real_parseFromString = DOMParser_proto.parseFromString
    ;
  
    // Firefox/Opera/IE throw errors on unsupported types
    try {
      // WebKit returns null on unsupported types
      if ((new DOMParser).parseFromString("", "text/html")) {
        // text/html parsing is natively supported
        return;
      }
    } catch (ex) {}
  
    DOMParser_proto.parseFromString = function(markup, type) {
      if (/^\s*text\/html\s*(?:;|$)/i.test(type)) {
        var
          doc = document.implementation.createHTMLDocument("")
        ;
              if (markup.toLowerCase().indexOf('<!doctype') > -1) {
                doc.documentElement.innerHTML = markup;
              }
              else {
                doc.body.innerHTML = markup;
              }
        return doc;
      } else {
        return real_parseFromString.apply(this, arguments);
      }
    };
  }(DOMParser));
};
/*!
* inputmask.js
* https://github.com/RobinHerbots/jquery.inputmask
* Copyright (c) 2010 - 2016 Robin Herbots
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
* Version: 3.3.3
*/
!function(factory) {
    "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
}(function($) {
    function Inputmask(alias, options) {
        return this instanceof Inputmask ? ($.isPlainObject(alias) ? options = alias : (options = options || {}, 
        options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options), 
        this.noMasksCache = options && void 0 !== options.definitions, this.userOptions = options || {}, 
        this.events = {}, void resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
    }
    function isInputEventSupported(eventName) {
        var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
        return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]), 
        el = null, isSupported;
    }
    function isElementTypeSupported(input, opts) {
        var elementType = input.getAttribute("type"), isSupported = "INPUT" === input.tagName && $.inArray(elementType, opts.supportsInputType) !== -1 || input.isContentEditable || "TEXTAREA" === input.tagName;
        if (!isSupported && "INPUT" === input.tagName) {
            var el = document.createElement("input");
            el.setAttribute("type", elementType), isSupported = "text" === el.type, el = null;
        }
        return isSupported;
    }
    function resolveAlias(aliasStr, options, opts) {
        var aliasDefinition = opts.aliases[aliasStr];
        return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts), 
        $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr), 
        !1);
    }
    function importAttributeOptions(npt, opts, userOptions) {
        function importOption(option, optionData) {
            optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option), 
            null !== optionData && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)), 
            userOptions[option] = optionData);
        }
        var option, dataoptions, optionData, p, attrOptions = npt.getAttribute("data-inputmask");
        if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'), 
        dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
            optionData = void 0;
            for (p in dataoptions) if ("alias" === p.toLowerCase()) {
                optionData = dataoptions[p];
                break;
            }
        }
        importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
        for (option in opts) {
            if (dataoptions) {
                optionData = void 0;
                for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
                    optionData = dataoptions[p];
                    break;
                }
            }
            importOption(option, optionData);
        }
        return $.extend(!0, opts, userOptions), opts;
    }
    function generateMaskSet(opts, nocache) {
        function analyseMask(mask) {
            function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
                this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1, 
                this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1, 
                this.quantifier = {
                    min: 1,
                    max: 1
                };
            }
            function insertTestDefinition(mtoken, element, position) {
                var maskdef = opts.definitions[element];
                position = void 0 !== position ? position : mtoken.matches.length;
                var prevMatch = mtoken.matches[position - 1];
                if (maskdef && !escaped) {
                    maskdef.placeholder = $.isFunction(maskdef.placeholder) ? maskdef.placeholder(opts) : maskdef.placeholder;
                    for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
                        var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
                        mtoken.matches.splice(position++, 0, {
                            fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
                                this.test = validator;
                            }() : new RegExp("."),
                            cardinality: cardinality ? cardinality : 1,
                            optionality: mtoken.isOptional,
                            newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
                            casing: maskdef.casing,
                            def: maskdef.definitionSymbol || element,
                            placeholder: maskdef.placeholder,
                            mask: element
                        }), prevMatch = mtoken.matches[position - 1];
                    }
                    mtoken.matches.splice(position++, 0, {
                        fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
                            this.test = maskdef.validator;
                        }() : new RegExp("."),
                        cardinality: maskdef.cardinality,
                        optionality: mtoken.isOptional,
                        newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
                        casing: maskdef.casing,
                        def: maskdef.definitionSymbol || element,
                        placeholder: maskdef.placeholder,
                        mask: element
                    });
                } else mtoken.matches.splice(position++, 0, {
                    fn: null,
                    cardinality: 0,
                    optionality: mtoken.isOptional,
                    newBlockMarker: void 0 === prevMatch || prevMatch.def !== element,
                    casing: null,
                    def: opts.staticDefinitionSymbol || element,
                    placeholder: void 0 !== opts.staticDefinitionSymbol ? element : void 0,
                    mask: element
                }), escaped = !1;
            }
            function verifyGroupMarker(lastMatch, isOpenGroup) {
                lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0), 
                isOpenGroup !== !0 && insertTestDefinition(lastMatch, opts.groupmarker.end));
            }
            function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
                currentToken.matches.length > 0 && (void 0 === extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
                verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
            }
            function defaultCase() {
                if (openenings.length > 0) {
                    if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator), 
                    currentOpeningToken.isAlternator) {
                        alternator = openenings.pop();
                        for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
                        openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1], 
                        currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
                    }
                } else maskCurrentToken(m, currentToken, lastMatch);
            }
            function reverseTokens(maskToken) {
                function reverseStatic(st) {
                    return st === opts.optionalmarker.start ? st = opts.optionalmarker.end : st === opts.optionalmarker.end ? st = opts.optionalmarker.start : st === opts.groupmarker.start ? st = opts.groupmarker.end : st === opts.groupmarker.end && (st = opts.groupmarker.start), 
                    st;
                }
                maskToken.matches = maskToken.matches.reverse();
                for (var match in maskToken.matches) {
                    var intMatch = parseInt(match);
                    if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
                        var qt = maskToken.matches[match];
                        maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
                    }
                    void 0 !== maskToken.matches[match].matches ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
                }
                return maskToken;
            }
            for (var match, m, openingToken, currentOpeningToken, alternator, lastMatch, groupToken, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g, escaped = !1, currentToken = new MaskToken(), openenings = [], maskTokens = []; match = tokenizer.exec(mask); ) if (m = match[0], 
            escaped) defaultCase(); else switch (m.charAt(0)) {
              case opts.escapeChar:
                escaped = !0;
                break;

              case opts.optionalmarker.end:
              case opts.groupmarker.end:
                if (openingToken = openenings.pop(), void 0 !== openingToken) if (openenings.length > 0) {
                    if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken), 
                    currentOpeningToken.isAlternator) {
                        alternator = openenings.pop();
                        for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
                        openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1], 
                        currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
                    }
                } else currentToken.matches.push(openingToken); else defaultCase();
                break;

              case opts.optionalmarker.start:
                openenings.push(new MaskToken((!1), (!0)));
                break;

              case opts.groupmarker.start:
                openenings.push(new MaskToken((!0)));
                break;

              case opts.quantifiermarker.start:
                var quantifier = new MaskToken((!1), (!1), (!0));
                m = m.replace(/[{}]/g, "");
                var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
                if ("*" !== mq1 && "+" !== mq1 || (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
                    min: mq0,
                    max: mq1
                }, openenings.length > 0) {
                    var matches = openenings[openenings.length - 1].matches;
                    match = matches.pop(), match.isGroup || (groupToken = new MaskToken((!0)), groupToken.matches.push(match), 
                    match = groupToken), matches.push(match), matches.push(quantifier);
                } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken((!0)), 
                groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match), 
                currentToken.matches.push(quantifier);
                break;

              case opts.alternatormarker:
                openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1], 
                lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(), 
                lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken((!1), (!1), (!1), (!0)), 
                alternator.matches.push(lastMatch), openenings.push(alternator));
                break;

              default:
                defaultCase();
            }
            for (;openenings.length > 0; ) openingToken = openenings.pop(), verifyGroupMarker(openingToken, !0), 
            currentToken.matches.push(openingToken);
            return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
            verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), opts.numericInput && reverseTokens(maskTokens[0]), 
            maskTokens;
        }
        function generateMask(mask, metadata) {
            if (null !== mask && "" !== mask) {
                if (1 === mask.length && opts.greedy === !1 && 0 !== opts.repeat && (opts.placeholder = ""), 
                opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) {
                    var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat;
                    mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
                }
                var masksetDefinition;
                return void 0 === Inputmask.prototype.masksCache[mask] || nocache === !0 ? (masksetDefinition = {
                    mask: mask,
                    maskToken: analyseMask(mask),
                    validPositions: {},
                    _buffer: void 0,
                    buffer: void 0,
                    tests: {},
                    metadata: metadata,
                    maskLength: void 0
                }, nocache !== !0 && (Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask] = masksetDefinition, 
                masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]))) : masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]), 
                masksetDefinition;
            }
        }
        function preProcessMask(mask) {
            return mask = mask.toString();
        }
        var ms;
        if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) {
            if (opts.mask.length > 1) {
                opts.keepStatic = null === opts.keepStatic || opts.keepStatic;
                var altMask = "(";
                return $.each(opts.numericInput ? opts.mask.reverse() : opts.mask, function(ndx, msk) {
                    altMask.length > 1 && (altMask += ")|("), altMask += preProcessMask(void 0 === msk.mask || $.isFunction(msk.mask) ? msk : msk.mask);
                }), altMask += ")", generateMask(altMask, opts.mask);
            }
            opts.mask = opts.mask.pop();
        }
        return opts.mask && (ms = void 0 === opts.mask.mask || $.isFunction(opts.mask.mask) ? generateMask(preProcessMask(opts.mask), opts.mask) : generateMask(preProcessMask(opts.mask.mask), opts.mask)), 
        ms;
    }
    function maskScope(actionObj, maskset, opts) {
        function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
            minimalPos = minimalPos || 0;
            var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0, lvp = getLastValidPosition();
            maxLength = void 0 !== el ? el.maxLength : void 0, maxLength === -1 && (maxLength = void 0);
            do {
                if (baseOnInput === !0 && getMaskSet().validPositions[pos]) {
                    var validPos = getMaskSet().validPositions[pos];
                    test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
                } else testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), test = testPos.match, 
                ndxIntlzr = testPos.locator.slice(), (opts.jitMasking === !1 || pos < lvp || isFinite(opts.jitMasking) && opts.jitMasking > pos) && maskTemplate.push(getPlaceholder(pos, test));
                pos++;
            } while ((void 0 === maxLength || pos < maxLength) && (null !== test.fn || "" !== test.def) || minimalPos > pos);
            return "" === maskTemplate[maskTemplate.length - 1] && maskTemplate.pop(), getMaskSet().maskLength = pos + 1, 
            maskTemplate;
        }
        function getMaskSet() {
            return maskset;
        }
        function resetMaskSet(soft) {
            var maskset = getMaskSet();
            maskset.buffer = void 0, soft !== !0 && (maskset._buffer = void 0, maskset.validPositions = {}, 
            maskset.p = 0);
        }
        function getLastValidPosition(closestTo, strict, validPositions) {
            var before = -1, after = -1, valids = validPositions || getMaskSet().validPositions;
            void 0 === closestTo && (closestTo = -1);
            for (var posNdx in valids) {
                var psNdx = parseInt(posNdx);
                valids[psNdx] && (strict || null !== valids[psNdx].match.fn) && (psNdx <= closestTo && (before = psNdx), 
                psNdx >= closestTo && (after = psNdx));
            }
            return before !== -1 && closestTo - before > 1 || after < closestTo ? before : after;
        }
        function stripValidPositions(start, end, nocheck, strict) {
            function IsEnclosedStatic(pos) {
                var posMatch = getMaskSet().validPositions[pos];
                if (void 0 !== posMatch && null === posMatch.match.fn) {
                    var prevMatch = getMaskSet().validPositions[pos - 1], nextMatch = getMaskSet().validPositions[pos + 1];
                    return void 0 !== prevMatch && void 0 !== nextMatch;
                }
                return !1;
            }
            var i, startPos = start, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), needsValidation = !1;
            for (getMaskSet().p = start, i = end - 1; i >= startPos; i--) void 0 !== getMaskSet().validPositions[i] && (nocheck === !0 || !IsEnclosedStatic(i) && opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts) !== !1) && delete getMaskSet().validPositions[i];
            for (resetMaskSet(!0), i = startPos + 1; i <= getLastValidPosition(); ) {
                for (;void 0 !== getMaskSet().validPositions[startPos]; ) startPos++;
                var s = getMaskSet().validPositions[startPos];
                if (i < startPos && (i = startPos + 1), void 0 === getMaskSet().validPositions[i] && isMask(i) || void 0 !== s) i++; else {
                    var t = getTestTemplate(i);
                    needsValidation === !1 && positionsClone[startPos] && positionsClone[startPos].match.def === t.match.def ? (getMaskSet().validPositions[startPos] = $.extend(!0, {}, positionsClone[startPos]), 
                    getMaskSet().validPositions[startPos].input = t.input, delete getMaskSet().validPositions[i], 
                    i++) : positionCanMatchDefinition(startPos, t.match.def) ? isValid(startPos, t.input || getPlaceholder(i), !0) !== !1 && (delete getMaskSet().validPositions[i], 
                    i++, needsValidation = !0) : isMask(i) || (i++, startPos--), startPos++;
                }
            }
            resetMaskSet(!0);
        }
        function determineTestTemplate(tests, guessNextBest) {
            for (var testPos, testPositions = tests, lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0], lvTestAltArr = void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation].toString().split(",") : [], ndx = 0; ndx < testPositions.length && (testPos = testPositions[ndx], 
            !(testPos.match && (opts.greedy && testPos.match.optionalQuantifier !== !0 || (testPos.match.optionality === !1 || testPos.match.newBlockMarker === !1) && testPos.match.optionalQuantifier !== !0) && (void 0 === lvTest.alternation || lvTest.alternation !== testPos.alternation || void 0 !== testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr))) || guessNextBest === !0 && (null !== testPos.match.fn || /[0-9a-bA-Z]/.test(testPos.match.def))); ndx++) ;
            return testPos;
        }
        function getTestTemplate(pos, ndxIntlzr, tstPs) {
            return getMaskSet().validPositions[pos] || determineTestTemplate(getTests(pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs));
        }
        function getTest(pos) {
            return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos] : getTests(pos)[0];
        }
        function positionCanMatchDefinition(pos, def) {
            for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) {
                valid = !0;
                break;
            }
            return valid;
        }
        function selectBestMatch(pos, alternateNdx) {
            var bestMatch, indexPos;
            return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) {
                var ndxPos = lmnt.alternation ? lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) : -1;
                (void 0 === indexPos || ndxPos < indexPos) && ndxPos !== -1 && (bestMatch = lmnt, 
                indexPos = ndxPos);
            }), bestMatch;
        }
        function getTests(pos, ndxIntlzr, tstPs) {
            function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
                function handleMatch(match, loopNdx, quantifierRecurse) {
                    function isFirstMatch(latestMatch, tokenGroup) {
                        var firstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches);
                        return firstMatch || $.each(tokenGroup.matches, function(ndx, match) {
                            if (match.isQuantifier === !0 && (firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]))) return !1;
                        }), firstMatch;
                    }
                    function resolveNdxInitializer(pos, alternateNdx) {
                        var bestMatch = selectBestMatch(pos, alternateNdx);
                        return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : void 0;
                    }
                    function staticCanMatchDefinition(source, target) {
                        return null === source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1);
                    }
                    if (testPos > 1e4) throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask;
                    if (testPos === pos && void 0 === match.matches) return matches.push({
                        match: match,
                        locator: loopNdx.reverse(),
                        cd: cacheDependency
                    }), !0;
                    if (void 0 !== match.matches) {
                        if (match.isGroup && quantifierRecurse !== match) {
                            if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
                        } else if (match.isOptional) {
                            var optionalToken = match;
                            if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
                                if (latestMatch = matches[matches.length - 1].match, !isFirstMatch(latestMatch, optionalToken)) return !0;
                                insertStop = !0, testPos = pos;
                            }
                        } else if (match.isAlternator) {
                            var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
                            if (altIndex === -1 || "string" == typeof altIndex) {
                                var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
                                if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
                                for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
                                    if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx) || ndxInitializerClone.slice(), 
                                    match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match, 
                                    match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
                                        var ntndx = $.inArray(match, maskToken.matches) + 1;
                                        maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse), 
                                        match && (altIndexArr.push(ntndx.toString()), $.each(matches, function(ndx, lmnt) {
                                            lmnt.alternation = loopNdx.length - 1;
                                        })));
                                    }
                                    maltMatches = matches.slice(), testPos = currentPos, matches = [];
                                    for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
                                        var altMatch = maltMatches[ndx1], hasMatch = !1;
                                        altMatch.alternation = altMatch.alternation || loopNdxCnt;
                                        for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
                                            var altMatch2 = malternateMatches[ndx2];
                                            if (("string" != typeof altIndex || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) && (altMatch.match.def === altMatch2.match.def || staticCanMatchDefinition(altMatch, altMatch2))) {
                                                hasMatch = altMatch.match.mask === altMatch2.match.mask, altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
                                                altMatch2.alternation = altMatch.alternation, null == altMatch.match.fn && (altMatch2.na = altMatch2.na || altMatch.locator[altMatch.alternation].toString(), 
                                                altMatch2.na.indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.na = altMatch2.na + "," + altMatch.locator[altMatch.alternation])));
                                                break;
                                            }
                                        }
                                        hasMatch || malternateMatches.push(altMatch);
                                    }
                                }
                                "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
                                    if (isFinite(ndx)) {
                                        var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
                                        lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
                                        for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = $.inArray(altLocArr[alndx], altIndexArr) !== -1, 
                                        mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",", 
                                        lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]), 
                                        lmnt.alternation = alternation);
                                        if (void 0 !== lmnt.locator[alternation]) return lmnt;
                                    }
                                })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, 
                                ndxInitializer = ndxInitializerClone.slice();
                            } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
                            if (match) return !0;
                        } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && testPos <= pos; qndx++) {
                            var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
                            if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
                                if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1, 
                                isFirstMatch(latestMatch, tokenGroup)) {
                                    if (qndx > qt.quantifier.min - 1) {
                                        insertStop = !0, testPos = pos;
                                        break;
                                    }
                                    return !0;
                                }
                                return !0;
                            }
                        } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
                    } else testPos++;
                }
                for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (maskToken.matches[tndx].isQuantifier !== !0) {
                    var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
                    if (match && testPos === pos) return match;
                    if (testPos > pos) break;
                }
            }
            function mergeLocators(tests) {
                var locator = [];
                return $.isArray(tests) || (tests = [ tests ]), tests.length > 0 && (void 0 === tests[0].alternation ? (locator = determineTestTemplate(tests.slice()).locator.slice(), 
                0 === locator.length && (locator = tests[0].locator.slice())) : $.each(tests, function(ndx, tst) {
                    if ("" !== tst.def) if (0 === locator.length) locator = tst.locator.slice(); else for (var i = 0; i < locator.length; i++) tst.locator[i] && locator[i].toString().indexOf(tst.locator[i]) === -1 && (locator[i] += "," + tst.locator[i]);
                })), locator;
            }
            function filterTests(tests) {
                return opts.keepStatic && pos > 0 && tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0) && tests[0].match.optionality !== !0 && tests[0].match.optionalQuantifier !== !0 && null === tests[0].match.fn && !/[0-9a-bA-Z]/.test(tests[0].match.def) ? [ determineTestTemplate(tests) ] : tests;
            }
            var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr ? ndxIntlzr.slice() : [ 0 ], matches = [], insertStop = !1, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "";
            if (pos > -1) {
                if (void 0 === ndxIntlzr) {
                    for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) && previousPos > -1; ) previousPos--;
                    void 0 !== test && previousPos > -1 && (ndxInitializer = mergeLocators(test), cacheDependency = ndxInitializer.join(""), 
                    testPos = previousPos);
                }
                if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) return filterTests(getMaskSet().tests[pos]);
                for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
                    var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
                    if (match && testPos === pos || testPos > pos) break;
                }
            }
            return (0 === matches.length || insertStop) && matches.push({
                match: {
                    fn: null,
                    cardinality: 0,
                    optionality: !0,
                    casing: null,
                    def: "",
                    placeholder: ""
                },
                locator: [],
                cd: cacheDependency
            }), void 0 !== ndxIntlzr && getMaskSet().tests[pos] ? filterTests($.extend(!0, [], matches)) : (getMaskSet().tests[pos] = $.extend(!0, [], matches), 
            filterTests(getMaskSet().tests[pos]));
        }
        function getBufferTemplate() {
            return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1), 
            void 0 === getMaskSet().buffer && getMaskSet()._buffer.slice()), getMaskSet()._buffer;
        }
        function getBuffer(noCache) {
            return void 0 !== getMaskSet().buffer && noCache !== !0 || (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)), 
            getMaskSet().buffer;
        }
        function refreshFromBuffer(start, end, buffer) {
            var i;
            if (start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; i < end; i++) delete getMaskSet().validPositions[i];
            for (i = start; i < end; i++) resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
        }
        function casing(elem, test, pos) {
            switch (opts.casing || test.casing) {
              case "upper":
                elem = elem.toUpperCase();
                break;

              case "lower":
                elem = elem.toLowerCase();
                break;

              case "title":
                var posBefore = getMaskSet().validPositions[pos - 1];
                elem = 0 === pos || posBefore && posBefore.input === String.fromCharCode(Inputmask.keyCode.SPACE) ? elem.toUpperCase() : elem.toLowerCase();
            }
            return elem;
        }
        function checkAlternationMatch(altArr1, altArr2) {
            for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if ($.inArray(altArr1[alndx], altArrC) !== -1) {
                isMatch = !0;
                break;
            }
            return isMatch;
        }
        function isValid(pos, c, strict, fromSetValid, fromAlternate) {
            function isSelection(posObj) {
                return isRTL ? posObj.begin - posObj.end > 1 || posObj.begin - posObj.end === 1 && opts.insertMode : posObj.end - posObj.begin > 1 || posObj.end - posObj.begin === 1 && opts.insertMode;
            }
            function _isValid(position, c, strict) {
                var rslt = !1;
                return $.each(getTests(position), function(ndx, tst) {
                    for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
                    if (c && (chrs += c), getBuffer(!0), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && "" !== test.def && {
                        c: test.placeholder || test.def,
                        pos: position
                    }, rslt !== !1) {
                        var elem = void 0 !== rslt.c ? rslt.c : c;
                        elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? test.placeholder || test.def : elem;
                        var validatedPos = position, possibleModifiedBuffer = getBuffer();
                        if (void 0 !== rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]), 
                        $.each(rslt.remove.sort(function(a, b) {
                            return b - a;
                        }), function(ndx, lmnt) {
                            stripValidPositions(lmnt, lmnt + 1, !0);
                        })), void 0 !== rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]), 
                        $.each(rslt.insert.sort(function(a, b) {
                            return a - b;
                        }), function(ndx, lmnt) {
                            isValid(lmnt.pos, lmnt.c, !1, fromSetValid);
                        })), rslt.refreshFromBuffer) {
                            var refresh = rslt.refreshFromBuffer;
                            if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer), 
                            void 0 === rslt.pos && void 0 === rslt.c) return rslt.pos = getLastValidPosition(), 
                            !1;
                            if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0, fromSetValid)), 
                            !1;
                        } else if (rslt !== !0 && void 0 !== rslt.pos && rslt.pos !== position && (validatedPos = rslt.pos, 
                        refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)), 
                        !1;
                        return (rslt === !0 || void 0 !== rslt.pos || void 0 !== rslt.c) && (ndx > 0 && resetMaskSet(!0), 
                        setValidPosition(validatedPos, $.extend({}, tst, {
                            input: casing(elem, test, validatedPos)
                        }), fromSetValid, isSelection(pos)) || (rslt = !1), !1);
                    }
                }), rslt;
            }
            function alternate(pos, c, strict) {
                var lastAlt, alternation, altPos, prevAltPos, i, validPos, altNdxs, decisionPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), isValidRslt = !1, lAltPos = getLastValidPosition();
                for (prevAltPos = getMaskSet().validPositions[lAltPos]; lAltPos >= 0; lAltPos--) if (altPos = getMaskSet().validPositions[lAltPos], 
                altPos && void 0 !== altPos.alternation) {
                    if (lastAlt = lAltPos, alternation = getMaskSet().validPositions[lastAlt].alternation, 
                    prevAltPos.locator[altPos.alternation] !== altPos.locator[altPos.alternation]) break;
                    prevAltPos = altPos;
                }
                if (void 0 !== alternation) {
                    decisionPos = parseInt(lastAlt);
                    var decisionTaker = void 0 !== prevAltPos.locator[prevAltPos.alternation || alternation] ? prevAltPos.locator[prevAltPos.alternation || alternation] : altNdxs[0];
                    decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
                    var possibilityPos = getMaskSet().validPositions[decisionPos], prevPos = getMaskSet().validPositions[decisionPos - 1];
                    $.each(getTests(decisionPos, prevPos ? prevPos.locator : void 0, decisionPos - 1), function(ndx, test) {
                        altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
                        for (var mndx = 0; mndx < altNdxs.length; mndx++) {
                            var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
                            if (decisionTaker < altNdxs[mndx] && (void 0 === test.na || $.inArray(altNdxs[mndx], test.na.split(",")) === -1)) {
                                getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
                                var possibilities = getMaskSet().validPositions[decisionPos].locator;
                                for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]), 
                                null == test.match.fn ? (possibilityPos.input !== test.match.def && (verifyValidInput = !0, 
                                possibilityPos.generatedInput !== !0 && validInputs.push(possibilityPos.input)), 
                                staticInputsBeforePosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !/[0-9a-bA-Z]/.test(test.match.def), 
                                getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input, 
                                i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) validPos = getMaskSet().validPositions[i], 
                                validPos && validPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsBeforePos++, 
                                delete getMaskSet().validPositions[i];
                                for (verifyValidInput && validInputs[0] === test.match.def && validInputs.shift(), 
                                resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
                                    var input = validInputs.shift();
                                    if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid, !0))) break;
                                }
                                if (isValidRslt) {
                                    getMaskSet().validPositions[decisionPos].locator = possibilities;
                                    var targetLvp = getLastValidPosition(pos) + 1;
                                    for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
                                    (void 0 === validPos || null == validPos.match.fn) && i < pos + (staticInputsBeforePosAlternate - staticInputsBeforePos) && staticInputsBeforePosAlternate++;
                                    pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
                                }
                                if (isValidRslt) return !1;
                                resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
                            }
                        }
                    });
                }
                return isValidRslt;
            }
            function trackbackAlternations(originalPos, newPos) {
                for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; ps < newPos; ps++) if (void 0 === getMaskSet().validPositions[ps] && !isMask(ps, !0)) {
                    var tests = getTests(ps), bestMatch = tests[0], equality = -1;
                    $.each(tests, function(ndx, tst) {
                        for (var i = 0; i < tll && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","))); i++) equality < i && (equality = i, 
                        bestMatch = tst);
                    }), setValidPosition(ps, $.extend({}, bestMatch, {
                        input: bestMatch.match.placeholder || bestMatch.match.def
                    }), !0);
                }
            }
            function setValidPosition(pos, validTest, fromSetValid, isSelection) {
                if (isSelection || opts.insertMode && void 0 !== getMaskSet().validPositions[pos] && void 0 === fromSetValid) {
                    var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition();
                    for (i = pos; i <= lvp; i++) delete getMaskSet().validPositions[i];
                    getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
                    var j, valid = !0, vps = getMaskSet().validPositions, needsValidation = !1, initialLength = getMaskSet().maskLength;
                    for (i = j = pos; i <= lvp; i++) {
                        var t = positionsClone[i];
                        if (void 0 !== t) for (var posMatch = j; posMatch < getMaskSet().maskLength && (null == t.match.fn && vps[i] && (vps[i].match.optionalQuantifier === !0 || vps[i].match.optionality === !0) || null != t.match.fn); ) {
                            if (posMatch++, needsValidation === !1 && positionsClone[posMatch] && positionsClone[posMatch].match.def === t.match.def) getMaskSet().validPositions[posMatch] = $.extend(!0, {}, positionsClone[posMatch]), 
                            getMaskSet().validPositions[posMatch].input = t.input, fillMissingNonMask(posMatch), 
                            j = posMatch, valid = !0; else if (positionCanMatchDefinition(posMatch, t.match.def)) {
                                var result = isValid(posMatch, t.input, !0, !0);
                                valid = result !== !1, j = result.caret || result.insert ? getLastValidPosition() : posMatch, 
                                needsValidation = !0;
                            } else valid = t.generatedInput === !0;
                            if (getMaskSet().maskLength < initialLength && (getMaskSet().maskLength = initialLength), 
                            valid) break;
                        }
                        if (!valid) break;
                    }
                    if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone), 
                    resetMaskSet(!0), !1;
                } else getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
                return resetMaskSet(!0), !0;
            }
            function fillMissingNonMask(maskPos) {
                for (var pndx = maskPos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
                var testTemplate, testsFromPos;
                for (pndx++; pndx < maskPos; pndx++) void 0 === getMaskSet().validPositions[pndx] && (opts.jitMasking === !1 || opts.jitMasking > pndx) && (testsFromPos = getTests(pndx, getTestTemplate(pndx - 1).locator, pndx - 1).slice(), 
                "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop(), testTemplate = determineTestTemplate(testsFromPos), 
                testTemplate && (testTemplate.match.def === opts.radixPointDefinitionSymbol || !isMask(pndx, !0) || $.inArray(opts.radixPoint, getBuffer()) < pndx && testTemplate.match.fn && testTemplate.match.fn.test(getPlaceholder(pndx), getMaskSet(), pndx, !1, opts)) && (result = _isValid(pndx, testTemplate.match.placeholder || (null == testTemplate.match.fn ? testTemplate.match.def : "" !== getPlaceholder(pndx) ? getPlaceholder(pndx) : getBuffer()[pndx]), !0), 
                result !== !1 && (getMaskSet().validPositions[result.pos || pndx].generatedInput = !0)));
            }
            strict = strict === !0;
            var maskPos = pos;
            void 0 !== pos.begin && (maskPos = isRTL && !isSelection(pos) ? pos.end : pos.begin);
            var result = !1, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
            if (fillMissingNonMask(maskPos), isSelection(pos) && (handleRemove(void 0, Inputmask.keyCode.DELETE, pos), 
            maskPos = getMaskSet().p), maskPos < getMaskSet().maskLength && (result = _isValid(maskPos, c, strict), 
            (!strict || fromSetValid === !0) && result === !1)) {
                var currentPosValid = getMaskSet().validPositions[maskPos];
                if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
                    if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
                        var testsFromPos = getTests(maskPos).slice();
                        "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop();
                        var staticChar = determineTestTemplate(testsFromPos, !0);
                        staticChar && (staticChar = staticChar.match.placeholder || staticChar.match.def, 
                        _isValid(maskPos, staticChar, strict), getMaskSet().validPositions[maskPos].generatedInput = !0);
                        for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (result = _isValid(nPos, c, strict), 
                        result !== !1) {
                            trackbackAlternations(maskPos, nPos), maskPos = nPos;
                            break;
                        }
                    }
                } else result = {
                    caret: seekNext(maskPos)
                };
            }
            return result === !1 && opts.keepStatic && !strict && fromAlternate !== !0 && (result = alternate(maskPos, c, strict)), 
            result === !0 && (result = {
                pos: maskPos
            }), $.isFunction(opts.postValidation) && result !== !1 && !strict && fromSetValid !== !0 && (result = !!opts.postValidation(getBuffer(!0), result, opts) && result), 
            void 0 === result.pos && (result.pos = maskPos), result === !1 && (resetMaskSet(!0), 
            getMaskSet().validPositions = $.extend(!0, {}, positionsClone)), result;
        }
        function isMask(pos, strict) {
            var test;
            if (strict ? (test = getTestTemplate(pos).match, "" === test.def && (test = getTest(pos).match)) : test = getTest(pos).match, 
            null != test.fn) return test.fn;
            if (strict !== !0 && pos > -1) {
                var tests = getTests(pos);
                return tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0);
            }
            return !1;
        }
        function seekNext(pos, newBlock) {
            var maskL = getMaskSet().maskLength;
            if (pos >= maskL) return maskL;
            for (var position = pos; ++position < maskL && (newBlock === !0 && (getTest(position).match.newBlockMarker !== !0 || !isMask(position)) || newBlock !== !0 && !isMask(position)); ) ;
            return position;
        }
        function seekPrevious(pos, newBlock) {
            var tests, position = pos;
            if (position <= 0) return 0;
            for (;--position > 0 && (newBlock === !0 && getTest(position).match.newBlockMarker !== !0 || newBlock !== !0 && !isMask(position) && (tests = getTests(position), 
            tests.length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ;
            return position;
        }
        function getBufferElement(position) {
            return void 0 === getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
        }
        function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
            if (event && $.isFunction(opts.onBeforeWrite)) {
                var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
                if (result) {
                    if (result.refreshFromBuffer) {
                        var refresh = result.refreshFromBuffer;
                        refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer || buffer), 
                        buffer = getBuffer(!0);
                    }
                    void 0 !== caretPos && (caretPos = void 0 !== result.caret ? result.caret : caretPos);
                }
            }
            input.inputmask._valueSet(buffer.join("")), void 0 === caretPos || void 0 !== event && "blur" === event.type || caret(input, caretPos), 
            triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
        }
        function getPlaceholder(pos, test) {
            if (test = test || getTest(pos).match, void 0 !== test.placeholder) return test.placeholder;
            if (null === test.fn) {
                if (pos > -1 && void 0 === getMaskSet().validPositions[pos]) {
                    var prevTest, tests = getTests(pos), staticAlternations = [];
                    if (tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0)) for (var i = 0; i < tests.length; i++) if (tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (null === tests[i].match.fn || void 0 === prevTest || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts) !== !1) && (staticAlternations.push(tests[i]), 
                    null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations.length > 1 && /[0-9a-bA-Z]/.test(staticAlternations[0].match.def))) return opts.placeholder.charAt(pos % opts.placeholder.length);
                }
                return test.def;
            }
            return opts.placeholder.charAt(pos % opts.placeholder.length);
        }
        function checkVal(input, writeOut, strict, nptvl, initiatingEvent, stickyCaret) {
            function isTemplateMatch() {
                var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
                if (charCodeNdx !== -1 && !isMask(initialNdx)) {
                    isMatch = !0;
                    for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " !== bufferTemplateArr[i]) {
                        isMatch = !1;
                        break;
                    }
                }
                return isMatch;
            }
            var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0, result = void 0;
            if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) if (opts.autoUnmask !== !0) {
                var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
                matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length), 
                initialNdx = seekNext(initialNdx));
            } else initialNdx = seekNext(initialNdx);
            if ($.each(inputValue, function(ndx, charCode) {
                if (void 0 !== charCode) {
                    var keypress = new $.Event("keypress");
                    keypress.which = charCode.charCodeAt(0), charCodes += charCode;
                    var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
                    if (!isTemplateMatch() || strict || opts.autoUnmask) {
                        var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
                        result = keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1, 
                        charCodes = "";
                    } else result = keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
                    if (!strict && $.isFunction(opts.onBeforeWrite) && (result = opts.onBeforeWrite(keypress, getBuffer(), result.forwardPosition, opts), 
                    result && result.refreshFromBuffer)) {
                        var refresh = result.refreshFromBuffer;
                        refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer), 
                        resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
                    }
                }
            }), writeOut) {
                var caretPos = void 0, lvp = getLastValidPosition();
                document.activeElement === input && (initiatingEvent || result) && (caretPos = caret(input).begin - (stickyCaret === !0 ? 1 : 0), 
                result && stickyCaret !== !0 && (caretPos < lvp + 1 || lvp === -1) && (caretPos = opts.numericInput && void 0 === result.caret ? seekPrevious(result.forwardPosition) : result.forwardPosition)), 
                writeBuffer(input, getBuffer(), caretPos, initiatingEvent || new $.Event("checkval"));
            }
        }
        function unmaskedvalue(input) {
            if (input && void 0 === input.inputmask) return input.value;
            var umValue = [], vps = getMaskSet().validPositions;
            for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
            var unmaskedValue = 0 === umValue.length ? "" : (isRTL ? umValue.reverse() : umValue).join("");
            if ($.isFunction(opts.onUnMask)) {
                var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
                unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue;
            }
            return unmaskedValue;
        }
        function caret(input, begin, end, notranslate) {
            function translatePosition(pos) {
                if (notranslate !== !0 && isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
                    var bffrLght = getBuffer().join("").length;
                    pos = bffrLght - pos;
                }
                return pos;
            }
            var range;
            if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart, 
            end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0), 
            range.commonAncestorContainer.parentNode !== input && range.commonAncestorContainer !== input || (begin = range.startOffset, 
            end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(), 
            begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length), 
            end = begin + range.text.length), {
                begin: translatePosition(begin),
                end: translatePosition(end)
            };
            begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
            var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
            if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, mobile || opts.insertMode !== !1 || begin !== end || end++, 
            input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
                if (range = document.createRange(), void 0 === input.firstChild || null === input.firstChild) {
                    var textNode = document.createTextNode("");
                    input.appendChild(textNode);
                }
                range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length), 
                range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length), 
                range.collapse(!0);
                var sel = window.getSelection();
                sel.removeAllRanges(), sel.addRange(range);
            } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0), 
            range.moveEnd("character", end), range.moveStart("character", begin), range.select());
        }
        function determineLastRequiredPosition(returnDefinition) {
            var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== lvTest ? lvTest.locator.slice() : void 0;
            for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), 
            ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
            var lvTestAlt = lvTest && void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation] : void 0;
            for (pos = bl - 1; pos > lvp && (testPos = positions[pos], (testPos.match.optionality || testPos.match.optionalQuantifier || lvTestAlt && (lvTestAlt !== positions[pos].locator[lvTest.alternation] && null != testPos.match.fn || null === testPos.match.fn && testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) && "" !== getTests(pos)[0].def)) && buffer[pos] === getPlaceholder(pos, testPos.match)); pos--) bl--;
            return returnDefinition ? {
                l: bl,
                def: positions[bl] ? positions[bl].match : void 0
            } : bl;
        }
        function clearOptionalTail(buffer) {
            for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
            return buffer.splice(rl, lmib + 1 - rl), buffer;
        }
        function isComplete(buffer) {
            if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
            if ("*" !== opts.repeat) {
                var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
                if (void 0 === lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
                    complete = !0;
                    for (var i = 0; i <= aml; i++) {
                        var test = getTestTemplate(i).match;
                        if (null !== test.fn && void 0 === getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
                            complete = !1;
                            break;
                        }
                    }
                }
                return complete;
            }
        }
        function patchValueProperty(npt) {
            function patchValhook(type) {
                if ($.valHooks && (void 0 === $.valHooks[type] || $.valHooks[type].inputmaskpatch !== !0)) {
                    var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
                        return elem.value;
                    }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
                        return elem.value = value, elem;
                    };
                    $.valHooks[type] = {
                        get: function(elem) {
                            if (elem.inputmask) {
                                if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
                                var result = valhookGet(elem);
                                return getLastValidPosition(void 0, void 0, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== !0 ? result : "";
                            }
                            return valhookGet(elem);
                        },
                        set: function(elem, value) {
                            var result, $elem = $(elem);
                            return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"), 
                            result;
                        },
                        inputmaskpatch: !0
                    };
                }
            }
            function getter() {
                return this.inputmask ? this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : getLastValidPosition() !== -1 || opts.nullable !== !0 ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "" : valueGet.call(this);
            }
            function setter(value) {
                valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
            }
            function installNativeValueSetFallback(npt) {
                EventRuler.on(npt, "mouseenter", function(event) {
                    var $input = $(this), input = this, value = input.inputmask._valueGet();
                    value !== getBuffer().join("") && $input.trigger("setvalue");
                });
            }
            var valueGet, valueSet;
            if (!npt.inputmask.__valueGet) {
                if (Object.getOwnPropertyDescriptor) {
                    "function" != typeof Object.getPrototypeOf && (Object.getPrototypeOf = "object" == typeof "test".__proto__ ? function(object) {
                        return object.__proto__;
                    } : function(object) {
                        return object.constructor.prototype;
                    });
                    var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : void 0;
                    valueProperty && valueProperty.get && valueProperty.set ? (valueGet = valueProperty.get, 
                    valueSet = valueProperty.set, Object.defineProperty(npt, "value", {
                        get: getter,
                        set: setter,
                        configurable: !0
                    })) : "INPUT" !== npt.tagName && (valueGet = function() {
                        return this.textContent;
                    }, valueSet = function(value) {
                        this.textContent = value;
                    }, Object.defineProperty(npt, "value", {
                        get: getter,
                        set: setter,
                        configurable: !0
                    }));
                } else document.__lookupGetter__ && npt.__lookupGetter__("value") && (valueGet = npt.__lookupGetter__("value"), 
                valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter), 
                npt.__defineSetter__("value", setter));
                npt.inputmask.__valueGet = valueGet, npt.inputmask._valueGet = function(overruleRTL) {
                    return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
                }, npt.inputmask.__valueSet = valueSet, npt.inputmask._valueSet = function(value, overruleRTL) {
                    valueSet.call(this.el, null === value || void 0 === value ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
                }, void 0 === valueGet && (valueGet = function() {
                    return this.value;
                }, valueSet = function(value) {
                    this.value = value;
                }, patchValhook(npt.type), installNativeValueSetFallback(npt));
            }
        }
        function handleRemove(input, k, pos, strict) {
            function generalize() {
                if (opts.keepStatic) {
                    for (var validInputs = [], lastAlt = getLastValidPosition(-1, !0), positionsClone = $.extend(!0, {}, getMaskSet().validPositions), prevAltPos = getMaskSet().validPositions[lastAlt]; lastAlt >= 0; lastAlt--) {
                        var altPos = getMaskSet().validPositions[lastAlt];
                        if (altPos) {
                            if (altPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(altPos.input) && validInputs.push(altPos.input), 
                            delete getMaskSet().validPositions[lastAlt], void 0 !== altPos.alternation && altPos.locator[altPos.alternation] !== prevAltPos.locator[altPos.alternation]) break;
                            prevAltPos = altPos;
                        }
                    }
                    if (lastAlt > -1) for (getMaskSet().p = seekNext(getLastValidPosition(-1, !0)); validInputs.length > 0; ) {
                        var keypress = new $.Event("keypress");
                        keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
                    } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
                }
            }
            if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE), 
            isRTL)) {
                var pend = pos.end;
                pos.end = pos.begin, pos.begin = pend;
            }
            k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin), 
            void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) ? pos.end + 1 : seekNext(pos.end) + 1, 
            void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++), 
            stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
            var lvp = getLastValidPosition(pos.begin, !0);
            lvp < pos.begin ? getMaskSet().p = seekNext(lvp) : strict !== !0 && (getMaskSet().p = pos.begin);
        }
        function keydownEvent(e) {
            var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
            if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) e.preventDefault(), 
            handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")), 
            input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"), 
            opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
                e.preventDefault();
                var caretPos = seekNext(getLastValidPosition());
                opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--, 
                caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
            } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(), 
            caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")), 
            $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? opts.tabThrough === !0 && k === Inputmask.keyCode.TAB ? (e.shiftKey === !0 ? (null === getTest(pos.begin).match.fn && (pos.begin = seekNext(pos.begin)), 
            pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0), 
            pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--), 
            pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : opts.insertMode !== !1 || e.shiftKey || (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
                var caretPos = caret(input);
                caret(input, caretPos.begin);
            }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
                var caretPos = caret(input);
                caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
            }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1));
            opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = $.inArray(k, opts.ignorables) !== -1;
        }
        function keypressEvent(e, checkval, writeOut, strict, ndx) {
            var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
            if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""), 
            setTimeout(function() {
                $input.trigger("change");
            }, 0)), !0;
            if (k) {
                46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
                var forwardPosition, pos = checkval ? {
                    begin: ndx,
                    end: ndx
                } : caret(input), c = String.fromCharCode(k);
                getMaskSet().writeOutBuffer = !0;
                var valResult = isValid(pos, c, strict);
                if (valResult !== !1 && (resetMaskSet(!0), forwardPosition = void 0 !== valResult.caret ? valResult.caret : checkval ? valResult.pos + 1 : seekNext(valResult.pos), 
                getMaskSet().p = forwardPosition), writeOut !== !1) {
                    var self = this;
                    if (setTimeout(function() {
                        opts.onKeyValidation.call(self, k, valResult, opts);
                    }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
                        var buffer = getBuffer();
                        writeBuffer(input, buffer, opts.numericInput && void 0 === valResult.caret ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0), 
                        checkval !== !0 && setTimeout(function() {
                            isComplete(buffer) === !0 && $input.trigger("complete");
                        }, 0);
                    }
                }
                if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), e.preventDefault(), 
                checkval) return valResult.forwardPosition = forwardPosition, valResult;
            }
        }
        function pasteEvent(e) {
            var tempValue, input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
            isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue);
            var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
            if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""), 
            valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""), 
            isRTL && (tempValue = valueBeforeCaret, valueBeforeCaret = valueAfterCaret, valueAfterCaret = tempValue), 
            window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else {
                if (!ev.clipboardData || !ev.clipboardData.getData) return !0;
                inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret;
            }
            var pasteValue = inputValue;
            if ($.isFunction(opts.onBeforePaste)) {
                if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault();
                pasteValue || (pasteValue = inputValue);
            }
            return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")), 
            writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")), 
            isComplete(getBuffer()) === !0 && $input.trigger("complete"), e.preventDefault();
        }
        function inputFallBackEvent(e) {
            var input = this, inputValue = input.inputmask._valueGet();
            if (getBuffer().join("") !== inputValue) {
                var caretPos = caret(input);
                if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""), 
                iemobile) {
                    var inputChar = inputValue.replace(getBuffer().join(""), "");
                    if (1 === inputChar.length) {
                        var keypress = new $.Event("keypress");
                        return keypress.which = inputChar.charCodeAt(0), keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1), 
                        !1;
                    }
                }
                if (caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input)), 
                getBuffer().length - inputValue.length !== 1 || inputValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || inputValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin)) {
                    for (var lvp = getLastValidPosition() + 1, bufferTemplate = getBuffer().slice(lvp).join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
                    inputValue = inputValue.replace(bufferTemplate, ""), inputValue = inputValue.split(""), 
                    checkVal(input, !0, !1, inputValue, e, caretPos.begin < lvp), isComplete(getBuffer()) === !0 && $(input).trigger("complete");
                } else e.keyCode = Inputmask.keyCode.BACKSPACE, keydownEvent.call(input, e);
                e.preventDefault();
            }
        }
        function setValueEvent(e) {
            var input = this, value = input.inputmask._valueGet();
            checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")), 
            undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
        }
        function focusEvent(e) {
            var input = this, nptValue = input.inputmask._valueGet();
            opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())), 
            opts.positionCaretOnTab === !0 && setTimeout(function() {
                clickEvent.apply(this, [ e ]);
            }, 0), undoValue = getBuffer().join("");
        }
        function mouseleaveEvent(e) {
            var input = this;
            if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
                var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
                nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer), 
                writeBuffer(input, buffer));
            }
        }
        function clickEvent(e) {
            function doRadixFocus(clickPos) {
                if ("" !== opts.radixPoint) {
                    var vps = getMaskSet().validPositions;
                    if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
                        if (clickPos < seekNext(-1)) return !0;
                        var radixPos = $.inArray(opts.radixPoint, getBuffer());
                        if (radixPos !== -1) {
                            for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1;
                            return !0;
                        }
                    }
                }
                return !1;
            }
            var input = this;
            setTimeout(function() {
                if (document.activeElement === input) {
                    var selectedCaret = caret(input);
                    if (selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) {
                      case "none":
                        break;

                      case "radixFocus":
                        if (doRadixFocus(selectedCaret.begin)) {
                            var radixPos = $.inArray(opts.radixPoint, getBuffer().join(""));
                            caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
                            break;
                        }

                      default:
                        var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition);
                        if (clickPosition < lastPosition) caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)); else {
                            var placeholder = getPlaceholder(lastPosition);
                            ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && getTest(lastPosition).match.optionalQuantifier !== !0 || !isMask(lastPosition, !0) && getTest(lastPosition).match.def === placeholder) && (lastPosition = seekNext(lastPosition)), 
                            caret(input, lastPosition);
                        }
                    }
                }
            }, 0);
        }
        function dblclickEvent(e) {
            var input = this;
            setTimeout(function() {
                caret(input, 0, seekNext(getLastValidPosition()));
            }, 0);
        }
        function cutEvent(e) {
            var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
            clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")), 
            document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos), 
            writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")), 
            input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"), 
            opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
        }
        function blurEvent(e) {
            var $input = $(this), input = this;
            if (input.inputmask) {
                var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
                undoValue !== buffer.join("") && setTimeout(function() {
                    $input.trigger("change"), undoValue = buffer.join("");
                }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)), 
                isComplete(buffer) === !1 && (setTimeout(function() {
                    $input.trigger("incomplete");
                }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())), 
                writeBuffer(input, buffer, void 0, e));
            }
        }
        function mouseenterEvent(e) {
            var input = this;
            mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
        }
        function submitEvent(e) {
            undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""), 
            opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0), 
            setTimeout(function() {
                writeBuffer(el, getBuffer());
            }, 0));
        }
        function resetEvent(e) {
            setTimeout(function() {
                $el.trigger("setvalue");
            }, 0);
        }
        function mask(elem) {
            if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask), 
            ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr", 
            el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), EventRuler.off(el), 
            patchValueProperty(el), isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent), 
            EventRuler.on(el, "reset", resetEvent), EventRuler.on(el, "mouseenter", mouseenterEvent), 
            EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent), 
            EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent), 
            EventRuler.on(el, "paste", pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent), 
            EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete), 
            EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared), 
            opts.inputEventOnly !== !0 && (EventRuler.on(el, "keydown", keydownEvent), EventRuler.on(el, "keypress", keypressEvent)), 
            EventRuler.on(el, "input", inputFallBackEvent)), EventRuler.on(el, "setvalue", setValueEvent), 
            getBufferTemplate(), "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el) {
                var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
                checkVal(el, !0, !1, initialValue.split(""));
                var buffer = getBuffer().slice();
                undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(), 
                opts.clearMaskOnLostFocus && document.activeElement !== el && (getLastValidPosition() === -1 ? buffer = [] : clearOptionalTail(buffer)), 
                writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
            }
        }
        var undoValue, el, $el, maxLength, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !0, EventRuler = {
            on: function(input, eventName, eventHandler) {
                var ev = function(e) {
                    if (void 0 === this.inputmask && "FORM" !== this.nodeName) {
                        var imOpts = $.data(this, "_inputmask_opts");
                        imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
                    } else {
                        if ("setvalue" === e.type || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || opts.tabThrough === !1 && e.keyCode === Inputmask.keyCode.TAB))) {
                            switch (e.type) {
                              case "input":
                                if (skipInputEvent === !0) return skipInputEvent = !1, e.preventDefault();
                                break;

                              case "keydown":
                                skipKeyPressEvent = !1, skipInputEvent = !1;
                                break;

                              case "keypress":
                                if (skipKeyPressEvent === !0) return e.preventDefault();
                                skipKeyPressEvent = !0;
                                break;

                              case "click":
                                if (iemobile) {
                                    var that = this;
                                    return setTimeout(function() {
                                        eventHandler.apply(that, arguments);
                                    }, 0), !1;
                                }
                            }
                            var returnVal = eventHandler.apply(this, arguments);
                            return returnVal === !1 && (e.preventDefault(), e.stopPropagation()), returnVal;
                        }
                        e.preventDefault();
                    }
                };
                input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev), 
                $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? null != input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
            },
            off: function(input, event) {
                if (input.inputmask && input.inputmask.events) {
                    var events;
                    event ? (events = [], events[event] = input.inputmask.events[event]) : events = input.inputmask.events, 
                    $.each(events, function(eventName, evArr) {
                        for (;evArr.length > 0; ) {
                            var ev = evArr.pop();
                            $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? null != input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
                        }
                        delete input.inputmask.events[eventName];
                    });
                }
            }
        };
        if (void 0 !== actionObj) switch (actionObj.action) {
          case "isComplete":
            return el = actionObj.el, isComplete(getBuffer());

          case "unmaskedvalue":
            return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset, 
            opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value, 
            opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""), 
            checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)), 
            unmaskedvalue(el);

          case "mask":
            el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL, 
            mask(el);
            break;

          case "format":
            return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""), 
            checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts), 
            actionObj.metadata ? {
                value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
                metadata: maskScope({
                    action: "getmetadata"
                }, maskset, opts)
            } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");

          case "isValid":
            opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""), 
            checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
            for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
            return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");

          case "getemptymask":
            return getBufferTemplate().join("");

          case "remove":
            el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts, 
            el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
            var valueProperty;
            Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? (valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value"), 
            valueProperty && el.inputmask.__valueGet && Object.defineProperty(el, "value", {
                get: el.inputmask.__valueGet,
                set: el.inputmask.__valueSet,
                configurable: !0
            })) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet), 
            el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
            break;

          case "getmetadata":
            if ($.isArray(maskset.metadata)) {
                for (var alternation, lvp = getLastValidPosition(void 0, !0), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 !== getMaskSet().validPositions[firstAlt].alternation) {
                    alternation = getMaskSet().validPositions[firstAlt].alternation;
                    break;
                }
                return void 0 !== alternation ? maskset.metadata[getMaskSet().validPositions[firstAlt].locator[alternation]] : [];
            }
            return maskset.metadata;
        }
    }
    Inputmask.prototype = {
        defaults: {
            placeholder: "_",
            optionalmarker: {
                start: "[",
                end: "]"
            },
            quantifiermarker: {
                start: "{",
                end: "}"
            },
            groupmarker: {
                start: "(",
                end: ")"
            },
            alternatormarker: "|",
            escapeChar: "\\",
            mask: null,
            oncomplete: $.noop,
            onincomplete: $.noop,
            oncleared: $.noop,
            repeat: 0,
            greedy: !0,
            autoUnmask: !1,
            removeMaskOnSubmit: !1,
            clearMaskOnLostFocus: !0,
            insertMode: !0,
            clearIncomplete: !1,
            aliases: {},
            alias: null,
            onKeyDown: $.noop,
            onBeforeMask: null,
            onBeforePaste: function(pastedValue, opts) {
                return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
            },
            onBeforeWrite: null,
            onUnMask: null,
            showMaskOnFocus: !0,
            showMaskOnHover: !0,
            onKeyValidation: $.noop,
            skipOptionalPartCharacter: " ",
            showTooltip: !1,
            tooltip: void 0,
            numericInput: !1,
            rightAlign: !1,
            undoOnEscape: !0,
            radixPoint: "",
            radixPointDefinitionSymbol: void 0,
            groupSeparator: "",
            keepStatic: null,
            positionCaretOnTab: !0,
            tabThrough: !1,
            supportsInputType: [ "text", "tel", "password" ],
            definitions: {
                "9": {
                    validator: "[0-9]",
                    cardinality: 1,
                    definitionSymbol: "*"
                },
                a: {
                    validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
                    cardinality: 1,
                    definitionSymbol: "*"
                },
                "*": {
                    validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
                    cardinality: 1
                }
            },
            ignorables: [ 8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123 ],
            isComplete: null,
            canClearPosition: $.noop,
            postValidation: null,
            staticDefinitionSymbol: void 0,
            jitMasking: !1,
            nullable: !0,
            inputEventOnly: !1,
            positionCaretOnClick: "lvp",
            casing: null
        },
        masksCache: {},
        mask: function(elems) {
            var that = this;
            return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)), 
            elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
                var scopedOpts = $.extend(!0, {}, that.opts);
                importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
                var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
                void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(), 
                el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions), 
                el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts), 
                maskScope({
                    action: "mask",
                    el: el
                }));
            }), elems && elems[0] ? elems[0].inputmask || this : this;
        },
        option: function(options, noremask) {
            return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.userOptions, options), 
            this.el && noremask !== !0 && this.mask(this.el), this) : void 0;
        },
        unmaskedvalue: function(value) {
            return maskScope({
                action: "unmaskedvalue",
                el: this.el,
                value: value
            }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
        },
        remove: function() {
            if (this.el) return maskScope({
                action: "remove",
                el: this.el
            }), this.el.inputmask = void 0, this.el;
        },
        getemptymask: function() {
            return maskScope({
                action: "getemptymask"
            }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
        },
        hasMaskedValue: function() {
            return !this.opts.autoUnmask;
        },
        isComplete: function() {
            return maskScope({
                action: "isComplete",
                el: this.el
            }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
        },
        getmetadata: function() {
            return maskScope({
                action: "getmetadata"
            }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
        },
        isValid: function(value) {
            return maskScope({
                action: "isValid",
                value: value
            }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
        },
        format: function(value, metadata) {
            return maskScope({
                action: "format",
                value: value,
                metadata: metadata
            }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
        }
    }, Inputmask.extendDefaults = function(options) {
        $.extend(!0, Inputmask.prototype.defaults, options);
    }, Inputmask.extendDefinitions = function(definition) {
        $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
    }, Inputmask.extendAliases = function(alias) {
        $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
    }, Inputmask.format = function(value, options, metadata) {
        return Inputmask(options).format(value, metadata);
    }, Inputmask.unmask = function(value, options) {
        return Inputmask(options).unmaskedvalue(value);
    }, Inputmask.isValid = function(value, options) {
        return Inputmask(options).isValid(value);
    }, Inputmask.remove = function(elems) {
        $.each(elems, function(ndx, el) {
            el.inputmask && el.inputmask.remove();
        });
    }, Inputmask.escapeRegex = function(str) {
        var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
        return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
    }, Inputmask.keyCode = {
        ALT: 18,
        BACKSPACE: 8,
        BACKSPACE_SAFARI: 127,
        CAPS_LOCK: 20,
        COMMA: 188,
        COMMAND: 91,
        COMMAND_LEFT: 91,
        COMMAND_RIGHT: 93,
        CONTROL: 17,
        DELETE: 46,
        DOWN: 40,
        END: 35,
        ENTER: 13,
        ESCAPE: 27,
        HOME: 36,
        INSERT: 45,
        LEFT: 37,
        MENU: 93,
        NUMPAD_ADD: 107,
        NUMPAD_DECIMAL: 110,
        NUMPAD_DIVIDE: 111,
        NUMPAD_ENTER: 108,
        NUMPAD_MULTIPLY: 106,
        NUMPAD_SUBTRACT: 109,
        PAGE_DOWN: 34,
        PAGE_UP: 33,
        PERIOD: 190,
        RIGHT: 39,
        SHIFT: 16,
        SPACE: 32,
        TAB: 9,
        UP: 38,
        WINDOWS: 91,
        X: 88
    };
    var ua = navigator.userAgent, mobile = /mobile/i.test(ua), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile;
    return window.Inputmask = Inputmask, Inputmask;
});
/*!
* jquery.inputmask.js
* https://github.com/RobinHerbots/jquery.inputmask
* Copyright (c) 2010 - 2016 Robin Herbots
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
* Version: 3.3.3
*/
!function(factory) {
    "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);
}(function($, Inputmask) {
    return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
        var nptmask, input = this[0];
        if (void 0 === options && (options = {}), "string" == typeof fn) switch (fn) {
          case "unmaskedvalue":
            return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();

          case "remove":
            return this.each(function() {
                this.inputmask && this.inputmask.remove();
            });

          case "getemptymask":
            return input && input.inputmask ? input.inputmask.getemptymask() : "";

          case "hasMaskedValue":
            return !(!input || !input.inputmask) && input.inputmask.hasMaskedValue();

          case "isComplete":
            return !input || !input.inputmask || input.inputmask.isComplete();

          case "getmetadata":
            return input && input.inputmask ? input.inputmask.getmetadata() : void 0;

          case "setvalue":
            $(input).val(options), input && void 0 === input.inputmask && $(input).triggerHandler("setvalue");
            break;

          case "option":
            if ("string" != typeof options) return this.each(function() {
                if (void 0 !== this.inputmask) return this.inputmask.option(options);
            });
            if (input && void 0 !== input.inputmask) return input.inputmask.option(options);
            break;

          default:
            return options.alias = fn, nptmask = new Inputmask(options), this.each(function() {
                nptmask.mask(this);
            });
        } else {
            if ("object" == typeof fn) return nptmask = new Inputmask(fn), void 0 === fn.mask && void 0 === fn.alias ? this.each(function() {
                return void 0 !== this.inputmask ? this.inputmask.option(fn) : void nptmask.mask(this);
            }) : this.each(function() {
                nptmask.mask(this);
            });
            if (void 0 === fn) return this.each(function() {
                nptmask = new Inputmask(options), nptmask.mask(this);
            });
        }
    }), $.fn.inputmask;
});
/**
 * @license Highcharts JS v6.0.1 (2017-10-05)
 *
 * (c) 2009-2016 Torstein Honsi
 *
 * License: www.highcharts.com/license
 */
'use strict';
(function(root, factory) {
    if (typeof module === 'object' && module.exports) {
        module.exports = root.document ?
            factory(root) :
            factory;
    } else {
        root.Highcharts = factory(root);
    }
}(typeof window !== 'undefined' ? window : this, function(win) {
    var Highcharts = (function() {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        /* global win */
        var doc = win.document,
            SVG_NS = 'http://www.w3.org/2000/svg',
            userAgent = (win.navigator && win.navigator.userAgent) || '',
            svg = doc && doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect,
            isMS = /(edge|msie|trident)/i.test(userAgent) && !win.opera,
            isFirefox = /Firefox/.test(userAgent),
            hasBidiBug = isFirefox && parseInt(userAgent.split('Firefox/')[1], 10) < 4; // issue #38

        var Highcharts = win.Highcharts ? win.Highcharts.error(16, true) : {
            product: 'Highcharts',
            version: '6.0.1',
            deg2rad: Math.PI * 2 / 360,
            doc: doc,
            hasBidiBug: hasBidiBug,
            hasTouch: doc && doc.documentElement.ontouchstart !== undefined,
            isMS: isMS,
            isWebKit: /AppleWebKit/.test(userAgent),
            isFirefox: isFirefox,
            isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
            SVG_NS: SVG_NS,
            chartCount: 0,
            seriesTypes: {},
            symbolSizes: {},
            svg: svg,
            win: win,
            marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
            noop: function() {
                return undefined;
            },
            /**
             * An array containing the current chart objects in the page. A chart's
             * position in the array is preserved throughout the page's lifetime. When
             * a chart is destroyed, the array item becomes `undefined`.
             * @type {Array.<Highcharts.Chart>}
             * @memberOf Highcharts
             */
            charts: []
        };
        return Highcharts;
    }());
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        /* eslint max-len: ["warn", 80, 4] */

        /**
         * The Highcharts object is the placeholder for all other members, and various
         * utility functions. The most important member of the namespace would be the
         * chart constructor.
         *
         * @example
         * var chart = Highcharts.chart('container', { ... });
         * 
         * @namespace Highcharts
         */

        var timers = [];

        var charts = H.charts,
            doc = H.doc,
            win = H.win;

        /**
         * Provide error messages for debugging, with links to online explanation. This
         * function can be overridden to provide custom error handling.
         *
         * @function #error
         * @memberOf Highcharts
         * @param {Number|String} code - The error code. See [errors.xml]{@link 
         *     https://github.com/highcharts/highcharts/blob/master/errors/errors.xml}
         *     for available codes. If it is a string, the error message is printed
         *     directly in the console.
         * @param {Boolean} [stop=false] - Whether to throw an error or just log a 
         *     warning in the console.
         *
         * @sample highcharts/chart/highcharts-error/ Custom error handler
         */
        H.error = function(code, stop) {
            var msg = H.isNumber(code) ?
                'Highcharts error #' + code + ': www.highcharts.com/errors/' + code :
                code;
            if (stop) {
                throw new Error(msg);
            }
            // else ...
            if (win.console) {
                console.log(msg); // eslint-disable-line no-console
            }
        };

        /**
         * An animator object used internally. One instance applies to one property
         * (attribute or style prop) on one element. Animation is always initiated
         * through {@link SVGElement#animate}.
         *
         * @constructor Fx
         * @memberOf Highcharts
         * @param {HTMLDOMElement|SVGElement} elem - The element to animate.
         * @param {AnimationOptions} options - Animation options.
         * @param {string} prop - The single attribute or CSS property to animate.
         * @private
         *
         * @example
         * var rect = renderer.rect(0, 0, 10, 10).add();
         * rect.animate({ width: 100 });
         */
        H.Fx = function(elem, options, prop) {
            this.options = options;
            this.elem = elem;
            this.prop = prop;
        };
        H.Fx.prototype = {

            /**
             * Set the current step of a path definition on SVGElement.
             *
             * @function #dSetter
             * @memberOf Highcharts.Fx
             */
            dSetter: function() {
                var start = this.paths[0],
                    end = this.paths[1],
                    ret = [],
                    now = this.now,
                    i = start.length,
                    startVal;

                // Land on the final path without adjustment points appended in the ends
                if (now === 1) {
                    ret = this.toD;

                } else if (i === end.length && now < 1) {
                    while (i--) {
                        startVal = parseFloat(start[i]);
                        ret[i] =
                            isNaN(startVal) ? // a letter instruction like M or L
                            start[i] :
                            now * (parseFloat(end[i] - startVal)) + startVal;

                    }
                    // If animation is finished or length not matching, land on right value
                } else {
                    ret = end;
                }
                this.elem.attr('d', ret, null, true);
            },

            /**
             * Update the element with the current animation step.
             *
             * @function #update
             * @memberOf Highcharts.Fx
             */
            update: function() {
                var elem = this.elem,
                    prop = this.prop, // if destroyed, it is null
                    now = this.now,
                    step = this.options.step;

                // Animation setter defined from outside
                if (this[prop + 'Setter']) {
                    this[prop + 'Setter']();

                    // Other animations on SVGElement
                } else if (elem.attr) {
                    if (elem.element) {
                        elem.attr(prop, now, null, true);
                    }

                    // HTML styles, raw HTML content like container size
                } else {
                    elem.style[prop] = now + this.unit;
                }

                if (step) {
                    step.call(elem, now, this);
                }

            },

            /**
             * Run an animation.
             *
             * @function #run
             * @memberOf Highcharts.Fx
             * @param {Number} from - The current value, value to start from.
             * @param {Number} to - The end value, value to land on.
             * @param {String} [unit] - The property unit, for example `px`.
             * 
             */
            run: function(from, to, unit) {
                var self = this,
                    timer = function(gotoEnd) {
                        return timer.stopped ? false : self.step(gotoEnd);
                    },
                    requestAnimationFrame =
                    win.requestAnimationFrame ||
                    function(step) {
                        setTimeout(step, 13);
                    },
                    step = function() {
                        var i;
                        for (i = 0; i < timers.length; i++) {
                            if (!timers[i]()) {
                                timers.splice(i--, 1);
                            }
                        }

                        if (timers.length) {
                            requestAnimationFrame(step);
                        }
                    };

                if (from === to) {
                    delete this.options.curAnim[this.prop];
                } else { // #7166
                    this.startTime = +new Date();
                    this.start = from;
                    this.end = to;
                    this.unit = unit;
                    this.now = this.start;
                    this.pos = 0;

                    timer.elem = this.elem;
                    timer.prop = this.prop;

                    if (timer() && timers.push(timer) === 1) {
                        requestAnimationFrame(step);
                    }
                }
            },

            /**
             * Run a single step in the animation.
             *
             * @function #step
             * @memberOf Highcharts.Fx
             * @param   {Boolean} [gotoEnd] - Whether to go to the endpoint of the
             *     animation after abort.
             * @returns {Boolean} Returns `true` if animation continues.
             */
            step: function(gotoEnd) {
                var t = +new Date(),
                    ret,
                    done,
                    options = this.options,
                    elem = this.elem,
                    complete = options.complete,
                    duration = options.duration,
                    curAnim = options.curAnim;

                if (elem.attr && !elem.element) { // #2616, element is destroyed
                    ret = false;

                } else if (gotoEnd || t >= duration + this.startTime) {
                    this.now = this.end;
                    this.pos = 1;
                    this.update();

                    curAnim[this.prop] = true;

                    done = true;

                    H.objectEach(curAnim, function(val) {
                        if (val !== true) {
                            done = false;
                        }
                    });

                    if (done && complete) {
                        complete.call(elem);
                    }
                    ret = false;

                } else {
                    this.pos = options.easing((t - this.startTime) / duration);
                    this.now = this.start + ((this.end - this.start) * this.pos);
                    this.update();
                    ret = true;
                }
                return ret;
            },

            /**
             * Prepare start and end values so that the path can be animated one to one.
             *
             * @function #initPath
             * @memberOf Highcharts.Fx
             * @param {SVGElement} elem - The SVGElement item.
             * @param {String} fromD - Starting path definition.
             * @param {Array} toD - Ending path definition.
             * @returns {Array} An array containing start and end paths in array form
             * so that they can be animated in parallel.
             */
            initPath: function(elem, fromD, toD) {
                fromD = fromD || '';
                var shift,
                    startX = elem.startX,
                    endX = elem.endX,
                    bezier = fromD.indexOf('C') > -1,
                    numParams = bezier ? 7 : 3,
                    fullLength,
                    slice,
                    i,
                    start = fromD.split(' '),
                    end = toD.slice(), // copy
                    isArea = elem.isArea,
                    positionFactor = isArea ? 2 : 1,
                    reverse;

                /**
                 * In splines make moveTo and lineTo points have six parameters like
                 * bezier curves, to allow animation one-to-one.
                 */
                function sixify(arr) {
                    var isOperator,
                        nextIsOperator;
                    i = arr.length;
                    while (i--) {

                        // Fill in dummy coordinates only if the next operator comes
                        // three places behind (#5788)
                        isOperator = arr[i] === 'M' || arr[i] === 'L';
                        nextIsOperator = /[a-zA-Z]/.test(arr[i + 3]);
                        if (isOperator && nextIsOperator) {
                            arr.splice(
                                i + 1, 0,
                                arr[i + 1], arr[i + 2],
                                arr[i + 1], arr[i + 2]
                            );
                        }
                    }
                }

                /**
                 * Insert an array at the given position of another array
                 */
                function insertSlice(arr, subArr, index) {
                    [].splice.apply(
                        arr, [index, 0].concat(subArr)
                    );
                }

                /**
                 * If shifting points, prepend a dummy point to the end path. 
                 */
                function prepend(arr, other) {
                    while (arr.length < fullLength) {

                        // Move to, line to or curve to?
                        arr[0] = other[fullLength - arr.length];

                        // Prepend a copy of the first point
                        insertSlice(arr, arr.slice(0, numParams), 0);

                        // For areas, the bottom path goes back again to the left, so we
                        // need to append a copy of the last point.
                        if (isArea) {
                            insertSlice(
                                arr,
                                arr.slice(arr.length - numParams), arr.length
                            );
                            i--;
                        }
                    }
                    arr[0] = 'M';
                }

                /**
                 * Copy and append last point until the length matches the end length
                 */
                function append(arr, other) {
                    var i = (fullLength - arr.length) / numParams;
                    while (i > 0 && i--) {

                        // Pull out the slice that is going to be appended or inserted.
                        // In a line graph, the positionFactor is 1, and the last point
                        // is sliced out. In an area graph, the positionFactor is 2,
                        // causing the middle two points to be sliced out, since an area
                        // path starts at left, follows the upper path then turns and
                        // follows the bottom back. 
                        slice = arr.slice().splice(
                            (arr.length / positionFactor) - numParams,
                            numParams * positionFactor
                        );

                        // Move to, line to or curve to?
                        slice[0] = other[fullLength - numParams - (i * numParams)];

                        // Disable first control point
                        if (bezier) {
                            slice[numParams - 6] = slice[numParams - 2];
                            slice[numParams - 5] = slice[numParams - 1];
                        }

                        // Now insert the slice, either in the middle (for areas) or at
                        // the end (for lines)
                        insertSlice(arr, slice, arr.length / positionFactor);

                        if (isArea) {
                            i--;
                        }
                    }
                }

                if (bezier) {
                    sixify(start);
                    sixify(end);
                }

                // For sideways animation, find out how much we need to shift to get the
                // start path Xs to match the end path Xs.
                if (startX && endX) {
                    for (i = 0; i < startX.length; i++) {
                        // Moving left, new points coming in on right
                        if (startX[i] === endX[0]) {
                            shift = i;
                            break;
                            // Moving right
                        } else if (startX[0] ===
                            endX[endX.length - startX.length + i]) {
                            shift = i;
                            reverse = true;
                            break;
                        }
                    }
                    if (shift === undefined) {
                        start = [];
                    }
                }

                if (start.length && H.isNumber(shift)) {

                    // The common target length for the start and end array, where both 
                    // arrays are padded in opposite ends
                    fullLength = end.length + shift * positionFactor * numParams;

                    if (!reverse) {
                        prepend(end, start);
                        append(start, end);
                    } else {
                        prepend(start, end);
                        append(end, start);
                    }
                }

                return [start, end];
            }
        }; // End of Fx prototype

        /**
         * Handle animation of the color attributes directly.
         */
        H.Fx.prototype.fillSetter =
            H.Fx.prototype.strokeSetter = function() {
                this.elem.attr(
                    this.prop,
                    H.color(this.start).tweenTo(H.color(this.end), this.pos),
                    null,
                    true
                );
            };

        /**
         * Utility function to extend an object with the members of another.
         *
         * @function #extend
         * @memberOf Highcharts
         * @param {Object} a - The object to be extended.
         * @param {Object} b - The object to add to the first one.
         * @returns {Object} Object a, the original object.
         */
        H.extend = function(a, b) {
            var n;
            if (!a) {
                a = {};
            }
            for (n in b) {
                a[n] = b[n];
            }
            return a;
        };

        /**
         * Utility function to deep merge two or more objects and return a third object.
         * If the first argument is true, the contents of the second object is copied
         * into the first object. The merge function can also be used with a single 
         * object argument to create a deep copy of an object.
         *
         * @function #merge
         * @memberOf Highcharts
         * @param {Boolean} [extend] - Whether to extend the left-side object (a) or
                  return a whole new object.
         * @param {Object} a - The first object to extend. When only this is given, the
                  function returns a deep copy.
         * @param {...Object} [n] - An object to merge into the previous one.
         * @returns {Object} - The merged object. If the first argument is true, the 
         * return is the same as the second argument.
         */
        H.merge = function() {
            var i,
                args = arguments,
                len,
                ret = {},
                doCopy = function(copy, original) {
                    // An object is replacing a primitive
                    if (typeof copy !== 'object') {
                        copy = {};
                    }

                    H.objectEach(original, function(value, key) {

                        // Copy the contents of objects, but not arrays or DOM nodes
                        if (
                            H.isObject(value, true) &&
                            !H.isClass(value) &&
                            !H.isDOMElement(value)
                        ) {
                            copy[key] = doCopy(copy[key] || {}, value);

                            // Primitives and arrays are copied over directly
                        } else {
                            copy[key] = original[key];
                        }
                    });
                    return copy;
                };

            // If first argument is true, copy into the existing object. Used in
            // setOptions.
            if (args[0] === true) {
                ret = args[1];
                args = Array.prototype.slice.call(args, 2);
            }

            // For each argument, extend the return
            len = args.length;
            for (i = 0; i < len; i++) {
                ret = doCopy(ret, args[i]);
            }

            return ret;
        };

        /**
         * Shortcut for parseInt
         * @ignore
         * @param {Object} s
         * @param {Number} mag Magnitude
         */
        H.pInt = function(s, mag) {
            return parseInt(s, mag || 10);
        };

        /**
         * Utility function to check for string type.
         *
         * @function #isString
         * @memberOf Highcharts
         * @param {Object} s - The item to check.
         * @returns {Boolean} - True if the argument is a string.
         */
        H.isString = function(s) {
            return typeof s === 'string';
        };

        /**
         * Utility function to check if an item is an array.
         *
         * @function #isArray
         * @memberOf Highcharts
         * @param {Object} obj - The item to check.
         * @returns {Boolean} - True if the argument is an array.
         */
        H.isArray = function(obj) {
            var str = Object.prototype.toString.call(obj);
            return str === '[object Array]' || str === '[object Array Iterator]';
        };

        /**
         * Utility function to check if an item is of type object.
         *
         * @function #isObject
         * @memberOf Highcharts
         * @param {Object} obj - The item to check.
         * @param {Boolean} [strict=false] - Also checks that the object is not an
         *    array.
         * @returns {Boolean} - True if the argument is an object.
         */
        H.isObject = function(obj, strict) {
            return !!obj && typeof obj === 'object' && (!strict || !H.isArray(obj));
        };

        /**
         * Utility function to check if an Object is a HTML Element.
         *
         * @function #isDOMElement
         * @memberOf Highcharts
         * @param {Object} obj - The item to check.
         * @returns {Boolean} - True if the argument is a HTML Element.
         */
        H.isDOMElement = function(obj) {
            return H.isObject(obj) && typeof obj.nodeType === 'number';
        };

        /**
         * Utility function to check if an Object is an class.
         *
         * @function #isClass
         * @memberOf Highcharts
         * @param {Object} obj - The item to check.
         * @returns {Boolean} - True if the argument is an class.
         */
        H.isClass = function(obj) {
            var c = obj && obj.constructor;
            return !!(
                H.isObject(obj, true) &&
                !H.isDOMElement(obj) &&
                (c && c.name && c.name !== 'Object')
            );
        };

        /**
         * Utility function to check if an item is of type number.
         *
         * @function #isNumber
         * @memberOf Highcharts
         * @param {Object} n - The item to check.
         * @returns {Boolean} - True if the item is a number and is not NaN.
         */
        H.isNumber = function(n) {
            return typeof n === 'number' && !isNaN(n);
        };

        /**
         * Remove the last occurence of an item from an array.
         *
         * @function #erase
         * @memberOf Highcharts
         * @param {Array} arr - The array.
         * @param {*} item - The item to remove.
         */
        H.erase = function(arr, item) {
            var i = arr.length;
            while (i--) {
                if (arr[i] === item) {
                    arr.splice(i, 1);
                    break;
                }
            }
        };

        /**
         * Check if an object is null or undefined.
         *
         * @function #defined
         * @memberOf Highcharts
         * @param {Object} obj - The object to check.
         * @returns {Boolean} - False if the object is null or undefined, otherwise
         *        true.
         */
        H.defined = function(obj) {
            return obj !== undefined && obj !== null;
        };

        /**
         * Set or get an attribute or an object of attributes. To use as a setter, pass
         * a key and a value, or let the second argument be a collection of keys and
         * values. To use as a getter, pass only a string as the second argument.
         *
         * @function #attr
         * @memberOf Highcharts
         * @param {Object} elem - The DOM element to receive the attribute(s).
         * @param {String|Object} [prop] - The property or an object of key-value pairs.
         * @param {String} [value] - The value if a single property is set.
         * @returns {*} When used as a getter, return the value.
         */
        H.attr = function(elem, prop, value) {
            var ret;

            // if the prop is a string
            if (H.isString(prop)) {
                // set the value
                if (H.defined(value)) {
                    elem.setAttribute(prop, value);

                    // get the value
                } else if (elem && elem.getAttribute) {
                    ret = elem.getAttribute(prop);
                }

                // else if prop is defined, it is a hash of key/value pairs
            } else if (H.defined(prop) && H.isObject(prop)) {
                H.objectEach(prop, function(val, key) {
                    elem.setAttribute(key, val);
                });
            }
            return ret;
        };

        /**
         * Check if an element is an array, and if not, make it into an array.
         *
         * @function #splat
         * @memberOf Highcharts
         * @param obj {*} - The object to splat.
         * @returns {Array} The produced or original array.
         */
        H.splat = function(obj) {
            return H.isArray(obj) ? obj : [obj];
        };

        /**
         * Set a timeout if the delay is given, otherwise perform the function
         * synchronously.
         *
         * @function #syncTimeout
         * @memberOf Highcharts
         * @param   {Function} fn - The function callback.
         * @param   {Number}   delay - Delay in milliseconds.
         * @param   {Object}   [context] - The context.
         * @returns {Number} An identifier for the timeout that can later be cleared
         * with clearTimeout.
         */
        H.syncTimeout = function(fn, delay, context) {
            if (delay) {
                return setTimeout(fn, delay, context);
            }
            fn.call(0, context);
        };


        /**
         * Return the first value that is not null or undefined.
         *
         * @function #pick
         * @memberOf Highcharts
         * @param {...*} items - Variable number of arguments to inspect.
         * @returns {*} The value of the first argument that is not null or undefined.
         */
        H.pick = function() {
            var args = arguments,
                i,
                arg,
                length = args.length;
            for (i = 0; i < length; i++) {
                arg = args[i];
                if (arg !== undefined && arg !== null) {
                    return arg;
                }
            }
        };

        /**
         * @typedef {Object} CSSObject - A style object with camel case property names.
         * The properties can be whatever styles are supported on the given SVG or HTML
         * element.
         * @example
         * {
         *    fontFamily: 'monospace',
         *    fontSize: '1.2em'
         * }
         */
        /**
         * Set CSS on a given element.
         *
         * @function #css
         * @memberOf Highcharts
         * @param {HTMLDOMElement} el - A HTML DOM element.
         * @param {CSSObject} styles - Style object with camel case property names.
         * 
         */
        H.css = function(el, styles) {
            if (H.isMS && !H.svg) { // #2686
                if (styles && styles.opacity !== undefined) {
                    styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')';
                }
            }
            H.extend(el.style, styles);
        };

        /**
         * A HTML DOM element.
         * @typedef {Object} HTMLDOMElement
         */

        /**
         * Utility function to create an HTML element with attributes and styles.
         *
         * @function #createElement
         * @memberOf Highcharts
         * @param {String} tag - The HTML tag.
         * @param {Object} [attribs] - Attributes as an object of key-value pairs.
         * @param {CSSObject} [styles] - Styles as an object of key-value pairs.
         * @param {Object} [parent] - The parent HTML object.
         * @param {Boolean} [nopad=false] - If true, remove all padding, border and
         *    margin.
         * @returns {HTMLDOMElement} The created DOM element.
         */
        H.createElement = function(tag, attribs, styles, parent, nopad) {
            var el = doc.createElement(tag),
                css = H.css;
            if (attribs) {
                H.extend(el, attribs);
            }
            if (nopad) {
                css(el, {
                    padding: 0,
                    border: 'none',
                    margin: 0
                });
            }
            if (styles) {
                css(el, styles);
            }
            if (parent) {
                parent.appendChild(el);
            }
            return el;
        };

        /**
         * Extend a prototyped class by new members.
         *
         * @function #extendClass
         * @memberOf Highcharts
         * @param {Object} parent - The parent prototype to inherit.
         * @param {Object} members - A collection of prototype members to add or
         *        override compared to the parent prototype.
         * @returns {Object} A new prototype.
         */
        H.extendClass = function(parent, members) {
            var object = function() {};
            object.prototype = new parent(); // eslint-disable-line new-cap
            H.extend(object.prototype, members);
            return object;
        };

        /**
         * Left-pad a string to a given length by adding a character repetetively.
         *
         * @function #pad
         * @memberOf Highcharts
         * @param {Number} number - The input string or number.
         * @param {Number} length - The desired string length.
         * @param {String} [padder=0] - The character to pad with.
         * @returns {String} The padded string.
         */
        H.pad = function(number, length, padder) {
            return new Array((length || 2) + 1 -
                String(number).length).join(padder || 0) + number;
        };

        /**
         * @typedef {Number|String} RelativeSize - If a number is given, it defines the
         *    pixel length. If a percentage string is given, like for example `'50%'`,
         *    the setting defines a length relative to a base size, for example the size
         *    of a container.
         */
        /**
         * Return a length based on either the integer value, or a percentage of a base.
         *
         * @function #relativeLength
         * @memberOf Highcharts
         * @param  {RelativeSize} value
         *         A percentage string or a number.
         * @param  {number} base
         *         The full length that represents 100%.
         * @param  {number} [offset=0]
         *         A pixel offset to apply for percentage values. Used internally in 
         *         axis positioning.
         * @return {number}
         *         The computed length.
         */
        H.relativeLength = function(value, base, offset) {
            return (/%$/).test(value) ?
                (base * parseFloat(value) / 100) + (offset || 0) :
                parseFloat(value);
        };

        /**
         * Wrap a method with extended functionality, preserving the original function.
         *
         * @function #wrap
         * @memberOf Highcharts
         * @param {Object} obj - The context object that the method belongs to. In real
         *        cases, this is often a prototype.
         * @param {String} method - The name of the method to extend.
         * @param {Function} func - A wrapper function callback. This function is called
         *        with the same arguments as the original function, except that the
         *        original function is unshifted and passed as the first argument.
         * 
         */
        H.wrap = function(obj, method, func) {
            var proceed = obj[method];
            obj[method] = function() {
                var args = Array.prototype.slice.call(arguments),
                    outerArgs = arguments,
                    ctx = this,
                    ret;
                ctx.proceed = function() {
                    proceed.apply(ctx, arguments.length ? arguments : outerArgs);
                };
                args.unshift(proceed);
                ret = func.apply(this, args);
                ctx.proceed = null;
                return ret;
            };
        };

        /**
         * Get the time zone offset based on the current timezone information as set in
         * the global options.
         *
         * @function #getTZOffset
         * @memberOf Highcharts
         * @param  {Number} timestamp - The JavaScript timestamp to inspect.
         * @return {Number} - The timezone offset in minutes compared to UTC.
         */
        H.getTZOffset = function(timestamp) {
            var d = H.Date;
            return ((d.hcGetTimezoneOffset && d.hcGetTimezoneOffset(timestamp)) ||
                d.hcTimezoneOffset || 0) * 60000;
        };

        /**
         * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
         * human readable date string. The format is a subset of the formats for PHP's
         * [strftime]{@link
         * http://www.php.net/manual/en/function.strftime.php} function. Additional
         * formats can be given in the {@link Highcharts.dateFormats} hook.
         *
         * @function #dateFormat
         * @memberOf Highcharts
         * @param {String} format - The desired format where various time
         *        representations are prefixed with %.
         * @param {Number} timestamp - The JavaScript timestamp.
         * @param {Boolean} [capitalize=false] - Upper case first letter in the return.
         * @returns {String} The formatted date.
         */
        H.dateFormat = function(format, timestamp, capitalize) {
            if (!H.defined(timestamp) || isNaN(timestamp)) {
                return H.defaultOptions.lang.invalidDate || '';
            }
            format = H.pick(format, '%Y-%m-%d %H:%M:%S');

            var D = H.Date,
                date = new D(timestamp - H.getTZOffset(timestamp)),
                // get the basic time values
                hours = date[D.hcGetHours](),
                day = date[D.hcGetDay](),
                dayOfMonth = date[D.hcGetDate](),
                month = date[D.hcGetMonth](),
                fullYear = date[D.hcGetFullYear](),
                lang = H.defaultOptions.lang,
                langWeekdays = lang.weekdays,
                shortWeekdays = lang.shortWeekdays,
                pad = H.pad,

                // List all format keys. Custom formats can be added from the outside. 
                replacements = H.extend({

                        // Day
                        // Short weekday, like 'Mon'
                        'a': shortWeekdays ?
                            shortWeekdays[day] : langWeekdays[day].substr(0, 3),
                        // Long weekday, like 'Monday'
                        'A': langWeekdays[day],
                        // Two digit day of the month, 01 to 31
                        'd': pad(dayOfMonth),
                        // Day of the month, 1 through 31
                        'e': pad(dayOfMonth, 2, ' '),
                        'w': day,

                        // Week (none implemented)
                        // 'W': weekNumber(),

                        // Month
                        // Short month, like 'Jan'
                        'b': lang.shortMonths[month],
                        // Long month, like 'January'
                        'B': lang.months[month],
                        // Two digit month number, 01 through 12
                        'm': pad(month + 1),

                        // Year
                        // Two digits year, like 09 for 2009
                        'y': fullYear.toString().substr(2, 2),
                        // Four digits year, like 2009
                        'Y': fullYear,

                        // Time
                        // Two digits hours in 24h format, 00 through 23
                        'H': pad(hours),
                        // Hours in 24h format, 0 through 23
                        'k': hours,
                        // Two digits hours in 12h format, 00 through 11
                        'I': pad((hours % 12) || 12),
                        // Hours in 12h format, 1 through 12
                        'l': (hours % 12) || 12,
                        // Two digits minutes, 00 through 59
                        'M': pad(date[D.hcGetMinutes]()),
                        // Upper case AM or PM
                        'p': hours < 12 ? 'AM' : 'PM',
                        // Lower case AM or PM
                        'P': hours < 12 ? 'am' : 'pm',
                        // Two digits seconds, 00 through  59
                        'S': pad(date.getSeconds()),
                        // Milliseconds (naming from Ruby)
                        'L': pad(Math.round(timestamp % 1000), 3)
                    },

                    /**
                     * A hook for defining additional date format specifiers. New
                     * specifiers are defined as key-value pairs by using the specifier
                     * as key, and a function which takes the timestamp as value. This
                     * function returns the formatted portion of the date.
                     *
                     * @type {Object}
                     * @name dateFormats
                     * @memberOf Highcharts
                     * @sample highcharts/global/dateformats/ Adding support for week
                     * number
                     */
                    H.dateFormats
                );


            // Do the replaces
            H.objectEach(replacements, function(val, key) {
                // Regex would do it in one line, but this is faster
                while (format.indexOf('%' + key) !== -1) {
                    format = format.replace(
                        '%' + key,
                        typeof val === 'function' ? val(timestamp) : val
                    );
                }

            });

            // Optionally capitalize the string and return
            return capitalize ?
                format.substr(0, 1).toUpperCase() + format.substr(1) :
                format;
        };

        /**
         * Format a single variable. Similar to sprintf, without the % prefix.
         *
         * @example
         * formatSingle('.2f', 5); // => '5.00'.
         *
         * @function #formatSingle
         * @memberOf Highcharts
         * @param {String} format The format string.
         * @param {*} val The value.
         * @returns {String} The formatted representation of the value.
         */
        H.formatSingle = function(format, val) {
            var floatRegex = /f$/,
                decRegex = /\.([0-9])/,
                lang = H.defaultOptions.lang,
                decimals;

            if (floatRegex.test(format)) { // float
                decimals = format.match(decRegex);
                decimals = decimals ? decimals[1] : -1;
                if (val !== null) {
                    val = H.numberFormat(
                        val,
                        decimals,
                        lang.decimalPoint,
                        format.indexOf(',') > -1 ? lang.thousandsSep : ''
                    );
                }
            } else {
                val = H.dateFormat(format, val);
            }
            return val;
        };

        /**
         * Format a string according to a subset of the rules of Python's String.format
         * method.
         *
         * @function #format
         * @memberOf Highcharts
         * @param {String} str The string to format.
         * @param {Object} ctx The context, a collection of key-value pairs where each
         *        key is replaced by its value.
         * @returns {String} The formatted string.
         *
         * @example
         * var s = Highcharts.format(
         *     'The {color} fox was {len:.2f} feet long',
         *     { color: 'red', len: Math.PI }
         * );
         * // => The red fox was 3.14 feet long
         */
        H.format = function(str, ctx) {
            var splitter = '{',
                isInside = false,
                segment,
                valueAndFormat,
                path,
                i,
                len,
                ret = [],
                val,
                index;

            while (str) {
                index = str.indexOf(splitter);
                if (index === -1) {
                    break;
                }

                segment = str.slice(0, index);
                if (isInside) { // we're on the closing bracket looking back

                    valueAndFormat = segment.split(':');
                    path = valueAndFormat.shift().split('.'); // get first and leave
                    len = path.length;
                    val = ctx;

                    // Assign deeper paths
                    for (i = 0; i < len; i++) {
                        if (val) {
                            val = val[path[i]];
                        }
                    }

                    // Format the replacement
                    if (valueAndFormat.length) {
                        val = H.formatSingle(valueAndFormat.join(':'), val);
                    }

                    // Push the result and advance the cursor
                    ret.push(val);

                } else {
                    ret.push(segment);

                }
                str = str.slice(index + 1); // the rest
                isInside = !isInside; // toggle
                splitter = isInside ? '}' : '{'; // now look for next matching bracket
            }
            ret.push(str);
            return ret.join('');
        };

        /**
         * Get the magnitude of a number.
         *
         * @function #getMagnitude
         * @memberOf Highcharts
         * @param {Number} number The number.
         * @returns {Number} The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2
         *        etc.
         */
        H.getMagnitude = function(num) {
            return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
        };

        /**
         * Take an interval and normalize it to multiples of round numbers.
         *
         * @todo  Move this function to the Axis prototype. It is here only for
         *        historical reasons.
         * @function #normalizeTickInterval
         * @memberOf Highcharts
         * @param {Number} interval - The raw, un-rounded interval.
         * @param {Array} [multiples] - Allowed multiples.
         * @param {Number} [magnitude] - The magnitude of the number.
         * @param {Boolean} [allowDecimals] - Whether to allow decimals.
         * @param {Boolean} [hasTickAmount] - If it has tickAmount, avoid landing
         *        on tick intervals lower than original.
         * @returns {Number} The normalized interval.
         */
        H.normalizeTickInterval = function(interval, multiples, magnitude,
            allowDecimals, hasTickAmount) {
            var normalized,
                i,
                retInterval = interval;

            // round to a tenfold of 1, 2, 2.5 or 5
            magnitude = H.pick(magnitude, 1);
            normalized = interval / magnitude;

            // multiples for a linear scale
            if (!multiples) {
                multiples = hasTickAmount ?
                    // Finer grained ticks when the tick amount is hard set, including
                    // when alignTicks is true on multiple axes (#4580).
                    [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :

                    // Else, let ticks fall on rounder numbers
                    [1, 2, 2.5, 5, 10];


                // the allowDecimals option
                if (allowDecimals === false) {
                    if (magnitude === 1) {
                        multiples = H.grep(multiples, function(num) {
                            return num % 1 === 0;
                        });
                    } else if (magnitude <= 0.1) {
                        multiples = [1 / magnitude];
                    }
                }
            }

            // normalize the interval to the nearest multiple
            for (i = 0; i < multiples.length; i++) {
                retInterval = multiples[i];
                // only allow tick amounts smaller than natural
                if ((hasTickAmount && retInterval * magnitude >= interval) ||
                    (!hasTickAmount && (normalized <= (multiples[i] +
                        (multiples[i + 1] || multiples[i])) / 2))) {
                    break;
                }
            }

            // Multiply back to the correct magnitude. Correct floats to appropriate 
            // precision (#6085).
            retInterval = H.correctFloat(
                retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10)
            );

            return retInterval;
        };


        /**
         * Sort an object array and keep the order of equal items. The ECMAScript
         * standard does not specify the behaviour when items are equal.
         *
         * @function #stableSort
         * @memberOf Highcharts
         * @param {Array} arr - The array to sort.
         * @param {Function} sortFunction - The function to sort it with, like with 
         *        regular Array.prototype.sort.
         * 
         */
        H.stableSort = function(arr, sortFunction) {
            var length = arr.length,
                sortValue,
                i;

            // Add index to each item
            for (i = 0; i < length; i++) {
                arr[i].safeI = i; // stable sort index
            }

            arr.sort(function(a, b) {
                sortValue = sortFunction(a, b);
                return sortValue === 0 ? a.safeI - b.safeI : sortValue;
            });

            // Remove index from items
            for (i = 0; i < length; i++) {
                delete arr[i].safeI; // stable sort index
            }
        };

        /**
         * Non-recursive method to find the lowest member of an array. `Math.min` raises
         * a maximum call stack size exceeded error in Chrome when trying to apply more
         * than 150.000 points. This method is slightly slower, but safe.
         *
         * @function #arrayMin
         * @memberOf  Highcharts
         * @param {Array} data An array of numbers.
         * @returns {Number} The lowest number.
         */
        H.arrayMin = function(data) {
            var i = data.length,
                min = data[0];

            while (i--) {
                if (data[i] < min) {
                    min = data[i];
                }
            }
            return min;
        };

        /**
         * Non-recursive method to find the lowest member of an array. `Math.max` raises
         * a maximum call stack size exceeded error in Chrome when trying to apply more
         * than 150.000 points. This method is slightly slower, but safe.
         *
         * @function #arrayMax
         * @memberOf  Highcharts
         * @param {Array} data - An array of numbers.
         * @returns {Number} The highest number.
         */
        H.arrayMax = function(data) {
            var i = data.length,
                max = data[0];

            while (i--) {
                if (data[i] > max) {
                    max = data[i];
                }
            }
            return max;
        };

        /**
         * Utility method that destroys any SVGElement instances that are properties on
         * the given object. It loops all properties and invokes destroy if there is a
         * destroy method. The property is then delete.
         *
         * @function #destroyObjectProperties
         * @memberOf Highcharts
         * @param {Object} obj - The object to destroy properties on.
         * @param {Object} [except] - Exception, do not destroy this property, only
         *    delete it.
         * 
         */
        H.destroyObjectProperties = function(obj, except) {
            H.objectEach(obj, function(val, n) {
                // If the object is non-null and destroy is defined
                if (val && val !== except && val.destroy) {
                    // Invoke the destroy
                    val.destroy();
                }

                // Delete the property from the object.
                delete obj[n];
            });
        };


        /**
         * Discard a HTML element by moving it to the bin and delete.
         *
         * @function #discardElement
         * @memberOf Highcharts
         * @param {HTMLDOMElement} element - The HTML node to discard.
         * 
         */
        H.discardElement = function(element) {
            var garbageBin = H.garbageBin;
            // create a garbage bin element, not part of the DOM
            if (!garbageBin) {
                garbageBin = H.createElement('div');
            }

            // move the node and empty bin
            if (element) {
                garbageBin.appendChild(element);
            }
            garbageBin.innerHTML = '';
        };

        /**
         * Fix JS round off float errors.
         *
         * @function #correctFloat
         * @memberOf Highcharts
         * @param {Number} num - A float number to fix.
         * @param {Number} [prec=14] - The precision.
         * @returns {Number} The corrected float number.
         */
        H.correctFloat = function(num, prec) {
            return parseFloat(
                num.toPrecision(prec || 14)
            );
        };

        /**
         * Set the global animation to either a given value, or fall back to the given
         * chart's animation option.
         *
         * @function #setAnimation
         * @memberOf Highcharts
         * @param {Boolean|Animation} animation - The animation object.
         * @param {Object} chart - The chart instance.
         * 
         * @todo This function always relates to a chart, and sets a property on the
         *        renderer, so it should be moved to the SVGRenderer.
         */
        H.setAnimation = function(animation, chart) {
            chart.renderer.globalAnimation = H.pick(
                animation,
                chart.options.chart.animation,
                true
            );
        };

        /**
         * Get the animation in object form, where a disabled animation is always
         * returned as `{ duration: 0 }`.
         *
         * @function #animObject
         * @memberOf Highcharts
         * @param {Boolean|AnimationOptions} animation - An animation setting. Can be an
         *        object with duration, complete and easing properties, or a boolean to
         *        enable or disable.
         * @returns {AnimationOptions} An object with at least a duration property.
         */
        H.animObject = function(animation) {
            return H.isObject(animation) ?
                H.merge(animation) : {
                    duration: animation ? 500 : 0
                };
        };

        /**
         * The time unit lookup
         */
        H.timeUnits = {
            millisecond: 1,
            second: 1000,
            minute: 60000,
            hour: 3600000,
            day: 24 * 3600000,
            week: 7 * 24 * 3600000,
            month: 28 * 24 * 3600000,
            year: 364 * 24 * 3600000
        };

        /**
         * Format a number and return a string based on input settings.
         *
         * @function #numberFormat
         * @memberOf Highcharts
         * @param {Number} number - The input number to format.
         * @param {Number} decimals - The amount of decimals. A value of -1 preserves
         *        the amount in the input number.
         * @param {String} [decimalPoint] - The decimal point, defaults to the one given
         *        in the lang options, or a dot.
         * @param {String} [thousandsSep] - The thousands separator, defaults to the one
         *        given in the lang options, or a space character.
         * @returns {String} The formatted number.
         *
         * @sample highcharts/members/highcharts-numberformat/ Custom number format
         */
        H.numberFormat = function(number, decimals, decimalPoint, thousandsSep) {
            number = +number || 0;
            decimals = +decimals;

            var lang = H.defaultOptions.lang,
                origDec = (number.toString().split('.')[1] || '').split('e')[0].length,
                strinteger,
                thousands,
                ret,
                roundedNumber,
                exponent = number.toString().split('e');

            if (decimals === -1) {
                // Preserve decimals. Not huge numbers (#3793).
                decimals = Math.min(origDec, 20);
            } else if (!H.isNumber(decimals)) {
                decimals = 2;
            }

            // Add another decimal to avoid rounding errors of float numbers. (#4573)
            // Then use toFixed to handle rounding.
            roundedNumber = (
                Math.abs(exponent[1] ? exponent[0] : number) +
                Math.pow(10, -Math.max(decimals, origDec) - 1)
            ).toFixed(decimals);

            // A string containing the positive integer component of the number
            strinteger = String(H.pInt(roundedNumber));

            // Leftover after grouping into thousands. Can be 0, 1 or 3.
            thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;

            // Language
            decimalPoint = H.pick(decimalPoint, lang.decimalPoint);
            thousandsSep = H.pick(thousandsSep, lang.thousandsSep);

            // Start building the return
            ret = number < 0 ? '-' : '';

            // Add the leftover after grouping into thousands. For example, in the
            // number 42 000 000, this line adds 42.
            ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';

            // Add the remaining thousands groups, joined by the thousands separator
            ret += strinteger
                .substr(thousands)
                .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);

            // Add the decimal point and the decimal component
            if (decimals) {
                // Get the decimal component
                ret += decimalPoint + roundedNumber.slice(-decimals);
            }

            if (exponent[1]) {
                ret += 'e' + exponent[1];
            }

            return ret;
        };

        /**
         * Easing definition
         * @ignore
         * @param   {Number} pos Current position, ranging from 0 to 1.
         */
        Math.easeInOutSine = function(pos) {
            return -0.5 * (Math.cos(Math.PI * pos) - 1);
        };

        /**
         * Get the computed CSS value for given element and property, only for numerical
         * properties. For width and height, the dimension of the inner box (excluding
         * padding) is returned. Used for fitting the chart within the container.
         *
         * @function #getStyle
         * @memberOf Highcharts
         * @param {HTMLDOMElement} el - A HTML element.
         * @param {String} prop - The property name.
         * @param {Boolean} [toInt=true] - Parse to integer.
         * @returns {Number} - The numeric value.
         */
        H.getStyle = function(el, prop, toInt) {

            var style;

            // For width and height, return the actual inner pixel size (#4913)
            if (prop === 'width') {
                return Math.min(el.offsetWidth, el.scrollWidth) -
                    H.getStyle(el, 'padding-left') -
                    H.getStyle(el, 'padding-right');
            } else if (prop === 'height') {
                return Math.min(el.offsetHeight, el.scrollHeight) -
                    H.getStyle(el, 'padding-top') -
                    H.getStyle(el, 'padding-bottom');
            }

            if (!win.getComputedStyle) {
                // SVG not supported, forgot to load oldie.js?
                H.error(27, true);
            }

            // Otherwise, get the computed style
            style = win.getComputedStyle(el, undefined);
            if (style) {
                style = style.getPropertyValue(prop);
                if (H.pick(toInt, prop !== 'opacity')) {
                    style = H.pInt(style);
                }
            }
            return style;
        };

        /**
         * Search for an item in an array.
         *
         * @function #inArray
         * @memberOf Highcharts
         * @param {*} item - The item to search for.
         * @param {arr} arr - The array or node collection to search in.
         * @returns {Number} - The index within the array, or -1 if not found.
         */
        H.inArray = function(item, arr) {
            return (H.indexOfPolyfill || Array.prototype.indexOf).call(arr, item);
        };

        /**
         * Filter an array by a callback.
         *
         * @function #grep
         * @memberOf Highcharts
         * @param {Array} arr - The array to filter.
         * @param {Function} callback - The callback function. The function receives the
         *        item as the first argument. Return `true` if the item is to be
         *        preserved.
         * @returns {Array} - A new, filtered array.
         */
        H.grep = function(arr, callback) {
            return (H.filterPolyfill || Array.prototype.filter).call(arr, callback);
        };

        /**
         * Return the value of the first element in the array that satisfies the 
         * provided testing function.
         *
         * @function #find
         * @memberOf Highcharts
         * @param {Array} arr - The array to test.
         * @param {Function} callback - The callback function. The function receives the
         *        item as the first argument. Return `true` if this item satisfies the
         *        condition.
         * @returns {Mixed} - The value of the element.
         */
        H.find = Array.prototype.find ?
            function(arr, callback) {
                return arr.find(callback);
            } :
            // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
            function(arr, fn) {
                var i,
                    length = arr.length;

                for (i = 0; i < length; i++) {
                    if (fn(arr[i], i)) {
                        return arr[i];
                    }
                }
            };

        /**
         * Map an array by a callback.
         *
         * @function #map
         * @memberOf Highcharts
         * @param {Array} arr - The array to map.
         * @param {Function} fn - The callback function. Return the new value for the 
         *        new array.
         * @returns {Array} - A new array item with modified items.
         */
        H.map = function(arr, fn) {
            var results = [],
                i = 0,
                len = arr.length;

            for (; i < len; i++) {
                results[i] = fn.call(arr[i], arr[i], i, arr);
            }

            return results;
        };

        /**
         * Reduce an array to a single value.
         *
         * @function #reduce
         * @memberOf Highcharts
         * @param {Array} arr - The array to reduce.
         * @param {Function} fn - The callback function. Return the reduced value. 
         *  Receives 4 arguments: Accumulated/reduced value, current value, current 
         *  array index, and the array.
         * @param {Mixed} initialValue - The initial value of the accumulator.
         * @returns {Mixed} - The reduced value.
         */
        H.reduce = function(arr, func, initialValue) {
            return (H.reducePolyfill || Array.prototype.reduce).call(
                arr,
                func,
                initialValue
            );
        };

        /**
         * Get the element's offset position, corrected for `overflow: auto`.
         *
         * @function #offset
         * @memberOf Highcharts
         * @param {HTMLDOMElement} el - The HTML element.
         * @returns {Object} An object containing `left` and `top` properties for the
         * position in the page.
         */
        H.offset = function(el) {
            var docElem = doc.documentElement,
                box = el.getBoundingClientRect();

            return {
                top: box.top + (win.pageYOffset || docElem.scrollTop) -
                    (docElem.clientTop || 0),
                left: box.left + (win.pageXOffset || docElem.scrollLeft) -
                    (docElem.clientLeft || 0)
            };
        };

        /**
         * Stop running animation.
         *
         * @todo A possible extension to this would be to stop a single property, when
         * we want to continue animating others. Then assign the prop to the timer
         * in the Fx.run method, and check for the prop here. This would be an
         * improvement in all cases where we stop the animation from .attr. Instead of
         * stopping everything, we can just stop the actual attributes we're setting.
         *
         * @function #stop
         * @memberOf Highcharts
         * @param {SVGElement} el - The SVGElement to stop animation on.
         * @param {string} [prop] - The property to stop animating. If given, the stop
         *    method will stop a single property from animating, while others continue.
         * 
         */
        H.stop = function(el, prop) {

            var i = timers.length;

            // Remove timers related to this element (#4519)
            while (i--) {
                if (timers[i].elem === el && (!prop || prop === timers[i].prop)) {
                    timers[i].stopped = true; // #4667
                }
            }
        };

        /**
         * Iterate over an array.
         *
         * @function #each
         * @memberOf Highcharts
         * @param {Array} arr - The array to iterate over.
         * @param {Function} fn - The iterator callback. It passes three arguments:
         * * item - The array item.
         * * index - The item's index in the array.
         * * arr - The array that each is being applied to.
         * @param {Object} [ctx] The context.
         */
        H.each = function(arr, fn, ctx) { // modern browsers
            return (H.forEachPolyfill || Array.prototype.forEach).call(arr, fn, ctx);
        };

        /**
         * Iterate over object key pairs in an object.
         *
         * @function #objectEach
         * @memberOf Highcharts
         * @param  {Object}   obj - The object to iterate over.
         * @param  {Function} fn  - The iterator callback. It passes three arguments:
         * * value - The property value.
         * * key - The property key.
         * * obj - The object that objectEach is being applied to.
         * @param  {Object}   ctx The context
         */
        H.objectEach = function(obj, fn, ctx) {
            for (var key in obj) {
                if (obj.hasOwnProperty(key)) {
                    fn.call(ctx, obj[key], key, obj);
                }
            }
        };

        /**
         * Add an event listener.
         *
         * @function #addEvent
         * @memberOf Highcharts
         * @param {Object} el - The element or object to add a listener to. It can be a
         *        {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
         * @param {String} type - The event type.
         * @param {Function} fn - The function callback to execute when the event is 
         *        fired.
         * @returns {Function} A callback function to remove the added event.
         */
        H.addEvent = function(el, type, fn) {

            var events = el.hcEvents = el.hcEvents || {},
                addEventListener = el.addEventListener || H.addEventListenerPolyfill;

            // Handle DOM events
            if (addEventListener) {
                addEventListener.call(el, type, fn, false);
            }

            if (!events[type]) {
                events[type] = [];
            }

            events[type].push(fn);

            // Return a function that can be called to remove this event.
            return function() {
                H.removeEvent(el, type, fn);
            };
        };

        /**
         * Remove an event that was added with {@link Highcharts#addEvent}.
         *
         * @function #removeEvent
         * @memberOf Highcharts
         * @param {Object} el - The element to remove events on.
         * @param {String} [type] - The type of events to remove. If undefined, all
         *        events are removed from the element.
         * @param {Function} [fn] - The specific callback to remove. If undefined, all
         *        events that match the element and optionally the type are removed.
         * 
         */
        H.removeEvent = function(el, type, fn) {

            var events,
                hcEvents = el.hcEvents,
                index;

            function removeOneEvent(type, fn) {
                var removeEventListener =
                    el.removeEventListener || H.removeEventListenerPolyfill;

                if (removeEventListener) {
                    removeEventListener.call(el, type, fn, false);
                }
            }

            function removeAllEvents() {
                var types,
                    len;

                if (!el.nodeName) {
                    return; // break on non-DOM events
                }

                if (type) {
                    types = {};
                    types[type] = true;
                } else {
                    types = hcEvents;
                }

                H.objectEach(types, function(val, n) {
                    if (hcEvents[n]) {
                        len = hcEvents[n].length;
                        while (len--) {
                            removeOneEvent(n, hcEvents[n][len]);
                        }
                    }
                });
            }

            if (hcEvents) {
                if (type) {
                    events = hcEvents[type] || [];
                    if (fn) {
                        index = H.inArray(fn, events);
                        if (index > -1) {
                            events.splice(index, 1);
                            hcEvents[type] = events;
                        }
                        removeOneEvent(type, fn);

                    } else {
                        removeAllEvents();
                        hcEvents[type] = [];
                    }
                } else {
                    removeAllEvents();
                    el.hcEvents = {};
                }
            }
        };

        /**
         * Fire an event that was registered with {@link Highcharts#addEvent}.
         *
         * @function #fireEvent
         * @memberOf Highcharts
         * @param {Object} el - The object to fire the event on. It can be a
         *        {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
         * @param {String} type - The type of event.
         * @param {Object} [eventArguments] - Custom event arguments that are passed on
         *        as an argument to the event handler.
         * @param {Function} [defaultFunction] - The default function to execute if the 
         *        other listeners haven't returned false.
         * 
         */
        H.fireEvent = function(el, type, eventArguments, defaultFunction) {
            var e,
                hcEvents = el.hcEvents,
                events,
                len,
                i,
                fn;

            eventArguments = eventArguments || {};

            if (doc.createEvent && (el.dispatchEvent || el.fireEvent)) {
                e = doc.createEvent('Events');
                e.initEvent(type, true, true);

                H.extend(e, eventArguments);

                if (el.dispatchEvent) {
                    el.dispatchEvent(e);
                } else {
                    el.fireEvent(type, e);
                }

            } else if (hcEvents) {

                events = hcEvents[type] || [];
                len = events.length;

                if (!eventArguments.target) { // We're running a custom event

                    H.extend(eventArguments, {
                        // Attach a simple preventDefault function to skip default
                        // handler if called. The built-in defaultPrevented property is
                        // not overwritable (#5112)
                        preventDefault: function() {
                            eventArguments.defaultPrevented = true;
                        },
                        // Setting target to native events fails with clicking the
                        // zoom-out button in Chrome.
                        target: el,
                        // If the type is not set, we're running a custom event (#2297).
                        // If it is set, we're running a browser event, and setting it
                        // will cause en error in IE8 (#2465).		
                        type: type
                    });
                }


                for (i = 0; i < len; i++) {
                    fn = events[i];

                    // If the event handler return false, prevent the default handler
                    // from executing
                    if (fn && fn.call(el, eventArguments) === false) {
                        eventArguments.preventDefault();
                    }
                }
            }

            // Run the default if not prevented
            if (defaultFunction && !eventArguments.defaultPrevented) {
                defaultFunction(eventArguments);
            }
        };

        /**
         * An animation configuration. Animation configurations can also be defined as
         * booleans, where `false` turns off animation and `true` defaults to a duration
         * of 500ms.
         * @typedef {Object} AnimationOptions
         * @property {Number} duration - The animation duration in milliseconds.
         * @property {String} [easing] - The name of an easing function as defined on
         *     the `Math` object.
         * @property {Function} [complete] - A callback function to exectute when the
         *     animation finishes.
         * @property {Function} [step] - A callback function to execute on each step of
         *     each attribute or CSS property that's being animated. The first argument
         *     contains information about the animation and progress.
         */


        /**
         * The global animate method, which uses Fx to create individual animators.
         *
         * @function #animate
         * @memberOf Highcharts
         * @param {HTMLDOMElement|SVGElement} el - The element to animate.
         * @param {Object} params - An object containing key-value pairs of the
         *        properties to animate. Supports numeric as pixel-based CSS properties
         *        for HTML objects and attributes for SVGElements.
         * @param {AnimationOptions} [opt] - Animation options.
         */
        H.animate = function(el, params, opt) {
            var start,
                unit = '',
                end,
                fx,
                args;

            if (!H.isObject(opt)) { // Number or undefined/null
                args = arguments;
                opt = {
                    duration: args[2],
                    easing: args[3],
                    complete: args[4]
                };
            }
            if (!H.isNumber(opt.duration)) {
                opt.duration = 400;
            }
            opt.easing = typeof opt.easing === 'function' ?
                opt.easing :
                (Math[opt.easing] || Math.easeInOutSine);
            opt.curAnim = H.merge(params);

            H.objectEach(params, function(val, prop) {
                // Stop current running animation of this property
                H.stop(el, prop);

                fx = new H.Fx(el, opt, prop);
                end = null;

                if (prop === 'd') {
                    fx.paths = fx.initPath(
                        el,
                        el.d,
                        params.d
                    );
                    fx.toD = params.d;
                    start = 0;
                    end = 1;
                } else if (el.attr) {
                    start = el.attr(prop);
                } else {
                    start = parseFloat(H.getStyle(el, prop)) || 0;
                    if (prop !== 'opacity') {
                        unit = 'px';
                    }
                }

                if (!end) {
                    end = val;
                }
                if (end && end.match && end.match('px')) {
                    end = end.replace(/px/g, ''); // #4351
                }
                fx.run(start, end, unit);
            });
        };

        /**
         * Factory to create new series prototypes.
         *
         * @function #seriesType
         * @memberOf Highcharts
         *
         * @param {String} type - The series type name.
         * @param {String} parent - The parent series type name. Use `line` to inherit
         *        from the basic {@link Series} object.
         * @param {Object} options - The additional default options that is merged with
         *        the parent's options.
         * @param {Object} props - The properties (functions and primitives) to set on
         *        the new prototype.
         * @param {Object} [pointProps] - Members for a series-specific extension of the
         *        {@link Point} prototype if needed.
         * @returns {*} - The newly created prototype as extended from {@link Series}
         * or its derivatives.
         */
        // docs: add to API + extending Highcharts
        H.seriesType = function(type, parent, options, props, pointProps) {
            var defaultOptions = H.getOptions(),
                seriesTypes = H.seriesTypes;

            // Merge the options
            defaultOptions.plotOptions[type] = H.merge(
                defaultOptions.plotOptions[parent],
                options
            );

            // Create the class
            seriesTypes[type] = H.extendClass(seriesTypes[parent] ||
                function() {}, props);
            seriesTypes[type].prototype.type = type;

            // Create the point class if needed
            if (pointProps) {
                seriesTypes[type].prototype.pointClass =
                    H.extendClass(H.Point, pointProps);
            }

            return seriesTypes[type];
        };

        /**
         * Get a unique key for using in internal element id's and pointers. The key
         * is composed of a random hash specific to this Highcharts instance, and a 
         * counter.
         * @function #uniqueKey
         * @memberOf Highcharts
         * @return {string} The key.
         * @example
         * var id = H.uniqueKey(); // => 'highcharts-x45f6hp-0'
         */
        H.uniqueKey = (function() {

            var uniqueKeyHash = Math.random().toString(36).substring(2, 9),
                idCounter = 0;

            return function() {
                return 'highcharts-' + uniqueKeyHash + '-' + idCounter++;
            };
        }());

        /**
         * Register Highcharts as a plugin in jQuery
         */
        if (win.jQuery) {
            win.jQuery.fn.highcharts = function() {
                var args = [].slice.call(arguments);

                if (this[0]) { // this[0] is the renderTo div

                    // Create the chart
                    if (args[0]) {
                        new H[ // eslint-disable-line no-new
                            // Constructor defaults to Chart
                            H.isString(args[0]) ? args.shift() : 'Chart'
                        ](this[0], args[0], args[1]);
                        return this;
                    }

                    // When called without parameters or with the return argument,
                    // return an existing chart
                    return charts[H.attr(this[0], 'data-highcharts-chart')];
                }
            };
        }

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var each = H.each,
            isNumber = H.isNumber,
            map = H.map,
            merge = H.merge,
            pInt = H.pInt;

        /**
         * @typedef {string} ColorString
         * A valid color to be parsed and handled by Highcharts. Highcharts internally 
         * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
         * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
         * browsers and displayed correctly, but Highcharts is not able to process them
         * and apply concepts like opacity and brightening.
         */
        /**
         * Handle color operations. The object methods are chainable.
         * @param {String} input The input color in either rbga or hex format
         */
        H.Color = function(input) {
            // Backwards compatibility, allow instanciation without new
            if (!(this instanceof H.Color)) {
                return new H.Color(input);
            }
            // Initialize
            this.init(input);
        };
        H.Color.prototype = {

            // Collection of parsers. This can be extended from the outside by pushing parsers
            // to Highcharts.Color.prototype.parsers.
            parsers: [{
                // RGBA color
                regex: /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,
                parse: function(result) {
                    return [pInt(result[1]), pInt(result[2]), pInt(result[3]), parseFloat(result[4], 10)];
                }
            }, {
                // RGB color
                regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
                parse: function(result) {
                    return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
                }
            }],

            // Collection of named colors. Can be extended from the outside by adding
            // colors to Highcharts.Color.prototype.names.
            names: {
                none: 'rgba(255,255,255,0)',
                white: '#ffffff',
                black: '#000000'
            },

            /**
             * Parse the input color to rgba array
             * @param {String} input
             */
            init: function(input) {
                var result,
                    rgba,
                    i,
                    parser,
                    len;

                this.input = input = this.names[
                    input && input.toLowerCase ?
                    input.toLowerCase() :
                    ''
                ] || input;

                // Gradients
                if (input && input.stops) {
                    this.stops = map(input.stops, function(stop) {
                        return new H.Color(stop[1]);
                    });

                    // Solid colors
                } else {

                    // Bitmasking as input[0] is not working for legacy IE.
                    if (input && input.charAt && input.charAt() === '#') {

                        len = input.length;
                        input = parseInt(input.substr(1), 16);

                        // Handle long-form, e.g. #AABBCC
                        if (len === 7) {

                            rgba = [
                                (input & 0xFF0000) >> 16,
                                (input & 0xFF00) >> 8,
                                (input & 0xFF),
                                1
                            ];

                            // Handle short-form, e.g. #ABC
                            // In short form, the value is assumed to be the same 
                            // for both nibbles for each component. e.g. #ABC = #AABBCC
                        } else if (len === 4) {

                            rgba = [
                                ((input & 0xF00) >> 4) | (input & 0xF00) >> 8,
                                ((input & 0xF0) >> 4) | (input & 0xF0),
                                ((input & 0xF) << 4) | (input & 0xF),
                                1
                            ];
                        }
                    }

                    // Otherwise, check regex parsers
                    if (!rgba) {
                        i = this.parsers.length;
                        while (i-- && !rgba) {
                            parser = this.parsers[i];
                            result = parser.regex.exec(input);
                            if (result) {
                                rgba = parser.parse(result);
                            }
                        }
                    }
                }
                this.rgba = rgba || [];
            },

            /**
             * Return the color a specified format
             * @param {String} format
             */
            get: function(format) {
                var input = this.input,
                    rgba = this.rgba,
                    ret;

                if (this.stops) {
                    ret = merge(input);
                    ret.stops = [].concat(ret.stops);
                    each(this.stops, function(stop, i) {
                        ret.stops[i] = [ret.stops[i][0], stop.get(format)];
                    });

                    // it's NaN if gradient colors on a column chart
                } else if (rgba && isNumber(rgba[0])) {
                    if (format === 'rgb' || (!format && rgba[3] === 1)) {
                        ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
                    } else if (format === 'a') {
                        ret = rgba[3];
                    } else {
                        ret = 'rgba(' + rgba.join(',') + ')';
                    }
                } else {
                    ret = input;
                }
                return ret;
            },

            /**
             * Brighten the color
             * @param {Number} alpha
             */
            brighten: function(alpha) {
                var i,
                    rgba = this.rgba;

                if (this.stops) {
                    each(this.stops, function(stop) {
                        stop.brighten(alpha);
                    });

                } else if (isNumber(alpha) && alpha !== 0) {
                    for (i = 0; i < 3; i++) {
                        rgba[i] += pInt(alpha * 255);

                        if (rgba[i] < 0) {
                            rgba[i] = 0;
                        }
                        if (rgba[i] > 255) {
                            rgba[i] = 255;
                        }
                    }
                }
                return this;
            },

            /**
             * Set the color's opacity to a given alpha value
             * @param {Number} alpha
             */
            setOpacity: function(alpha) {
                this.rgba[3] = alpha;
                return this;
            },

            /*
             * Return an intermediate color between two colors.
             *
             * @param  {Highcharts.Color} to
             *         The color object to tween to.
             * @param  {Number} pos
             *         The intermediate position, where 0 is the from color (current
             *         color item), and 1 is the `to` color.
             *
             * @return {String}
             *         The intermediate color in rgba notation.
             */
            tweenTo: function(to, pos) {
                // Check for has alpha, because rgba colors perform worse due to lack of
                // support in WebKit.
                var fromRgba = this.rgba,
                    toRgba = to.rgba,
                    hasAlpha,
                    ret;

                // Unsupported color, return to-color (#3920, #7034)
                if (!toRgba.length || !fromRgba || !fromRgba.length) {
                    ret = to.input || 'none';

                    // Interpolate
                } else {
                    hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
                    ret = (hasAlpha ? 'rgba(' : 'rgb(') +
                        Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
                        ',' +
                        Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
                        ',' +
                        Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
                        (
                            hasAlpha ?
                            (
                                ',' +
                                (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))
                            ) :
                            ''
                        ) +
                        ')';
                }
                return ret;
            }
        };
        H.color = function(input) {
            return new H.Color(input);
        };

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var SVGElement,
            SVGRenderer,

            addEvent = H.addEvent,
            animate = H.animate,
            attr = H.attr,
            charts = H.charts,
            color = H.color,
            css = H.css,
            createElement = H.createElement,
            defined = H.defined,
            deg2rad = H.deg2rad,
            destroyObjectProperties = H.destroyObjectProperties,
            doc = H.doc,
            each = H.each,
            extend = H.extend,
            erase = H.erase,
            grep = H.grep,
            hasTouch = H.hasTouch,
            inArray = H.inArray,
            isArray = H.isArray,
            isFirefox = H.isFirefox,
            isMS = H.isMS,
            isObject = H.isObject,
            isString = H.isString,
            isWebKit = H.isWebKit,
            merge = H.merge,
            noop = H.noop,
            objectEach = H.objectEach,
            pick = H.pick,
            pInt = H.pInt,
            removeEvent = H.removeEvent,
            splat = H.splat,
            stop = H.stop,
            svg = H.svg,
            SVG_NS = H.SVG_NS,
            symbolSizes = H.symbolSizes,
            win = H.win;

        /**
         * @typedef {Object} SVGDOMElement - An SVG DOM element.
         */
        /**
         * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
         * rendering layer of Highcharts. Combined with the {@link
         * Highcharts.SVGRenderer} object, these prototypes allow freeform annotation
         * in the charts or even in HTML pages without instanciating a chart. The
         * SVGElement can also wrap HTML labels, when `text` or `label` elements are
         * created with the `useHTML` parameter.
         *
         * The SVGElement instances are created through factory functions on the 
         * {@link Highcharts.SVGRenderer} object, like
         * [rect]{@link Highcharts.SVGRenderer#rect}, [path]{@link
         * Highcharts.SVGRenderer#path}, [text]{@link Highcharts.SVGRenderer#text},
         * [label]{@link Highcharts.SVGRenderer#label}, [g]{@link
         * Highcharts.SVGRenderer#g} and more.
         *
         * @class Highcharts.SVGElement
         */
        SVGElement = H.SVGElement = function() {
            return this;
        };
        extend(SVGElement.prototype, /** @lends Highcharts.SVGElement.prototype */ {

            // Default base for animation
            opacity: 1,
            SVG_NS: SVG_NS,

            /**
             * For labels, these CSS properties are applied to the `text` node directly.
             *
             * @private
             * @type {Array.<string>}
             */
            textProps: ['direction', 'fontSize', 'fontWeight', 'fontFamily',
                'fontStyle', 'color', 'lineHeight', 'width', 'textAlign',
                'textDecoration', 'textOverflow', 'textOutline'
            ],

            /**
             * Initialize the SVG renderer. This function only exists to make the
             * initiation process overridable. It should not be called directly.
             *
             * @param  {SVGRenderer} renderer
             *         The SVGRenderer instance to initialize to.
             * @param  {String} nodeName
             *         The SVG node name.
             * 
             */
            init: function(renderer, nodeName) {

                /** 
                 * The primary DOM node. Each `SVGElement` instance wraps a main DOM
                 * node, but may also represent more nodes.
                 *
                 * @name  element
                 * @memberOf SVGElement
                 * @type {SVGDOMNode|HTMLDOMNode}
                 */
                this.element = nodeName === 'span' ?
                    createElement(nodeName) :
                    doc.createElementNS(this.SVG_NS, nodeName);

                /**
                 * The renderer that the SVGElement belongs to.
                 *
                 * @name renderer
                 * @memberOf SVGElement
                 * @type {SVGRenderer}
                 */
                this.renderer = renderer;
            },

            /**
             * Animate to given attributes or CSS properties.
             * 
             * @param {SVGAttributes} params SVG attributes or CSS to animate.
             * @param {AnimationOptions} [options] Animation options.
             * @param {Function} [complete] Function to perform at the end of animation.
             *
             * @sample highcharts/members/element-on/
             *         Setting some attributes by animation
             * 
             * @returns {SVGElement} Returns the SVGElement for chaining.
             */
            animate: function(params, options, complete) {
                var animOptions = H.animObject(
                    pick(options, this.renderer.globalAnimation, true)
                );
                if (animOptions.duration !== 0) {
                    // allows using a callback with the global animation without
                    // overwriting it
                    if (complete) {
                        animOptions.complete = complete;
                    }
                    animate(this, params, animOptions);
                } else {
                    this.attr(params, null, complete);
                    if (animOptions.step) {
                        animOptions.step.call(this);
                    }
                }
                return this;
            },

            /**
             * @typedef {Object} GradientOptions
             * @property {Object} linearGradient Holds an object that defines the start
             *    position and the end position relative to the shape.
             * @property {Number} linearGradient.x1 Start horizontal position of the
             *    gradient. Ranges 0-1.
             * @property {Number} linearGradient.x2 End horizontal position of the
             *    gradient. Ranges 0-1.
             * @property {Number} linearGradient.y1 Start vertical position of the
             *    gradient. Ranges 0-1.
             * @property {Number} linearGradient.y2 End vertical position of the
             *    gradient. Ranges 0-1.
             * @property {Object} radialGradient Holds an object that defines the center
             *    position and the radius.
             * @property {Number} radialGradient.cx Center horizontal position relative
             *    to the shape. Ranges 0-1.
             * @property {Number} radialGradient.cy Center vertical position relative
             *    to the shape. Ranges 0-1.
             * @property {Number} radialGradient.r Radius relative to the shape. Ranges
             *    0-1.
             * @property {Array.<Array>} stops The first item in each tuple is the
             *    position in the gradient, where 0 is the start of the gradient and 1
             *    is the end of the gradient. Multiple stops can be applied. The second
             *    item is the color for each stop. This color can also be given in the
             *    rgba format.
             *
             * @example
             * // Linear gradient used as a color option
             * color: {
             *     linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
             *         stops: [
             *             [0, '#003399'], // start
             *             [0.5, '#ffffff'], // middle
             *             [1, '#3366AA'] // end
             *         ]
             *     }
             * }
             */
            /**
             * Build and apply an SVG gradient out of a common JavaScript configuration
             * object. This function is called from the attribute setters.
             *
             * @private
             * @param {GradientOptions} color The gradient options structure.
             * @param {string} prop The property to apply, can either be `fill` or
             * `stroke`. 
             * @param {SVGDOMElement} elem SVG DOM element to apply the gradient on.
             */
            colorGradient: function(color, prop, elem) {
                var renderer = this.renderer,
                    colorObject,
                    gradName,
                    gradAttr,
                    radAttr,
                    gradients,
                    gradientObject,
                    stops,
                    stopColor,
                    stopOpacity,
                    radialReference,
                    id,
                    key = [],
                    value;

                // Apply linear or radial gradients
                if (color.radialGradient) {
                    gradName = 'radialGradient';
                } else if (color.linearGradient) {
                    gradName = 'linearGradient';
                }

                if (gradName) {
                    gradAttr = color[gradName];
                    gradients = renderer.gradients;
                    stops = color.stops;
                    radialReference = elem.radialReference;

                    // Keep < 2.2 kompatibility
                    if (isArray(gradAttr)) {
                        color[gradName] = gradAttr = {
                            x1: gradAttr[0],
                            y1: gradAttr[1],
                            x2: gradAttr[2],
                            y2: gradAttr[3],
                            gradientUnits: 'userSpaceOnUse'
                        };
                    }

                    // Correct the radial gradient for the radial reference system
                    if (
                        gradName === 'radialGradient' &&
                        radialReference &&
                        !defined(gradAttr.gradientUnits)
                    ) {
                        radAttr = gradAttr; // Save the radial attributes for updating
                        gradAttr = merge(
                            gradAttr,
                            renderer.getRadialAttr(radialReference, radAttr), {
                                gradientUnits: 'userSpaceOnUse'
                            }
                        );
                    }

                    // Build the unique key to detect whether we need to create a new
                    // element (#1282)
                    objectEach(gradAttr, function(val, n) {
                        if (n !== 'id') {
                            key.push(n, val);
                        }
                    });
                    objectEach(stops, function(val) {
                        key.push(val);
                    });
                    key = key.join(',');

                    // Check if a gradient object with the same config object is created
                    // within this renderer
                    if (gradients[key]) {
                        id = gradients[key].attr('id');

                    } else {

                        // Set the id and create the element
                        gradAttr.id = id = H.uniqueKey();
                        gradients[key] = gradientObject =
                            renderer.createElement(gradName)
                            .attr(gradAttr)
                            .add(renderer.defs);

                        gradientObject.radAttr = radAttr;

                        // The gradient needs to keep a list of stops to be able to
                        // destroy them
                        gradientObject.stops = [];
                        each(stops, function(stop) {
                            var stopObject;
                            if (stop[1].indexOf('rgba') === 0) {
                                colorObject = H.color(stop[1]);
                                stopColor = colorObject.get('rgb');
                                stopOpacity = colorObject.get('a');
                            } else {
                                stopColor = stop[1];
                                stopOpacity = 1;
                            }
                            stopObject = renderer.createElement('stop').attr({
                                offset: stop[0],
                                'stop-color': stopColor,
                                'stop-opacity': stopOpacity
                            }).add(gradientObject);

                            // Add the stop element to the gradient
                            gradientObject.stops.push(stopObject);
                        });
                    }

                    // Set the reference to the gradient object
                    value = 'url(' + renderer.url + '#' + id + ')';
                    elem.setAttribute(prop, value);
                    elem.gradient = key;

                    // Allow the color to be concatenated into tooltips formatters etc.
                    // (#2995)
                    color.toString = function() {
                        return value;
                    };
                }
            },

            /**
             * Apply a text outline through a custom CSS property, by copying the text
             * element and apply stroke to the copy. Used internally. Contrast checks
             * at http://jsfiddle.net/highcharts/43soe9m1/2/ .
             *
             * @private
             * @param {String} textOutline A custom CSS `text-outline` setting, defined
             *    by `width color`. 
             * @example
             * // Specific color
             * text.css({
             *    textOutline: '1px black'
             * });
             * // Automatic contrast
             * text.css({
             *    color: '#000000', // black text
             *    textOutline: '1px contrast' // => white outline
             * });
             */
            applyTextOutline: function(textOutline) {
                var elem = this.element,
                    tspans,
                    tspan,
                    hasContrast = textOutline.indexOf('contrast') !== -1,
                    styles = {},
                    color,
                    strokeWidth,
                    firstRealChild,
                    i;

                // When the text shadow is set to contrast, use dark stroke for light
                // text and vice versa.
                if (hasContrast) {
                    styles.textOutline = textOutline = textOutline.replace(
                        /contrast/g,
                        this.renderer.getContrast(elem.style.fill)
                    );
                }

                // Extract the stroke width and color
                textOutline = textOutline.split(' ');
                color = textOutline[textOutline.length - 1];
                strokeWidth = textOutline[0];

                if (strokeWidth && strokeWidth !== 'none' && H.svg) {

                    this.fakeTS = true; // Fake text shadow

                    tspans = [].slice.call(elem.getElementsByTagName('tspan'));

                    // In order to get the right y position of the clone,
                    // copy over the y setter
                    this.ySetter = this.xSetter;

                    // Since the stroke is applied on center of the actual outline, we
                    // need to double it to get the correct stroke-width outside the 
                    // glyphs.
                    strokeWidth = strokeWidth.replace(
                        /(^[\d\.]+)(.*?)$/g,
                        function(match, digit, unit) {
                            return (2 * digit) + unit;
                        }
                    );

                    // Remove shadows from previous runs. Iterate from the end to
                    // support removing items inside the cycle (#6472).
                    i = tspans.length;
                    while (i--) {
                        tspan = tspans[i];
                        if (tspan.getAttribute('class') === 'highcharts-text-outline') {
                            // Remove then erase
                            erase(tspans, elem.removeChild(tspan));
                        }
                    }

                    // For each of the tspans, create a stroked copy behind it.
                    firstRealChild = elem.firstChild;
                    each(tspans, function(tspan, y) {
                        var clone;

                        // Let the first line start at the correct X position
                        if (y === 0) {
                            tspan.setAttribute('x', elem.getAttribute('x'));
                            y = elem.getAttribute('y');
                            tspan.setAttribute('y', y || 0);
                            if (y === null) {
                                elem.setAttribute('y', 0);
                            }
                        }

                        // Create the clone and apply outline properties
                        clone = tspan.cloneNode(1);
                        attr(clone, {
                            'class': 'highcharts-text-outline',
                            'fill': color,
                            'stroke': color,
                            'stroke-width': strokeWidth,
                            'stroke-linejoin': 'round'
                        });
                        elem.insertBefore(clone, firstRealChild);
                    });
                }
            },

            /**
             *
             * @typedef {Object} SVGAttributes An object of key-value pairs for SVG
             *   attributes. Attributes in Highcharts elements for the most parts
             *   correspond to SVG, but some are specific to Highcharts, like `zIndex`,
             *   `rotation`, `rotationOriginX`, `rotationOriginY`, `translateX`,
             *   `translateY`, `scaleX` and `scaleY`. SVG attributes containing a hyphen
             *   are _not_ camel-cased, they should be quoted to preserve the hyphen.
             *   
             * @example
             * {
             *     'stroke': '#ff0000', // basic
             *     'stroke-width': 2, // hyphenated
             *     'rotation': 45 // custom
             *     'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
             * }
             */
            /**
             * Apply native and custom attributes to the SVG elements.
             * 
             * In order to set the rotation center for rotation, set x and y to 0 and
             * use `translateX` and `translateY` attributes to position the element
             * instead.
             *
             * Attributes frequently used in Highcharts are `fill`, `stroke`,
             * `stroke-width`.
             *
             * @param {SVGAttributes|String} hash - The native and custom SVG
             *    attributes. 
             * @param {string} [val] - If the type of the first argument is `string`, 
             *    the second can be a value, which will serve as a single attribute
             *    setter. If the first argument is a string and the second is undefined,
             *    the function serves as a getter and the current value of the property
             *    is returned.
             * @param {Function} [complete] - A callback function to execute after
             *    setting the attributes. This makes the function compliant and
             *    interchangeable with the {@link SVGElement#animate} function.
             * @param {boolean} [continueAnimation=true] Used internally when `.attr` is
             *    called as part of an animation step. Otherwise, calling `.attr` for an
             *    attribute will stop animation for that attribute.
             *    
             * @returns {SVGElement|string|number} If used as a setter, it returns the 
             *    current {@link SVGElement} so the calls can be chained. If used as a 
             *    getter, the current value of the attribute is returned.
             *
             * @sample highcharts/members/renderer-rect/
             *         Setting some attributes
             * 
             * @example
             * // Set multiple attributes
             * element.attr({
             *     stroke: 'red',
             *     fill: 'blue',
             *     x: 10,
             *     y: 10
             * });
             *
             * // Set a single attribute
             * element.attr('stroke', 'red');
             *
             * // Get an attribute
             * element.attr('stroke'); // => 'red'
             * 
             */
            attr: function(hash, val, complete, continueAnimation) {
                var key,
                    element = this.element,
                    hasSetSymbolSize,
                    ret = this,
                    skipAttr,
                    setter;

                // single key-value pair
                if (typeof hash === 'string' && val !== undefined) {
                    key = hash;
                    hash = {};
                    hash[key] = val;
                }

                // used as a getter: first argument is a string, second is undefined
                if (typeof hash === 'string') {
                    ret = (this[hash + 'Getter'] || this._defaultGetter).call(
                        this,
                        hash,
                        element
                    );

                    // setter
                } else {

                    objectEach(hash, function(val, key) {
                        skipAttr = false;

                        // Unless .attr is from the animator update, stop current
                        // running animation of this property
                        if (!continueAnimation) {
                            stop(this, key);
                        }

                        // Special handling of symbol attributes
                        if (
                            this.symbolName &&
                            /^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)$/
                            .test(key)
                        ) {
                            if (!hasSetSymbolSize) {
                                this.symbolAttr(hash);
                                hasSetSymbolSize = true;
                            }
                            skipAttr = true;
                        }

                        if (this.rotation && (key === 'x' || key === 'y')) {
                            this.doTransform = true;
                        }

                        if (!skipAttr) {
                            setter = this[key + 'Setter'] || this._defaultSetter;
                            setter.call(this, val, key, element);


                            // Let the shadow follow the main element
                            if (
                                this.shadows &&
                                /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/
                                .test(key)
                            ) {
                                this.updateShadows(key, val, setter);
                            }

                        }
                    }, this);

                    this.afterSetters();
                }

                // In accordance with animate, run a complete callback
                if (complete) {
                    complete();
                }

                return ret;
            },

            /**
             * This method is executed in the end of `attr()`, after setting all
             * attributes in the hash. In can be used to efficiently consolidate
             * multiple attributes in one SVG property -- e.g., translate, rotate and
             * scale are merged in one "transform" attribute in the SVG node.
             *
             * @private
             */
            afterSetters: function() {
                // Update transform. Do this outside the loop to prevent redundant
                // updating for batch setting of attributes.
                if (this.doTransform) {
                    this.updateTransform();
                    this.doTransform = false;
                }
            },


            /**
             * Update the shadow elements with new attributes.
             *
             * @private
             * @param {String} key - The attribute name.
             * @param {String|Number} value - The value of the attribute.
             * @param {Function} setter - The setter function, inherited from the
             *   parent wrapper
             * 
             */
            updateShadows: function(key, value, setter) {
                var shadows = this.shadows,
                    i = shadows.length;

                while (i--) {
                    setter.call(
                        shadows[i],
                        key === 'height' ?
                        Math.max(value - (shadows[i].cutHeight || 0), 0) :
                        key === 'd' ? this.d : value,
                        key,
                        shadows[i]
                    );
                }
            },


            /**
             * Add a class name to an element.
             *
             * @param {string} className - The new class name to add.
             * @param {boolean} [replace=false] - When true, the existing class name(s)
             *    will be overwritten with the new one. When false, the new one is
             *    added.
             * @returns {SVGElement} Return the SVG element for chainability.
             */
            addClass: function(className, replace) {
                var currentClassName = this.attr('class') || '';
                if (currentClassName.indexOf(className) === -1) {
                    if (!replace) {
                        className =
                            (currentClassName + (currentClassName ? ' ' : '') +
                                className).replace('  ', ' ');
                    }
                    this.attr('class', className);
                }

                return this;
            },

            /**
             * Check if an element has the given class name.
             * @param  {string} className
             *         The class name to check for.
             * @return {Boolean}
             *         Whether the class name is found.
             */
            hasClass: function(className) {
                return inArray(
                    className,
                    (this.attr('class') || '').split(' ')
                ) !== -1;
            },

            /**
             * Remove a class name from the element.
             * @param  {String|RegExp} className The class name to remove.
             * @return {SVGElement} Returns the SVG element for chainability.
             */
            removeClass: function(className) {
                return this.attr(
                    'class',
                    (this.attr('class') || '').replace(className, '')
                );
            },

            /**
             * If one of the symbol size affecting parameters are changed,
             * check all the others only once for each call to an element's
             * .attr() method
             * @param {Object} hash - The attributes to set.
             * @private
             */
            symbolAttr: function(hash) {
                var wrapper = this;

                each([
                    'x',
                    'y',
                    'r',
                    'start',
                    'end',
                    'width',
                    'height',
                    'innerR',
                    'anchorX',
                    'anchorY'
                ], function(key) {
                    wrapper[key] = pick(hash[key], wrapper[key]);
                });

                wrapper.attr({
                    d: wrapper.renderer.symbols[wrapper.symbolName](
                        wrapper.x,
                        wrapper.y,
                        wrapper.width,
                        wrapper.height,
                        wrapper
                    )
                });
            },

            /**
             * Apply a clipping rectangle to this element.
             * 
             * @param {ClipRect} [clipRect] - The clipping rectangle. If skipped, the
             *    current clip is removed.
             * @returns {SVGElement} Returns the SVG element to allow chaining.
             */
            clip: function(clipRect) {
                return this.attr(
                    'clip-path',
                    clipRect ?
                    'url(' + this.renderer.url + '#' + clipRect.id + ')' :
                    'none'
                );
            },

            /**
             * Calculate the coordinates needed for drawing a rectangle crisply and
             * return the calculated attributes.
             * 
             * @param {Object} rect - A rectangle.
             * @param {number} rect.x - The x position.
             * @param {number} rect.y - The y position.
             * @param {number} rect.width - The width.
             * @param {number} rect.height - The height.
             * @param {number} [strokeWidth] - The stroke width to consider when
             *    computing crisp positioning. It can also be set directly on the rect
             *    parameter.
             *
             * @returns {{x: Number, y: Number, width: Number, height: Number}} The
             *    modified rectangle arguments.
             */
            crisp: function(rect, strokeWidth) {

                var wrapper = this,
                    attribs = {},
                    normalizer;

                strokeWidth = strokeWidth || rect.strokeWidth || 0;
                // Math.round because strokeWidth can sometimes have roundoff errors
                normalizer = Math.round(strokeWidth) % 2 / 2;

                // normalize for crisp edges
                rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
                rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
                rect.width = Math.floor(
                    (rect.width || wrapper.width || 0) - 2 * normalizer
                );
                rect.height = Math.floor(
                    (rect.height || wrapper.height || 0) - 2 * normalizer
                );
                if (defined(rect.strokeWidth)) {
                    rect.strokeWidth = strokeWidth;
                }

                objectEach(rect, function(val, key) {
                    if (wrapper[key] !== val) { // only set attribute if changed
                        wrapper[key] = attribs[key] = val;
                    }
                });

                return attribs;
            },

            /**
             * Set styles for the element. In addition to CSS styles supported by 
             * native SVG and HTML elements, there are also some custom made for 
             * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
             * elements.
             * @param {CSSObject} styles The new CSS styles.
             * @returns {SVGElement} Return the SVG element for chaining.
             *
             * @sample highcharts/members/renderer-text-on-chart/
             *         Styled text
             */
            css: function(styles) {
                var oldStyles = this.styles,
                    newStyles = {},
                    elem = this.element,
                    textWidth,
                    serializedCss = '',
                    hyphenate,
                    hasNew = !oldStyles,
                    // These CSS properties are interpreted internally by the SVG
                    // renderer, but are not supported by SVG and should not be added to
                    // the DOM. In styled mode, no CSS should find its way to the DOM
                    // whatsoever (#6173, #6474).
                    svgPseudoProps = ['textOutline', 'textOverflow', 'width'];

                // convert legacy
                if (styles && styles.color) {
                    styles.fill = styles.color;
                }

                // Filter out existing styles to increase performance (#2640)
                if (oldStyles) {
                    objectEach(styles, function(style, n) {
                        if (style !== oldStyles[n]) {
                            newStyles[n] = style;
                            hasNew = true;
                        }
                    });
                }
                if (hasNew) {

                    // Merge the new styles with the old ones
                    if (oldStyles) {
                        styles = extend(
                            oldStyles,
                            newStyles
                        );
                    }

                    // Get the text width from style
                    textWidth = this.textWidth = (
                        styles &&
                        styles.width &&
                        styles.width !== 'auto' &&
                        elem.nodeName.toLowerCase() === 'text' &&
                        pInt(styles.width)
                    );

                    // store object
                    this.styles = styles;

                    if (textWidth && (!svg && this.renderer.forExport)) {
                        delete styles.width;
                    }

                    // serialize and set style attribute
                    if (isMS && !svg) {
                        css(this.element, styles);
                    } else {
                        hyphenate = function(a, b) {
                            return '-' + b.toLowerCase();
                        };
                        objectEach(styles, function(style, n) {
                            if (inArray(n, svgPseudoProps) === -1) {
                                serializedCss +=
                                    n.replace(/([A-Z])/g, hyphenate) + ':' +
                                    style + ';';
                            }
                        });
                        if (serializedCss) {
                            attr(elem, 'style', serializedCss); // #1881
                        }
                    }


                    if (this.added) {

                        // Rebuild text after added. Cache mechanisms in the buildText
                        // will prevent building if there are no significant changes.
                        if (this.element.nodeName === 'text') {
                            this.renderer.buildText(this);
                        }

                        // Apply text outline after added
                        if (styles && styles.textOutline) {
                            this.applyTextOutline(styles.textOutline);
                        }
                    }
                }

                return this;
            },


            /**
             * Get the current stroke width. In classic mode, the setter registers it 
             * directly on the element.
             * @returns {number} The stroke width in pixels.
             * @ignore
             */
            strokeWidth: function() {
                return this['stroke-width'] || 0;
            },


            /**
             * Add an event listener. This is a simple setter that replaces all other
             * events of the same type, opposed to the {@link Highcharts#addEvent}
             * function.
             * @param {string} eventType - The event type. If the type is `click`, 
             *    Highcharts will internally translate it to a `touchstart` event on 
             *    touch devices, to prevent the browser from waiting for a click event
             *    from firing.
             * @param {Function} handler - The handler callback.
             * @returns {SVGElement} The SVGElement for chaining.
             *
             * @sample highcharts/members/element-on/
             *         A clickable rectangle
             */
            on: function(eventType, handler) {
                var svgElement = this,
                    element = svgElement.element;

                // touch
                if (hasTouch && eventType === 'click') {
                    element.ontouchstart = function(e) {
                        svgElement.touchEventFired = Date.now(); // #2269
                        e.preventDefault();
                        handler.call(element, e);
                    };
                    element.onclick = function(e) {
                        if (win.navigator.userAgent.indexOf('Android') === -1 ||
                            Date.now() - (svgElement.touchEventFired || 0) > 1100) {
                            handler.call(element, e);
                        }
                    };
                } else {
                    // simplest possible event model for internal use
                    element['on' + eventType] = handler;
                }
                return this;
            },

            /**
             * Set the coordinates needed to draw a consistent radial gradient across
             * a shape regardless of positioning inside the chart. Used on pie slices
             * to make all the slices have the same radial reference point.
             *
             * @param {Array} coordinates The center reference. The format is
             *    `[centerX, centerY, diameter]` in pixels.
             * @returns {SVGElement} Returns the SVGElement for chaining.
             */
            setRadialReference: function(coordinates) {
                var existingGradient = this.renderer.gradients[this.element.gradient];

                this.element.radialReference = coordinates;

                // On redrawing objects with an existing gradient, the gradient needs
                // to be repositioned (#3801)
                if (existingGradient && existingGradient.radAttr) {
                    existingGradient.animate(
                        this.renderer.getRadialAttr(
                            coordinates,
                            existingGradient.radAttr
                        )
                    );
                }

                return this;
            },

            /**
             * Move an object and its children by x and y values.
             * 
             * @param {number} x - The x value.
             * @param {number} y - The y value.
             */
            translate: function(x, y) {
                return this.attr({
                    translateX: x,
                    translateY: y
                });
            },

            /**
             * Invert a group, rotate and flip. This is used internally on inverted 
             * charts, where the points and graphs are drawn as if not inverted, then
             * the series group elements are inverted.
             *
             * @param  {boolean} inverted
             *         Whether to invert or not. An inverted shape can be un-inverted by
             *         setting it to false.
             * @return {SVGElement}
             *         Return the SVGElement for chaining.
             */
            invert: function(inverted) {
                var wrapper = this;
                wrapper.inverted = inverted;
                wrapper.updateTransform();
                return wrapper;
            },

            /**
             * Update the transform attribute based on internal properties. Deals with
             * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
             * attributes and updates the SVG `transform` attribute.
             * @private
             * 
             */
            updateTransform: function() {
                var wrapper = this,
                    translateX = wrapper.translateX || 0,
                    translateY = wrapper.translateY || 0,
                    scaleX = wrapper.scaleX,
                    scaleY = wrapper.scaleY,
                    inverted = wrapper.inverted,
                    rotation = wrapper.rotation,
                    matrix = wrapper.matrix,
                    element = wrapper.element,
                    transform;

                // Flipping affects translate as adjustment for flipping around the
                // group's axis
                if (inverted) {
                    translateX += wrapper.width;
                    translateY += wrapper.height;
                }

                // Apply translate. Nearly all transformed elements have translation,
                // so instead of checking for translate = 0, do it always (#1767,
                // #1846).
                transform = ['translate(' + translateX + ',' + translateY + ')'];

                // apply matrix
                if (defined(matrix)) {
                    transform.push(
                        'matrix(' + matrix.join(',') + ')'
                    );
                }

                // apply rotation
                if (inverted) {
                    transform.push('rotate(90) scale(-1,1)');
                } else if (rotation) { // text rotation
                    transform.push(
                        'rotate(' + rotation + ' ' +
                        pick(this.rotationOriginX, element.getAttribute('x'), 0) +
                        ' ' +
                        pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')'
                    );
                }

                // apply scale
                if (defined(scaleX) || defined(scaleY)) {
                    transform.push(
                        'scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')'
                    );
                }

                if (transform.length) {
                    element.setAttribute('transform', transform.join(' '));
                }
            },

            /**
             * Bring the element to the front. Alternatively, a new zIndex can be set.
             *
             * @returns {SVGElement} Returns the SVGElement for chaining.
             *
             * @sample highcharts/members/element-tofront/
             *         Click an element to bring it to front
             */
            toFront: function() {
                var element = this.element;
                element.parentNode.appendChild(element);
                return this;
            },


            /**
             * Align the element relative to the chart or another box.
             * 
             * @param {Object} [alignOptions] The alignment options. The function can be
             *   called without this parameter in order to re-align an element after the
             *   box has been updated.
             * @param {string} [alignOptions.align=left] Horizontal alignment. Can be
             *   one of `left`, `center` and `right`.
             * @param {string} [alignOptions.verticalAlign=top] Vertical alignment. Can
             *   be one of `top`, `middle` and `bottom`.
             * @param {number} [alignOptions.x=0] Horizontal pixel offset from
             *   alignment.
             * @param {number} [alignOptions.y=0] Vertical pixel offset from alignment.
             * @param {Boolean} [alignByTranslate=false] Use the `transform` attribute
             *   with translateX and translateY custom attributes to align this elements
             *   rather than `x` and `y` attributes.
             * @param {String|Object} box The box to align to, needs a width and height.
             *   When the box is a string, it refers to an object in the Renderer. For
             *   example, when box is `spacingBox`, it refers to `Renderer.spacingBox`
             *   which holds `width`, `height`, `x` and `y` properties.
             * @returns {SVGElement} Returns the SVGElement for chaining.
             */
            align: function(alignOptions, alignByTranslate, box) {
                var align,
                    vAlign,
                    x,
                    y,
                    attribs = {},
                    alignTo,
                    renderer = this.renderer,
                    alignedObjects = renderer.alignedObjects,
                    alignFactor,
                    vAlignFactor;

                // First call on instanciate
                if (alignOptions) {
                    this.alignOptions = alignOptions;
                    this.alignByTranslate = alignByTranslate;
                    if (!box || isString(box)) {
                        this.alignTo = alignTo = box || 'renderer';
                        // prevent duplicates, like legendGroup after resize
                        erase(alignedObjects, this);
                        alignedObjects.push(this);
                        box = null; // reassign it below
                    }

                    // When called on resize, no arguments are supplied
                } else {
                    alignOptions = this.alignOptions;
                    alignByTranslate = this.alignByTranslate;
                    alignTo = this.alignTo;
                }

                box = pick(box, renderer[alignTo], renderer);

                // Assign variables
                align = alignOptions.align;
                vAlign = alignOptions.verticalAlign;
                x = (box.x || 0) + (alignOptions.x || 0); // default: left align
                y = (box.y || 0) + (alignOptions.y || 0); // default: top align

                // Align
                if (align === 'right') {
                    alignFactor = 1;
                } else if (align === 'center') {
                    alignFactor = 2;
                }
                if (alignFactor) {
                    x += (box.width - (alignOptions.width || 0)) / alignFactor;
                }
                attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);


                // Vertical align
                if (vAlign === 'bottom') {
                    vAlignFactor = 1;
                } else if (vAlign === 'middle') {
                    vAlignFactor = 2;
                }
                if (vAlignFactor) {
                    y += (box.height - (alignOptions.height || 0)) / vAlignFactor;
                }
                attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);

                // Animate only if already placed
                this[this.placed ? 'animate' : 'attr'](attribs);
                this.placed = true;
                this.alignAttr = attribs;

                return this;
            },

            /**
             * Get the bounding box (width, height, x and y) for the element. Generally
             * used to get rendered text size. Since this is called a lot in charts,
             * the results are cached based on text properties, in order to save DOM
             * traffic. The returned bounding box includes the rotation, so for example
             * a single text line of rotation 90 will report a greater height, and a
             * width corresponding to the line-height.
             *
             * @param {boolean} [reload] Skip the cache and get the updated DOM bouding
             *   box.
             * @param {number} [rot] Override the element's rotation. This is internally
             *   used on axis labels with a value of 0 to find out what the bounding box
             *   would be have been if it were not rotated.
             * @returns {Object} The bounding box with `x`, `y`, `width` and `height`
             * properties.
             *
             * @sample highcharts/members/renderer-on-chart/
             *         Draw a rectangle based on a text's bounding box
             */
            getBBox: function(reload, rot) {
                var wrapper = this,
                    bBox, // = wrapper.bBox,
                    renderer = wrapper.renderer,
                    width,
                    height,
                    rotation,
                    rad,
                    element = wrapper.element,
                    styles = wrapper.styles,
                    fontSize,
                    textStr = wrapper.textStr,
                    toggleTextShadowShim,
                    cache = renderer.cache,
                    cacheKeys = renderer.cacheKeys,
                    cacheKey;

                rotation = pick(rot, wrapper.rotation);
                rad = rotation * deg2rad;


                fontSize = styles && styles.fontSize;


                if (textStr !== undefined) {

                    cacheKey = textStr.toString();

                    // Since numbers are monospaced, and numerical labels appear a lot
                    // in a chart, we assume that a label of n characters has the same
                    // bounding box as others of the same length. Unless there is inner
                    // HTML in the label. In that case, leave the numbers as is (#5899).
                    if (cacheKey.indexOf('<') === -1) {
                        cacheKey = cacheKey.replace(/[0-9]/g, '0');
                    }

                    // Properties that affect bounding box
                    cacheKey += [
                            '',
                            rotation || 0,
                            fontSize,
                            styles && styles.width,
                            styles && styles.textOverflow // #5968
                        ]
                        .join(',');

                }

                if (cacheKey && !reload) {
                    bBox = cache[cacheKey];
                }

                // No cache found
                if (!bBox) {

                    // SVG elements
                    if (element.namespaceURI === wrapper.SVG_NS || renderer.forExport) {
                        try { // Fails in Firefox if the container has display: none.

                            // When the text shadow shim is used, we need to hide the
                            // fake shadows to get the correct bounding box (#3872)
                            toggleTextShadowShim = this.fakeTS && function(display) {
                                each(
                                    element.querySelectorAll(
                                        '.highcharts-text-outline'
                                    ),
                                    function(tspan) {
                                        tspan.style.display = display;
                                    }
                                );
                            };

                            // Workaround for #3842, Firefox reporting wrong bounding
                            // box for shadows
                            if (toggleTextShadowShim) {
                                toggleTextShadowShim('none');
                            }

                            bBox = element.getBBox ?
                                // SVG: use extend because IE9 is not allowed to change
                                // width and height in case of rotation (below)
                                extend({}, element.getBBox()) : {

                                    // Legacy IE in export mode
                                    width: element.offsetWidth,
                                    height: element.offsetHeight
                                };

                            // #3842
                            if (toggleTextShadowShim) {
                                toggleTextShadowShim('');
                            }
                        } catch (e) {}

                        // If the bBox is not set, the try-catch block above failed. The
                        // other condition is for Opera that returns a width of
                        // -Infinity on hidden elements.
                        if (!bBox || bBox.width < 0) {
                            bBox = {
                                width: 0,
                                height: 0
                            };
                        }


                        // VML Renderer or useHTML within SVG
                    } else {

                        bBox = wrapper.htmlGetBBox();

                    }

                    // True SVG elements as well as HTML elements in modern browsers
                    // using the .useHTML option need to compensated for rotation
                    if (renderer.isSVG) {
                        width = bBox.width;
                        height = bBox.height;

                        // Workaround for wrong bounding box in IE, Edge and Chrome on
                        // Windows. With Highcharts' default font, IE and Edge report
                        // a box height of 16.899 and Chrome rounds it to 17. If this 
                        // stands uncorrected, it results in more padding added below
                        // the text than above when adding a label border or background.
                        // Also vertical positioning is affected.
                        // http://jsfiddle.net/highcharts/em37nvuj/
                        // (#1101, #1505, #1669, #2568, #6213).
                        if (
                            styles &&
                            styles.fontSize === '11px' &&
                            Math.round(height) === 17
                        ) {
                            bBox.height = height = 14;
                        }

                        // Adjust for rotated text
                        if (rotation) {
                            bBox.width = Math.abs(height * Math.sin(rad)) +
                                Math.abs(width * Math.cos(rad));
                            bBox.height = Math.abs(height * Math.cos(rad)) +
                                Math.abs(width * Math.sin(rad));
                        }
                    }

                    // Cache it. When loading a chart in a hidden iframe in Firefox and
                    // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
                    if (cacheKey && bBox.height > 0) {

                        // Rotate (#4681)
                        while (cacheKeys.length > 250) {
                            delete cache[cacheKeys.shift()];
                        }

                        if (!cache[cacheKey]) {
                            cacheKeys.push(cacheKey);
                        }
                        cache[cacheKey] = bBox;
                    }
                }
                return bBox;
            },

            /**
             * Show the element after it has been hidden. 
             *
             * @param {boolean} [inherit=false] Set the visibility attribute to
             * `inherit` rather than `visible`. The difference is that an element with
             * `visibility="visible"` will be visible even if the parent is hidden.
             *
             * @returns {SVGElement} Returns the SVGElement for chaining.
             */
            show: function(inherit) {
                return this.attr({
                    visibility: inherit ? 'inherit' : 'visible'
                });
            },

            /**
             * Hide the element, equivalent to setting the `visibility` attribute to
             * `hidden`.
             *
             * @returns {SVGElement} Returns the SVGElement for chaining.
             */
            hide: function() {
                return this.attr({
                    visibility: 'hidden'
                });
            },

            /**
             * Fade out an element by animating its opacity down to 0, and hide it on
             * complete. Used internally for the tooltip.
             * 
             * @param {number} [duration=150] The fade duration in milliseconds.
             */
            fadeOut: function(duration) {
                var elemWrapper = this;
                elemWrapper.animate({
                    opacity: 0
                }, {
                    duration: duration || 150,
                    complete: function() {
                        // #3088, assuming we're only using this for tooltips
                        elemWrapper.attr({
                            y: -9999
                        });
                    }
                });
            },

            /**
             * Add the element to the DOM. All elements must be added this way.
             * 
             * @param {SVGElement|SVGDOMElement} [parent] The parent item to add it to.
             *   If undefined, the element is added to the {@link
             *   Highcharts.SVGRenderer.box}.
             *
             * @returns {SVGElement} Returns the SVGElement for chaining.
             *
             * @sample highcharts/members/renderer-g - Elements added to a group
             */
            add: function(parent) {

                var renderer = this.renderer,
                    element = this.element,
                    inserted;

                if (parent) {
                    this.parentGroup = parent;
                }

                // mark as inverted
                this.parentInverted = parent && parent.inverted;

                // build formatted text
                if (this.textStr !== undefined) {
                    renderer.buildText(this);
                }

                // Mark as added
                this.added = true;

                // If we're adding to renderer root, or other elements in the group
                // have a z index, we need to handle it
                if (!parent || parent.handleZ || this.zIndex) {
                    inserted = this.zIndexSetter();
                }

                // If zIndex is not handled, append at the end
                if (!inserted) {
                    (parent ? parent.element : renderer.box).appendChild(element);
                }

                // fire an event for internal hooks
                if (this.onAdd) {
                    this.onAdd();
                }

                return this;
            },

            /**
             * Removes an element from the DOM.
             *
             * @private
             * @param {SVGDOMElement|HTMLDOMElement} element The DOM node to remove.
             */
            safeRemoveChild: function(element) {
                var parentNode = element.parentNode;
                if (parentNode) {
                    parentNode.removeChild(element);
                }
            },

            /**
             * Destroy the element and element wrapper and clear up the DOM and event
             * hooks.
             *
             * 
             */
            destroy: function() {
                var wrapper = this,
                    element = wrapper.element || {},
                    parentToClean =
                    wrapper.renderer.isSVG &&
                    element.nodeName === 'SPAN' &&
                    wrapper.parentGroup,
                    grandParent,
                    ownerSVGElement = element.ownerSVGElement,
                    i;

                // remove events
                element.onclick = element.onmouseout = element.onmouseover =
                    element.onmousemove = element.point = null;
                stop(wrapper); // stop running animations

                if (wrapper.clipPath && ownerSVGElement) {
                    // Look for existing references to this clipPath and remove them
                    // before destroying the element (#6196).
                    each(
                        ownerSVGElement.querySelectorAll('[clip-path]'),
                        function(el) {
                            // Include the closing paranthesis in the test to rule out
                            // id's from 10 and above (#6550)
                            if (el.getAttribute('clip-path')
                                .indexOf(wrapper.clipPath.element.id + ')') > -1) {
                                el.removeAttribute('clip-path');
                            }
                        }
                    );
                    wrapper.clipPath = wrapper.clipPath.destroy();
                }

                // Destroy stops in case this is a gradient object
                if (wrapper.stops) {
                    for (i = 0; i < wrapper.stops.length; i++) {
                        wrapper.stops[i] = wrapper.stops[i].destroy();
                    }
                    wrapper.stops = null;
                }

                // remove element
                wrapper.safeRemoveChild(element);


                wrapper.destroyShadows();


                // In case of useHTML, clean up empty containers emulating SVG groups
                // (#1960, #2393, #2697).
                while (
                    parentToClean &&
                    parentToClean.div &&
                    parentToClean.div.childNodes.length === 0
                ) {
                    grandParent = parentToClean.parentGroup;
                    wrapper.safeRemoveChild(parentToClean.div);
                    delete parentToClean.div;
                    parentToClean = grandParent;
                }

                // remove from alignObjects
                if (wrapper.alignTo) {
                    erase(wrapper.renderer.alignedObjects, wrapper);
                }

                objectEach(wrapper, function(val, key) {
                    delete wrapper[key];
                });

                return null;
            },


            /**
             * @typedef {Object} ShadowOptions
             * @property {string} [color=#000000] The shadow color.
             * @property {number} [offsetX=1] The horizontal offset from the element.
             * @property {number} [offsetY=1] The vertical offset from the element.
             * @property {number} [opacity=0.15] The shadow opacity.
             * @property {number} [width=3] The shadow width or distance from the
             *    element.
             */
            /**
             * Add a shadow to the element. Must be called after the element is added to
             * the DOM. In styled mode, this method is not used, instead use `defs` and
             * filters.
             * 
             * @param {boolean|ShadowOptions} shadowOptions The shadow options. If
             *    `true`, the default options are applied. If `false`, the current
             *    shadow will be removed.
             * @param {SVGElement} [group] The SVG group element where the shadows will 
             *    be applied. The default is to add it to the same parent as the current
             *    element. Internally, this is ised for pie slices, where all the
             *    shadows are added to an element behind all the slices.
             * @param {boolean} [cutOff] Used internally for column shadows.
             *
             * @returns {SVGElement} Returns the SVGElement for chaining.
             *
             * @example
             * renderer.rect(10, 100, 100, 100)
             *     .attr({ fill: 'red' })
             *     .shadow(true);
             */
            shadow: function(shadowOptions, group, cutOff) {
                var shadows = [],
                    i,
                    shadow,
                    element = this.element,
                    strokeWidth,
                    shadowWidth,
                    shadowElementOpacity,

                    // compensate for inverted plot area
                    transform;

                if (!shadowOptions) {
                    this.destroyShadows();

                } else if (!this.shadows) {
                    shadowWidth = pick(shadowOptions.width, 3);
                    shadowElementOpacity = (shadowOptions.opacity || 0.15) /
                        shadowWidth;
                    transform = this.parentInverted ?
                        '(-1,-1)' :
                        '(' + pick(shadowOptions.offsetX, 1) + ', ' +
                        pick(shadowOptions.offsetY, 1) + ')';
                    for (i = 1; i <= shadowWidth; i++) {
                        shadow = element.cloneNode(0);
                        strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
                        attr(shadow, {
                            'isShadow': 'true',
                            'stroke': shadowOptions.color || '#000000',
                            'stroke-opacity': shadowElementOpacity * i,
                            'stroke-width': strokeWidth,
                            'transform': 'translate' + transform,
                            'fill': 'none'
                        });
                        if (cutOff) {
                            attr(
                                shadow,
                                'height',
                                Math.max(attr(shadow, 'height') - strokeWidth, 0)
                            );
                            shadow.cutHeight = strokeWidth;
                        }

                        if (group) {
                            group.element.appendChild(shadow);
                        } else if (element.parentNode) {
                            element.parentNode.insertBefore(shadow, element);
                        }

                        shadows.push(shadow);
                    }

                    this.shadows = shadows;
                }
                return this;

            },

            /**
             * Destroy shadows on the element.
             * @private
             */
            destroyShadows: function() {
                each(this.shadows || [], function(shadow) {
                    this.safeRemoveChild(shadow);
                }, this);
                this.shadows = undefined;
            },



            xGetter: function(key) {
                if (this.element.nodeName === 'circle') {
                    if (key === 'x') {
                        key = 'cx';
                    } else if (key === 'y') {
                        key = 'cy';
                    }
                }
                return this._defaultGetter(key);
            },

            /**
             * Get the current value of an attribute or pseudo attribute, used mainly
             * for animation. Called internally from the {@link
             * Highcharts.SVGRenderer#attr}
             * function.
             *
             * @private
             */
            _defaultGetter: function(key) {
                var ret = pick(
                    this[key],
                    this.element ? this.element.getAttribute(key) : null,
                    0
                );

                if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
                    ret = parseFloat(ret);
                }
                return ret;
            },


            dSetter: function(value, key, element) {
                if (value && value.join) { // join path
                    value = value.join(' ');
                }
                if (/(NaN| {2}|^$)/.test(value)) {
                    value = 'M 0 0';
                }

                // Check for cache before resetting. Resetting causes disturbance in the
                // DOM, causing flickering in some cases in Edge/IE (#6747). Also
                // possible performance gain.
                if (this[key] !== value) {
                    element.setAttribute(key, value);
                    this[key] = value;
                }

            },

            dashstyleSetter: function(value) {
                var i,
                    strokeWidth = this['stroke-width'];

                // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
                // strokeWidth function, we should be able to use that instead.
                if (strokeWidth === 'inherit') {
                    strokeWidth = 1;
                }
                value = value && value.toLowerCase();
                if (value) {
                    value = value
                        .replace('shortdashdotdot', '3,1,1,1,1,1,')
                        .replace('shortdashdot', '3,1,1,1')
                        .replace('shortdot', '1,1,')
                        .replace('shortdash', '3,1,')
                        .replace('longdash', '8,3,')
                        .replace(/dot/g, '1,3,')
                        .replace('dash', '4,3,')
                        .replace(/,$/, '')
                        .split(','); // ending comma

                    i = value.length;
                    while (i--) {
                        value[i] = pInt(value[i]) * strokeWidth;
                    }
                    value = value.join(',')
                        .replace(/NaN/g, 'none'); // #3226
                    this.element.setAttribute('stroke-dasharray', value);
                }
            },

            alignSetter: function(value) {
                var convert = {
                    left: 'start',
                    center: 'middle',
                    right: 'end'
                };
                this.element.setAttribute('text-anchor', convert[value]);
            },
            opacitySetter: function(value, key, element) {
                this[key] = value;
                element.setAttribute(key, value);
            },
            titleSetter: function(value) {
                var titleNode = this.element.getElementsByTagName('title')[0];
                if (!titleNode) {
                    titleNode = doc.createElementNS(this.SVG_NS, 'title');
                    this.element.appendChild(titleNode);
                }

                // Remove text content if it exists
                if (titleNode.firstChild) {
                    titleNode.removeChild(titleNode.firstChild);
                }

                titleNode.appendChild(
                    doc.createTextNode(
                        // #3276, #3895
                        (String(pick(value), '')).replace(/<[^>]*>/g, '')
                    )
                );
            },
            textSetter: function(value) {
                if (value !== this.textStr) {
                    // Delete bBox memo when the text changes
                    delete this.bBox;

                    this.textStr = value;
                    if (this.added) {
                        this.renderer.buildText(this);
                    }
                }
            },
            fillSetter: function(value, key, element) {
                if (typeof value === 'string') {
                    element.setAttribute(key, value);
                } else if (value) {
                    this.colorGradient(value, key, element);
                }
            },
            visibilitySetter: function(value, key, element) {
                // IE9-11 doesn't handle visibilty:inherit well, so we remove the
                // attribute instead (#2881, #3909)
                if (value === 'inherit') {
                    element.removeAttribute(key);
                } else if (this[key] !== value) { // #6747
                    element.setAttribute(key, value);
                }
                this[key] = value;
            },
            zIndexSetter: function(value, key) {
                var renderer = this.renderer,
                    parentGroup = this.parentGroup,
                    parentWrapper = parentGroup || renderer,
                    parentNode = parentWrapper.element || renderer.box,
                    childNodes,
                    otherElement,
                    otherZIndex,
                    element = this.element,
                    inserted,
                    undefinedOtherZIndex,
                    svgParent = parentNode === renderer.box,
                    run = this.added,
                    i;

                if (defined(value)) {
                    // So we can read it for other elements in the group
                    element.zIndex = value;

                    value = +value;
                    if (this[key] === value) { // Only update when needed (#3865)
                        run = false;
                    }
                    this[key] = value;
                }

                // Insert according to this and other elements' zIndex. Before .add() is
                // called, nothing is done. Then on add, or by later calls to
                // zIndexSetter, the node is placed on the right place in the DOM.
                if (run) {
                    value = this.zIndex;

                    if (value && parentGroup) {
                        parentGroup.handleZ = true;
                    }

                    childNodes = parentNode.childNodes;
                    for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
                        otherElement = childNodes[i];
                        otherZIndex = otherElement.zIndex;
                        undefinedOtherZIndex = !defined(otherZIndex);

                        if (otherElement !== element) {
                            if (
                                // Negative zIndex versus no zIndex:
                                // On all levels except the highest. If the parent is <svg>,
                                // then we don't want to put items before <desc> or <defs>
                                (value < 0 && undefinedOtherZIndex && !svgParent && !i)
                            ) {
                                parentNode.insertBefore(element, childNodes[i]);
                                inserted = true;
                            } else if (
                                // Insert after the first element with a lower zIndex
                                pInt(otherZIndex) <= value ||
                                // If negative zIndex, add this before first undefined zIndex element
                                (undefinedOtherZIndex && (!defined(value) || value >= 0))
                            ) {
                                parentNode.insertBefore(
                                    element,
                                    childNodes[i + 1] || null // null for oldIE export
                                );
                                inserted = true;
                            }
                        }
                    }

                    if (!inserted) {
                        parentNode.insertBefore(
                            element,
                            childNodes[svgParent ? 3 : 0] || null // null for oldIE
                        );
                        inserted = true;
                    }
                }
                return inserted;
            },
            _defaultSetter: function(value, key, element) {
                element.setAttribute(key, value);
            }
        });

        // Some shared setters and getters
        SVGElement.prototype.yGetter =
            SVGElement.prototype.xGetter;
        SVGElement.prototype.translateXSetter =
            SVGElement.prototype.translateYSetter =
            SVGElement.prototype.rotationSetter =
            SVGElement.prototype.verticalAlignSetter =
            SVGElement.prototype.rotationOriginXSetter =
            SVGElement.prototype.rotationOriginYSetter =
            SVGElement.prototype.scaleXSetter =
            SVGElement.prototype.scaleYSetter =
            SVGElement.prototype.matrixSetter = function(value, key) {
                this[key] = value;
                this.doTransform = true;
            };


        // WebKit and Batik have problems with a stroke-width of zero, so in this case
        // we remove the stroke attribute altogether. #1270, #1369, #3065, #3072.
        SVGElement.prototype['stroke-widthSetter'] =
            SVGElement.prototype.strokeSetter = function(value, key, element) {
                this[key] = value;
                // Only apply the stroke attribute if the stroke width is defined and larger
                // than 0
                if (this.stroke && this['stroke-width']) {
                    // Use prototype as instance may be overridden
                    SVGElement.prototype.fillSetter.call(
                        this,
                        this.stroke,
                        'stroke',
                        element
                    );

                    element.setAttribute('stroke-width', this['stroke-width']);
                    this.hasStroke = true;
                } else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
                    element.removeAttribute('stroke');
                    this.hasStroke = false;
                }
            };


        /**
         * Allows direct access to the Highcharts rendering layer in order to draw
         * primitive shapes like circles, rectangles, paths or text directly on a chart,
         * or independent from any chart. The SVGRenderer represents a wrapper object
         * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
         * module, it also brings vector graphics to IE <= 8.
         *
         * An existing chart's renderer can be accessed through {@link Chart.renderer}.
         * The renderer can also be used completely decoupled from a chart.
         *
         * @param {HTMLDOMElement} container - Where to put the SVG in the web page.
         * @param {number} width - The width of the SVG.
         * @param {number} height - The height of the SVG.
         * @param {boolean} [forExport=false] - Whether the rendered content is intended
         *   for export.
         * @param {boolean} [allowHTML=true] - Whether the renderer is allowed to
         *   include HTML text, which will be projected on top of the SVG.
         *
         * @example
         * // Use directly without a chart object.
         * var renderer = new Highcharts.Renderer(parentNode, 600, 400);
         *
         * @sample highcharts/members/renderer-on-chart
         *         Annotating a chart programmatically.
         * @sample highcharts/members/renderer-basic
         *         Independent SVG drawing.
         *
         * @class Highcharts.SVGRenderer
         */
        SVGRenderer = H.SVGRenderer = function() {
            this.init.apply(this, arguments);
        };
        extend(SVGRenderer.prototype, /** @lends Highcharts.SVGRenderer.prototype */ {
            /**
             * A pointer to the renderer's associated Element class. The VMLRenderer
             * will have a pointer to VMLElement here.
             * @type {SVGElement}
             */
            Element: SVGElement,
            SVG_NS: SVG_NS,
            /**
             * Initialize the SVGRenderer. Overridable initiator function that takes
             * the same parameters as the constructor.
             */
            init: function(container, width, height, style, forExport, allowHTML) {
                var renderer = this,
                    boxWrapper,
                    element,
                    desc;

                boxWrapper = renderer.createElement('svg')
                    .attr({
                        'version': '1.1',
                        'class': 'highcharts-root'
                    })

                    .css(this.getStyle(style));
                element = boxWrapper.element;
                container.appendChild(element);

                // For browsers other than IE, add the namespace attribute (#1978)
                if (container.innerHTML.indexOf('xmlns') === -1) {
                    attr(element, 'xmlns', this.SVG_NS);
                }

                // object properties
                renderer.isSVG = true;

                /** 
                 * The root `svg` node of the renderer.
                 * @name box
                 * @memberOf SVGRenderer
                 * @type {SVGDOMElement}
                 */
                this.box = element;
                /** 
                 * The wrapper for the root `svg` node of the renderer.
                 *
                 * @name boxWrapper
                 * @memberOf SVGRenderer
                 * @type {SVGElement}
                 */
                this.boxWrapper = boxWrapper;
                renderer.alignedObjects = [];

                /**
                 * Page url used for internal references.
                 * @type {string}
                 */
                // #24, #672, #1070
                this.url = (
                        (isFirefox || isWebKit) &&
                        doc.getElementsByTagName('base').length
                    ) ?
                    win.location.href
                    .replace(/#.*?$/, '') // remove the hash
                    .replace(/<[^>]*>/g, '') // wing cut HTML
                    // escape parantheses and quotes
                    .replace(/([\('\)])/g, '\\$1')
                    // replace spaces (needed for Safari only)
                    .replace(/ /g, '%20') :
                    '';

                // Add description
                desc = this.createElement('desc').add();
                desc.element.appendChild(
                    doc.createTextNode('Created with Highcharts 6.0.1')
                );

                /**
                 * A pointer to the `defs` node of the root SVG.
                 * @type {SVGElement}
                 * @name defs
                 * @memberOf SVGRenderer
                 */
                renderer.defs = this.createElement('defs').add();
                renderer.allowHTML = allowHTML;
                renderer.forExport = forExport;
                renderer.gradients = {}; // Object where gradient SvgElements are stored
                renderer.cache = {}; // Cache for numerical bounding boxes
                renderer.cacheKeys = [];
                renderer.imgCount = 0;

                renderer.setSize(width, height, false);



                // Issue 110 workaround:
                // In Firefox, if a div is positioned by percentage, its pixel position
                // may land between pixels. The container itself doesn't display this,
                // but an SVG element inside this container will be drawn at subpixel
                // precision. In order to draw sharp lines, this must be compensated
                // for. This doesn't seem to work inside iframes though (like in
                // jsFiddle).
                var subPixelFix, rect;
                if (isFirefox && container.getBoundingClientRect) {
                    subPixelFix = function() {
                        css(container, {
                            left: 0,
                            top: 0
                        });
                        rect = container.getBoundingClientRect();
                        css(container, {
                            left: (Math.ceil(rect.left) - rect.left) + 'px',
                            top: (Math.ceil(rect.top) - rect.top) + 'px'
                        });
                    };

                    // run the fix now
                    subPixelFix();

                    // run it on resize
                    renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
                }
            },



            /**
             * Get the global style setting for the renderer.
             * @private
             * @param  {CSSObject} style - Style settings.
             * @return {CSSObject} The style settings mixed with defaults.
             */
            getStyle: function(style) {
                this.style = extend({

                    fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
                        'Arial, Helvetica, sans-serif',
                    fontSize: '12px'

                }, style);
                return this.style;
            },
            /**
             * Apply the global style on the renderer, mixed with the default styles.
             * 
             * @param {CSSObject} style - CSS to apply.
             */
            setStyle: function(style) {
                this.boxWrapper.css(this.getStyle(style));
            },


            /**
             * Detect whether the renderer is hidden. This happens when one of the
             * parent elements has `display: none`. Used internally to detect when we
             * needto render preliminarily in another div to get the text bounding boxes
             * right.
             *
             * @returns {boolean} True if it is hidden.
             */
            isHidden: function() { // #608
                return !this.boxWrapper.getBBox().width;
            },

            /**
             * Destroys the renderer and its allocated members.
             */
            destroy: function() {
                var renderer = this,
                    rendererDefs = renderer.defs;
                renderer.box = null;
                renderer.boxWrapper = renderer.boxWrapper.destroy();

                // Call destroy on all gradient elements
                destroyObjectProperties(renderer.gradients || {});
                renderer.gradients = null;

                // Defs are null in VMLRenderer
                // Otherwise, destroy them here.
                if (rendererDefs) {
                    renderer.defs = rendererDefs.destroy();
                }

                // Remove sub pixel fix handler (#982)
                if (renderer.unSubPixelFix) {
                    renderer.unSubPixelFix();
                }

                renderer.alignedObjects = null;

                return null;
            },

            /**
             * Create a wrapper for an SVG element. Serves as a factory for 
             * {@link SVGElement}, but this function is itself mostly called from 
             * primitive factories like {@link SVGRenderer#path}, {@link
             * SVGRenderer#rect} or {@link SVGRenderer#text}.
             * 
             * @param {string} nodeName - The node name, for example `rect`, `g` etc.
             * @returns {SVGElement} The generated SVGElement.
             */
            createElement: function(nodeName) {
                var wrapper = new this.Element();
                wrapper.init(this, nodeName);
                return wrapper;
            },

            /**
             * Dummy function for plugins, called every time the renderer is updated.
             * Prior to Highcharts 5, this was used for the canvg renderer.
             * @function
             */
            draw: noop,

            /**
             * Get converted radial gradient attributes according to the radial
             * reference. Used internally from the {@link SVGElement#colorGradient}
             * function.
             *
             * @private
             */
            getRadialAttr: function(radialReference, gradAttr) {
                return {
                    cx: (radialReference[0] - radialReference[2] / 2) +
                        gradAttr.cx * radialReference[2],
                    cy: (radialReference[1] - radialReference[2] / 2) +
                        gradAttr.cy * radialReference[2],
                    r: gradAttr.r * radialReference[2]
                };
            },

            getSpanWidth: function(wrapper, tspan) {
                var renderer = this,
                    bBox = wrapper.getBBox(true),
                    actualWidth = bBox.width;

                // Old IE cannot measure the actualWidth for SVG elements (#2314)
                if (!svg && renderer.forExport) {
                    actualWidth = renderer.measureSpanWidth(
                        tspan.firstChild.data,
                        wrapper.styles
                    );
                }
                return actualWidth;
            },

            applyEllipsis: function(wrapper, tspan, text, width) {
                var renderer = this,
                    rotation = wrapper.rotation,
                    str = text,
                    currentIndex,
                    minIndex = 0,
                    maxIndex = text.length,
                    updateTSpan = function(s) {
                        tspan.removeChild(tspan.firstChild);
                        if (s) {
                            tspan.appendChild(doc.createTextNode(s));
                        }
                    },
                    actualWidth,
                    wasTooLong;
                wrapper.rotation = 0; // discard rotation when computing box
                actualWidth = renderer.getSpanWidth(wrapper, tspan);
                wasTooLong = actualWidth > width;
                if (wasTooLong) {
                    while (minIndex <= maxIndex) {
                        currentIndex = Math.ceil((minIndex + maxIndex) / 2);
                        str = text.substring(0, currentIndex) + '\u2026';
                        updateTSpan(str);
                        actualWidth = renderer.getSpanWidth(wrapper, tspan);
                        if (minIndex === maxIndex) {
                            // Complete
                            minIndex = maxIndex + 1;
                        } else if (actualWidth > width) {
                            // Too large. Set max index to current.
                            maxIndex = currentIndex - 1;
                        } else {
                            // Within width. Set min index to current.
                            minIndex = currentIndex;
                        }
                    }
                    // If max index was 0 it means just ellipsis was also to large.
                    if (maxIndex === 0) {
                        // Remove ellipses.
                        updateTSpan('');
                    }
                }
                wrapper.rotation = rotation; // Apply rotation again.
                return wasTooLong;
            },

            /**
             * A collection of characters mapped to HTML entities. When `useHTML` on an
             * element is true, these entities will be rendered correctly by HTML. In 
             * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
             * so for example `&lt;` will render as `<`.
             *
             * @example
             * // Add support for unescaping quotes
             * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
             * 
             * @type {Object}
             */
            escapes: {
                '&': '&amp;',
                '<': '&lt;',
                '>': '&gt;',
                "'": '&#39;', // eslint-disable-line quotes
                '"': '&quot'
            },

            /**
             * Parse a simple HTML string into SVG tspans. Called internally when text
             *   is set on an SVGElement. The function supports a subset of HTML tags,
             *   CSS text features like `width`, `text-overflow`, `white-space`, and
             *   also attributes like `href` and `style`.
             * @private
             * @param {SVGElement} wrapper The parent SVGElement.
             */
            buildText: function(wrapper) {
                var textNode = wrapper.element,
                    renderer = this,
                    forExport = renderer.forExport,
                    textStr = pick(wrapper.textStr, '').toString(),
                    hasMarkup = textStr.indexOf('<') !== -1,
                    lines,
                    childNodes = textNode.childNodes,
                    clsRegex,
                    styleRegex,
                    hrefRegex,
                    wasTooLong,
                    parentX = attr(textNode, 'x'),
                    textStyles = wrapper.styles,
                    width = wrapper.textWidth,
                    textLineHeight = textStyles && textStyles.lineHeight,
                    textOutline = textStyles && textStyles.textOutline,
                    ellipsis = textStyles && textStyles.textOverflow === 'ellipsis',
                    noWrap = textStyles && textStyles.whiteSpace === 'nowrap',
                    fontSize = textStyles && textStyles.fontSize,
                    textCache,
                    isSubsequentLine,
                    i = childNodes.length,
                    tempParent = width && !wrapper.added && this.box,
                    getLineHeight = function(tspan) {
                        var fontSizeStyle;

                        fontSizeStyle = /(px|em)$/.test(tspan && tspan.style.fontSize) ?
                            tspan.style.fontSize :
                            (fontSize || renderer.style.fontSize || 12);


                        return textLineHeight ?
                            pInt(textLineHeight) :
                            renderer.fontMetrics(
                                fontSizeStyle,
                                // Get the computed size from parent if not explicit
                                tspan.getAttribute('style') ? tspan : textNode
                            ).h;
                    },
                    unescapeEntities = function(inputStr) {
                        objectEach(renderer.escapes, function(value, key) {
                            inputStr = inputStr.replace(
                                new RegExp(value, 'g'),
                                key
                            );
                        });
                        return inputStr;
                    };

                // The buildText code is quite heavy, so if we're not changing something
                // that affects the text, skip it (#6113).
                textCache = [
                    textStr,
                    ellipsis,
                    noWrap,
                    textLineHeight,
                    textOutline,
                    fontSize,
                    width
                ].join(',');
                if (textCache === wrapper.textCache) {
                    return;
                }
                wrapper.textCache = textCache;

                // Remove old text
                while (i--) {
                    textNode.removeChild(childNodes[i]);
                }

                // Skip tspans, add text directly to text node. The forceTSpan is a hook
                // used in text outline hack.
                if (!hasMarkup &&
                    !textOutline &&
                    !ellipsis &&
                    !width &&
                    textStr.indexOf(' ') === -1
                ) {
                    textNode.appendChild(doc.createTextNode(unescapeEntities(textStr)));

                    // Complex strings, add more logic
                } else {

                    clsRegex = /<.*class="([^"]+)".*>/;
                    styleRegex = /<.*style="([^"]+)".*>/;
                    hrefRegex = /<.*href="([^"]+)".*>/;

                    if (tempParent) {
                        // attach it to the DOM to read offset width
                        tempParent.appendChild(textNode);
                    }

                    if (hasMarkup) {
                        lines = textStr

                            .replace(/<(b|strong)>/g, '<span style="font-weight:bold">')
                            .replace(/<(i|em)>/g, '<span style="font-style:italic">')

                            .replace(/<a/g, '<span')
                            .replace(/<\/(b|strong|i|em|a)>/g, '</span>')
                            .split(/<br.*?>/g);

                    } else {
                        lines = [textStr];
                    }


                    // Trim empty lines (#5261)
                    lines = grep(lines, function(line) {
                        return line !== '';
                    });


                    // build the lines
                    each(lines, function buildTextLines(line, lineNo) {
                        var spans,
                            spanNo = 0;
                        line = line
                            // Trim to prevent useless/costly process on the spaces
                            // (#5258)
                            .replace(/^\s+|\s+$/g, '')
                            .replace(/<span/g, '|||<span')
                            .replace(/<\/span>/g, '</span>|||');
                        spans = line.split('|||');

                        each(spans, function buildTextSpans(span) {
                            if (span !== '' || spans.length === 1) {
                                var attributes = {},
                                    tspan = doc.createElementNS(
                                        renderer.SVG_NS,
                                        'tspan'
                                    ),
                                    spanCls,
                                    spanStyle; // #390
                                if (clsRegex.test(span)) {
                                    spanCls = span.match(clsRegex)[1];
                                    attr(tspan, 'class', spanCls);
                                }
                                if (styleRegex.test(span)) {
                                    spanStyle = span.match(styleRegex)[1].replace(
                                        /(;| |^)color([ :])/,
                                        '$1fill$2'
                                    );
                                    attr(tspan, 'style', spanStyle);
                                }

                                // Not for export - #1529
                                if (hrefRegex.test(span) && !forExport) {
                                    attr(
                                        tspan,
                                        'onclick',
                                        'location.href=\"' +
                                        span.match(hrefRegex)[1] + '\"'
                                    );
                                    attr(tspan, 'class', 'highcharts-anchor');

                                    css(tspan, {
                                        cursor: 'pointer'
                                    });

                                }

                                // Strip away unsupported HTML tags (#7126)
                                span = unescapeEntities(
                                    span.replace(/<[a-zA-Z\/](.|\n)*?>/g, '') || ' '
                                );

                                // Nested tags aren't supported, and cause crash in
                                // Safari (#1596)
                                if (span !== ' ') {

                                    // add the text node
                                    tspan.appendChild(doc.createTextNode(span));

                                    // First span in a line, align it to the left
                                    if (!spanNo) {
                                        if (lineNo && parentX !== null) {
                                            attributes.x = parentX;
                                        }
                                    } else {
                                        attributes.dx = 0; // #16
                                    }

                                    // add attributes
                                    attr(tspan, attributes);

                                    // Append it
                                    textNode.appendChild(tspan);

                                    // first span on subsequent line, add the line
                                    // height
                                    if (!spanNo && isSubsequentLine) {

                                        // allow getting the right offset height in
                                        // exporting in IE
                                        if (!svg && forExport) {
                                            css(tspan, {
                                                display: 'block'
                                            });
                                        }

                                        // Set the line height based on the font size of
                                        // either the text element or the tspan element
                                        attr(
                                            tspan,
                                            'dy',
                                            getLineHeight(tspan)
                                        );
                                    }

                                    /* 
                                    if (width) {
                                    	renderer.breakText(wrapper, width);
                                    }
                                    */

                                    // Check width and apply soft breaks or ellipsis
                                    if (width) {
                                        var words = span.replace(
                                                /([^\^])-/g,
                                                '$1- '
                                            ).split(' '), // #1273
                                            hasWhiteSpace = (
                                                spans.length > 1 ||
                                                lineNo ||
                                                (words.length > 1 && !noWrap)
                                            ),
                                            tooLong,
                                            rest = [],
                                            actualWidth,
                                            dy = getLineHeight(tspan),
                                            rotation = wrapper.rotation;

                                        if (ellipsis) {
                                            wasTooLong = renderer.applyEllipsis(
                                                wrapper,
                                                tspan,
                                                span,
                                                width
                                            );
                                        }

                                        while (!ellipsis &&
                                            hasWhiteSpace &&
                                            (words.length || rest.length)
                                        ) {
                                            // discard rotation when computing box
                                            wrapper.rotation = 0;
                                            actualWidth = renderer.getSpanWidth(
                                                wrapper,
                                                tspan
                                            );
                                            tooLong = actualWidth > width;

                                            // For ellipsis, do a binary search for the 
                                            // correct string length
                                            if (wasTooLong === undefined) {
                                                wasTooLong = tooLong; // First time
                                            }

                                            // Looping down, this is the first word
                                            // sequence that is not too long, so we can
                                            // move on to build the next line.
                                            if (!tooLong || words.length === 1) {
                                                words = rest;
                                                rest = [];

                                                if (words.length && !noWrap) {
                                                    tspan = doc.createElementNS(
                                                        SVG_NS,
                                                        'tspan'
                                                    );
                                                    attr(tspan, {
                                                        dy: dy,
                                                        x: parentX
                                                    });
                                                    if (spanStyle) { // #390
                                                        attr(tspan, 'style', spanStyle);
                                                    }
                                                    textNode.appendChild(tspan);
                                                }

                                                // a single word is pressing it out
                                                if (actualWidth > width) {
                                                    width = actualWidth;
                                                }
                                            } else { // append to existing line tspan
                                                tspan.removeChild(tspan.firstChild);
                                                rest.unshift(words.pop());
                                            }
                                            if (words.length) {
                                                tspan.appendChild(
                                                    doc.createTextNode(
                                                        words.join(' ')
                                                        .replace(/- /g, '-')
                                                    )
                                                );
                                            }
                                        }
                                        wrapper.rotation = rotation;
                                    }

                                    spanNo++;
                                }
                            }
                        });
                        // To avoid beginning lines that doesn't add to the textNode
                        // (#6144)
                        isSubsequentLine = (
                            isSubsequentLine ||
                            textNode.childNodes.length
                        );
                    });

                    if (wasTooLong) {
                        wrapper.attr('title', wrapper.textStr);
                    }
                    if (tempParent) {
                        tempParent.removeChild(textNode);
                    }

                    // Apply the text outline
                    if (textOutline && wrapper.applyTextOutline) {
                        wrapper.applyTextOutline(textOutline);
                    }
                }
            },



            /*
            breakText: function (wrapper, width) {
            	var bBox = wrapper.getBBox(),
            		node = wrapper.element,
            		textLength = node.textContent.length,
            		// try this position first, based on average character width
            		pos = Math.round(width * textLength / bBox.width),
            		increment = 0,
            		finalPos;

            	if (bBox.width > width) {
            		while (finalPos === undefined) {
            			textLength = node.getSubStringLength(0, pos);

            			if (textLength <= width) {
            				if (increment === -1) {
            					finalPos = pos;
            				} else {
            					increment = 1;
            				}
            			} else {
            				if (increment === 1) {
            					finalPos = pos - 1;
            				} else {
            					increment = -1;
            				}
            			}
            			pos += increment;
            		}
            	}
            	console.log(
            		'width',
            		width,
            		'stringWidth',
            		node.getSubStringLength(0, finalPos)
            	)
            },
            */

            /**
             * Returns white for dark colors and black for bright colors.
             *
             * @param {ColorString} rgba - The color to get the contrast for.
             * @returns {string} The contrast color, either `#000000` or `#FFFFFF`.
             */
            getContrast: function(rgba) {
                rgba = color(rgba).rgba;

                // The threshold may be discussed. Here's a proposal for adding
                // different weight to the color channels (#6216)
                /*
        rgba[0] *= 1; // red
        rgba[1] *= 1.2; // green
        rgba[2] *= 0.7; // blue
        */

                return rgba[0] + rgba[1] + rgba[2] > 2 * 255 ? '#000000' : '#FFFFFF';
            },

            /**
             * Create a button with preset states.
             * @param {string} text - The text or HTML to draw.
             * @param {number} x - The x position of the button's left side.
             * @param {number} y - The y position of the button's top side.
             * @param {Function} callback - The function to execute on button click or 
             *    touch.
             * @param {SVGAttributes} [normalState] - SVG attributes for the normal
             *    state.
             * @param {SVGAttributes} [hoverState] - SVG attributes for the hover state.
             * @param {SVGAttributes} [pressedState] - SVG attributes for the pressed
             *    state.
             * @param {SVGAttributes} [disabledState] - SVG attributes for the disabled
             *    state.
             * @param {Symbol} [shape=rect] - The shape type.
             * @returns {SVGRenderer} The button element.
             */
            button: function(
                text,
                x,
                y,
                callback,
                normalState,
                hoverState,
                pressedState,
                disabledState,
                shape
            ) {
                var label = this.label(
                        text,
                        x,
                        y,
                        shape,
                        null,
                        null,
                        null,
                        null,
                        'button'
                    ),
                    curState = 0;

                // Default, non-stylable attributes
                label.attr(merge({
                    'padding': 8,
                    'r': 2
                }, normalState));


                // Presentational
                var normalStyle,
                    hoverStyle,
                    pressedStyle,
                    disabledStyle;

                // Normal state - prepare the attributes
                normalState = merge({
                    fill: '#f7f7f7',
                    stroke: '#cccccc',
                    'stroke-width': 1,
                    style: {
                        color: '#333333',
                        cursor: 'pointer',
                        fontWeight: 'normal'
                    }
                }, normalState);
                normalStyle = normalState.style;
                delete normalState.style;

                // Hover state
                hoverState = merge(normalState, {
                    fill: '#e6e6e6'
                }, hoverState);
                hoverStyle = hoverState.style;
                delete hoverState.style;

                // Pressed state
                pressedState = merge(normalState, {
                    fill: '#e6ebf5',
                    style: {
                        color: '#000000',
                        fontWeight: 'bold'
                    }
                }, pressedState);
                pressedStyle = pressedState.style;
                delete pressedState.style;

                // Disabled state
                disabledState = merge(normalState, {
                    style: {
                        color: '#cccccc'
                    }
                }, disabledState);
                disabledStyle = disabledState.style;
                delete disabledState.style;


                // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
                // (#667).
                addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function() {
                    if (curState !== 3) {
                        label.setState(1);
                    }
                });
                addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function() {
                    if (curState !== 3) {
                        label.setState(curState);
                    }
                });

                label.setState = function(state) {
                    // Hover state is temporary, don't record it
                    if (state !== 1) {
                        label.state = curState = state;
                    }
                    // Update visuals
                    label.removeClass(
                            /highcharts-button-(normal|hover|pressed|disabled)/
                        )
                        .addClass(
                            'highcharts-button-' + ['normal', 'hover', 'pressed', 'disabled'][state || 0]
                        );


                    label.attr([
                            normalState,
                            hoverState,
                            pressedState,
                            disabledState
                        ][state || 0])
                        .css([
                            normalStyle,
                            hoverStyle,
                            pressedStyle,
                            disabledStyle
                        ][state || 0]);

                };



                // Presentational attributes
                label
                    .attr(normalState)
                    .css(extend({
                        cursor: 'default'
                    }, normalStyle));


                return label
                    .on('click', function(e) {
                        if (curState !== 3) {
                            callback.call(label, e);
                        }
                    });
            },

            /**
             * Make a straight line crisper by not spilling out to neighbour pixels.
             * 
             * @param {Array} points - The original points on the format `['M', 0, 0,
             *    'L', 100, 0]`.
             * @param {number} width - The width of the line.
             * @returns {Array} The original points array, but modified to render
             * crisply.
             */
            crispLine: function(points, width) {
                // normalize to a crisp line
                if (points[1] === points[4]) {
                    // Substract due to #1129. Now bottom and left axis gridlines behave
                    // the same.
                    points[1] = points[4] = Math.round(points[1]) - (width % 2 / 2);
                }
                if (points[2] === points[5]) {
                    points[2] = points[5] = Math.round(points[2]) + (width % 2 / 2);
                }
                return points;
            },


            /**
             * Draw a path, wraps the SVG `path` element.
             * 
             * @param {Array} [path] An SVG path definition in array form.
             * 
             * @example
             * var path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
             *     .attr({ stroke: '#ff00ff' })
             *     .add();
             * @returns {SVGElement} The generated wrapper element.
             *
             * @sample highcharts/members/renderer-path-on-chart/
             *         Draw a path in a chart
             * @sample highcharts/members/renderer-path/
             *         Draw a path independent from a chart
             *
             */
            /**
             * Draw a path, wraps the SVG `path` element.
             * 
             * @param {SVGAttributes} [attribs] The initial attributes.
             * @returns {SVGElement} The generated wrapper element.
             */
            path: function(path) {
                var attribs = {

                    fill: 'none'

                };
                if (isArray(path)) {
                    attribs.d = path;
                } else if (isObject(path)) { // attributes
                    extend(attribs, path);
                }
                return this.createElement('path').attr(attribs);
            },

            /**
             * Draw a circle, wraps the SVG `circle` element.
             * 
             * @param {number} [x] The center x position.
             * @param {number} [y] The center y position.
             * @param {number} [r] The radius.
             * @returns {SVGElement} The generated wrapper element.
             *
             * @sample highcharts/members/renderer-circle/ Drawing a circle
             */
            /**
             * Draw a circle, wraps the SVG `circle` element.
             * 
             * @param {SVGAttributes} [attribs] The initial attributes.
             * @returns {SVGElement} The generated wrapper element.
             */
            circle: function(x, y, r) {
                var attribs = isObject(x) ? x : {
                        x: x,
                        y: y,
                        r: r
                    },
                    wrapper = this.createElement('circle');

                // Setting x or y translates to cx and cy
                wrapper.xSetter = wrapper.ySetter = function(value, key, element) {
                    element.setAttribute('c' + key, value);
                };

                return wrapper.attr(attribs);
            },

            /**
             * Draw and return an arc.
             * @param {number} [x=0] Center X position.
             * @param {number} [y=0] Center Y position.
             * @param {number} [r=0] The outer radius of the arc.
             * @param {number} [innerR=0] Inner radius like used in donut charts.
             * @param {number} [start=0] The starting angle of the arc in radians, where
             *    0 is to the right and `-Math.PI/2` is up.
             * @param {number} [end=0] The ending angle of the arc in radians, where 0
             *    is to the right and `-Math.PI/2` is up.
             * @returns {SVGElement} The generated wrapper element.
             *
             * @sample highcharts/members/renderer-arc/
             *         Drawing an arc
             */
            /**
             * Draw and return an arc. Overloaded function that takes arguments object.
             * @param {SVGAttributes} attribs Initial SVG attributes.
             * @returns {SVGElement} The generated wrapper element.
             */
            arc: function(x, y, r, innerR, start, end) {
                var arc,
                    options;

                if (isObject(x)) {
                    options = x;
                    y = options.y;
                    r = options.r;
                    innerR = options.innerR;
                    start = options.start;
                    end = options.end;
                    x = options.x;
                } else {
                    options = {
                        innerR: innerR,
                        start: start,
                        end: end
                    };
                }

                // Arcs are defined as symbols for the ability to set
                // attributes in attr and animate
                arc = this.symbol('arc', x, y, r, r, options);
                arc.r = r; // #959
                return arc;
            },

            /**
             * Draw and return a rectangle.
             * @param {number} [x] Left position.
             * @param {number} [y] Top position.
             * @param {number} [width] Width of the rectangle.
             * @param {number} [height] Height of the rectangle.
             * @param {number} [r] Border corner radius.
             * @param {number} [strokeWidth] A stroke width can be supplied to allow
             *    crisp drawing.
             * @returns {SVGElement} The generated wrapper element.
             */
            /**
             * Draw and return a rectangle.
             * @param  {SVGAttributes} [attributes]
             *         General SVG attributes for the rectangle.
             * @return {SVGElement}
             *         The generated wrapper element.
             *
             * @sample highcharts/members/renderer-rect-on-chart/
             *         Draw a rectangle in a chart
             * @sample highcharts/members/renderer-rect/
             *         Draw a rectangle independent from a chart
             */
            rect: function(x, y, width, height, r, strokeWidth) {

                r = isObject(x) ? x.r : r;

                var wrapper = this.createElement('rect'),
                    attribs = isObject(x) ? x : x === undefined ? {} : {
                        x: x,
                        y: y,
                        width: Math.max(width, 0),
                        height: Math.max(height, 0)
                    };


                if (strokeWidth !== undefined) {
                    attribs.strokeWidth = strokeWidth;
                    attribs = wrapper.crisp(attribs);
                }
                attribs.fill = 'none';


                if (r) {
                    attribs.r = r;
                }

                wrapper.rSetter = function(value, key, element) {
                    attr(element, {
                        rx: value,
                        ry: value
                    });
                };

                return wrapper.attr(attribs);
            },

            /**
             * Resize the {@link SVGRenderer#box} and re-align all aligned child
             * elements.
             * @param  {number} width
             *         The new pixel width.
             * @param  {number} height
             *         The new pixel height.
             * @param  {Boolean|AnimationOptions} [animate=true]
             *         Whether and how to animate.
             */
            setSize: function(width, height, animate) {
                var renderer = this,
                    alignedObjects = renderer.alignedObjects,
                    i = alignedObjects.length;

                renderer.width = width;
                renderer.height = height;

                renderer.boxWrapper.animate({
                    width: width,
                    height: height
                }, {
                    step: function() {
                        this.attr({
                            viewBox: '0 0 ' + this.attr('width') + ' ' +
                                this.attr('height')
                        });
                    },
                    duration: pick(animate, true) ? undefined : 0
                });

                while (i--) {
                    alignedObjects[i].align();
                }
            },

            /**
             * Create and return an svg group element. Child
             * {@link Highcharts.SVGElement} objects are added to the group by using the
             * group as the first parameter
             * in {@link Highcharts.SVGElement#add|add()}.
             * 
             * @param {string} [name] The group will be given a class name of
             * `highcharts-{name}`. This can be used for styling and scripting.
             * @returns {SVGElement} The generated wrapper element.
             *
             * @sample highcharts/members/renderer-g/
             *         Show and hide grouped objects
             */
            g: function(name) {
                var elem = this.createElement('g');
                return name ? elem.attr({
                    'class': 'highcharts-' + name
                }) : elem;
            },

            /**
             * Display an image.
             * @param {string} src The image source.
             * @param {number} [x] The X position.
             * @param {number} [y] The Y position.
             * @param {number} [width] The image width. If omitted, it defaults to the 
             *    image file width.
             * @param {number} [height] The image height. If omitted it defaults to the
             *    image file height.
             * @returns {SVGElement} The generated wrapper element.
             *
             * @sample highcharts/members/renderer-image-on-chart/
             *         Add an image in a chart
             * @sample highcharts/members/renderer-image/
             *         Add an image independent of a chart
             */
            image: function(src, x, y, width, height) {
                var attribs = {
                        preserveAspectRatio: 'none'
                    },
                    elemWrapper;

                // optional properties
                if (arguments.length > 1) {
                    extend(attribs, {
                        x: x,
                        y: y,
                        width: width,
                        height: height
                    });
                }

                elemWrapper = this.createElement('image').attr(attribs);

                // set the href in the xlink namespace
                if (elemWrapper.element.setAttributeNS) {
                    elemWrapper.element.setAttributeNS('http://www.w3.org/1999/xlink',
                        'href', src);
                } else {
                    // could be exporting in IE
                    // using href throws "not supported" in ie7 and under, requries
                    // regex shim to fix later
                    elemWrapper.element.setAttribute('hc-svg-href', src);
                }
                return elemWrapper;
            },

            /**
             * Draw a symbol out of pre-defined shape paths from
             * {@link SVGRenderer#symbols}.
             * It is used in Highcharts for point makers, which cake a `symbol` option,
             * and label and button backgrounds like in the tooltip and stock flags.
             *
             * @param {Symbol} symbol - The symbol name.
             * @param {number} x - The X coordinate for the top left position.
             * @param {number} y - The Y coordinate for the top left position.
             * @param {number} width - The pixel width.
             * @param {number} height - The pixel height.
             * @param {Object} [options] - Additional options, depending on the actual
             *    symbol drawn. 
             * @param {number} [options.anchorX] - The anchor X position for the
             *    `callout` symbol. This is where the chevron points to.
             * @param {number} [options.anchorY] - The anchor Y position for the
             *    `callout` symbol. This is where the chevron points to.
             * @param {number} [options.end] - The end angle of an `arc` symbol.
             * @param {boolean} [options.open] - Whether to draw `arc` symbol open or
             *    closed.
             * @param {number} [options.r] - The radius of an `arc` symbol, or the
             *    border radius for the `callout` symbol.
             * @param {number} [options.start] - The start angle of an `arc` symbol.
             */
            symbol: function(symbol, x, y, width, height, options) {

                var ren = this,
                    obj,
                    imageRegex = /^url\((.*?)\)$/,
                    isImage = imageRegex.test(symbol),
                    sym = !isImage && (this.symbols[symbol] ? symbol : 'circle'),


                    // get the symbol definition function
                    symbolFn = sym && this.symbols[sym],

                    // check if there's a path defined for this symbol
                    path = defined(x) && symbolFn && symbolFn.call(
                        this.symbols,
                        Math.round(x),
                        Math.round(y),
                        width,
                        height,
                        options
                    ),
                    imageSrc,
                    centerImage;

                if (symbolFn) {
                    obj = this.path(path);


                    obj.attr('fill', 'none');


                    // expando properties for use in animate and attr
                    extend(obj, {
                        symbolName: sym,
                        x: x,
                        y: y,
                        width: width,
                        height: height
                    });
                    if (options) {
                        extend(obj, options);
                    }


                    // Image symbols
                } else if (isImage) {


                    imageSrc = symbol.match(imageRegex)[1];

                    // Create the image synchronously, add attribs async
                    obj = this.image(imageSrc);

                    // The image width is not always the same as the symbol width. The
                    // image may be centered within the symbol, as is the case when
                    // image shapes are used as label backgrounds, for example in flags.
                    obj.imgwidth = pick(
                        symbolSizes[imageSrc] && symbolSizes[imageSrc].width,
                        options && options.width
                    );
                    obj.imgheight = pick(
                        symbolSizes[imageSrc] && symbolSizes[imageSrc].height,
                        options && options.height
                    );
                    /**
                     * Set the size and position
                     */
                    centerImage = function() {
                        obj.attr({
                            width: obj.width,
                            height: obj.height
                        });
                    };

                    /**
                     * Width and height setters that take both the image's physical size
                     * and the label size into consideration, and translates the image
                     * to center within the label.
                     */
                    each(['width', 'height'], function(key) {
                        obj[key + 'Setter'] = function(value, key) {
                            var attribs = {},
                                imgSize = this['img' + key],
                                trans = key === 'width' ? 'translateX' : 'translateY';
                            this[key] = value;
                            if (defined(imgSize)) {
                                if (this.element) {
                                    this.element.setAttribute(key, imgSize);
                                }
                                if (!this.alignByTranslate) {
                                    attribs[trans] = ((this[key] || 0) - imgSize) / 2;
                                    this.attr(attribs);
                                }
                            }
                        };
                    });


                    if (defined(x)) {
                        obj.attr({
                            x: x,
                            y: y
                        });
                    }
                    obj.isImg = true;

                    if (defined(obj.imgwidth) && defined(obj.imgheight)) {
                        centerImage();
                    } else {
                        // Initialize image to be 0 size so export will still function
                        // if there's no cached sizes.
                        obj.attr({
                            width: 0,
                            height: 0
                        });

                        // Create a dummy JavaScript image to get the width and height. 
                        createElement('img', {
                            onload: function() {

                                var chart = charts[ren.chartIndex];

                                // Special case for SVGs on IE11, the width is not
                                // accessible until the image is part of the DOM
                                // (#2854).
                                if (this.width === 0) {
                                    css(this, {
                                        position: 'absolute',
                                        top: '-999em'
                                    });
                                    doc.body.appendChild(this);
                                }

                                // Center the image
                                symbolSizes[imageSrc] = { // Cache for next	
                                    width: this.width,
                                    height: this.height
                                };
                                obj.imgwidth = this.width;
                                obj.imgheight = this.height;

                                if (obj.element) {
                                    centerImage();
                                }

                                // Clean up after #2854 workaround.
                                if (this.parentNode) {
                                    this.parentNode.removeChild(this);
                                }

                                // Fire the load event when all external images are
                                // loaded
                                ren.imgCount--;
                                if (!ren.imgCount && chart && chart.onload) {
                                    chart.onload();
                                }
                            },
                            src: imageSrc
                        });
                        this.imgCount++;
                    }
                }

                return obj;
            },

            /**
             * @typedef {string} Symbol
             * 
             * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`,
             * `triangle`, `triangle-down`. Symbols are used internally for point
             * markers, button and label borders and backgrounds, or custom shapes.
             * Extendable by adding to {@link SVGRenderer#symbols}.
             */
            /**
             * An extendable collection of functions for defining symbol paths.
             */
            symbols: {
                'circle': function(x, y, w, h) {
                    // Return a full arc
                    return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
                        start: 0,
                        end: Math.PI * 2,
                        open: false
                    });
                },

                'square': function(x, y, w, h) {
                    return [
                        'M', x, y,
                        'L', x + w, y,
                        x + w, y + h,
                        x, y + h,
                        'Z'
                    ];
                },

                'triangle': function(x, y, w, h) {
                    return [
                        'M', x + w / 2, y,
                        'L', x + w, y + h,
                        x, y + h,
                        'Z'
                    ];
                },

                'triangle-down': function(x, y, w, h) {
                    return [
                        'M', x, y,
                        'L', x + w, y,
                        x + w / 2, y + h,
                        'Z'
                    ];
                },
                'diamond': function(x, y, w, h) {
                    return [
                        'M', x + w / 2, y,
                        'L', x + w, y + h / 2,
                        x + w / 2, y + h,
                        x, y + h / 2,
                        'Z'
                    ];
                },
                'arc': function(x, y, w, h, options) {
                    var start = options.start,
                        rx = options.r || w,
                        ry = options.r || h || w,
                        proximity = 0.001,
                        fullCircle =
                        Math.abs(options.end - options.start - 2 * Math.PI) <
                        proximity,
                        // Substract a small number to prevent cos and sin of start and
                        // end from becoming equal on 360 arcs (related: #1561)
                        end = options.end - proximity,
                        innerRadius = options.innerR,
                        open = pick(options.open, fullCircle),
                        cosStart = Math.cos(start),
                        sinStart = Math.sin(start),
                        cosEnd = Math.cos(end),
                        sinEnd = Math.sin(end),
                        // Proximity takes care of rounding errors around PI (#6971)
                        longArc = options.end - start - Math.PI < proximity ? 0 : 1,
                        arc;

                    arc = [
                        'M',
                        x + rx * cosStart,
                        y + ry * sinStart,
                        'A', // arcTo
                        rx, // x radius
                        ry, // y radius
                        0, // slanting
                        longArc, // long or short arc
                        1, // clockwise
                        x + rx * cosEnd,
                        y + ry * sinEnd
                    ];

                    if (defined(innerRadius)) {
                        arc.push(
                            open ? 'M' : 'L',
                            x + innerRadius * cosEnd,
                            y + innerRadius * sinEnd,
                            'A', // arcTo
                            innerRadius, // x radius
                            innerRadius, // y radius
                            0, // slanting
                            longArc, // long or short arc
                            0, // clockwise
                            x + innerRadius * cosStart,
                            y + innerRadius * sinStart
                        );
                    }

                    arc.push(open ? '' : 'Z'); // close
                    return arc;
                },

                /**
                 * Callout shape used for default tooltips, also used for rounded
                 * rectangles in VML
                 */
                callout: function(x, y, w, h, options) {
                    var arrowLength = 6,
                        halfDistance = 6,
                        r = Math.min((options && options.r) || 0, w, h),
                        safeDistance = r + halfDistance,
                        anchorX = options && options.anchorX,
                        anchorY = options && options.anchorY,
                        path;

                    path = [
                        'M', x + r, y,
                        'L', x + w - r, y, // top side
                        'C', x + w, y, x + w, y, x + w, y + r, // top-right corner
                        'L', x + w, y + h - r, // right side
                        'C', x + w, y + h, x + w, y + h, x + w - r, y + h, // bottom-rgt
                        'L', x + r, y + h, // bottom side
                        'C', x, y + h, x, y + h, x, y + h - r, // bottom-left corner
                        'L', x, y + r, // left side
                        'C', x, y, x, y, x + r, y // top-left corner
                    ];

                    // Anchor on right side
                    if (anchorX && anchorX > w) {

                        // Chevron
                        if (
                            anchorY > y + safeDistance &&
                            anchorY < y + h - safeDistance
                        ) {
                            path.splice(13, 3,
                                'L', x + w, anchorY - halfDistance,
                                x + w + arrowLength, anchorY,
                                x + w, anchorY + halfDistance,
                                x + w, y + h - r
                            );

                            // Simple connector
                        } else {
                            path.splice(13, 3,
                                'L', x + w, h / 2,
                                anchorX, anchorY,
                                x + w, h / 2,
                                x + w, y + h - r
                            );
                        }

                        // Anchor on left side
                    } else if (anchorX && anchorX < 0) {

                        // Chevron
                        if (
                            anchorY > y + safeDistance &&
                            anchorY < y + h - safeDistance
                        ) {
                            path.splice(33, 3,
                                'L', x, anchorY + halfDistance,
                                x - arrowLength, anchorY,
                                x, anchorY - halfDistance,
                                x, y + r
                            );

                            // Simple connector
                        } else {
                            path.splice(33, 3,
                                'L', x, h / 2,
                                anchorX, anchorY,
                                x, h / 2,
                                x, y + r
                            );
                        }

                    } else if ( // replace bottom
                        anchorY &&
                        anchorY > h &&
                        anchorX > x + safeDistance &&
                        anchorX < x + w - safeDistance
                    ) {
                        path.splice(23, 3,
                            'L', anchorX + halfDistance, y + h,
                            anchorX, y + h + arrowLength,
                            anchorX - halfDistance, y + h,
                            x + r, y + h
                        );

                    } else if ( // replace top
                        anchorY &&
                        anchorY < 0 &&
                        anchorX > x + safeDistance &&
                        anchorX < x + w - safeDistance
                    ) {
                        path.splice(3, 3,
                            'L', anchorX - halfDistance, y,
                            anchorX, y - arrowLength,
                            anchorX + halfDistance, y,
                            w - r, y
                        );
                    }

                    return path;
                }
            },

            /**
             * @typedef {SVGElement} ClipRect - A clipping rectangle that can be applied
             * to one or more {@link SVGElement} instances. It is instanciated with the
             * {@link SVGRenderer#clipRect} function and applied with the {@link 
             * SVGElement#clip} function.
             *
             * @example
             * var circle = renderer.circle(100, 100, 100)
             *     .attr({ fill: 'red' })
             *     .add();
             * var clipRect = renderer.clipRect(100, 100, 100, 100);
             *
             * // Leave only the lower right quarter visible
             * circle.clip(clipRect);
             */
            /**
             * Define a clipping rectangle. The clipping rectangle is later applied
             * to {@link SVGElement} objects through the {@link SVGElement#clip}
             * function.
             * 
             * @param {String} id
             * @param {number} x
             * @param {number} y
             * @param {number} width
             * @param {number} height
             * @returns {ClipRect} A clipping rectangle.
             *
             * @example
             * var circle = renderer.circle(100, 100, 100)
             *     .attr({ fill: 'red' })
             *     .add();
             * var clipRect = renderer.clipRect(100, 100, 100, 100);
             *
             * // Leave only the lower right quarter visible
             * circle.clip(clipRect);
             */
            clipRect: function(x, y, width, height) {
                var wrapper,
                    id = H.uniqueKey(),

                    clipPath = this.createElement('clipPath').attr({
                        id: id
                    }).add(this.defs);

                wrapper = this.rect(x, y, width, height, 0).add(clipPath);
                wrapper.id = id;
                wrapper.clipPath = clipPath;
                wrapper.count = 0;

                return wrapper;
            },





            /**
             * Draw text. The text can contain a subset of HTML, like spans and anchors
             * and some basic text styling of these. For more advanced features like
             * border and background, use {@link Highcharts.SVGRenderer#label} instead.
             * To update the text after render, run `text.attr({ text: 'New text' })`.
             * @param  {String} str
             *         The text of (subset) HTML to draw.
             * @param  {number} x
             *         The x position of the text's lower left corner.
             * @param  {number} y
             *         The y position of the text's lower left corner.
             * @param  {Boolean} [useHTML=false]
             *         Use HTML to render the text.
             *
             * @return {SVGElement} The text object.
             *
             * @sample highcharts/members/renderer-text-on-chart/
             *         Annotate the chart freely
             * @sample highcharts/members/renderer-on-chart/
             *         Annotate with a border and in response to the data
             * @sample highcharts/members/renderer-text/
             *         Formatted text
             */
            text: function(str, x, y, useHTML) {

                // declare variables
                var renderer = this,
                    wrapper,
                    attribs = {};

                if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
                    return renderer.html(str, x, y);
                }

                attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
                if (y) {
                    attribs.y = Math.round(y);
                }
                if (str || str === 0) {
                    attribs.text = str;
                }

                wrapper = renderer.createElement('text')
                    .attr(attribs);

                if (!useHTML) {
                    wrapper.xSetter = function(value, key, element) {
                        var tspans = element.getElementsByTagName('tspan'),
                            tspan,
                            parentVal = element.getAttribute(key),
                            i;
                        for (i = 0; i < tspans.length; i++) {
                            tspan = tspans[i];
                            // If the x values are equal, the tspan represents a
                            // linebreak
                            if (tspan.getAttribute(key) === parentVal) {
                                tspan.setAttribute(key, value);
                            }
                        }
                        element.setAttribute(key, value);
                    };
                }

                return wrapper;
            },

            /**
             * Utility to return the baseline offset and total line height from the font
             * size.
             *
             * @param {?string} fontSize The current font size to inspect. If not given,
             *   the font size will be found from the DOM element.
             * @param {SVGElement|SVGDOMElement} [elem] The element to inspect for a
             *   current font size.
             * @returns {Object} An object containing `h`: the line height, `b`: the
             * baseline relative to the top of the box, and `f`: the font size.
             */
            fontMetrics: function(fontSize, elem) {
                var lineHeight,
                    baseline;


                fontSize = fontSize ||
                    // When the elem is a DOM element (#5932)
                    (elem && elem.style && elem.style.fontSize) ||
                    // Fall back on the renderer style default
                    (this.style && this.style.fontSize);



                // Handle different units
                if (/px/.test(fontSize)) {
                    fontSize = pInt(fontSize);
                } else if (/em/.test(fontSize)) {
                    // The em unit depends on parent items
                    fontSize = parseFloat(fontSize) *
                        (elem ? this.fontMetrics(null, elem.parentNode).f : 16);
                } else {
                    fontSize = 12;
                }

                // Empirical values found by comparing font size and bounding box
                // height. Applies to the default font family.
                // http://jsfiddle.net/highcharts/7xvn7/
                lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
                baseline = Math.round(lineHeight * 0.8);

                return {
                    h: lineHeight,
                    b: baseline,
                    f: fontSize
                };
            },

            /**
             * Correct X and Y positioning of a label for rotation (#1764).
             *
             * @private
             */
            rotCorr: function(baseline, rotation, alterY) {
                var y = baseline;
                if (rotation && alterY) {
                    y = Math.max(y * Math.cos(rotation * deg2rad), 4);
                }
                return {
                    x: (-baseline / 3) * Math.sin(rotation * deg2rad),
                    y: y
                };
            },

            /**
             * Draw a label, which is an extended text element with support for border
             * and background. Highcharts creates a `g` element with a text and a `path`
             * or `rect` inside, to make it behave somewhat like a HTML div. Border and
             * background are set through `stroke`, `stroke-width` and `fill` attributes
             * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
             * text after render, run `label.attr({ text: 'New text' })`.
             * 
             * @param  {string} str
             *         The initial text string or (subset) HTML to render.
             * @param  {number} x
             *         The x position of the label's left side.
             * @param  {number} y
             *         The y position of the label's top side or baseline, depending on
             *         the `baseline` parameter.
             * @param  {String} shape
             *         The shape of the label's border/background, if any. Defaults to
             *         `rect`. Other possible values are `callout` or other shapes
             *         defined in {@link Highcharts.SVGRenderer#symbols}.
             * @param  {number} anchorX
             *         In case the `shape` has a pointer, like a flag, this is the
             *         coordinates it should be pinned to.
             * @param  {number} anchorY
             *         In case the `shape` has a pointer, like a flag, this is the
             *         coordinates it should be pinned to.
             * @param  {Boolean} baseline
             *         Whether to position the label relative to the text baseline,
             *	       like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
             *	       upper border of the rectangle.
             * @param  {String} className
             *         Class name for the group.
             *
             * @return {SVGElement}
             *         The generated label.
             *
             * @sample highcharts/members/renderer-label-on-chart/
             *         A label on the chart
             */
            label: function(
                str,
                x,
                y,
                shape,
                anchorX,
                anchorY,
                useHTML,
                baseline,
                className
            ) {

                var renderer = this,
                    wrapper = renderer.g(className !== 'button' && 'label'),
                    text = wrapper.text = renderer.text('', 0, 0, useHTML)
                    .attr({
                        zIndex: 1
                    }),
                    box,
                    bBox,
                    alignFactor = 0,
                    padding = 3,
                    paddingLeft = 0,
                    width,
                    height,
                    wrapperX,
                    wrapperY,
                    textAlign,
                    deferredAttr = {},
                    strokeWidth,
                    baselineOffset,
                    hasBGImage = /^url\((.*?)\)$/.test(shape),
                    needsBox = hasBGImage,
                    getCrispAdjust,
                    updateBoxSize,
                    updateTextPadding,
                    boxAttr;

                if (className) {
                    wrapper.addClass('highcharts-' + className);
                }


                needsBox = hasBGImage;
                getCrispAdjust = function() {
                    return (strokeWidth || 0) % 2 / 2;
                };



                /**
                 * This function runs after the label is added to the DOM (when the
                 * bounding box is available), and after the text of the label is
                 * updated to detect the new bounding box and reflect it in the border
                 * box.
                 */
                updateBoxSize = function() {
                    var style = text.element.style,
                        crispAdjust,
                        attribs = {};

                    bBox = (
                        (width === undefined || height === undefined || textAlign) &&
                        defined(text.textStr) &&
                        text.getBBox()
                    ); // #3295 && 3514 box failure when string equals 0
                    wrapper.width = (
                        (width || bBox.width || 0) +
                        2 * padding +
                        paddingLeft
                    );
                    wrapper.height = (height || bBox.height || 0) + 2 * padding;

                    // Update the label-scoped y offset
                    baselineOffset = padding +
                        renderer.fontMetrics(style && style.fontSize, text).b;


                    if (needsBox) {

                        // Create the border box if it is not already present
                        if (!box) {
                            // Symbol definition exists (#5324)
                            wrapper.box = box = renderer.symbols[shape] || hasBGImage ?
                                renderer.symbol(shape) :
                                renderer.rect();

                            box.addClass( // Don't use label className for buttons
                                (className === 'button' ? '' : 'highcharts-label-box') +
                                (className ? ' highcharts-' + className + '-box' : '')
                            );

                            box.add(wrapper);

                            crispAdjust = getCrispAdjust();
                            attribs.x = crispAdjust;
                            attribs.y = (baseline ? -baselineOffset : 0) + crispAdjust;
                        }

                        // Apply the box attributes
                        attribs.width = Math.round(wrapper.width);
                        attribs.height = Math.round(wrapper.height);

                        box.attr(extend(attribs, deferredAttr));
                        deferredAttr = {};
                    }
                };

                /**
                 * This function runs after setting text or padding, but only if padding
                 * is changed
                 */
                updateTextPadding = function() {
                    var textX = paddingLeft + padding,
                        textY;

                    // determin y based on the baseline
                    textY = baseline ? 0 : baselineOffset;

                    // compensate for alignment
                    if (
                        defined(width) &&
                        bBox &&
                        (textAlign === 'center' || textAlign === 'right')
                    ) {
                        textX += {
                                center: 0.5,
                                right: 1
                            }[textAlign] *
                            (width - bBox.width);
                    }

                    // update if anything changed
                    if (textX !== text.x || textY !== text.y) {
                        text.attr('x', textX);
                        if (textY !== undefined) {
                            text.attr('y', textY);
                        }
                    }

                    // record current values
                    text.x = textX;
                    text.y = textY;
                };

                /**
                 * Set a box attribute, or defer it if the box is not yet created
                 * @param {Object} key
                 * @param {Object} value
                 */
                boxAttr = function(key, value) {
                    if (box) {
                        box.attr(key, value);
                    } else {
                        deferredAttr[key] = value;
                    }
                };

                /**
                 * After the text element is added, get the desired size of the border
                 * box and add it before the text in the DOM.
                 */
                wrapper.onAdd = function() {
                    text.add(wrapper);
                    wrapper.attr({
                        // Alignment is available now  (#3295, 0 not rendered if given
                        // as a value)
                        text: (str || str === 0) ? str : '',
                        x: x,
                        y: y
                    });

                    if (box && defined(anchorX)) {
                        wrapper.attr({
                            anchorX: anchorX,
                            anchorY: anchorY
                        });
                    }
                };

                /*
                 * Add specific attribute setters.
                 */

                // only change local variables
                wrapper.widthSetter = function(value) {
                    width = H.isNumber(value) ? value : null; // width:auto => null
                };
                wrapper.heightSetter = function(value) {
                    height = value;
                };
                wrapper['text-alignSetter'] = function(value) {
                    textAlign = value;
                };
                wrapper.paddingSetter = function(value) {
                    if (defined(value) && value !== padding) {
                        padding = wrapper.padding = value;
                        updateTextPadding();
                    }
                };
                wrapper.paddingLeftSetter = function(value) {
                    if (defined(value) && value !== paddingLeft) {
                        paddingLeft = value;
                        updateTextPadding();
                    }
                };


                // change local variable and prevent setting attribute on the group
                wrapper.alignSetter = function(value) {
                    value = {
                        left: 0,
                        center: 0.5,
                        right: 1
                    }[value];
                    if (value !== alignFactor) {
                        alignFactor = value;
                        // Bounding box exists, means we're dynamically changing
                        if (bBox) {
                            wrapper.attr({
                                x: wrapperX
                            }); // #5134
                        }
                    }
                };

                // apply these to the box and the text alike
                wrapper.textSetter = function(value) {
                    if (value !== undefined) {
                        text.textSetter(value);
                    }
                    updateBoxSize();
                    updateTextPadding();
                };

                // apply these to the box but not to the text
                wrapper['stroke-widthSetter'] = function(value, key) {
                    if (value) {
                        needsBox = true;
                    }
                    strokeWidth = this['stroke-width'] = value;
                    boxAttr(key, value);
                };

                wrapper.strokeSetter =
                    wrapper.fillSetter =
                    wrapper.rSetter = function(value, key) {
                        if (key !== 'r') {
                            if (key === 'fill' && value) {
                                needsBox = true;
                            }
                            // for animation getter (#6776)
                            wrapper[key] = value;
                        }
                        boxAttr(key, value);
                    };

                wrapper.anchorXSetter = function(value, key) {
                    anchorX = wrapper.anchorX = value;
                    boxAttr(key, Math.round(value) - getCrispAdjust() - wrapperX);
                };
                wrapper.anchorYSetter = function(value, key) {
                    anchorY = wrapper.anchorY = value;
                    boxAttr(key, value - wrapperY);
                };

                // rename attributes
                wrapper.xSetter = function(value) {
                    wrapper.x = value; // for animation getter
                    if (alignFactor) {
                        value -= alignFactor * ((width || bBox.width) + 2 * padding);
                    }
                    wrapperX = Math.round(value);
                    wrapper.attr('translateX', wrapperX);
                };
                wrapper.ySetter = function(value) {
                    wrapperY = wrapper.y = Math.round(value);
                    wrapper.attr('translateY', wrapperY);
                };

                // Redirect certain methods to either the box or the text
                var baseCss = wrapper.css;
                return extend(wrapper, {
                    /**
                     * Pick up some properties and apply them to the text instead of the
                     * wrapper.
                     * @ignore
                     */
                    css: function(styles) {
                        if (styles) {
                            var textStyles = {};
                            // Create a copy to avoid altering the original object
                            // (#537)
                            styles = merge(styles);
                            each(wrapper.textProps, function(prop) {
                                if (styles[prop] !== undefined) {
                                    textStyles[prop] = styles[prop];
                                    delete styles[prop];
                                }
                            });
                            text.css(textStyles);
                        }
                        return baseCss.call(wrapper, styles);
                    },
                    /**
                     * Return the bounding box of the box, not the group.
                     * @ignore
                     */
                    getBBox: function() {
                        return {
                            width: bBox.width + 2 * padding,
                            height: bBox.height + 2 * padding,
                            x: bBox.x - padding,
                            y: bBox.y - padding
                        };
                    },

                    /**
                     * Apply the shadow to the box.
                     * @ignore
                     */
                    shadow: function(b) {
                        if (b) {
                            updateBoxSize();
                            if (box) {
                                box.shadow(b);
                            }
                        }
                        return wrapper;
                    },

                    /**
                     * Destroy and release memory.
                     * @ignore
                     */
                    destroy: function() {

                        // Added by button implementation
                        removeEvent(wrapper.element, 'mouseenter');
                        removeEvent(wrapper.element, 'mouseleave');

                        if (text) {
                            text = text.destroy();
                        }
                        if (box) {
                            box = box.destroy();
                        }
                        // Call base implementation to destroy the rest
                        SVGElement.prototype.destroy.call(wrapper);

                        // Release local pointers (#1298)
                        wrapper =
                            renderer =
                            updateBoxSize =
                            updateTextPadding =
                            boxAttr = null;
                    }
                });
            }
        }); // end SVGRenderer


        // general renderer
        H.Renderer = SVGRenderer;

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        /* eslint max-len: ["warn", 80, 4] */
        var attr = H.attr,
            createElement = H.createElement,
            css = H.css,
            defined = H.defined,
            each = H.each,
            extend = H.extend,
            isFirefox = H.isFirefox,
            isMS = H.isMS,
            isWebKit = H.isWebKit,
            pInt = H.pInt,
            SVGElement = H.SVGElement,
            SVGRenderer = H.SVGRenderer,
            win = H.win,
            wrap = H.wrap;

        // Extend SvgElement for useHTML option
        extend(SVGElement.prototype, /** @lends SVGElement.prototype */ {
            /**
             * Apply CSS to HTML elements. This is used in text within SVG rendering and
             * by the VML renderer
             */
            htmlCss: function(styles) {
                var wrapper = this,
                    element = wrapper.element,
                    textWidth = styles && element.tagName === 'SPAN' && styles.width;

                if (textWidth) {
                    delete styles.width;
                    wrapper.textWidth = textWidth;
                    wrapper.updateTransform();
                }
                if (styles && styles.textOverflow === 'ellipsis') {
                    styles.whiteSpace = 'nowrap';
                    styles.overflow = 'hidden';
                }
                wrapper.styles = extend(wrapper.styles, styles);
                css(wrapper.element, styles);

                return wrapper;
            },

            /**
             * VML and useHTML method for calculating the bounding box based on offsets
             * @param {Boolean} refresh Whether to force a fresh value from the DOM or
             * to use the cached value.
             *
             * @return {Object} A hash containing values for x, y, width and height
             */

            htmlGetBBox: function() {
                var wrapper = this,
                    element = wrapper.element;

                return {
                    x: element.offsetLeft,
                    y: element.offsetTop,
                    width: element.offsetWidth,
                    height: element.offsetHeight
                };
            },

            /**
             * VML override private method to update elements based on internal
             * properties based on SVG transform
             */
            htmlUpdateTransform: function() {
                // aligning non added elements is expensive
                if (!this.added) {
                    this.alignOnAdd = true;
                    return;
                }

                var wrapper = this,
                    renderer = wrapper.renderer,
                    elem = wrapper.element,
                    translateX = wrapper.translateX || 0,
                    translateY = wrapper.translateY || 0,
                    x = wrapper.x || 0,
                    y = wrapper.y || 0,
                    align = wrapper.textAlign || 'left',
                    alignCorrection = {
                        left: 0,
                        center: 0.5,
                        right: 1
                    }[align],
                    styles = wrapper.styles;

                // apply translate
                css(elem, {
                    marginLeft: translateX,
                    marginTop: translateY
                });


                if (wrapper.shadows) { // used in labels/tooltip
                    each(wrapper.shadows, function(shadow) {
                        css(shadow, {
                            marginLeft: translateX + 1,
                            marginTop: translateY + 1
                        });
                    });
                }


                // apply inversion
                if (wrapper.inverted) { // wrapper is a group
                    each(elem.childNodes, function(child) {
                        renderer.invertChild(child, elem);
                    });
                }

                if (elem.tagName === 'SPAN') {

                    var rotation = wrapper.rotation,
                        baseline,
                        textWidth = pInt(wrapper.textWidth),
                        whiteSpace = styles && styles.whiteSpace,
                        currentTextTransform = [
                            rotation,
                            align,
                            elem.innerHTML,
                            wrapper.textWidth,
                            wrapper.textAlign
                        ].join(',');

                    // Do the calculations and DOM access only if properties changed
                    if (currentTextTransform !== wrapper.cTT) {


                        baseline = renderer.fontMetrics(elem.style.fontSize).b;

                        // Renderer specific handling of span rotation
                        if (defined(rotation)) {
                            wrapper.setSpanRotation(
                                rotation,
                                alignCorrection,
                                baseline
                            );
                        }

                        // Reset multiline/ellipsis in order to read width (#4928,
                        // #5417)
                        css(elem, {
                            width: '',
                            whiteSpace: whiteSpace || 'nowrap'
                        });

                        // Update textWidth
                        if (
                            elem.offsetWidth > textWidth &&
                            /[ \-]/.test(elem.textContent || elem.innerText)
                        ) { // #983, #1254
                            css(elem, {
                                width: textWidth + 'px',
                                display: 'block',
                                whiteSpace: whiteSpace || 'normal' // #3331
                            });
                        }


                        wrapper.getSpanCorrection(
                            elem.offsetWidth,
                            baseline,
                            alignCorrection,
                            rotation,
                            align
                        );
                    }

                    // apply position with correction
                    css(elem, {
                        left: (x + (wrapper.xCorr || 0)) + 'px',
                        top: (y + (wrapper.yCorr || 0)) + 'px'
                    });

                    // Force reflow in webkit to apply the left and top on useHTML
                    // element (#1249)
                    if (isWebKit) {
                        // Assigned to baseline for lint purpose
                        baseline = elem.offsetHeight;
                    }

                    // record current text transform
                    wrapper.cTT = currentTextTransform;
                }
            },

            /**
             * Set the rotation of an individual HTML span
             */
            setSpanRotation: function(rotation, alignCorrection, baseline) {
                var rotationStyle = {},
                    cssTransformKey = this.renderer.getTransformKey();

                rotationStyle[cssTransformKey] = rotationStyle.transform =
                    'rotate(' + rotation + 'deg)';
                rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] =
                    rotationStyle.transformOrigin =
                    (alignCorrection * 100) + '% ' + baseline + 'px';
                css(this.element, rotationStyle);
            },

            /**
             * Get the correction in X and Y positioning as the element is rotated.
             */
            getSpanCorrection: function(width, baseline, alignCorrection) {
                this.xCorr = -width * alignCorrection;
                this.yCorr = -baseline;
            }
        });

        // Extend SvgRenderer for useHTML option.
        extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {

            getTransformKey: function() {
                return isMS && !/Edge/.test(win.navigator.userAgent) ?
                    '-ms-transform' :
                    isWebKit ?
                    '-webkit-transform' :
                    isFirefox ?
                    'MozTransform' :
                    win.opera ?
                    '-o-transform' :
                    '';
            },

            /**
             * Create HTML text node. This is used by the VML renderer as well as the
             * SVG renderer through the useHTML option.
             *
             * @param {String} str
             * @param {Number} x
             * @param {Number} y
             */
            html: function(str, x, y) {
                var wrapper = this.createElement('span'),
                    element = wrapper.element,
                    renderer = wrapper.renderer,
                    isSVG = renderer.isSVG,
                    addSetters = function(element, style) {
                        // These properties are set as attributes on the SVG group, and
                        // as identical CSS properties on the div. (#3542)
                        each(['opacity', 'visibility'], function(prop) {
                            wrap(element, prop + 'Setter', function(
                                proceed,
                                value,
                                key,
                                elem
                            ) {
                                proceed.call(this, value, key, elem);
                                style[key] = value;
                            });
                        });
                    };

                // Text setter
                wrapper.textSetter = function(value) {
                    if (value !== element.innerHTML) {
                        delete this.bBox;
                    }
                    element.innerHTML = this.textStr = value;
                    wrapper.htmlUpdateTransform();
                };

                // Add setters for the element itself (#4938)
                if (isSVG) { // #4938, only for HTML within SVG
                    addSetters(wrapper, wrapper.element.style);
                }

                // Various setters which rely on update transform
                wrapper.xSetter =
                    wrapper.ySetter =
                    wrapper.alignSetter =
                    wrapper.rotationSetter =
                    function(value, key) {
                        if (key === 'align') {
                            // Do not overwrite the SVGElement.align method. Same as VML.
                            key = 'textAlign';
                        }
                        wrapper[key] = value;
                        wrapper.htmlUpdateTransform();
                    };

                // Set the default attributes
                wrapper
                    .attr({
                        text: str,
                        x: Math.round(x),
                        y: Math.round(y)
                    })
                    .css({

                        fontFamily: this.style.fontFamily,
                        fontSize: this.style.fontSize,

                        position: 'absolute'
                    });

                // Keep the whiteSpace style outside the wrapper.styles collection
                element.style.whiteSpace = 'nowrap';

                // Use the HTML specific .css method
                wrapper.css = wrapper.htmlCss;

                // This is specific for HTML within SVG
                if (isSVG) {
                    wrapper.add = function(svgGroupWrapper) {

                        var htmlGroup,
                            container = renderer.box.parentNode,
                            parentGroup,
                            parents = [];

                        this.parentGroup = svgGroupWrapper;

                        // Create a mock group to hold the HTML elements
                        if (svgGroupWrapper) {
                            htmlGroup = svgGroupWrapper.div;
                            if (!htmlGroup) {

                                // Read the parent chain into an array and read from top
                                // down
                                parentGroup = svgGroupWrapper;
                                while (parentGroup) {

                                    parents.push(parentGroup);

                                    // Move up to the next parent group
                                    parentGroup = parentGroup.parentGroup;
                                }

                                // Ensure dynamically updating position when any parent
                                // is translated
                                each(parents.reverse(), function(parentGroup) {
                                    var htmlGroupStyle,
                                        cls = attr(parentGroup.element, 'class');

                                    // Common translate setter for X and Y on the HTML
                                    // group. Using CSS transform instead of left and
                                    // right prevents flickering in IE and Edge when 
                                    // moving tooltip (#6957).
                                    function translateSetter(value, key) {
                                        parentGroup[key] = value;
                                        htmlGroupStyle[renderer.getTransformKey()] =
                                            'translate(' +
                                            parentGroup.x + 'px,' +
                                            parentGroup.y + 'px)';

                                        parentGroup.doTransform = true;
                                    }

                                    if (cls) {
                                        cls = {
                                            className: cls
                                        };
                                    } // else null

                                    // Create a HTML div and append it to the parent div
                                    // to emulate the SVG group structure
                                    htmlGroup =
                                        parentGroup.div =
                                        parentGroup.div || createElement('div', cls, {
                                            position: 'absolute',
                                            left: (parentGroup.translateX || 0) + 'px',
                                            top: (parentGroup.translateY || 0) + 'px',
                                            display: parentGroup.display,
                                            opacity: parentGroup.opacity, // #5075
                                            pointerEvents: (
                                                parentGroup.styles &&
                                                parentGroup.styles.pointerEvents
                                            ) // #5595

                                            // the top group is appended to container
                                        }, htmlGroup || container);

                                    // Shortcut
                                    htmlGroupStyle = htmlGroup.style;

                                    // Set listeners to update the HTML div's position
                                    // whenever the SVG group position is changed.
                                    extend(parentGroup, {
                                        classSetter: function(value) {
                                            this.element.setAttribute('class', value);
                                            htmlGroup.className = value;
                                        },
                                        on: function() {
                                            if (parents[0].div) { // #6418
                                                wrapper.on.apply({
                                                        element: parents[0].div
                                                    },
                                                    arguments
                                                );
                                            }
                                            return parentGroup;
                                        },
                                        translateXSetter: translateSetter,
                                        translateYSetter: translateSetter
                                    });
                                    addSetters(parentGroup, htmlGroupStyle);
                                });

                            }
                        } else {
                            htmlGroup = container;
                        }

                        htmlGroup.appendChild(element);

                        // Shared with VML:
                        wrapper.added = true;
                        if (wrapper.alignOnAdd) {
                            wrapper.htmlUpdateTransform();
                        }

                        return wrapper;
                    };
                }
                return wrapper;
            }
        });

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var color = H.color,
            getTZOffset = H.getTZOffset,
            isTouchDevice = H.isTouchDevice,
            merge = H.merge,
            pick = H.pick,
            svg = H.svg,
            win = H.win;

        /* ****************************************************************************
         * Handle the options                                                         *
         *****************************************************************************/
        /** 	 
         * @optionparent
         */
        H.defaultOptions = {


            /**
             * An array containing the default colors for the chart's series. When
             * all colors are used, new colors are pulled from the start again.
             * 
             * Default colors can also be set on a series or series.type basis,
             * see [column.colors](#plotOptions.column.colors), [pie.colors](#plotOptions.
             * pie.colors).
             * 
             * In styled mode, the colors option doesn't exist. Instead, colors
             * are defined in CSS and applied either through series or point class
             * names, or through the [chart.colorCount](#chart.colorCount) option.
             * 
             * 
             * ### Legacy
             * 
             * In Highcharts 3.x, the default colors were:
             * 
             * <pre>colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce', 
             *     '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']</pre> 
             * 
             * In Highcharts 2.x, the default colors were:
             * 
             * <pre>colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', 
             *    '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']</pre>
             * 
             * @type {Array<Color>}
             * @sample {highcharts} highcharts/chart/colors/ Assign a global color theme
             * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
             *          "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
             */
            colors: '#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1'.split(' '),



            /**
             * Styled mode only. Configuration object for adding SVG definitions for
             * reusable elements. See [gradients, shadows and patterns](http://www.
             * highcharts.com/docs/chart-design-and-style/gradients-shadows-and-
             * patterns) for more information and code examples.
             * 
             * @type {Object}
             * @since 5.0.0
             * @apioption defs
             */

            /**
             * @ignore
             */
            symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
            lang: {

                /**
                 * The loading text that appears when the chart is set into the loading
                 * state following a call to `chart.showLoading`.
                 * 
                 * @type {String}
                 * @default Loading...
                 */
                loading: 'Loading...',

                /**
                 * An array containing the months names. Corresponds to the `%B` format
                 * in `Highcharts.dateFormat()`.
                 * 
                 * @type {Array<String>}
                 * @default [ "January" , "February" , "March" , "April" , "May" ,
                 *          "June" , "July" , "August" , "September" , "October" ,
                 *          "November" , "December"]
                 */
                months: [
                    'January', 'February', 'March', 'April', 'May', 'June', 'July',
                    'August', 'September', 'October', 'November', 'December'
                ],

                /**
                 * An array containing the months names in abbreviated form. Corresponds
                 * to the `%b` format in `Highcharts.dateFormat()`.
                 * 
                 * @type {Array<String>}
                 * @default [ "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" ,
                 *          "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec"]
                 */
                shortMonths: [
                    'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
                    'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
                ],

                /**
                 * An array containing the weekday names.
                 * 
                 * @type {Array<String>}
                 * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
                 *          "Friday", "Saturday"]
                 */
                weekdays: [
                    'Sunday', 'Monday', 'Tuesday', 'Wednesday',
                    'Thursday', 'Friday', 'Saturday'
                ],

                /**
                 * Short week days, starting Sunday. If not specified, Highcharts uses
                 * the first three letters of the `lang.weekdays` option.
                 * 
                 * @type {Array<String>}
                 * @sample highcharts/lang/shortweekdays/
                 *         Finnish two-letter abbreviations
                 * @since 4.2.4
                 * @apioption lang.shortWeekdays
                 */

                /**
                 * What to show in a date field for invalid dates. Defaults to an empty
                 * string.
                 * 
                 * @type {String}
                 * @since 4.1.8
                 * @product highcharts highstock
                 * @apioption lang.invalidDate
                 */

                /**
                 * The default decimal point used in the `Highcharts.numberFormat`
                 * method unless otherwise specified in the function arguments.
                 * 
                 * @type {String}
                 * @default .
                 * @since 1.2.2
                 */
                decimalPoint: '.',

                /**
                 * [Metric prefixes](http://en.wikipedia.org/wiki/Metric_prefix) used
                 * to shorten high numbers in axis labels. Replacing any of the positions
                 * with `null` causes the full number to be written. Setting `numericSymbols`
                 * to `null` disables shortening altogether.
                 * 
                 * @type {Array<String>}
                 * @sample {highcharts} highcharts/lang/numericsymbols/
                 *         Replacing the symbols with text
                 * @sample {highstock} highcharts/lang/numericsymbols/
                 *         Replacing the symbols with text
                 * @default [ "k" , "M" , "G" , "T" , "P" , "E"]
                 * @since 2.3.0
                 */
                numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],

                /**
                 * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
                 * Use 10000 for Japanese, Korean and various Chinese locales, which
                 * use symbols for 10^4, 10^8 and 10^12.
                 * 
                 * @type {Number}
                 * @sample highcharts/lang/numericsymbolmagnitude/
                 *         10000 magnitude for Japanese
                 * @default 1000
                 * @since 5.0.3
                 * @apioption lang.numericSymbolMagnitude
                 */

                /**
                 * The text for the label appearing when a chart is zoomed.
                 * 
                 * @type {String}
                 * @default Reset zoom
                 * @since 1.2.4
                 */
                resetZoom: 'Reset zoom',

                /**
                 * The tooltip title for the label appearing when a chart is zoomed.
                 * 
                 * @type {String}
                 * @default Reset zoom level 1:1
                 * @since 1.2.4
                 */
                resetZoomTitle: 'Reset zoom level 1:1',

                /**
                 * The default thousands separator used in the `Highcharts.numberFormat`
                 * method unless otherwise specified in the function arguments. Since
                 * Highcharts 4.1 it defaults to a single space character, which is
                 * compatible with ISO and works across Anglo-American and continental
                 * European languages.
                 * 
                 * The default is a single space.
                 * 
                 * @type {String}
                 * @default  
                 * @since 1.2.2
                 */
                thousandsSep: ' '
            },

            /**
             * Global options that don't apply to each chart. These options, like
             * the `lang` options, must be set using the `Highcharts.setOptions`
             * method.
             * 
             * <pre>Highcharts.setOptions({
             *     global: {
             *         useUTC: false
             *     }
             * });</pre>
             *
             */
            global: {

                /**
                 * Whether to use UTC time for axis scaling, tickmark placement and
                 * time display in `Highcharts.dateFormat`. Advantages of using UTC
                 * is that the time displays equally regardless of the user agent's
                 * time zone settings. Local time can be used when the data is loaded
                 * in real time or when correct Daylight Saving Time transitions are
                 * required.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/global/useutc-true/ True by default
                 * @sample {highcharts} highcharts/global/useutc-false/ False
                 * @default true
                 */
                useUTC: true

                /**
                 * A custom `Date` class for advanced date handling. For example,
                 * [JDate](https://githubcom/tahajahangir/jdate) can be hooked in to
                 * handle Jalali dates.
                 * 
                 * @type {Object}
                 * @since 4.0.4
                 * @product highcharts highstock
                 * @apioption global.Date
                 */

                /**
                 * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
                 * Use the [libURL](#exporting.libURL) option to configure exporting._
                 * 
                 * The URL to the additional file to lazy load for Android 2.x devices.
                 * These devices don't support SVG, so we download a helper file that
                 * contains [canvg](http://code.google.com/p/canvg/), its dependency
                 * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
                 * our site, you can install canvas-tools.js on your own server and
                 * change this option accordingly.
                 * 
                 * @type {String}
                 * @deprecated
                 * @default http://code.highcharts.com/{version}/modules/canvas-tools.js
                 * @product highcharts highmaps
                 * @apioption global.canvasToolsURL
                 */

                /**
                 * A callback to return the time zone offset for a given datetime. It
                 * takes the timestamp in terms of milliseconds since January 1 1970,
                 * and returns the timezone offset in minutes. This provides a hook
                 * for drawing time based charts in specific time zones using their
                 * local DST crossover dates, with the help of external libraries.
                 * 
                 * @type {Function}
                 * @see [global.timezoneOffset](#global.timezoneOffset)
                 * @sample {highcharts} highcharts/global/gettimezoneoffset/
                 *         Use moment.js to draw Oslo time regardless of browser locale
                 * @sample {highstock} highcharts/global/gettimezoneoffset/
                 *         Use moment.js to draw Oslo time regardless of browser locale
                 * @since 4.1.0
                 * @product highcharts highstock
                 * @apioption global.getTimezoneOffset
                 */

                /**
                 * Requires [moment.js](http://momentjs.com/). If the timezone option
                 * is specified, it creates a default
                 * [getTimezoneOffset](#global.getTimezoneOffset) function that looks
                 * up the specified timezone in moment.js. If moment.js is not included,
                 * this throws a Highcharts error in the console, but does not crash the
                 * chart.
                 * 
                 * @type {String}
                 * @see [getTimezoneOffset](#global.getTimezoneOffset)
                 * @sample {highcharts} highcharts/global/timezone/ Europe/Oslo
                 * @sample {highstock} highcharts/global/timezone/ Europe/Oslo
                 * @default undefined
                 * @since 5.0.7
                 * @product highcharts highstock
                 * @apioption global.timezone
                 */

                /**
                 * The timezone offset in minutes. Positive values are west, negative
                 * values are east of UTC, as in the ECMAScript [getTimezoneOffset](https://developer.
                 * mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
                 * method. Use this to display UTC based data in a predefined time zone.
                 * 
                 * @type {Number}
                 * @see [global.getTimezoneOffset](#global.getTimezoneOffset)
                 * @sample {highcharts} highcharts/global/timezoneoffset/
                 *         Timezone offset
                 * @sample {highstock} highcharts/global/timezoneoffset/
                 *         Timezone offset
                 * @default 0
                 * @since 3.0.8
                 * @product highcharts highstock
                 * @apioption global.timezoneOffset
                 */
            },
            chart: {

                /**
                 * When using multiple axis, the ticks of two or more opposite axes
                 * will automatically be aligned by adding ticks to the axis or axes
                 * with the least ticks, as if `tickAmount` were specified.
                 * 
                 * This can be prevented by setting `alignTicks` to false. If the grid
                 * lines look messy, it's a good idea to hide them for the secondary
                 * axis by setting `gridLineWidth` to 0.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/alignticks-true/ True by default
                 * @sample {highcharts} highcharts/chart/alignticks-false/ False
                 * @sample {highstock} stock/chart/alignticks-true/
                 *         True by default
                 * @sample {highstock} stock/chart/alignticks-false/
                 *         False
                 * @default true
                 * @product highcharts highstock
                 * @apioption chart.alignTicks
                 */


                /**
                 * Set the overall animation for all chart updating. Animation can be
                 * disabled throughout the chart by setting it to false here. It can
                 * be overridden for each individual API method as a function parameter.
                 * The only animation not affected by this option is the initial series
                 * animation, see [plotOptions.series.animation](#plotOptions.series.
                 * animation).
                 * 
                 * The animation can either be set as a boolean or a configuration
                 * object. If `true`, it will use the 'swing' jQuery easing and a
                 * duration of 500 ms. If used as a configuration object, the following
                 * properties are supported:
                 * 
                 * <dl>
                 * 
                 * <dt>duration</dt>
                 * 
                 * <dd>The duration of the animation in milliseconds.</dd>
                 * 
                 * <dt>easing</dt>
                 * 
                 * <dd>A string reference to an easing function set on the `Math` object.
                 * See [the easing demo](http://jsfiddle.net/gh/get/library/pure/
                 * highcharts/highcharts/tree/master/samples/highcharts/plotoptions/
                 * series-animation-easing/).</dd>
                 * 
                 * </dl>
                 * 
                 * @type {Boolean|Object}
                 * @sample {highcharts} highcharts/chart/animation-none/
                 *         Updating with no animation
                 * @sample {highcharts} highcharts/chart/animation-duration/
                 *         With a longer duration
                 * @sample {highcharts} highcharts/chart/animation-easing/
                 *         With a jQuery UI easing
                 * @sample {highmaps} maps/chart/animation-none/
                 *         Updating with no animation
                 * @sample {highmaps} maps/chart/animation-duration/
                 *         With a longer duration
                 * @default true
                 * @apioption chart.animation
                 */

                /**
                 * A CSS class name to apply to the charts container `div`, allowing
                 * unique CSS styling for each chart.
                 * 
                 * @type {String}
                 * @apioption chart.className
                 */

                /**
                 * Event listeners for the chart.
                 * 
                 * @apioption chart.events
                 */

                /**
                 * Fires when a series is added to the chart after load time, using
                 * the `addSeries` method. One parameter, `event`, is passed to the
                 * function, containing common event information.
                 * Through `event.options` you can access the series options that was
                 * passed to the `addSeries` method. Returning false prevents the series
                 * from being added.
                 * 
                 * @type {Function}
                 * @context Chart
                 * @sample {highcharts} highcharts/chart/events-addseries/ Alert on add series
                 * @sample {highstock} stock/chart/events-addseries/ Alert on add series
                 * @since 1.2.0
                 * @apioption chart.events.addSeries
                 */

                /**
                 * Fires when clicking on the plot background. One parameter, `event`,
                 * is passed to the function, containing common event information.
                 * 
                 * Information on the clicked spot can be found through `event.xAxis`
                 * and `event.yAxis`, which are arrays containing the axes of each dimension
                 * and each axis' value at the clicked spot. The primary axes are `event.
                 * xAxis[0]` and `event.yAxis[0]`. Remember the unit of a datetime axis
                 * is milliseconds since 1970-01-01 00:00:00.
                 * 
                 * <pre>click: function(e) {
                 *     console.log(
                 *         Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', e.xAxis[0].value),
                 *         e.yAxis[0].value
                 *     )
                 * }</pre>
                 * 
                 * @type {Function}
                 * @context Chart
                 * @sample {highcharts} highcharts/chart/events-click/
                 *         Alert coordinates on click
                 * @sample {highcharts} highcharts/chart/events-container/
                 *         Alternatively, attach event to container
                 * @sample {highstock} stock/chart/events-click/
                 *         Alert coordinates on click
                 * @sample {highstock} highcharts/chart/events-container/
                 *         Alternatively, attach event to container
                 * @sample {highmaps} maps/chart/events-click/
                 *         Record coordinates on click
                 * @sample {highmaps} highcharts/chart/events-container/
                 *         Alternatively, attach event to container
                 * @since 1.2.0
                 * @apioption chart.events.click
                 */


                /**
                 * Fires when the chart is finished loading. Since v4.2.2, it also waits
                 * for images to be loaded, for example from point markers. One parameter,
                 * `event`, is passed to the function, containing common event information.
                 * 
                 * There is also a second parameter to the chart constructor where a
                 * callback function can be passed to be executed on chart.load.
                 * 
                 * @type {Function}
                 * @context Chart
                 * @sample {highcharts} highcharts/chart/events-load/
                 *         Alert on chart load
                 * @sample {highstock} stock/chart/events-load/
                 *         Alert on chart load
                 * @sample {highmaps} maps/chart/events-load/
                 *         Add series on chart load
                 * @apioption chart.events.load
                 */

                /**
                 * Fires when the chart is redrawn, either after a call to chart.redraw()
                 * or after an axis, series or point is modified with the `redraw` option
                 * set to true. One parameter, `event`, is passed to the function, containing common event information.
                 * 
                 * @type {Function}
                 * @context Chart
                 * @sample {highcharts} highcharts/chart/events-redraw/
                 *         Alert on chart redraw
                 * @sample {highstock} stock/chart/events-redraw/
                 *         Alert on chart redraw when adding a series or moving the
                 *         zoomed range
                 * @sample {highmaps} maps/chart/events-redraw/
                 *         Set subtitle on chart redraw
                 * @since 1.2.0
                 * @apioption chart.events.redraw
                 */

                /**
                 * Fires after initial load of the chart (directly after the `load`
                 * event), and after each redraw (directly after the `redraw` event).
                 * 
                 * @type {Function}
                 * @context Chart
                 * @since 5.0.7
                 * @apioption chart.events.render
                 */

                /**
                 * Fires when an area of the chart has been selected. Selection is enabled
                 * by setting the chart's zoomType. One parameter, `event`, is passed
                 * to the function, containing common event information. The default action for the selection event is to
                 * zoom the chart to the selected area. It can be prevented by calling
                 * `event.preventDefault()`.
                 * 
                 * Information on the selected area can be found through `event.xAxis`
                 * and `event.yAxis`, which are arrays containing the axes of each dimension
                 * and each axis' min and max values. The primary axes are `event.xAxis[0]`
                 * and `event.yAxis[0]`. Remember the unit of a datetime axis is milliseconds
                 * since 1970-01-01 00:00:00.
                 * 
                 * <pre>selection: function(event) {
                 *     // log the min and max of the primary, datetime x-axis
                 *     console.log(
                 *         Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', event.xAxis[0].min),
                 *         Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', event.xAxis[0].max)
                 *     );
                 *     // log the min and max of the y axis
                 *     console.log(event.yAxis[0].min, event.yAxis[0].max);
                 * }</pre>
                 * 
                 * @type {Function}
                 * @sample {highcharts} highcharts/chart/events-selection/
                 *         Report on selection and reset
                 * @sample {highcharts} highcharts/chart/events-selection-points/
                 *         Select a range of points through a drag selection
                 * @sample {highstock} stock/chart/events-selection/
                 *         Report on selection and reset
                 * @sample {highstock} highcharts/chart/events-selection-points/
                 *         Select a range of points through a drag selection (Highcharts)
                 * @apioption chart.events.selection
                 */

                /**
                 * The margin between the outer edge of the chart and the plot area.
                 * The numbers in the array designate top, right, bottom and left
                 * respectively. Use the options `marginTop`, `marginRight`,
                 * `marginBottom` and `marginLeft` for shorthand setting of one option.
                 * 
                 * By default there is no margin. The actual space is dynamically calculated
                 * from the offset of axis labels, axis title, title, subtitle and legend
                 * in addition to the `spacingTop`, `spacingRight`, `spacingBottom`
                 * and `spacingLeft` options.
                 * 
                 * @type {Array}
                 * @sample {highcharts} highcharts/chart/margins-zero/
                 *         Zero margins
                 * @sample {highstock} stock/chart/margin-zero/
                 *         Zero margins
                 *
                 * @defaults {all} null
                 * @apioption chart.margin
                 */

                /**
                 * The margin between the bottom outer edge of the chart and the plot
                 * area. Use this to set a fixed pixel value for the margin as opposed
                 * to the default dynamic margin. See also `spacingBottom`.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/marginbottom/
                 *         100px bottom margin
                 * @sample {highstock} stock/chart/marginbottom/
                 *         100px bottom margin
                 * @sample {highmaps} maps/chart/margin/
                 *         100px margins
                 * @since 2.0
                 * @apioption chart.marginBottom
                 */

                /**
                 * The margin between the left outer edge of the chart and the plot
                 * area. Use this to set a fixed pixel value for the margin as opposed
                 * to the default dynamic margin. See also `spacingLeft`.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/marginleft/
                 *         150px left margin
                 * @sample {highstock} stock/chart/marginleft/
                 *         150px left margin
                 * @sample {highmaps} maps/chart/margin/
                 *         100px margins
                 * @default null
                 * @since 2.0
                 * @apioption chart.marginLeft
                 */

                /**
                 * The margin between the right outer edge of the chart and the plot
                 * area. Use this to set a fixed pixel value for the margin as opposed
                 * to the default dynamic margin. See also `spacingRight`.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/marginright/
                 *         100px right margin
                 * @sample {highstock} stock/chart/marginright/
                 *         100px right margin
                 * @sample {highmaps} maps/chart/margin/
                 *         100px margins
                 * @default null
                 * @since 2.0
                 * @apioption chart.marginRight
                 */

                /**
                 * The margin between the top outer edge of the chart and the plot area.
                 * Use this to set a fixed pixel value for the margin as opposed to
                 * the default dynamic margin. See also `spacingTop`.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
                 * @sample {highstock} stock/chart/margintop/
                 *         100px top margin
                 * @sample {highmaps} maps/chart/margin/
                 *         100px margins
                 * @default null
                 * @since 2.0
                 * @apioption chart.marginTop
                 */

                /**
                 * Allows setting a key to switch between zooming and panning. Can be
                 * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
                 * key on Windows) or `shift`. The keys are mapped directly to the key
                 * properties of the click event argument (`event.altKey`, `event.ctrlKey`,
                 * `event.metaKey` and `event.shiftKey`).
                 * 
                 * @validvalue [null, "alt", "ctrl", "meta", "shift"]
                 * @type {String}
                 * @since 4.0.3
                 * @product highcharts
                 * @apioption chart.panKey
                 */

                /**
                 * Allow panning in a chart. Best used with [panKey](#chart.panKey)
                 * to combine zooming and panning.
                 * 
                 * On touch devices, when the [tooltip.followTouchMove](#tooltip.followTouchMove)
                 * option is `true` (default), panning requires two fingers. To allow
                 * panning with one finger, set `followTouchMove` to `false`.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
                 * @default {highcharts} false
                 * @default {highstock} true
                 * @since 4.0.3
                 * @product highcharts highstock
                 * @apioption chart.panning
                 */


                /**
                 * Equivalent to [zoomType](#chart.zoomType), but for multitouch gestures
                 * only. By default, the `pinchType` is the same as the `zoomType` setting.
                 * However, pinching can be enabled separately in some cases, for example
                 * in stock charts where a mouse drag pans the chart, while pinching
                 * is enabled. When [tooltip.followTouchMove](#tooltip.followTouchMove)
                 * is true, pinchType only applies to two-finger touches.
                 * 
                 * @validvalue ["x", "y", "xy"]
                 * @type {String}
                 * @default {highcharts} null
                 * @default {highstock} x
                 * @since 3.0
                 * @product highcharts highstock
                 * @apioption chart.pinchType
                 */

                /**
                 * The corner radius of the outer chart border.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/borderradius/ 20px radius
                 * @sample {highstock} stock/chart/border/ 10px radius
                 * @sample {highmaps} maps/chart/border/ Border options
                 * @default 0
                 */
                borderRadius: 0,


                /**
                 * Alias of `type`.
                 * 
                 * @validvalue ["line", "spline", "column", "area", "areaspline", "pie"]
                 * @type {String}
                 * @deprecated
                 * @sample {highcharts} highcharts/chart/defaultseriestype/ Bar
                 * @default line
                 * @product highcharts
                 */
                defaultSeriesType: 'line',

                /**
                 * If true, the axes will scale to the remaining visible series once
                 * one series is hidden. If false, hiding and showing a series will
                 * not affect the axes or the other series. For stacks, once one series
                 * within the stack is hidden, the rest of the stack will close in
                 * around it even if the axis is not affected.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
                 *         True by default
                 * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
                 *         False
                 * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
                 *         True with stack
                 * @sample {highstock} stock/chart/ignorehiddenseries-true/
                 *         True by default
                 * @sample {highstock} stock/chart/ignorehiddenseries-false/
                 *         False
                 * @default true
                 * @since 1.2.0
                 * @product highcharts highstock
                 */
                ignoreHiddenSeries: true,


                /**
                 * Whether to invert the axes so that the x axis is vertical and y axis
                 * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
                 * by default.
                 *
                 * @productdesc {highcharts}
                 * If a bar series is present in the chart, it will be inverted
                 * automatically. Inverting the chart doesn't have an effect if there
                 * are no cartesian series in the chart, or if the chart is
                 * [polar](#chart.polar).
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/inverted/
                 *         Inverted line
                 * @sample {highstock} stock/navigator/inverted/
                 *         Inverted stock chart
                 * @default false
                 * @product highcharts highstock
                 * @apioption chart.inverted
                 */

                /**
                 * The distance between the outer edge of the chart and the content,
                 * like title or legend, or axis title and labels if present. The
                 * numbers in the array designate top, right, bottom and left respectively.
                 * Use the options spacingTop, spacingRight, spacingBottom and spacingLeft
                 * options for shorthand setting of one option.
                 * 
                 * @type {Array<Number>}
                 * @see [chart.margin](#chart.margin)
                 * @default [10, 10, 15, 10]
                 * @since 3.0.6
                 */
                spacing: [10, 10, 15, 10],

                /**
                 * The button that appears after a selection zoom, allowing the user
                 * to reset zoom.
                 *
                 */
                resetZoomButton: {

                    /**
                     * A collection of attributes for the button. The object takes SVG
                     * attributes like `fill`, `stroke`, `stroke-width` or `r`, the border
                     * radius. The theme also supports `style`, a collection of CSS properties
                     * for the text. Equivalent attributes for the hover state are given
                     * in `theme.states.hover`.
                     * 
                     * @type {Object}
                     * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
                     *         Theming the button
                     * @sample {highstock} highcharts/chart/resetzoombutton-theme/
                     *         Theming the button
                     * @since 2.2
                     */
                    theme: {

                        /**
                         * The Z index for the reset zoom button.
                         */
                        zIndex: 20
                    },

                    /**
                     * The position of the button.
                     * 
                     * @type {Object}
                     * @sample {highcharts} highcharts/chart/resetzoombutton-position/
                     *         Above the plot area
                     * @sample {highstock} highcharts/chart/resetzoombutton-position/
                     *         Above the plot area
                     * @sample {highmaps} highcharts/chart/resetzoombutton-position/
                     *         Above the plot area
                     * @since 2.2
                     */
                    position: {

                        /**
                         * The horizontal alignment of the button.
                         * 
                         * @type {String}
                         */
                        align: 'right',

                        /**
                         * The horizontal offset of the button.
                         * 
                         * @type {Number}
                         */
                        x: -10,

                        /**
                         * The vertical alignment of the button.
                         * 
                         * @validvalue ["top", "middle", "bottom"]
                         * @type {String}
                         * @default top
                         * @apioption chart.resetZoomButton.position.verticalAlign
                         */

                        /**
                         * The vertical offset of the button.
                         * 
                         * @type {Number}
                         */
                        y: 10
                    }

                    /**
                     * What frame the button should be placed related to. Can be either
                     * `plot` or `chart`
                     * 
                     * @validvalue ["plot", "chart"]
                     * @type {String}
                     * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
                     *         Relative to the chart
                     * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
                     *         Relative to the chart
                     * @default plot
                     * @since 2.2
                     * @apioption chart.resetZoomButton.relativeTo
                     */
                },

                /**
                 * An explicit width for the chart. By default (when `null`) the width
                 * is calculated from the offset width of the containing element.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/width/ 800px wide
                 * @sample {highstock} stock/chart/width/ 800px wide
                 * @sample {highmaps} maps/chart/size/ Chart with explicit size
                 * @default null
                 */
                width: null,

                /**
                 * An explicit height for the chart. If a _number_, the height is
                 * given in pixels. If given a _percentage string_ (for example `'56%'`),
                 * the height is given as the percentage of the actual chart width.
                 * This allows for preserving the aspect ratio across responsive
                 * sizes.
                 * 
                 * By default (when `null`) the height is calculated from the offset
                 * height of the containing element, or 400 pixels if the containing
                 * element's height is 0.
                 * 
                 * @type {Number|String}
                 * @sample {highcharts} highcharts/chart/height/
                 *         500px height
                 * @sample {highstock} stock/chart/height/
                 *         300px height
                 * @sample {highmaps} maps/chart/size/
                 *         Chart with explicit size
                 * @sample highcharts/chart/height-percent/
                 *         Highcharts with percentage height
                 * @default null
                 */
                height: null,



                /**
                 * The color of the outer chart border.
                 * 
                 * @type {Color}
                 * @see In styled mode, the stroke is set with the `.highcharts-background`
                 * class.
                 * @sample {highcharts} highcharts/chart/bordercolor/ Brown border
                 * @sample {highstock} stock/chart/border/ Brown border
                 * @sample {highmaps} maps/chart/border/ Border options
                 * @default #335cad
                 */
                borderColor: '#335cad',

                /**
                 * The pixel width of the outer chart border.
                 * 
                 * @type {Number}
                 * @see In styled mode, the stroke is set with the `.highcharts-background`
                 * class.
                 * @sample {highcharts} highcharts/chart/borderwidth/ 5px border
                 * @sample {highstock} stock/chart/border/
                 *         2px border
                 * @sample {highmaps} maps/chart/border/
                 *         Border options
                 * @default 0
                 * @apioption chart.borderWidth
                 */

                /**
                 * The background color or gradient for the outer chart area.
                 * 
                 * @type {Color}
                 * @see In styled mode, the background is set with the `.highcharts-background` class.
                 * @sample {highcharts} highcharts/chart/backgroundcolor-color/ Color
                 * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/ Gradient
                 * @sample {highstock} stock/chart/backgroundcolor-color/
                 *         Color
                 * @sample {highstock} stock/chart/backgroundcolor-gradient/
                 *         Gradient
                 * @sample {highmaps} maps/chart/backgroundcolor-color/
                 *         Color
                 * @sample {highmaps} maps/chart/backgroundcolor-gradient/
                 *         Gradient
                 * @default #FFFFFF
                 */
                backgroundColor: '#ffffff',

                /**
                 * The background color or gradient for the plot area.
                 * 
                 * @type {Color}
                 * @see In styled mode, the plot background is set with the `.highcharts-plot-background` class.
                 * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
                 *         Color
                 * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
                 *         Gradient
                 * @sample {highstock} stock/chart/plotbackgroundcolor-color/
                 *         Color
                 * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
                 *         Gradient
                 * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
                 *         Color
                 * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
                 *         Gradient
                 * @default null
                 * @apioption chart.plotBackgroundColor
                 */


                /**
                 * The URL for an image to use as the plot background. To set an image
                 * as the background for the entire chart, set a CSS background image
                 * to the container element. Note that for the image to be applied to
                 * exported charts, its URL needs to be accessible by the export server.
                 * 
                 * @type {String}
                 * @see In styled mode, a plot background image can be set with the
                 * `.highcharts-plot-background` class and a [custom pattern](http://www.
                 * highcharts.com/docs/chart-design-and-style/gradients-shadows-and-
                 * patterns).
                 * @sample {highcharts} highcharts/chart/plotbackgroundimage/ Skies
                 * @sample {highstock} stock/chart/plotbackgroundimage/ Skies
                 * @default null
                 * @apioption chart.plotBackgroundImage
                 */

                /**
                 * The color of the inner chart or plot area border.
                 * 
                 * @type {Color}
                 * @see In styled mode, a plot border stroke can be set with the `.
                 * highcharts-plot-border` class.
                 * @sample {highcharts} highcharts/chart/plotbordercolor/ Blue border
                 * @sample {highstock} stock/chart/plotborder/ Blue border
                 * @sample {highmaps} maps/chart/plotborder/ Plot border options
                 * @default #cccccc
                 */
                plotBorderColor: '#cccccc'


                /**
                 * The pixel width of the plot area border.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/plotborderwidth/ 1px border
                 * @sample {highstock} stock/chart/plotborder/
                 *         2px border
                 * @sample {highmaps} maps/chart/plotborder/
                 *         Plot border options
                 * @default 0
                 * @apioption chart.plotBorderWidth
                 */

                /**
                 * Whether to apply a drop shadow to the plot area. Requires that
                 * plotBackgroundColor be set. The shadow can be an object configuration
                 * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
                 * 
                 * @type {Boolean|Object}
                 * @sample {highcharts} highcharts/chart/plotshadow/ Plot shadow
                 * @sample {highstock} stock/chart/plotshadow/
                 *         Plot shadow
                 * @sample {highmaps} maps/chart/plotborder/
                 *         Plot border options
                 * @default false
                 * @apioption chart.plotShadow
                 */

                /**
                 * When true, cartesian charts like line, spline, area and column are
                 * transformed into the polar coordinate system. Requires `highcharts-
                 * more.js`.
                 * 
                 * @type {Boolean}
                 * @default false
                 * @since 2.3.0
                 * @product highcharts
                 * @apioption chart.polar
                 */

                /**
                 * Whether to reflow the chart to fit the width of the container div
                 * on resizing the window.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/reflow-true/ True by default
                 * @sample {highcharts} highcharts/chart/reflow-false/ False
                 * @sample {highstock} stock/chart/reflow-true/
                 *         True by default
                 * @sample {highstock} stock/chart/reflow-false/
                 *         False
                 * @sample {highmaps} maps/chart/reflow-true/
                 *         True by default
                 * @sample {highmaps} maps/chart/reflow-false/
                 *         False
                 * @default true
                 * @since 2.1
                 * @apioption chart.reflow
                 */




                /**
                 * The HTML element where the chart will be rendered. If it is a string,
                 * the element by that id is used. The HTML element can also be passed
                 * by direct reference, or as the first argument of the chart constructor,
                 *  in which case the option is not needed.
                 * 
                 * @type {String|Object}
                 * @sample {highcharts} highcharts/chart/reflow-true/
                 *         String
                 * @sample {highcharts} highcharts/chart/renderto-object/
                 *         Object reference
                 * @sample {highcharts} highcharts/chart/renderto-jquery/
                 *         Object reference through jQuery
                 * @sample {highstock} stock/chart/renderto-string/
                 *         String
                 * @sample {highstock} stock/chart/renderto-object/
                 *         Object reference
                 * @sample {highstock} stock/chart/renderto-jquery/
                 *         Object reference through jQuery
                 * @apioption chart.renderTo
                 */

                /**
                 * The background color of the marker square when selecting (zooming
                 * in on) an area of the chart.
                 * 
                 * @type {Color}
                 * @see In styled mode, the selection marker fill is set with the
                 * `.highcharts-selection-marker` class.
                 * @default rgba(51,92,173,0.25)
                 * @since 2.1.7
                 * @apioption chart.selectionMarkerFill
                 */

                /**
                 * Whether to apply a drop shadow to the outer chart area. Requires
                 * that backgroundColor be set. The shadow can be an object configuration
                 * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
                 * 
                 * @type {Boolean|Object}
                 * @sample {highcharts} highcharts/chart/shadow/ Shadow
                 * @sample {highstock} stock/chart/shadow/
                 *         Shadow
                 * @sample {highmaps} maps/chart/border/
                 *         Chart border and shadow
                 * @default false
                 * @apioption chart.shadow
                 */

                /**
                 * Whether to show the axes initially. This only applies to empty charts
                 * where series are added dynamically, as axes are automatically added
                 * to cartesian series.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/showaxes-false/ False by default
                 * @sample {highcharts} highcharts/chart/showaxes-true/ True
                 * @since 1.2.5
                 * @product highcharts
                 * @apioption chart.showAxes
                 */

                /**
                 * The space between the bottom edge of the chart and the content (plot
                 * area, axis title and labels, title, subtitle or legend in top position).
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/spacingbottom/
                 *         Spacing bottom set to 100
                 * @sample {highstock} stock/chart/spacingbottom/
                 *         Spacing bottom set to 100
                 * @sample {highmaps} maps/chart/spacing/
                 *         Spacing 100 all around
                 * @default 15
                 * @since 2.1
                 * @apioption chart.spacingBottom
                 */

                /**
                 * The space between the left edge of the chart and the content (plot
                 * area, axis title and labels, title, subtitle or legend in top position).
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/spacingleft/
                 *         Spacing left set to 100
                 * @sample {highstock} stock/chart/spacingleft/
                 *         Spacing left set to 100
                 * @sample {highmaps} maps/chart/spacing/
                 *         Spacing 100 all around
                 * @default 10
                 * @since 2.1
                 * @apioption chart.spacingLeft
                 */

                /**
                 * The space between the right edge of the chart and the content (plot
                 * area, axis title and labels, title, subtitle or legend in top
                 * position).
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/spacingright-100/
                 *         Spacing set to 100
                 * @sample {highcharts} highcharts/chart/spacingright-legend/
                 *         Legend in right position with default spacing
                 * @sample {highstock} stock/chart/spacingright/
                 *         Spacing set to 100
                 * @sample {highmaps} maps/chart/spacing/
                 *         Spacing 100 all around
                 * @default 10
                 * @since 2.1
                 * @apioption chart.spacingRight
                 */

                /**
                 * The space between the top edge of the chart and the content (plot
                 * area, axis title and labels, title, subtitle or legend in top
                 * position).
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/chart/spacingtop-100/
                 *         A top spacing of 100
                 * @sample {highcharts} highcharts/chart/spacingtop-10/
                 *         Floating chart title makes the plot area align to the default
                 *         spacingTop of 10.
                 * @sample {highstock} stock/chart/spacingtop/
                 *         A top spacing of 100
                 * @sample {highmaps} maps/chart/spacing/
                 *         Spacing 100 all around
                 * @default 10
                 * @since 2.1
                 * @apioption chart.spacingTop
                 */

                /**
                 * Additional CSS styles to apply inline to the container `div`. Note
                 * that since the default font styles are applied in the renderer, it
                 * is ignorant of the individual chart options and must be set globally.
                 * 
                 * @type {CSSObject}
                 * @see In styled mode, general chart styles can be set with the `.highcharts-root` class.
                 * @sample {highcharts} highcharts/chart/style-serif-font/
                 *         Using a serif type font
                 * @sample {highcharts} highcharts/css/em/
                 *         Styled mode with relative font sizes
                 * @sample {highstock} stock/chart/style/
                 *         Using a serif type font
                 * @sample {highmaps} maps/chart/style-serif-font/
                 *         Using a serif type font
                 * @default {"fontFamily":"\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
                 * @apioption chart.style
                 */

                /**
                 * The default series type for the chart. Can be any of the chart types
                 * listed under [plotOptions](#plotOptions).
                 * 
                 * @validvalue ["line", "spline", "column", "bar", "area", "areaspline", "pie", "arearange", "areasplinerange", "boxplot", "bubble", "columnrange", "errorbar", "funnel", "gauge", "heatmap", "polygon", "pyramid", "scatter", "solidgauge", "treemap", "waterfall"]
                 * @type {String}
                 * @sample {highcharts} highcharts/chart/type-bar/ Bar
                 * @sample {highstock} stock/chart/type/
                 *         Areaspline
                 * @sample {highmaps} maps/chart/type-mapline/
                 *         Mapline
                 * @default {highcharts} line
                 * @default {highstock} line
                 * @default {highmaps} map
                 * @since 2.1.0
                 * @apioption chart.type
                 */

                /**
                 * Decides in what dimensions the user can zoom by dragging the mouse.
                 * Can be one of `x`, `y` or `xy`.
                 * 
                 * @validvalue [null, "x", "y", "xy"]
                 * @type {String}
                 * @see [panKey](#chart.panKey)
                 * @sample {highcharts} highcharts/chart/zoomtype-none/ None by default
                 * @sample {highcharts} highcharts/chart/zoomtype-x/ X
                 * @sample {highcharts} highcharts/chart/zoomtype-y/ Y
                 * @sample {highcharts} highcharts/chart/zoomtype-xy/ Xy
                 * @sample {highstock} stock/demo/basic-line/ None by default
                 * @sample {highstock} stock/chart/zoomtype-x/ X
                 * @sample {highstock} stock/chart/zoomtype-y/ Y
                 * @sample {highstock} stock/chart/zoomtype-xy/ Xy
                 * @product highcharts highstock
                 * @apioption chart.zoomType
                 */
            },

            /**
             * The chart's main title.
             * 
             * @sample {highmaps} maps/title/title/ Title options demonstrated
             */
            title: {

                /**
                 * The title of the chart. To disable the title, set the `text` to
                 * `null`.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/title/text/ Custom title
                 * @sample {highstock} stock/chart/title-text/ Custom title
                 * @default {highcharts|highmaps} Chart title
                 * @default {highstock} null
                 */
                text: 'Chart title',

                /**
                 * The horizontal alignment of the title. Can be one of "left", "center"
                 * and "right".
                 * 
                 * @validvalue ["left", "center", "right"]
                 * @type {String}
                 * @sample {highcharts} highcharts/title/align/ Aligned to the plot area (x = 70px     = margin left - spacing left)
                 * @sample {highstock} stock/chart/title-align/ Aligned to the plot area (x = 50px     = margin left - spacing left)
                 * @default center
                 * @since 2.0
                 */
                align: 'center',

                /**
                 * The margin between the title and the plot area, or if a subtitle
                 * is present, the margin between the subtitle and the plot area.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/title/margin-50/ A chart title margin of 50
                 * @sample {highcharts} highcharts/title/margin-subtitle/ The same margin applied with a subtitle
                 * @sample {highstock} stock/chart/title-margin/ A chart title margin of 50
                 * @default 15
                 * @since 2.1
                 */
                margin: 15,

                /**
                 * Adjustment made to the title width, normally to reserve space for
                 * the exporting burger menu.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/title/widthadjust/ Wider menu, greater padding
                 * @sample {highstock} highcharts/title/widthadjust/ Wider menu, greater padding
                 * @sample {highmaps} highcharts/title/widthadjust/ Wider menu, greater padding
                 * @default -44
                 * @since 4.2.5
                 */
                widthAdjust: -44

                /**
                 * When the title is floating, the plot area will not move to make space
                 * for it.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/zoomtype-none/ False by default
                 * @sample {highcharts} highcharts/title/floating/
                 *         True - title on top of the plot area
                 * @sample {highstock} stock/chart/title-floating/
                 *         True - title on top of the plot area
                 * @default false
                 * @since 2.1
                 * @apioption title.floating
                 */

                /**
                 * CSS styles for the title. Use this for font styling, but use `align`,
                 * `x` and `y` for text alignment.
                 * 
                 * In styled mode, the title style is given in the `.highcharts-title` class.
                 * 
                 * @type {CSSObject}
                 * @sample {highcharts} highcharts/title/style/ Custom color and weight
                 * @sample {highcharts} highcharts/css/titles/ Styled mode
                 * @sample {highstock} stock/chart/title-style/ Custom color and weight
                 * @sample {highstock} highcharts/css/titles/ Styled mode
                 * @sample {highmaps} highcharts/css/titles/ Styled mode
                 * @default {highcharts,highmaps} { "color": "#333333", "fontSize": "18px" }
                 * @default {highstock} { "color": "#333333", "fontSize": "16px" }
                 * @apioption title.style
                 */

                /**
                 * Whether to [use HTML](http://www.highcharts.com/docs/chart-concepts/labels-
                 * and-string-formatting#html) to render the text.
                 * 
                 * @type {Boolean}
                 * @default false
                 * @apioption title.useHTML
                 */

                /**
                 * The vertical alignment of the title. Can be one of `"top"`, `"middle"`
                 * and `"bottom"`. When a value is given, the title behaves as if [floating](#title.
                 * floating) were `true`.
                 * 
                 * @validvalue ["top", "middle", "bottom"]
                 * @type {String}
                 * @sample {highcharts} highcharts/title/verticalalign/
                 *         Chart title in bottom right corner
                 * @sample {highstock} stock/chart/title-verticalalign/
                 *         Chart title in bottom right corner
                 * @since 2.1
                 * @apioption title.verticalAlign
                 */

                /**
                 * The x position of the title relative to the alignment within chart.
                 * spacingLeft and chart.spacingRight.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/title/align/
                 *         Aligned to the plot area (x = 70px = margin left - spacing left)
                 * @sample {highstock} stock/chart/title-align/
                 *         Aligned to the plot area (x = 50px = margin left - spacing left)
                 * @default 0
                 * @since 2.0
                 * @apioption title.x
                 */

                /**
                 * The y position of the title relative to the alignment within [chart.
                 * spacingTop](#chart.spacingTop) and [chart.spacingBottom](#chart.spacingBottom).
                 *  By default it depends on the font size.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/title/y/
                 *         Title inside the plot area
                 * @sample {highstock} stock/chart/title-verticalalign/
                 *         Chart title in bottom right corner
                 * @since 2.0
                 * @apioption title.y
                 */

            },

            /**
             * The chart's subtitle. This can be used both to display a subtitle below
             * the main title, and to display random text anywhere in the chart. The
             * subtitle can be updated after chart initialization through the 
             * `Chart.setTitle` method.
             * 
             * @sample {highmaps} maps/title/subtitle/ Subtitle options demonstrated
             */
            subtitle: {

                /**
                 * The subtitle of the chart.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/subtitle/text/ Custom subtitle
                 * @sample {highcharts} highcharts/subtitle/text-formatted/ Formatted and linked text.
                 * @sample {highstock} stock/chart/subtitle-text Custom subtitle
                 * @sample {highstock} stock/chart/subtitle-text-formatted Formatted and linked text.
                 */
                text: '',

                /**
                 * The horizontal alignment of the subtitle. Can be one of "left",
                 *  "center" and "right".
                 * 
                 * @validvalue ["left", "center", "right"]
                 * @type {String}
                 * @sample {highcharts} highcharts/subtitle/align/ Footnote at right of plot area
                 * @sample {highstock} stock/chart/subtitle-footnote Footnote at bottom right of plot area
                 * @default center
                 * @since 2.0
                 */
                align: 'center',

                /**
                 * Adjustment made to the subtitle width, normally to reserve space
                 * for the exporting burger menu.
                 * 
                 * @type {Number}
                 * @see [title.widthAdjust](#title.widthAdjust)
                 * @sample {highcharts} highcharts/title/widthadjust/ Wider menu, greater padding
                 * @sample {highstock} highcharts/title/widthadjust/ Wider menu, greater padding
                 * @sample {highmaps} highcharts/title/widthadjust/ Wider menu, greater padding
                 * @default -44
                 * @since 4.2.5
                 */
                widthAdjust: -44

                /**
                 * When the subtitle is floating, the plot area will not move to make
                 * space for it.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/subtitle/floating/
                 *         Floating title and subtitle
                 * @sample {highstock} stock/chart/subtitle-footnote
                 *         Footnote floating at bottom right of plot area
                 * @default false
                 * @since 2.1
                 * @apioption subtitle.floating
                 */

                /**
                 * CSS styles for the title.
                 * 
                 * In styled mode, the subtitle style is given in the `.highcharts-subtitle` class.
                 * 
                 * @type {CSSObject}
                 * @sample {highcharts} highcharts/subtitle/style/
                 *         Custom color and weight
                 * @sample {highcharts} highcharts/css/titles/
                 *         Styled mode
                 * @sample {highstock} stock/chart/subtitle-style
                 *         Custom color and weight
                 * @sample {highstock} highcharts/css/titles/
                 *         Styled mode
                 * @sample {highmaps} highcharts/css/titles/
                 *         Styled mode
                 * @default { "color": "#666666" }
                 * @apioption subtitle.style
                 */

                /**
                 * Whether to [use HTML](http://www.highcharts.com/docs/chart-concepts/labels-
                 * and-string-formatting#html) to render the text.
                 * 
                 * @type {Boolean}
                 * @default false
                 * @apioption subtitle.useHTML
                 */

                /**
                 * The vertical alignment of the title. Can be one of "top", "middle"
                 * and "bottom". When a value is given, the title behaves as floating.
                 * 
                 * @validvalue ["top", "middle", "bottom"]
                 * @type {String}
                 * @sample {highcharts} highcharts/subtitle/verticalalign/
                 *         Footnote at the bottom right of plot area
                 * @sample {highstock} stock/chart/subtitle-footnote
                 *         Footnote at the bottom right of plot area
                 * @default  
                 * @since 2.1
                 * @apioption subtitle.verticalAlign
                 */

                /**
                 * The x position of the subtitle relative to the alignment within chart.
                 * spacingLeft and chart.spacingRight.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/subtitle/align/
                 *         Footnote at right of plot area
                 * @sample {highstock} stock/chart/subtitle-footnote
                 *         Footnote at the bottom right of plot area
                 * @default 0
                 * @since 2.0
                 * @apioption subtitle.x
                 */

                /**
                 * The y position of the subtitle relative to the alignment within chart.
                 * spacingTop and chart.spacingBottom. By default the subtitle is laid
                 * out below the title unless the title is floating.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/subtitle/verticalalign/
                 *         Footnote at the bottom right of plot area
                 * @sample {highstock} stock/chart/subtitle-footnote
                 *         Footnote at the bottom right of plot area
                 * @default {highcharts}  null
                 * @default {highstock}  null
                 * @default {highmaps}  
                 * @since 2.0
                 * @apioption subtitle.y
                 */
            },

            /**
             * The plotOptions is a wrapper object for config objects for each series
             * type. The config objects for each series can also be overridden for
             * each series item as given in the series array.
             * 
             * Configuration options for the series are given in three levels. Options
             * for all series in a chart are given in the [plotOptions.series](#plotOptions.
             * series) object. Then options for all series of a specific type are
             * given in the plotOptions of that type, for example plotOptions.line.
             * Next, options for one single series are given in [the series array](#series).
             *
             */
            plotOptions: {},

            /**
             * HTML labels that can be positioned anywhere in the chart area.
             *
             */
            labels: {

                /**
                 * A HTML label that can be positioned anywhere in the chart area.
                 * 
                 * @type {Array<Object>}
                 * @apioption labels.items
                 */

                /**
                 * Inner HTML or text for the label.
                 * 
                 * @type {String}
                 * @apioption labels.items.html
                 */

                /**
                 * CSS styles for each label. To position the label, use left and top
                 * like this:
                 * 
                 * <pre>style: {
                 *     left: '100px',
                 *     top: '100px'
                 * }</pre>
                 * 
                 * @type {CSSObject}
                 * @apioption labels.items.style
                 */

                /**
                 * Shared CSS styles for all labels.
                 * 
                 * @type {CSSObject}
                 * @default { "color": "#333333" }
                 */
                style: {
                    position: 'absolute',
                    color: '#333333'
                }
            },

            /**
             * The legend is a box containing a symbol and name for each series
             * item or point item in the chart. Each series (or points in case
             * of pie charts) is represented by a symbol and its name in the legend.
             *  
             * It is possible to override the symbol creator function and
             * create [custom legend symbols](http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-
             * custom-symbol/).
             * 
             * @productdesc {highmaps}
             * A Highmaps legend by default contains one legend item per series, but if
             * a `colorAxis` is defined, the axis will be displayed in the legend.
             * Either as a gradient, or as multiple legend items for `dataClasses`.
             */
            legend: {

                /**
                 * The background color of the legend.
                 * 
                 * @type {Color}
                 * @see In styled mode, the legend background fill can be applied with
                 * the `.highcharts-legend-box` class.
                 * @sample {highcharts} highcharts/legend/backgroundcolor/ Yellowish background
                 * @sample {highstock} stock/legend/align/ Various legend options
                 * @sample {highmaps} maps/legend/border-background/ Border and background options
                 * @apioption legend.backgroundColor
                 */

                /**
                 * The width of the drawn border around the legend.
                 * 
                 * @type {Number}
                 * @see In styled mode, the legend border stroke width can be applied
                 * with the `.highcharts-legend-box` class.
                 * @sample {highcharts} highcharts/legend/borderwidth/ 2px border width
                 * @sample {highstock} stock/legend/align/ Various legend options
                 * @sample {highmaps} maps/legend/border-background/ Border and background options
                 * @default 0
                 * @apioption legend.borderWidth
                 */

                /**
                 * Enable or disable the legend.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
                 * @sample {highstock} stock/legend/align/ Various legend options
                 * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
                 * @default {highstock} false
                 * @default {highmaps} true
                 */
                enabled: true,

                /**
                 * The horizontal alignment of the legend box within the chart area.
                 * Valid values are `left`, `center` and `right`.
                 * 
                 * In the case that the legend is aligned in a corner position, the
                 * `layout` option will determine whether to place it above/below
                 * or on the side of the plot area.
                 * 
                 * @validvalue ["left", "center", "right"]
                 * @type {String}
                 * @sample {highcharts} highcharts/legend/align/
                 *         Legend at the right of the chart
                 * @sample {highstock} stock/legend/align/
                 *         Various legend options
                 * @sample {highmaps} maps/legend/alignment/
                 *         Legend alignment
                 * @since 2.0
                 */
                align: 'center',

                /**
                 * When the legend is floating, the plot area ignores it and is allowed
                 * to be placed below it.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/legend/floating-false/ False by default
                 * @sample {highcharts} highcharts/legend/floating-true/ True
                 * @sample {highmaps} maps/legend/alignment/ Floating legend
                 * @default false
                 * @since 2.1
                 * @apioption legend.floating
                 */

                /**
                 * The layout of the legend items. Can be one of "horizontal" or "vertical".
                 * 
                 * @validvalue ["horizontal", "vertical"]
                 * @type {String}
                 * @sample {highcharts} highcharts/legend/layout-horizontal/ Horizontal by default
                 * @sample {highcharts} highcharts/legend/layout-vertical/ Vertical
                 * @sample {highstock} stock/legend/layout-horizontal/ Horizontal by default
                 * @sample {highmaps} maps/legend/padding-itemmargin/ Vertical with data classes
                 * @sample {highmaps} maps/legend/layout-vertical/ Vertical with color axis gradient
                 * @default horizontal
                 */
                layout: 'horizontal',

                /**
                 * In a legend with horizontal layout, the itemDistance defines the
                 * pixel distance between each item.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/layout-horizontal/ 50px item distance
                 * @sample {highstock} highcharts/legend/layout-horizontal/ 50px item distance
                 * @default {highcharts} 20
                 * @default {highstock} 20
                 * @default {highmaps} 8
                 * @since 3.0.3
                 * @apioption legend.itemDistance
                 */

                /**
                 * The pixel bottom margin for each legend item.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/padding-itemmargin/ Padding and item margins demonstrated
                 * @sample {highstock} highcharts/legend/padding-itemmargin/ Padding and item margins demonstrated
                 * @sample {highmaps} maps/legend/padding-itemmargin/ Padding and item margins demonstrated
                 * @default 0
                 * @since 2.2.0
                 * @apioption legend.itemMarginBottom
                 */

                /**
                 * The pixel top margin for each legend item.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/padding-itemmargin/ Padding and item margins demonstrated
                 * @sample {highstock} highcharts/legend/padding-itemmargin/ Padding and item margins demonstrated
                 * @sample {highmaps} maps/legend/padding-itemmargin/ Padding and item margins demonstrated
                 * @default 0
                 * @since 2.2.0
                 * @apioption legend.itemMarginTop
                 */

                /**
                 * The width for each legend item. This is useful in a horizontal layout
                 * with many items when you want the items to align vertically. .
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/itemwidth-default/ Null by default
                 * @sample {highcharts} highcharts/legend/itemwidth-80/ 80 for aligned legend items
                 * @default null
                 * @since 2.0
                 * @apioption legend.itemWidth
                 */

                /**
                 * A [format string](http://www.highcharts.com/docs/chart-concepts/labels-
                 * and-string-formatting) for each legend label. Available variables
                 * relates to properties on the series, or the point in case of pies.
                 * 
                 * @type {String}
                 * @default {name}
                 * @since 1.3
                 * @apioption legend.labelFormat
                 */

                /**
                 * Callback function to format each of the series' labels. The `this`
                 * keyword refers to the series object, or the point object in case
                 * of pie charts. By default the series or point name is printed.
                 *
                 * @productdesc {highmaps}
                 *              In Highmaps the context can also be a data class in case
                 *              of a `colorAxis`.
                 * 
                 * @type {Function}
                 * @sample {highcharts} highcharts/legend/labelformatter/ Add text
                 * @sample {highmaps} maps/legend/labelformatter/ Data classes with label formatter
                 * @context {Series|Point}
                 */
                labelFormatter: function() {
                    return this.name;
                },

                /**
                 * Line height for the legend items. Deprecated as of 2.1\. Instead,
                 * the line height for each item can be set using itemStyle.lineHeight,
                 * and the padding between items using itemMarginTop and itemMarginBottom.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/lineheight/ Setting padding
                 * @default 16
                 * @since 2.0
                 * @product highcharts
                 * @apioption legend.lineHeight
                 */

                /**
                 * If the plot area sized is calculated automatically and the legend
                 * is not floating, the legend margin is the space between the legend
                 * and the axis labels or plot area.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/margin-default/ 12 pixels by default
                 * @sample {highcharts} highcharts/legend/margin-30/ 30 pixels
                 * @default 12
                 * @since 2.1
                 * @apioption legend.margin
                 */

                /**
                 * Maximum pixel height for the legend. When the maximum height is extended,
                 *  navigation will show.
                 * 
                 * @type {Number}
                 * @default undefined
                 * @since 2.3.0
                 * @apioption legend.maxHeight
                 */

                /**
                 * The color of the drawn border around the legend.
                 * 
                 * @type {Color}
                 * @see In styled mode, the legend border stroke can be applied with
                 * the `.highcharts-legend-box` class.
                 * @sample {highcharts} highcharts/legend/bordercolor/ Brown border
                 * @sample {highstock} stock/legend/align/ Various legend options
                 * @sample {highmaps} maps/legend/border-background/ Border and background options
                 * @default #999999
                 */
                borderColor: '#999999',

                /**
                 * The border corner radius of the legend.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/borderradius-default/ Square by default
                 * @sample {highcharts} highcharts/legend/borderradius-round/ 5px rounded
                 * @sample {highmaps} maps/legend/border-background/ Border and background options
                 * @default 0
                 */
                borderRadius: 0,

                /**
                 * Options for the paging or navigation appearing when the legend
                 * is overflown. Navigation works well on screen, but not in static
                 * exported images. One way of working around that is to [increase
                 * the chart height in export](http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-
                 * enabled-false/).
                 *
                 */
                navigation: {


                    /**
                     * The color for the active up or down arrow in the legend page navigation.
                     * 
                     * @type {Color}
                     * @see In styled mode, the active arrow be styled with the `.highcharts-legend-nav-active` class.
                     * @sample {highcharts} highcharts/legend/navigation/ Legend page navigation demonstrated
                     * @sample {highstock} highcharts/legend/navigation/ Legend page navigation demonstrated
                     * @default #003399
                     * @since 2.2.4
                     */
                    activeColor: '#003399',

                    /**
                     * The color of the inactive up or down arrow in the legend page
                     * navigation. .
                     * 
                     * @type {Color}
                     * @see In styled mode, the inactive arrow be styled with the
                     *      `.highcharts-legend-nav-inactive` class.
                     * @sample {highcharts} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @sample {highstock} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @default {highcharts} #cccccc
                     * @default {highstock} #cccccc
                     * @default {highmaps} ##cccccc
                     * @since 2.2.4
                     */
                    inactiveColor: '#cccccc'


                    /**
                     * How to animate the pages when navigating up or down. A value of `true`
                     * applies the default navigation given in the chart.animation option.
                     * Additional options can be given as an object containing values for
                     * easing and duration.
                     * 
                     * @type {Boolean|Object}
                     * @sample {highcharts} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @sample {highstock} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @default true
                     * @since 2.2.4
                     * @apioption legend.navigation.animation
                     */

                    /**
                     * The pixel size of the up and down arrows in the legend paging
                     * navigation.
                     * 
                     * @type {Number}
                     * @sample {highcharts} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @sample {highstock} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @default 12
                     * @since 2.2.4
                     * @apioption legend.navigation.arrowSize
                     */

                    /**
                     * Whether to enable the legend navigation. In most cases, disabling
                     * the navigation results in an unwanted overflow.
                     * 
                     * See also the [adapt chart to legend](http://www.highcharts.com/plugin-
                     * registry/single/8/Adapt-Chart-To-Legend) plugin for a solution to
                     * extend the chart height to make room for the legend, optionally in
                     * exported charts only.
                     * 
                     * @type {Boolean}
                     * @default true
                     * @since 4.2.4
                     * @apioption legend.navigation.enabled
                     */

                    /**
                     * Text styles for the legend page navigation.
                     * 
                     * @type {CSSObject}
                     * @see In styled mode, the navigation items are styled with the
                     * `.highcharts-legend-navigation` class.
                     * @sample {highcharts} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @sample {highstock} highcharts/legend/navigation/
                     *         Legend page navigation demonstrated
                     * @since 2.2.4
                     * @apioption legend.navigation.style
                     */
                },

                /**
                 * The inner padding of the legend box.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/padding-itemmargin/
                 *         Padding and item margins demonstrated
                 * @sample {highstock} highcharts/legend/padding-itemmargin/
                 *         Padding and item margins demonstrated
                 * @sample {highmaps} maps/legend/padding-itemmargin/
                 *         Padding and item margins demonstrated
                 * @default 8
                 * @since 2.2.0
                 * @apioption legend.padding
                 */

                /**
                 * Whether to reverse the order of the legend items compared to the
                 * order of the series or points as defined in the configuration object.
                 * 
                 * @type {Boolean}
                 * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
                 *      [series.legendIndex](#series.legendIndex)
                 * @sample {highcharts} highcharts/legend/reversed/
                 *         Stacked bar with reversed legend
                 * @default false
                 * @since 1.2.5
                 * @apioption legend.reversed
                 */

                /**
                 * Whether to show the symbol on the right side of the text rather than
                 * the left side. This is common in Arabic and Hebraic.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/legend/rtl/ Symbol to the right
                 * @default false
                 * @since 2.2
                 * @product highcharts highmaps
                 * @apioption legend.rtl
                 */

                /**
                 * CSS styles for the legend area. In the 1.x versions the position
                 * of the legend area was determined by CSS. In 2.x, the position is
                 * determined by properties like `align`, `verticalAlign`, `x` and `y`,
                 *  but the styles are still parsed for backwards compatibility.
                 * 
                 * @type {CSSObject}
                 * @deprecated
                 * @product highcharts highstock
                 * @apioption legend.style
                 */



                /**
                 * CSS styles for each legend item. Only a subset of CSS is supported,
                 * notably those options related to text. The default `textOverflow`
                 * property makes long texts truncate. Set it to `null` to wrap text
                 * instead. A `width` property can be added to control the text width.
                 * 
                 * @type {CSSObject}
                 * @see In styled mode, the legend items can be styled with the `.
                 * highcharts-legend-item` class.
                 * @sample {highcharts} highcharts/legend/itemstyle/ Bold black text
                 * @sample {highmaps} maps/legend/itemstyle/ Item text styles
                 * @default { "color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis" }
                 */
                itemStyle: {
                    color: '#333333',
                    fontSize: '12px',
                    fontWeight: 'bold',
                    textOverflow: 'ellipsis'
                },

                /**
                 * CSS styles for each legend item in hover mode. Only a subset of
                 * CSS is supported, notably those options related to text. Properties
                 * are inherited from `style` unless overridden here.
                 * 
                 * @type {CSSObject}
                 * @see In styled mode, the hovered legend items can be styled with
                 * the `.highcharts-legend-item:hover` pesudo-class.
                 * @sample {highcharts} highcharts/legend/itemhoverstyle/ Red on hover
                 * @sample {highmaps} maps/legend/itemstyle/ Item text styles
                 * @default { "color": "#000000" }
                 */
                itemHoverStyle: {
                    color: '#000000'
                },

                /**
                 * CSS styles for each legend item when the corresponding series or
                 * point is hidden. Only a subset of CSS is supported, notably those
                 * options related to text. Properties are inherited from `style`
                 * unless overridden here.
                 * 
                 * @type {CSSObject}
                 * @see In styled mode, the hidden legend items can be styled with
                 * the `.highcharts-legend-item-hidden` class.
                 * @sample {highcharts} highcharts/legend/itemhiddenstyle/ Darker gray color
                 * @default { "color": "#cccccc" }
                 */
                itemHiddenStyle: {
                    color: '#cccccc'
                },

                /**
                 * Whether to apply a drop shadow to the legend. A `backgroundColor`
                 * also needs to be applied for this to take effect. The shadow can be
                 * an object configuration containing `color`, `offsetX`, `offsetY`,
                 * `opacity` and `width`.
                 * 
                 * @type {Boolean|Object}
                 * @sample {highcharts} highcharts/legend/shadow/
                 *         White background and drop shadow
                 * @sample {highstock} stock/legend/align/
                 *         Various legend options
                 * @sample {highmaps} maps/legend/border-background/
                 *         Border and background options
                 * @default false
                 */
                shadow: false,


                /**
                 * Default styling for the checkbox next to a legend item when
                 * `showCheckbox` is true.
                 */
                itemCheckboxStyle: {
                    position: 'absolute',
                    width: '13px', // for IE precision
                    height: '13px'
                },
                // itemWidth: undefined,

                /**
                 * When this is true, the legend symbol width will be the same as
                 * the symbol height, which in turn defaults to the font size of the
                 * legend items.
                 * 
                 * @type {Boolean}
                 * @default true
                 * @since 5.0.0
                 */
                squareSymbol: true,

                /**
                 * The pixel height of the symbol for series types that use a rectangle
                 * in the legend. Defaults to the font size of legend items.
                 *
                 * @productdesc {highmaps}
                 * In Highmaps, when the symbol is the gradient of a vertical color
                 * axis, the height defaults to 200.
                 * 
                 * @type {Number}
                 * @sample {highmaps} maps/legend/layout-vertical-sized/
                 *         Sized vertical gradient
                 * @sample {highmaps} maps/legend/padding-itemmargin/
                 *         No distance between data classes
                 * @since 3.0.8
                 * @apioption legend.symbolHeight
                 */

                /**
                 * The border radius of the symbol for series types that use a rectangle
                 * in the legend. Defaults to half the `symbolHeight`.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/symbolradius/ Round symbols
                 * @sample {highstock} highcharts/legend/symbolradius/ Round symbols
                 * @sample {highmaps} highcharts/legend/symbolradius/ Round symbols
                 * @since 3.0.8
                 * @apioption legend.symbolRadius
                 */

                /**
                 * The pixel width of the legend item symbol. When the `squareSymbol`
                 * option is set, this defaults to the `symbolHeight`, otherwise 16.
                 * 
                 * @productdesc {highmaps}
                 * In Highmaps, when the symbol is the gradient of a horizontal color
                 * axis, the width defaults to 200.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/symbolwidth/
                 *         Greater symbol width and padding
                 * @sample {highmaps} maps/legend/padding-itemmargin/
                 *         Padding and item margins demonstrated
                 * @sample {highmaps} maps/legend/layout-vertical-sized/
                 *         Sized vertical gradient
                 * @apioption legend.symbolWidth
                 */

                /**
                 * Whether to [use HTML](http://www.highcharts.com/docs/chart-concepts/labels-
                 * and-string-formatting#html) to render the legend item texts. Prior
                 * to 4.1.7, when using HTML, [legend.navigation](#legend.navigation)
                 * was disabled.
                 * 
                 * @type {Boolean}
                 * @default false
                 * @apioption legend.useHTML
                 */

                /**
                 * The width of the legend box.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/width/ Aligned to the plot area
                 * @default null
                 * @since 2.0
                 * @apioption legend.width
                 */

                /**
                 * The pixel padding between the legend item symbol and the legend
                 * item text.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/symbolpadding/ Greater symbol width and padding
                 * @default 5
                 */
                symbolPadding: 5,

                /**
                 * The vertical alignment of the legend box. Can be one of `top`,
                 * `middle` or `bottom`. Vertical position can be further determined
                 * by the `y` option.
                 * 
                 * In the case that the legend is aligned in a corner position, the
                 * `layout` option will determine whether to place it above/below
                 * or on the side of the plot area.
                 * 
                 * @validvalue ["top", "middle", "bottom"]
                 * @type {String}
                 * @sample {highcharts} highcharts/legend/verticalalign/ Legend 100px from the top of the chart
                 * @sample {highstock} stock/legend/align/ Various legend options
                 * @sample {highmaps} maps/legend/alignment/ Legend alignment
                 * @default bottom
                 * @since 2.0
                 */
                verticalAlign: 'bottom',
                // width: undefined,

                /**
                 * The x offset of the legend relative to its horizontal alignment
                 * `align` within chart.spacingLeft and chart.spacingRight. Negative
                 * x moves it to the left, positive x moves it to the right.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/width/ Aligned to the plot area
                 * @default 0
                 * @since 2.0
                 */
                x: 0,

                /**
                 * The vertical offset of the legend relative to it's vertical alignment
                 * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
                 *  Negative y moves it up, positive y moves it down.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/legend/verticalalign/ Legend 100px from the top of the chart
                 * @sample {highstock} stock/legend/align/ Various legend options
                 * @sample {highmaps} maps/legend/alignment/ Legend alignment
                 * @default 0
                 * @since 2.0
                 */
                y: 0,

                /**
                 * A title to be added on top of the legend.
                 * 
                 * @sample {highcharts} highcharts/legend/title/ Legend title
                 * @sample {highmaps} maps/legend/alignment/ Legend with title
                 * @since 3.0
                 */
                title: {
                    /**
                     * A text or HTML string for the title.
                     * 
                     * @type {String}
                     * @default null
                     * @since 3.0
                     * @apioption legend.title.text
                     */



                    /**
                     * Generic CSS styles for the legend title.
                     * 
                     * @type {CSSObject}
                     * @see In styled mode, the legend title is styled with the
                     * `.highcharts-legend-title` class.
                     * @default {"fontWeight":"bold"}
                     * @since 3.0
                     */
                    style: {
                        fontWeight: 'bold'
                    }

                }
            },


            /**
             * The loading options control the appearance of the loading screen
             * that covers the plot area on chart operations. This screen only
             * appears after an explicit call to `chart.showLoading()`. It is a
             * utility for developers to communicate to the end user that something
             * is going on, for example while retrieving new data via an XHR connection.
             * The "Loading..." text itself is not part of this configuration
             * object, but part of the `lang` object.
             *
             */
            loading: {

                /**
                 * The duration in milliseconds of the fade out effect.
                 * 
                 * @type {Number}
                 * @sample highcharts/loading/hideduration/ Fade in and out over a second
                 * @default 100
                 * @since 1.2.0
                 * @apioption loading.hideDuration
                 */

                /**
                 * The duration in milliseconds of the fade in effect.
                 * 
                 * @type {Number}
                 * @sample highcharts/loading/hideduration/ Fade in and out over a second
                 * @default 100
                 * @since 1.2.0
                 * @apioption loading.showDuration
                 */


                /**
                 * CSS styles for the loading label `span`.
                 * 
                 * @type {CSSObject}
                 * @see In styled mode, the loading label is styled with the
                 * `.highcharts-legend-loading-inner` class.
                 * @sample {highcharts|highmaps} highcharts/loading/labelstyle/ Vertically centered
                 * @sample {highstock} stock/loading/general/ Label styles
                 * @default { "fontWeight": "bold", "position": "relative", "top": "45%" }
                 * @since 1.2.0
                 */
                labelStyle: {
                    fontWeight: 'bold',
                    position: 'relative',
                    top: '45%'
                },

                /**
                 * CSS styles for the loading screen that covers the plot area.
                 * 
                 * @type {CSSObject}
                 * @see In styled mode, the loading label is styled with the `.highcharts-legend-loading` class.
                 * @sample {highcharts|highmaps} highcharts/loading/style/ Gray plot area, white text
                 * @sample {highstock} stock/loading/general/ Gray plot area, white text
                 * @default { "position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center" }
                 * @since 1.2.0
                 */
                style: {
                    position: 'absolute',
                    backgroundColor: '#ffffff',
                    opacity: 0.5,
                    textAlign: 'center'
                }

            },


            /**
             * Options for the tooltip that appears when the user hovers over a
             * series or point.
             *
             */
            tooltip: {

                /**
                 * Enable or disable the tooltip.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/tooltip/enabled/ Disabled
                 * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/ Disable tooltip and show values on chart instead
                 * @default true
                 */
                enabled: true,

                /**
                 * Enable or disable animation of the tooltip. In slow legacy IE browsers
                 * the animation is disabled by default.
                 * 
                 * @type {Boolean}
                 * @default true
                 * @since 2.3.0
                 */
                animation: svg,

                /**
                 * The radius of the rounded border corners.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/tooltip/bordercolor-default/ 5px by default
                 * @sample {highcharts} highcharts/tooltip/borderradius-0/ Square borders
                 * @sample {highmaps} maps/tooltip/background-border/ Background and border demo
                 * @default 3
                 */
                borderRadius: 3,

                /**
                 * For series on a datetime axes, the date format in the tooltip's
                 * header will by default be guessed based on the closest data points.
                 * This member gives the default string representations used for
                 * each unit. For an overview of the replacement codes, see [dateFormat](#Highcharts.
                 * dateFormat).
                 * 
                 * Defaults to:
                 * 
                 * <pre>{
                 *     millisecond:"%A, %b %e, %H:%M:%S.%L",
                 *     second:"%A, %b %e, %H:%M:%S",
                 *     minute:"%A, %b %e, %H:%M",
                 *     hour:"%A, %b %e, %H:%M",
                 *     day:"%A, %b %e, %Y",
                 *     week:"Week from %A, %b %e, %Y",
                 *     month:"%B %Y",
                 *     year:"%Y"
                 * }</pre>
                 * 
                 * @type {Object}
                 * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
                 * @product highcharts highstock
                 */
                dateTimeLabelFormats: {
                    millisecond: '%A, %b %e, %H:%M:%S.%L',
                    second: '%A, %b %e, %H:%M:%S',
                    minute: '%A, %b %e, %H:%M',
                    hour: '%A, %b %e, %H:%M',
                    day: '%A, %b %e, %Y',
                    week: 'Week from %A, %b %e, %Y',
                    month: '%B %Y',
                    year: '%Y'
                },

                /**
                 * A string to append to the tooltip format.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/tooltip/footerformat/ A table for value alignment
                 * @sample {highmaps} maps/tooltip/format/ Format demo
                 * @default false
                 * @since 2.2
                 * @product highcharts highmaps
                 */
                footerFormat: '',

                /**
                 * Padding inside the tooltip, in pixels.
                 * 
                 * @type {Number}
                 * @default 8
                 * @since 5.0.0
                 */
                padding: 8,

                /**
                 * Proximity snap for graphs or single points. It defaults to 10 for
                 * mouse-powered devices and 25 for touch devices.
                 * 
                 * Note that in most cases the whole plot area captures the mouse
                 * movement, and in these cases `tooltip.snap` doesn't make sense.
                 * This applies when [stickyTracking](#plotOptions.series.stickyTracking)
                 * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
                 * or [split](#tooltip.split).
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/tooltip/bordercolor-default/ 10 px by default
                 * @sample {highcharts} highcharts/tooltip/snap-50/ 50 px on graph
                 * @default 10/25
                 * @since 1.2.0
                 * @product highcharts highstock
                 */
                snap: isTouchDevice ? 25 : 10,


                /**
                 * The background color or gradient for the tooltip.
                 * 
                 * In styled mode, the stroke width is set in the `.highcharts-tooltip-box` class.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/ Yellowish background
                 * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/ Gradient
                 * @sample {highcharts} highcharts/css/tooltip-border-background/ Tooltip in styled mode
                 * @sample {highstock} stock/tooltip/general/ Custom tooltip
                 * @sample {highstock} highcharts/css/tooltip-border-background/ Tooltip in styled mode
                 * @sample {highmaps} maps/tooltip/background-border/ Background and border demo
                 * @sample {highmaps} highcharts/css/tooltip-border-background/ Tooltip in styled mode
                 * @default rgba(247,247,247,0.85)
                 */
                backgroundColor: color('#f7f7f7').setOpacity(0.85).get(),

                /**
                 * The pixel width of the tooltip border.
                 * 
                 * In styled mode, the stroke width is set in the `.highcharts-tooltip-box` class.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/tooltip/bordercolor-default/ 2px by default
                 * @sample {highcharts} highcharts/tooltip/borderwidth/ No border (shadow only)
                 * @sample {highcharts} highcharts/css/tooltip-border-background/ Tooltip in styled mode
                 * @sample {highstock} stock/tooltip/general/ Custom tooltip
                 * @sample {highstock} highcharts/css/tooltip-border-background/ Tooltip in styled mode
                 * @sample {highmaps} maps/tooltip/background-border/ Background and border demo
                 * @sample {highmaps} highcharts/css/tooltip-border-background/ Tooltip in styled mode
                 * @default 1
                 */
                borderWidth: 1,

                /**
                 * The HTML of the tooltip header line. Variables are enclosed by
                 * curly brackets. Available variables are `point.key`, `series.name`,
                 * `series.color` and other members from the `point` and `series`
                 * objects. The `point.key` variable contains the category name, x
                 * value or datetime string depending on the type of axis. For datetime
                 * axes, the `point.key` date format can be set using tooltip.xDateFormat.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/tooltip/footerformat/
                 *         A HTML table in the tooltip
                 * @sample {highstock} highcharts/tooltip/footerformat/
                 *         A HTML table in the tooltip
                 * @sample {highmaps} maps/tooltip/format/ Format demo
                 */
                headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',

                /**
                 * The HTML of the point's line in the tooltip. Variables are enclosed
                 * by curly brackets. Available variables are point.x, point.y, series.
                 * name and series.color and other properties on the same form. Furthermore,
                 * point.y can be extended by the `tooltip.valuePrefix` and `tooltip.
                 * valueSuffix` variables. This can also be overridden for each series,
                 * which makes it a good hook for displaying units.
                 * 
                 * In styled mode, the dot is colored by a class name rather
                 * than the point color.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/tooltip/pointformat/ A different point format with value suffix
                 * @sample {highmaps} maps/tooltip/format/ Format demo
                 * @default <span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>
                 * @since 2.2
                 */
                pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',

                /**
                 * Whether to apply a drop shadow to the tooltip.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/tooltip/bordercolor-default/ True by default
                 * @sample {highcharts} highcharts/tooltip/shadow/ False
                 * @sample {highmaps} maps/tooltip/positioner/ Fixed tooltip position, border and shadow disabled
                 * @default true
                 */
                shadow: true,

                /**
                 * CSS styles for the tooltip. The tooltip can also be styled through
                 * the CSS class `.highcharts-tooltip`.
                 * 
                 * @type {CSSObject}
                 * @sample {highcharts} highcharts/tooltip/style/ Greater padding, bold text
                 * @default { "color": "#333333", "cursor": "default", "fontSize": "12px", "pointerEvents": "none", "whiteSpace": "nowrap" }
                 */
                style: {
                    color: '#333333',
                    cursor: 'default',
                    fontSize: '12px',
                    pointerEvents: 'none', // #1686 http://caniuse.com/#feat=pointer-events
                    whiteSpace: 'nowrap'
                }



                /**
                 * The color of the tooltip border. When `null`, the border takes the
                 * color of the corresponding series or point.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/tooltip/bordercolor-default/
                 *         Follow series by default
                 * @sample {highcharts} highcharts/tooltip/bordercolor-black/
                 *         Black border
                 * @sample {highstock} stock/tooltip/general/
                 *         Styled tooltip
                 * @sample {highmaps} maps/tooltip/background-border/
                 *         Background and border demo
                 * @default null
                 * @apioption tooltip.borderColor
                 */

                /**
                 * Since 4.1, the crosshair definitions are moved to the Axis object
                 * in order for a better separation from the tooltip. See [xAxis.crosshair](#xAxis.
                 * crosshair)<a>.</a>
                 * 
                 * @type {Mixed}
                 * @deprecated
                 * @sample {highcharts} highcharts/tooltip/crosshairs-x/
                 *         Enable a crosshair for the x value
                 * @default true
                 * @apioption tooltip.crosshairs
                 */

                /**
                 * Whether the tooltip should follow the mouse as it moves across columns,
                 * pie slices and other point types with an extent. By default it behaves
                 * this way for scatter, bubble and pie series by override in the `plotOptions`
                 * for those series types.
                 * 
                 * For touch moves to behave the same way, [followTouchMove](#tooltip.
                 * followTouchMove) must be `true` also.
                 * 
                 * @type {Boolean}
                 * @default {highcharts} false
                 * @default {highstock} false
                 * @default {highmaps} true
                 * @since 3.0
                 * @apioption tooltip.followPointer
                 */

                /**
                 * Whether the tooltip should follow the finger as it moves on a touch
                 * device. If this is `true` and [chart.panning](#chart.panning) is
                 * set,`followTouchMove` will take over one-finger touches, so the user
                 * needs to use two fingers for zooming and panning.
                 * 
                 * @type {Boolean}
                 * @default {highcharts} true
                 * @default {highstock} true
                 * @default {highmaps} false
                 * @since 3.0.1
                 * @apioption tooltip.followTouchMove
                 */

                /**
                 * Callback function to format the text of the tooltip from scratch. Return
                 * `false` to disable tooltip for a specific point on series.
                 * 
                 * A subset of HTML is supported. Unless `useHTML` is true, the HTML of the
                 * tooltip is parsed and converted to SVG, therefore this isn't a complete HTML
                 * renderer. The following tags are supported: `<b>`, `<strong>`, `<i>`, `<em>`,
                 * `<br/>`, `<span>`. Spans can be styled with a `style` attribute,
                 * but only text-related CSS that is shared with SVG is handled.
                 * 
                 * Since version 2.1 the tooltip can be shared between multiple series
                 * through the `shared` option. The available data in the formatter
                 * differ a bit depending on whether the tooltip is shared or not. In
                 * a shared tooltip, all properties except `x`, which is common for
                 * all points, are kept in an array, `this.points`.
                 * 
                 * Available data are:
                 * 
                 * <dl>
                 * 
                 * <dt>this.percentage (not shared) / this.points[i].percentage (shared)</dt>
                 * 
                 * <dd>Stacked series and pies only. The point's percentage of the total.
                 * </dd>
                 * 
                 * <dt>this.point (not shared) / this.points[i].point (shared)</dt>
                 * 
                 * <dd>The point object. The point name, if defined, is available through
                 * `this.point.name`.</dd>
                 * 
                 * <dt>this.points</dt>
                 * 
                 * <dd>In a shared tooltip, this is an array containing all other properties
                 * for each point.</dd>
                 * 
                 * <dt>this.series (not shared) / this.points[i].series (shared)</dt>
                 * 
                 * <dd>The series object. The series name is available through
                 * `this.series.name`.</dd>
                 * 
                 * <dt>this.total (not shared) / this.points[i].total (shared)</dt>
                 * 
                 * <dd>Stacked series only. The total value at this point's x value.
                 * </dd>
                 * 
                 * <dt>this.x</dt>
                 * 
                 * <dd>The x value. This property is the same regardless of the tooltip
                 * being shared or not.</dd>
                 * 
                 * <dt>this.y (not shared) / this.points[i].y (shared)</dt>
                 * 
                 * <dd>The y value.</dd>
                 * 
                 * </dl>
                 * 
                 * @type {Function}
                 * @sample {highcharts} highcharts/tooltip/formatter-simple/
                 *         Simple string formatting
                 * @sample {highcharts} highcharts/tooltip/formatter-shared/
                 *         Formatting with shared tooltip
                 * @sample {highstock} stock/tooltip/formatter/
                 *         Formatting with shared tooltip
                 * @sample {highmaps} maps/tooltip/formatter/
                 *         String formatting
                 * @apioption tooltip.formatter
                 */

                /**
                 * The number of milliseconds to wait until the tooltip is hidden when
                 * mouse out from a point or chart.
                 * 
                 * @type {Number}
                 * @default 500
                 * @since 3.0
                 * @product highcharts highmaps
                 * @apioption tooltip.hideDelay
                 */

                /**
                 * A callback function for formatting the HTML output for a single point
                 * in the tooltip. Like the `pointFormat` string, but with more flexibility.
                 * 
                 * @type {Function}
                 * @context Point
                 * @since 4.1.0
                 * @apioption tooltip.pointFormatter
                 */

                /**
                 * A callback function to place the tooltip in a default position. The
                 * callback receives three parameters: `labelWidth`, `labelHeight` and
                 * `point`, where point contains values for `plotX` and `plotY` telling
                 * where the reference point is in the plot area. Add `chart.plotLeft`
                 * and `chart.plotTop` to get the full coordinates.
                 * 
                 * The return should be an object containing x and y values, for example
                 * `{ x: 100, y: 100 }`.
                 * 
                 * @type {Function}
                 * @sample {highcharts} highcharts/tooltip/positioner/ A fixed tooltip position
                 * @sample {highstock} stock/tooltip/positioner/ A fixed tooltip position on top of the chart
                 * @sample {highmaps} maps/tooltip/positioner/ A fixed tooltip position
                 * @since 2.2.4
                 * @apioption tooltip.positioner
                 */

                /**
                 * The name of a symbol to use for the border around the tooltip.
                 * 
                 * @type {String}
                 * @default callout
                 * @validvalue ["callout", "square"]
                 * @since 4.0
                 * @apioption tooltip.shape
                 */

                /**
                 * When the tooltip is shared, the entire plot area will capture mouse
                 * movement or touch events. Tooltip texts for series types with ordered
                 * data (not pie, scatter, flags etc) will be shown in a single bubble.
                 * This is recommended for single series charts and for tablet/mobile
                 * optimized charts.
                 * 
                 * See also [tooltip.split](#tooltip.split), that is better suited for
                 * charts with many series, especially line-type series.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/tooltip/shared-false/ False by default
                 * @sample {highcharts} highcharts/tooltip/shared-true/ True
                 * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/ True with x axis crosshair
                 * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/ True with mixed series types
                 * @default false
                 * @since 2.1
                 * @product highcharts highstock
                 * @apioption tooltip.shared
                 */

                /**
                 * Split the tooltip into one label per series, with the header close
                 * to the axis. This is recommended over [shared](#tooltip.shared) tooltips
                 * for charts with multiple line series, generally making them easier
                 * to read.
                 *
                 * @productdesc {highstock} In Highstock, tooltips are split by default
                 * since v6.0.0. Stock charts typically contain multi-dimension points
                 * and multiple panes, making split tooltips the preferred layout over
                 * the previous `shared` tooltip.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/tooltip/split/ Split tooltip
                 * @sample {highstock} highcharts/tooltip/split/ Split tooltip
                 * @sample {highmaps} highcharts/tooltip/split/ Split tooltip
                 * @default {highcharts} false
                 * @default {highstock} true
                 * @product highcharts highstock
                 * @since 5.0.0
                 * @apioption tooltip.split
                 */

                /**
                 * Use HTML to render the contents of the tooltip instead of SVG. Using
                 * HTML allows advanced formatting like tables and images in the tooltip.
                 * It is also recommended for rtl languages as it works around rtl
                 * bugs in early Firefox.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/tooltip/footerformat/ A table for value alignment
                 * @sample {highcharts} highcharts/tooltip/fullhtml/ Full HTML tooltip
                 * @sample {highstock} highcharts/tooltip/footerformat/ A table for value alignment
                 * @sample {highstock} highcharts/tooltip/fullhtml/ Full HTML tooltip
                 * @sample {highmaps} maps/tooltip/usehtml/ Pure HTML tooltip
                 * @default false
                 * @since 2.2
                 * @apioption tooltip.useHTML
                 */

                /**
                 * How many decimals to show in each series' y value. This is overridable
                 * in each series' tooltip options object. The default is to preserve
                 * all decimals.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @sample {highstock} highcharts/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @sample {highmaps} maps/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @since 2.2
                 * @apioption tooltip.valueDecimals
                 */

                /**
                 * A string to prepend to each series' y value. Overridable in each
                 * series' tooltip options object.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @sample {highstock} highcharts/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @sample {highmaps} maps/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @since 2.2
                 * @apioption tooltip.valuePrefix
                 */

                /**
                 * A string to append to each series' y value. Overridable in each series'
                 * tooltip options object.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @sample {highstock} highcharts/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @sample {highmaps} maps/tooltip/valuedecimals/ Set decimals, prefix and suffix for the value
                 * @since 2.2
                 * @apioption tooltip.valueSuffix
                 */

                /**
                 * The format for the date in the tooltip header if the X axis is a
                 * datetime axis. The default is a best guess based on the smallest
                 * distance between points in the chart.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/tooltip/xdateformat/ A different format
                 * @product highcharts highstock
                 * @apioption tooltip.xDateFormat
                 */
            },


            /**
             * Highchart by default puts a credits label in the lower right corner
             * of the chart. This can be changed using these options.
             */
            credits: {

                /**
                 * Whether to show the credits text.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/credits/enabled-false/ Credits disabled
                 * @sample {highstock} stock/credits/enabled/ Credits disabled
                 * @sample {highmaps} maps/credits/enabled-false/ Credits disabled
                 * @default true
                 */
                enabled: true,

                /**
                 * The URL for the credits label.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/credits/href/ Custom URL and text
                 * @sample {highmaps} maps/credits/customized/ Custom URL and text
                 * @default {highcharts} http://www.highcharts.com
                 * @default {highstock} "http://www.highcharts.com"
                 * @default {highmaps} http://www.highcharts.com
                 */
                href: 'http://www.highcharts.com',

                /**
                 * Position configuration for the credits label.
                 * 
                 * @type {Object}
                 * @sample {highcharts} highcharts/credits/position-left/ Left aligned
                 * @sample {highcharts} highcharts/credits/position-left/ Left aligned
                 * @sample {highmaps} maps/credits/customized/ Left aligned
                 * @sample {highmaps} maps/credits/customized/ Left aligned
                 * @since 2.1
                 */
                position: {

                    /**
                     * Horizontal alignment of the credits.
                     * 
                     * @validvalue ["left", "center", "right"]
                     * @type {String}
                     * @default right
                     */
                    align: 'right',

                    /**
                     * Horizontal pixel offset of the credits.
                     * 
                     * @type {Number}
                     * @default -10
                     */
                    x: -10,

                    /**
                     * Vertical alignment of the credits.
                     * 
                     * @validvalue ["top", "middle", "bottom"]
                     * @type {String}
                     * @default bottom
                     */
                    verticalAlign: 'bottom',

                    /**
                     * Vertical pixel offset of the credits.
                     * 
                     * @type {Number}
                     * @default -5
                     */
                    y: -5
                },


                /**
                 * CSS styles for the credits label.
                 * 
                 * @type {CSSObject}
                 * @see In styled mode, credits styles can be set with the
                 * `.highcharts-credits` class.
                 * @default { "cursor": "pointer", "color": "#999999", "fontSize": "10px" }
                 */
                style: {
                    cursor: 'pointer',
                    color: '#999999',
                    fontSize: '9px'
                },


                /**
                 * The text for the credits label.
                 *
                 * @productdesc {highmaps}
                 * If a map is loaded as GeoJSON, the text defaults to `Highcharts @
                 * {map-credits}`. Otherwise, it defaults to `Highcharts.com`.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/credits/href/ Custom URL and text
                 * @sample {highmaps} maps/credits/customized/ Custom URL and text
                 * @default {highcharts|highstock} Highcharts.com
                 */
                text: 'Highcharts.com'
            }
        };



        /**
         * Sets the getTimezoneOffset function. If the timezone option is set, a default
         * getTimezoneOffset function with that timezone is returned. If not, the
         * specified getTimezoneOffset function is returned. If neither are specified,
         * undefined is returned.
         * @return {function} a getTimezoneOffset function or undefined
         */
        function getTimezoneOffsetOption() {
            var globalOptions = H.defaultOptions.global,
                moment = win.moment;

            if (globalOptions.timezone) {
                if (!moment) {
                    // getTimezoneOffset-function stays undefined because it depends on
                    // Moment.js
                    H.error(25);

                } else {
                    return function(timestamp) {
                        return -moment.tz(
                            timestamp,
                            globalOptions.timezone
                        ).utcOffset();
                    };
                }
            }

            // If not timezone is set, look for the getTimezoneOffset callback
            return globalOptions.useUTC && globalOptions.getTimezoneOffset;
        }

        /**
         * Set the time methods globally based on the useUTC option. Time method can be
         *   either local time or UTC (default). It is called internally on initiating
         *   Highcharts and after running `Highcharts.setOptions`.
         *
         * @private
         */
        function setTimeMethods() {
            var globalOptions = H.defaultOptions.global,
                Date,
                useUTC = globalOptions.useUTC,
                GET = useUTC ? 'getUTC' : 'get',
                SET = useUTC ? 'setUTC' : 'set',
                setters = ['Minutes', 'Hours', 'Day', 'Date', 'Month', 'FullYear'],
                getters = setters.concat(['Milliseconds', 'Seconds']),
                n;

            H.Date = Date = globalOptions.Date || win.Date; // Allow using a different Date class
            Date.hcTimezoneOffset = useUTC && globalOptions.timezoneOffset;
            Date.hcGetTimezoneOffset = getTimezoneOffsetOption();
            Date.hcMakeTime = function(year, month, date, hours, minutes, seconds) {
                var d;
                if (useUTC) {
                    d = Date.UTC.apply(0, arguments);
                    d += getTZOffset(d);
                } else {
                    d = new Date(
                        year,
                        month,
                        pick(date, 1),
                        pick(hours, 0),
                        pick(minutes, 0),
                        pick(seconds, 0)
                    ).getTime();
                }
                return d;
            };

            // Dynamically set setters and getters. Use for loop, H.each is not yet 
            // overridden in oldIE.
            for (n = 0; n < setters.length; n++) {
                Date['hcGet' + setters[n]] = GET + setters[n];
            }
            for (n = 0; n < getters.length; n++) {
                Date['hcSet' + getters[n]] = SET + getters[n];
            }
        }

        /**
         * Merge the default options with custom options and return the new options
         * structure. Commonly used for defining reusable templates.
         *
         * @function #setOptions
         * @memberOf  Highcharts
         * @sample highcharts/global/useutc-false Setting a global option
         * @sample highcharts/members/setoptions Applying a global theme
         * @param {Object} options The new custom chart options.
         * @returns {Object} Updated options.
         */
        H.setOptions = function(options) {

            // Copy in the default options
            H.defaultOptions = merge(true, H.defaultOptions, options);

            // Apply UTC
            setTimeMethods();

            return H.defaultOptions;
        };

        /**
         * Get the updated default options. Until 3.0.7, merely exposing defaultOptions for outside modules
         * wasn't enough because the setOptions method created a new object.
         */
        H.getOptions = function() {
            return H.defaultOptions;
        };


        // Series defaults
        H.defaultPlotOptions = H.defaultOptions.plotOptions;

        // set the default time methods
        setTimeMethods();

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var correctFloat = H.correctFloat,
            defined = H.defined,
            destroyObjectProperties = H.destroyObjectProperties,
            isNumber = H.isNumber,
            merge = H.merge,
            pick = H.pick,
            deg2rad = H.deg2rad;

        /**
         * The Tick class
         */
        H.Tick = function(axis, pos, type, noLabel) {
            this.axis = axis;
            this.pos = pos;
            this.type = type || '';
            this.isNew = true;
            this.isNewLabel = true;

            if (!type && !noLabel) {
                this.addLabel();
            }
        };

        H.Tick.prototype = {
            /**
             * Write the tick label
             */
            addLabel: function() {
                var tick = this,
                    axis = tick.axis,
                    options = axis.options,
                    chart = axis.chart,
                    categories = axis.categories,
                    names = axis.names,
                    pos = tick.pos,
                    labelOptions = options.labels,
                    str,
                    tickPositions = axis.tickPositions,
                    isFirst = pos === tickPositions[0],
                    isLast = pos === tickPositions[tickPositions.length - 1],
                    value = categories ?
                    pick(categories[pos], names[pos], pos) :
                    pos,
                    label = tick.label,
                    tickPositionInfo = tickPositions.info,
                    dateTimeLabelFormat;

                // Set the datetime label format. If a higher rank is set for this
                // position, use that. If not, use the general format.
                if (axis.isDatetimeAxis && tickPositionInfo) {
                    dateTimeLabelFormat =
                        options.dateTimeLabelFormats[
                            tickPositionInfo.higherRanks[pos] ||
                            tickPositionInfo.unitName
                        ];
                }
                // set properties for access in render method
                tick.isFirst = isFirst;
                tick.isLast = isLast;

                // get the string
                str = axis.labelFormatter.call({
                    axis: axis,
                    chart: chart,
                    isFirst: isFirst,
                    isLast: isLast,
                    dateTimeLabelFormat: dateTimeLabelFormat,
                    value: axis.isLog ? correctFloat(axis.lin2log(value)) : value,
                    pos: pos
                });

                // first call
                if (!defined(label)) {

                    tick.label = label =
                        defined(str) && labelOptions.enabled ?
                        chart.renderer.text(
                            str,
                            0,
                            0,
                            labelOptions.useHTML
                        )

                        // without position absolute, IE export sometimes is
                        // wrong.
                        .css(merge(labelOptions.style))

                        .add(axis.labelGroup) :
                        null;

                    // Un-rotated length
                    tick.labelLength = label && label.getBBox().width;
                    // Base value to detect change for new calls to getBBox
                    tick.rotation = 0;

                    // update
                } else if (label) {
                    label.attr({
                        text: str
                    });
                }
            },

            /**
             * Get the offset height or width of the label
             */
            getLabelSize: function() {
                return this.label ?
                    this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
                    0;
            },

            /**
             * Handle the label overflow by adjusting the labels to the left and right
             * edge, or hide them if they collide into the neighbour label.
             */
            handleOverflow: function(xy) {
                var axis = this.axis,
                    pxPos = xy.x,
                    chartWidth = axis.chart.chartWidth,
                    spacing = axis.chart.spacing,
                    leftBound = pick(axis.labelLeft, Math.min(axis.pos, spacing[3])),
                    rightBound = pick(
                        axis.labelRight,
                        Math.max(axis.pos + axis.len, chartWidth - spacing[1])
                    ),
                    label = this.label,
                    rotation = this.rotation,
                    factor = {
                        left: 0,
                        center: 0.5,
                        right: 1
                    }[axis.labelAlign],
                    labelWidth = label.getBBox().width,
                    slotWidth = axis.getSlotWidth(),
                    modifiedSlotWidth = slotWidth,
                    xCorrection = factor,
                    goRight = 1,
                    leftPos,
                    rightPos,
                    textWidth,
                    css = {};

                // Check if the label overshoots the chart spacing box. If it does, move
                // it. If it now overshoots the slotWidth, add ellipsis.
                if (!rotation) {
                    leftPos = pxPos - factor * labelWidth;
                    rightPos = pxPos + (1 - factor) * labelWidth;

                    if (leftPos < leftBound) {
                        modifiedSlotWidth = xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
                    } else if (rightPos > rightBound) {
                        modifiedSlotWidth =
                            rightBound - xy.x + modifiedSlotWidth * factor;
                        goRight = -1;
                    }

                    modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
                    if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
                        xy.x += (
                            goRight *
                            (
                                slotWidth -
                                modifiedSlotWidth -
                                xCorrection * (
                                    slotWidth - Math.min(labelWidth, modifiedSlotWidth)
                                )
                            )
                        );
                    }
                    // If the label width exceeds the available space, set a text width
                    // to be picked up below. Also, if a width has been set before, we
                    // need to set a new one because the reported labelWidth will be
                    // limited by the box (#3938).
                    if (
                        labelWidth > modifiedSlotWidth ||
                        (axis.autoRotation && (label.styles || {}).width)
                    ) {
                        textWidth = modifiedSlotWidth;
                    }

                    // Add ellipsis to prevent rotated labels to be clipped against the edge
                    // of the chart
                } else if (rotation < 0 && pxPos - factor * labelWidth < leftBound) {
                    textWidth = Math.round(
                        pxPos / Math.cos(rotation * deg2rad) - leftBound
                    );
                } else if (rotation > 0 && pxPos + factor * labelWidth > rightBound) {
                    textWidth = Math.round(
                        (chartWidth - pxPos) / Math.cos(rotation * deg2rad)
                    );
                }

                if (textWidth) {
                    css.width = textWidth;
                    if (!(axis.options.labels.style || {}).textOverflow) {
                        css.textOverflow = 'ellipsis';
                    }
                    label.css(css);
                }
            },

            /**
             * Get the x and y position for ticks and labels
             */
            getPosition: function(horiz, pos, tickmarkOffset, old) {
                var axis = this.axis,
                    chart = axis.chart,
                    cHeight = (old && chart.oldChartHeight) || chart.chartHeight;

                return {
                    x: horiz ?
                        (
                            axis.translate(pos + tickmarkOffset, null, null, old) +
                            axis.transB
                        ) :
                        (
                            axis.left +
                            axis.offset +
                            (
                                axis.opposite ?
                                (
                                    (
                                        (old && chart.oldChartWidth) ||
                                        chart.chartWidth
                                    ) -
                                    axis.right -
                                    axis.left
                                ) :
                                0
                            )
                        ),

                    y: horiz ?
                        (
                            cHeight -
                            axis.bottom +
                            axis.offset -
                            (axis.opposite ? axis.height : 0)
                        ) :
                        (
                            cHeight -
                            axis.translate(pos + tickmarkOffset, null, null, old) -
                            axis.transB
                        )
                };

            },

            /**
             * Get the x, y position of the tick label
             */
            getLabelPosition: function(
                x,
                y,
                label,
                horiz,
                labelOptions,
                tickmarkOffset,
                index,
                step
            ) {
                var axis = this.axis,
                    transA = axis.transA,
                    reversed = axis.reversed,
                    staggerLines = axis.staggerLines,
                    rotCorr = axis.tickRotCorr || {
                        x: 0,
                        y: 0
                    },
                    yOffset = labelOptions.y,
                    line;

                if (!defined(yOffset)) {
                    if (axis.side === 0) {
                        yOffset = label.rotation ? -8 : -label.getBBox().height;
                    } else if (axis.side === 2) {
                        yOffset = rotCorr.y + 8;
                    } else {
                        // #3140, #3140
                        yOffset = Math.cos(label.rotation * deg2rad) *
                            (rotCorr.y - label.getBBox(false, 0).height / 2);
                    }
                }

                x = x + labelOptions.x + rotCorr.x - (tickmarkOffset && horiz ?
                    tickmarkOffset * transA * (reversed ? -1 : 1) : 0);
                y = y + yOffset - (tickmarkOffset && !horiz ?
                    tickmarkOffset * transA * (reversed ? 1 : -1) : 0);

                // Correct for staggered labels
                if (staggerLines) {
                    line = (index / (step || 1) % staggerLines);
                    if (axis.opposite) {
                        line = staggerLines - line - 1;
                    }
                    y += line * (axis.labelOffset / staggerLines);
                }

                return {
                    x: x,
                    y: Math.round(y)
                };
            },

            /**
             * Extendible method to return the path of the marker
             */
            getMarkPath: function(x, y, tickLength, tickWidth, horiz, renderer) {
                return renderer.crispLine([
                    'M',
                    x,
                    y,
                    'L',
                    x + (horiz ? 0 : -tickLength),
                    y + (horiz ? tickLength : 0)
                ], tickWidth);
            },

            /**
             * Renders the gridLine.
             * @param  {Boolean} old         Whether or not the tick is old
             * @param  {number} opacity      The opacity of the grid line
             * @param  {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
             * @return {undefined}
             */
            renderGridLine: function(old, opacity, reverseCrisp) {
                var tick = this,
                    axis = tick.axis,
                    options = axis.options,
                    gridLine = tick.gridLine,
                    gridLinePath,
                    attribs = {},
                    pos = tick.pos,
                    type = tick.type,
                    tickmarkOffset = axis.tickmarkOffset,
                    renderer = axis.chart.renderer;


                var gridPrefix = type ? type + 'Grid' : 'grid',
                    gridLineWidth = options[gridPrefix + 'LineWidth'],
                    gridLineColor = options[gridPrefix + 'LineColor'],
                    dashStyle = options[gridPrefix + 'LineDashStyle'];


                if (!gridLine) {

                    attribs.stroke = gridLineColor;
                    attribs['stroke-width'] = gridLineWidth;
                    if (dashStyle) {
                        attribs.dashstyle = dashStyle;
                    }

                    if (!type) {
                        attribs.zIndex = 1;
                    }
                    if (old) {
                        attribs.opacity = 0;
                    }
                    tick.gridLine = gridLine = renderer.path()
                        .attr(attribs)
                        .addClass(
                            'highcharts-' + (type ? type + '-' : '') + 'grid-line'
                        )
                        .add(axis.gridGroup);
                }

                // If the parameter 'old' is set, the current call will be followed
                // by another call, therefore do not do any animations this time
                if (!old && gridLine) {
                    gridLinePath = axis.getPlotLinePath(
                        pos + tickmarkOffset,
                        gridLine.strokeWidth() * reverseCrisp,
                        old, true
                    );
                    if (gridLinePath) {
                        gridLine[tick.isNew ? 'attr' : 'animate']({
                            d: gridLinePath,
                            opacity: opacity
                        });
                    }
                }
            },

            /**
             * Renders the tick mark.
             * @param  {Object} xy           The position vector of the mark
             * @param  {number} xy.x         The x position of the mark
             * @param  {number} xy.y         The y position of the mark
             * @param  {number} opacity      The opacity of the mark
             * @param  {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
             * @return {undefined}
             */
            renderMark: function(xy, opacity, reverseCrisp) {
                var tick = this,
                    axis = tick.axis,
                    options = axis.options,
                    renderer = axis.chart.renderer,
                    type = tick.type,
                    tickPrefix = type ? type + 'Tick' : 'tick',
                    tickSize = axis.tickSize(tickPrefix),
                    mark = tick.mark,
                    isNewMark = !mark,
                    x = xy.x,
                    y = xy.y;


                var tickWidth = pick(
                        options[tickPrefix + 'Width'], !type && axis.isXAxis ? 1 : 0
                    ), // X axis defaults to 1
                    tickColor = options[tickPrefix + 'Color'];


                if (tickSize) {

                    // negate the length
                    if (axis.opposite) {
                        tickSize[0] = -tickSize[0];
                    }

                    // First time, create it
                    if (isNewMark) {
                        tick.mark = mark = renderer.path()
                            .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
                            .add(axis.axisGroup);


                        mark.attr({
                            stroke: tickColor,
                            'stroke-width': tickWidth
                        });

                    }
                    mark[isNewMark ? 'attr' : 'animate']({
                        d: tick.getMarkPath(
                            x,
                            y,
                            tickSize[0],
                            mark.strokeWidth() * reverseCrisp,
                            axis.horiz,
                            renderer),
                        opacity: opacity
                    });

                }
            },

            /**
             * Renders the tick label.
             * Note: The label should already be created in init(), so it should only
             * have to be moved into place.
             * @param  {Object} xy      The position vector of the label
             * @param  {number} xy.x    The x position of the label
             * @param  {number} xy.y    The y position of the label
             * @param  {Boolean} old    Whether or not the tick is old
             * @param  {number} opacity The opacity of the label
             * @param  {number} index   The index of the tick
             * @return {undefined}
             */
            renderLabel: function(xy, old, opacity, index) {
                var tick = this,
                    axis = tick.axis,
                    horiz = axis.horiz,
                    options = axis.options,
                    label = tick.label,
                    labelOptions = options.labels,
                    step = labelOptions.step,
                    tickmarkOffset = axis.tickmarkOffset,
                    show = true,
                    x = xy.x,
                    y = xy.y;
                if (label && isNumber(x)) {
                    label.xy = xy = tick.getLabelPosition(
                        x,
                        y,
                        label,
                        horiz,
                        labelOptions,
                        tickmarkOffset,
                        index,
                        step
                    );

                    // Apply show first and show last. If the tick is both first and
                    // last, it is a single centered tick, in which case we show the
                    // label anyway (#2100).
                    if (
                        (
                            tick.isFirst &&
                            !tick.isLast &&
                            !pick(options.showFirstLabel, 1)
                        ) ||
                        (
                            tick.isLast &&
                            !tick.isFirst &&
                            !pick(options.showLastLabel, 1)
                        )
                    ) {
                        show = false;

                        // Handle label overflow and show or hide accordingly
                    } else if (horiz && !axis.isRadial && !labelOptions.step &&
                        !labelOptions.rotation && !old && opacity !== 0) {
                        tick.handleOverflow(xy);
                    }

                    // apply step
                    if (step && index % step) {
                        // show those indices dividable by step
                        show = false;
                    }

                    // Set the new position, and show or hide
                    if (show && isNumber(xy.y)) {
                        xy.opacity = opacity;
                        label[tick.isNewLabel ? 'attr' : 'animate'](xy);
                        tick.isNewLabel = false;
                    } else {
                        label.attr('y', -9999); // #1338
                        tick.isNewLabel = true;
                    }
                }
            },

            /**
             * Put everything in place
             *
             * @param index {Number}
             * @param old {Boolean} Use old coordinates to prepare an animation into new
             *                      position
             */
            render: function(index, old, opacity) {
                var tick = this,
                    axis = tick.axis,
                    horiz = axis.horiz,
                    pos = tick.pos,
                    tickmarkOffset = axis.tickmarkOffset,
                    xy = tick.getPosition(horiz, pos, tickmarkOffset, old),
                    x = xy.x,
                    y = xy.y,
                    reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
                        (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687

                opacity = pick(opacity, 1);
                this.isActive = true;

                // Create the grid line
                this.renderGridLine(old, opacity, reverseCrisp);

                // create the tick mark
                this.renderMark(xy, opacity, reverseCrisp);

                // the label is created on init - now move it into place
                this.renderLabel(xy, old, opacity, index);

                tick.isNew = false;
            },

            /**
             * Destructor for the tick prototype
             */
            destroy: function() {
                destroyObjectProperties(this, this.axis);
            }
        };

    }(Highcharts));
    var Axis = (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */

        var addEvent = H.addEvent,
            animObject = H.animObject,
            arrayMax = H.arrayMax,
            arrayMin = H.arrayMin,
            color = H.color,
            correctFloat = H.correctFloat,
            defaultOptions = H.defaultOptions,
            defined = H.defined,
            deg2rad = H.deg2rad,
            destroyObjectProperties = H.destroyObjectProperties,
            each = H.each,
            extend = H.extend,
            fireEvent = H.fireEvent,
            format = H.format,
            getMagnitude = H.getMagnitude,
            grep = H.grep,
            inArray = H.inArray,
            isArray = H.isArray,
            isNumber = H.isNumber,
            isString = H.isString,
            merge = H.merge,
            normalizeTickInterval = H.normalizeTickInterval,
            objectEach = H.objectEach,
            pick = H.pick,
            removeEvent = H.removeEvent,
            splat = H.splat,
            syncTimeout = H.syncTimeout,
            Tick = H.Tick;

        /**
         * Create a new axis object. Called internally when instanciating a new chart or
         * adding axes by {@link Highcharts.Chart#addAxis}.
         *
         * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
         * series cartesian chart, there is one X axis and one Y axis.
         * 
         * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
         * an array of Axis objects. If there is only one axis, it can be referenced
         * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
         * pattern goes for Y axes.
         * 
         * If you need to get the axes from a series object, use the `series.xAxis` and
         * `series.yAxis` properties. These are not arrays, as one series can only be
         * associated to one X and one Y axis.
         * 
         * A third way to reference the axis programmatically is by `id`. Add an `id` in
         * the axis configuration options, and get the axis by
         * {@link Highcharts.Chart#get}.
         * 
         * Configuration options for the axes are given in options.xAxis and
         * options.yAxis.
         * 
         * @class Highcharts.Axis
         * @memberOf Highcharts
         * @param {Highcharts.Chart} chart - The Chart instance to apply the axis on.
         * @param {Object} options - Axis options
         */
        var Axis = function() {
            this.init.apply(this, arguments);
        };

        H.extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {

            /**
             * The X axis or category axis. Normally this is the horizontal axis,
             * though if the chart is inverted this is the vertical axis. In case of
             * multiple axes, the xAxis node is an array of configuration objects.
             * 
             * See [../class-reference/Highcharts.Axis](the Axis object) for
             * programmatic access to the axis.
             *
             * @productdesc {highmaps}
             * In Highmaps, the axis is hidden, but it is used behind the scenes to
             * control features like zooming and panning. Zooming is in effect the same
             * as setting the extremes of one of the exes.
             * 
             * @optionparent xAxis
             */
            defaultOptions: {
                // allowDecimals: null,
                // alternateGridColor: null,
                // categories: [],

                /**
                 * For a datetime axis, the scale will automatically adjust to the
                 * appropriate unit. This member gives the default string
                 * representations used for each unit. For intermediate values,
                 * different units may be used, for example the `day` unit can be used
                 * on midnight and `hour` unit be used for intermediate values on the
                 * same axis. For an overview of the replacement codes, see
                 * [dateFormat](#Highcharts.dateFormat). Defaults to:
                 * 
                 * <pre>{
                 *     millisecond: '%H:%M:%S.%L',
                 *     second: '%H:%M:%S',
                 *     minute: '%H:%M',
                 *     hour: '%H:%M',
                 *     day: '%e. %b',
                 *     week: '%e. %b',
                 *     month: '%b \'%y',
                 *     year: '%Y'
                 * }</pre>
                 * 
                 * @type {Object}
                 * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
                 *         Different day format on X axis
                 * @sample {highstock} stock/xaxis/datetimelabelformats/
                 *         More information in x axis labels
                 * @product highcharts highstock
                 */
                dateTimeLabelFormats: {
                    millisecond: '%H:%M:%S.%L',
                    second: '%H:%M:%S',
                    minute: '%H:%M',
                    hour: '%H:%M',
                    day: '%e. %b',
                    week: '%e. %b',
                    month: '%b \'%y',
                    year: '%Y'
                },

                /**
                 * Whether to force the axis to end on a tick. Use this option with
                 * the `maxPadding` option to control the axis end.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/reflow-true/ True by default
                 * @sample {highcharts} highcharts/yaxis/endontick/ False
                 * @sample {highstock} stock/demo/basic-line/ True by default
                 * @sample {highstock} stock/xaxis/endontick/ False
                 * @default false
                 * @since 1.2.0
                 */
                endOnTick: false,
                // reversed: false,


                /**
                 * The axis labels show the number or category for each tick.
                 *
                 * @productdesc {highmaps}
                 * X and Y axis labels are by default disabled in Highmaps, but the
                 * functionality is inherited from Highcharts and used on `colorAxis`,
                 * and can be enabled on X and Y axes too.
                 */
                labels: {

                    /**
                     * Enable or disable the axis labels.
                     * 
                     * @type {Boolean}
                     * @sample  {highcharts} highcharts/xaxis/labels-enabled/
                     *          X axis labels disabled
                     * @sample  {highstock} stock/xaxis/labels-enabled/
                     *          X axis labels disabled
                     * @default {highstock} true
                     * @default {highmaps} false
                     */
                    enabled: true,
                    // rotation: 0,
                    // align: 'center',
                    // step: null,


                    /**
                     * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
                     * wrapping of category labels. Use `textOverflow: 'none'` to
                     * prevent ellipsis (dots).
                     * 
                     * In styled mode, the labels are styled with the
                     * `.highcharts-axis-labels` class.
                     * 
                     * @type {CSSObject}
                     * @sample  {highcharts} highcharts/xaxis/labels-style/
                     *          Red X axis labels
                     */
                    style: {
                        color: '#666666',
                        cursor: 'default',
                        fontSize: '11px'
                    },


                    /**
                     * The x position offset of the label relative to the tick position
                     * on the axis.
                     * 
                     * @type {Number}
                     * @sample  {highcharts} highcharts/xaxis/labels-x/
                     *          Y axis labels placed on grid lines
                     * @default 0
                     */
                    x: 0
                },

                /**
                 * Padding of the min value relative to the length of the axis. A
                 * padding of 0.05 will make a 100px axis 5px longer. This is useful
                 * when you don't want the lowest data value to appear on the edge
                 * of the plot area. When the axis' `min` option is set or a min extreme
                 * is set using `axis.setExtremes()`, the minPadding will be ignored.
                 * 
                 * @type {Number}
                 * @sample  {highcharts} highcharts/yaxis/minpadding/
                 *          Min padding of 0.2
                 * @sample  {highstock} stock/xaxis/minpadding-maxpadding/
                 *          Greater min- and maxPadding
                 * @sample  {highmaps} maps/chart/plotbackgroundcolor-gradient/
                 *          Add some padding
                 * @default {highcharts} 0.01
                 * @default {highstock} 0
                 * @default {highmaps} 0
                 * @since 1.2.0
                 */
                minPadding: 0.01,

                /**
                 * Padding of the max value relative to the length of the axis. A
                 * padding of 0.05 will make a 100px axis 5px longer. This is useful
                 * when you don't want the highest data value to appear on the edge
                 * of the plot area. When the axis' `max` option is set or a max extreme
                 * is set using `axis.setExtremes()`, the maxPadding will be ignored.
                 * 
                 * @type {Number}
                 * @sample  {highcharts} highcharts/yaxis/maxpadding/
                 *          Max padding of 0.25 on y axis
                 * @sample  {highstock} stock/xaxis/minpadding-maxpadding/
                 *          Greater min- and maxPadding
                 * @sample  {highmaps} maps/chart/plotbackgroundcolor-gradient/
                 *          Add some padding
                 * @default {highcharts} 0.01
                 * @default {highstock} 0
                 * @default {highmaps} 0
                 * @since 1.2.0
                 */
                maxPadding: 0.01,

                /**
                 * The pixel length of the minor tick marks.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/yaxis/minorticklength/ 10px on Y axis
                 * @sample {highstock} stock/xaxis/minorticks/ 10px on Y axis
                 * @default 2
                 */
                minorTickLength: 2,

                /**
                 * The position of the minor tick marks relative to the axis line.
                 *  Can be one of `inside` and `outside`.
                 * 
                 * @validvalue ["inside", "outside"]
                 * @type {String}
                 * @sample  {highcharts} highcharts/yaxis/minortickposition-outside/
                 *          Outside by default
                 * @sample  {highcharts} highcharts/yaxis/minortickposition-inside/
                 *          Inside
                 * @sample  {highstock} stock/xaxis/minorticks/ Inside
                 * @default outside
                 */
                minorTickPosition: 'outside', // inside or outside

                /**
                 * For datetime axes, this decides where to put the tick between weeks.
                 *  0 = Sunday, 1 = Monday.
                 * 
                 * @type {Number}
                 * @sample  {highcharts} highcharts/xaxis/startofweek-monday/
                 *          Monday by default
                 * @sample  {highcharts} highcharts/xaxis/startofweek-sunday/
                 *          Sunday
                 * @sample  {highstock} stock/xaxis/startofweek-1
                 *          Monday by default
                 * @sample  {highstock} stock/xaxis/startofweek-0
                 *          Sunday
                 * @default 1
                 * @product highcharts highstock
                 */
                startOfWeek: 1,

                /**
                 * Whether to force the axis to start on a tick. Use this option with
                 * the `minPadding` option to control the axis start.
                 *
                 * @productdesc {highstock}
                 * In Highstock, `startOnTick` is always false when the navigator is
                 * enabled, to prevent jumpy scrolling.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/xaxis/startontick-false/
                 *         False by default
                 * @sample {highcharts} highcharts/xaxis/startontick-true/
                 *         True
                 * @sample {highstock} stock/xaxis/endontick/
                 *         False for Y axis
                 * @default false
                 * @since 1.2.0
                 */
                startOnTick: false,

                /**
                 * The pixel length of the main tick marks.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/xaxis/ticklength/
                 *         20 px tick length on the X axis
                 * @sample {highstock} stock/xaxis/ticks/
                 *         Formatted ticks on X axis
                 * @default 10
                 */
                tickLength: 10,

                /**
                 * For categorized axes only. If `on` the tick mark is placed in the
                 * center of the category, if `between` the tick mark is placed between
                 * categories. The default is `between` if the `tickInterval` is 1,
                 *  else `on`.
                 * 
                 * @validvalue [null, "on", "between"]
                 * @type {String}
                 * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
                 *         "between" by default
                 * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
                 *         "on"
                 * @default null
                 * @product highcharts
                 */
                tickmarkPlacement: 'between', // on or between

                /**
                 * If tickInterval is `null` this option sets the approximate pixel
                 * interval of the tick marks. Not applicable to categorized axis.
                 * 
                 * 
                 * The tick interval is also influenced by the [minTickInterval](#xAxis.
                 * minTickInterval) option, that, by default prevents ticks from being
                 * denser than the data points.
                 * 
                 * Defaults to `72` for the Y axis and `100` for the X axis.
                 * 
                 * @type {Number}
                 * @see    [tickInterval](#xAxis.tickInterval),
                 *         [tickPositioner](#xAxis.tickPositioner),
                 *         [tickPositions](#xAxis.tickPositions).
                 * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
                 *         50 px on X axis
                 * @sample {highstock} stock/xaxis/tickpixelinterval/
                 *         200 px on X axis
                 */
                tickPixelInterval: 100,

                /**
                 * The position of the major tick marks relative to the axis line.
                 *  Can be one of `inside` and `outside`.
                 * 
                 * @validvalue ["inside", "outside"]
                 * @type {String}
                 * @sample {highcharts} highcharts/xaxis/tickposition-outside/
                 *         "outside" by default
                 * @sample {highcharts} highcharts/xaxis/tickposition-inside/
                 *         "inside"
                 * @sample {highstock} stock/xaxis/ticks/
                 *         Formatted ticks on X axis
                 * @default {highcharts} outside
                 * @default {highstock} "outside"
                 * @default {highmaps} outside
                 */
                tickPosition: 'outside',

                /**
                 * The axis title, showing next to the axis line.
                 *
                 * @productdesc {highmaps}
                 * In Highmaps, the axis is hidden by default, but adding an axis title
                 * is still possible. X axis and Y axis titles will appear at the bottom
                 * and left by default.
                 */
                title: {

                    /**
                     * Alignment of the title relative to the axis values. Possible
                     * values are "low", "middle" or "high".
                     * 
                     * @validvalue ["low", "middle", "high"]
                     * @type {String}
                     * @sample {highcharts} highcharts/xaxis/title-align-low/
                     *         "low"
                     * @sample {highcharts} highcharts/xaxis/title-align-center/
                     *         "middle" by default
                     * @sample {highcharts} highcharts/xaxis/title-align-high/
                     *         "high"
                     * @sample {highcharts} highcharts/yaxis/title-offset/
                     *         Place the Y axis title on top of the axis
                     * @sample {highstock} stock/xaxis/title-align/
                     *         Aligned to "high" value
                     * @default {highcharts} middle
                     * @default {highstock} "middle"
                     * @default {highmaps} middle
                     */
                    align: 'middle', // low, middle or high



                    /**
                     * CSS styles for the title. If the title text is longer than the
                     * axis length, it will wrap to multiple lines by default. This can
                     * be customized by setting `textOverflow: 'ellipsis'`, by 
                     * setting a specific `width` or by setting `wordSpace: 'nowrap'`.
                     * 
                     * 
                     * In styled mode, the stroke width is given in the
                     * `.highcharts-axis-title` class.
                     * 
                     * @type {CSSObject}
                     * @sample {highcharts} highcharts/xaxis/title-style/ Red
                     * @sample {highcharts} highcharts/css/axis/ Styled mode
                     * @default { "color": "#666666" }
                     */
                    style: {
                        color: '#666666'
                    }

                },

                /**
                 * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
                 * or `category`. In a datetime axis, the numbers are given in
                 * milliseconds, and tick marks are placed on appropriate values like
                 * full hours or days. In a category axis, the 
                 * [point names](#series.line.data.name) of the chart's series are used
                 * for categories, if not a [categories](#xAxis.categories) array is
                 * defined.
                 * 
                 * @validvalue ["linear", "logarithmic", "datetime", "category"]
                 * @type {String}
                 * @sample {highcharts} highcharts/xaxis/type-linear/
                 *         Linear
                 * @sample {highcharts} highcharts/yaxis/type-log/
                 *         Logarithmic
                 * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
                 *         Logarithmic with minor grid lines
                 * @sample {highcharts} highcharts/xaxis/type-log-both/
                 *         Logarithmic on two axes
                 * @sample {highcharts} highcharts/yaxis/type-log-negative/
                 *         Logarithmic with extension to emulate negative values
                 * @default linear
                 * @product highcharts
                 */
                type: 'linear', // linear, logarithmic or datetime



                /**
                 * Color of the minor, secondary grid lines.
                 * 
                 * In styled mode, the stroke width is given in the
                 * `.highcharts-minor-grid-line` class.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
                 *         Bright grey lines from Y axis
                 * @sample {highcharts} highcharts/css/axis-grid/
                 *         Styled mode
                 * @sample {highstock} stock/xaxis/minorgridlinecolor/
                 *         Bright grey lines from Y axis
                 * @sample {highstock} highcharts/css/axis-grid/
                 *         Styled mode
                 * @default #f2f2f2
                 */
                minorGridLineColor: '#f2f2f2',
                // minorGridLineDashStyle: null,

                /**
                 * Width of the minor, secondary grid lines.
                 * 
                 * In styled mode, the stroke width is given in the
                 * `.highcharts-grid-line` class.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
                 *         2px lines from Y axis
                 * @sample {highcharts} highcharts/css/axis-grid/
                 *         Styled mode
                 * @sample {highstock} stock/xaxis/minorgridlinewidth/
                 *         2px lines from Y axis
                 * @sample {highstock} highcharts/css/axis-grid/
                 *         Styled mode
                 * @default 1
                 */
                minorGridLineWidth: 1,

                /**
                 * Color for the minor tick marks.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/yaxis/minortickcolor/
                 *         Black tick marks on Y axis
                 * @sample {highstock} stock/xaxis/minorticks/
                 *         Black tick marks on Y axis
                 * @default #999999
                 */
                minorTickColor: '#999999',

                /**
                 * The color of the line marking the axis itself.
                 * 
                 * In styled mode, the line stroke is given in the
                 * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
                 * 
                 * @productdesc {highmaps}
                 * In Highmaps, the axis line is hidden by default.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/yaxis/linecolor/ A red line on Y axis
                 * @sample {highcharts} highcharts/css/axis/ Axes in styled mode
                 * @sample {highstock} stock/xaxis/linecolor/ A red line on X axis
                 * @sample {highstock} highcharts/css/axis/ Axes in styled mode
                 * @default #ccd6eb
                 */
                lineColor: '#ccd6eb',

                /**
                 * The width of the line marking the axis itself.
                 * 
                 * In styled mode, the stroke width is given in the
                 * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/yaxis/linecolor/ A 1px line on Y axis
                 * @sample {highcharts} highcharts/css/axis/ Axes in styled mode
                 * @sample {highstock} stock/xaxis/linewidth/ A 2px line on X axis
                 * @sample {highstock} highcharts/css/axis/ Axes in styled mode
                 * @default {highcharts} 1
                 * @default {highstock} 1
                 * @default {highmaps} 0
                 */
                lineWidth: 1,

                /**
                 * Color of the grid lines extending the ticks across the plot area.
                 * 
                 * In styled mode, the stroke is given in the `.highcharts-grid-line`
                 * class.
                 *
                 * @productdesc {highmaps}
                 * In Highmaps, the grid lines are hidden by default.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/yaxis/gridlinecolor/ Green lines
                 * @sample {highcharts} highcharts/css/axis-grid/ Styled mode
                 * @sample {highstock} stock/xaxis/gridlinecolor/ Green lines
                 * @sample {highstock} highcharts/css/axis-grid/ Styled mode
                 * @default #e6e6e6
                 */
                gridLineColor: '#e6e6e6',
                // gridLineDashStyle: 'solid',
                // gridLineWidth: 0,

                /**
                 * Color for the main tick marks.
                 * 
                 * In styled mode, the stroke is given in the `.highcharts-tick`
                 * class.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/xaxis/tickcolor/ Red ticks on X axis
                 * @sample {highcharts} highcharts/css/axis-grid/ Styled mode
                 * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
                 * @sample {highstock} highcharts/css/axis-grid/ Styled mode
                 * @default #ccd6eb
                 */
                tickColor: '#ccd6eb'
                // tickWidth: 1

            },

            /**
             * This option set extends the defaultOptions for Y axes.
             * @extends xAxis
             * @optionparent yAxis
             */
            defaultYAxisOptions: {

                /**
                 * Whether to force the axis to end on a tick. Use this option with
                 * the `maxPadding` option to control the axis end.
                 *
                 * @productdesc {highstock}
                 * In Highstock, `endOnTick` is always false when the navigator is
                 * enabled, to prevent jumpy scrolling.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/chart/reflow-true/ True by default
                 * @sample {highcharts} highcharts/yaxis/endontick-false/ False
                 * @sample {highcharts} highcharts/yaxis/endontick-log-false/ False
                 * @sample {highstock} stock/demo/basic-line/ True by default
                 * @sample {highstock} stock/xaxis/endontick/ False
                 * @default true
                 * @since 1.2.0
                 * @product highcharts highstock
                 */
                endOnTick: true,

                tickPixelInterval: 72,

                /**
                 * Whether to show the last tick label. Defaults to `true` on cartesian
                 * charts, and `false` on polar charts.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
                 *         Set to true on X axis
                 * @sample {highstock} stock/xaxis/showfirstlabel/
                 *         Labels below plot lines on Y axis
                 * @default false
                 * @product highcharts highstock
                 */
                showLastLabel: true,

                /**
                 * @extends xAxis.labels
                 */
                labels: {

                    /**
                     * The x position offset of the label relative to the tick position
                     * on the axis. Defaults to -15 for left axis, 15 for right axis.
                     * 
                     * @type {Number}
                     * @sample {highcharts} highcharts/xaxis/labels-x/
                     *         Y axis labels placed on grid lines
                     * @default 0
                     */
                    x: -8
                },

                /**
                 * Padding of the max value relative to the length of the axis. A
                 * padding of 0.05 will make a 100px axis 5px longer. This is useful
                 * when you don't want the highest data value to appear on the edge
                 * of the plot area. When the axis' `max` option is set or a max extreme
                 * is set using `axis.setExtremes()`, the maxPadding will be ignored.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/yaxis/maxpadding-02/
                 *         Max padding of 0.2
                 * @sample {highstock} stock/xaxis/minpadding-maxpadding/
                 *         Greater min- and maxPadding
                 * @default 0.05
                 * @since 1.2.0
                 * @product highcharts highstock
                 */
                maxPadding: 0.05,

                /**
                 * Padding of the min value relative to the length of the axis. A
                 * padding of 0.05 will make a 100px axis 5px longer. This is useful
                 * when you don't want the lowest data value to appear on the edge
                 * of the plot area. When the axis' `min` option is set or a max extreme
                 * is set using `axis.setExtremes()`, the maxPadding will be ignored.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/yaxis/minpadding/
                 *         Min padding of 0.2
                 * @sample {highstock} stock/xaxis/minpadding-maxpadding/
                 *         Greater min- and maxPadding
                 * @default 0.05
                 * @since 1.2.0
                 * @product highcharts highstock
                 */
                minPadding: 0.05,

                /**
                 * Whether to force the axis to start on a tick. Use this option with
                 * the `maxPadding` option to control the axis start.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/xaxis/startontick-false/
                 *         False by default
                 * @sample {highcharts} highcharts/xaxis/startontick-true/
                 *         True
                 * @sample {highstock} stock/xaxis/endontick/
                 *         False for Y axis
                 * @default true
                 * @since 1.2.0
                 * @product highcharts highstock
                 */
                startOnTick: true,

                /**
                 * @extends xAxis.title
                 */
                title: {

                    /**
                     * The rotation of the text in degrees. 0 is horizontal, 270 is
                     * vertical reading from bottom to top.
                     * 
                     * @type {Number}
                     * @sample {highcharts} highcharts/yaxis/title-offset/ Horizontal
                     * @default 270
                     */
                    rotation: 270,

                    /**
                     * The actual text of the axis title. Horizontal texts can contain
                     * HTML, but rotated texts are painted using vector techniques and
                     * must be clean text. The Y axis title is disabled by setting the
                     * `text` option to `null`.
                     * 
                     * @type {String}
                     * @sample {highcharts} highcharts/xaxis/title-text/ Custom HTML
                     * @default Values
                     * @product highcharts
                     */
                    text: 'Values'
                },

                /**
                 * The stack labels show the total value for each bar in a stacked
                 * column or bar chart. The label will be placed on top of positive
                 * columns and below negative columns. In case of an inverted column
                 * chart or a bar chart the label is placed to the right of positive
                 * bars and to the left of negative bars.
                 * 
                 * @product highcharts
                 */
                stackLabels: {

                    /**
                     * Allow the stack labels to overlap.
                     * 
                     * @type {Boolean}
                     * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
                     *         Default false
                     * @since 5.0.13
                     * @product highcharts
                     */
                    allowOverlap: false,

                    /**
                     * Enable or disable the stack total labels.
                     * 
                     * @type {Boolean}
                     * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
                     *         Enabled stack total labels
                     * @since 2.1.5
                     * @product highcharts
                     */
                    enabled: false,

                    /**
                     * Callback JavaScript function to format the label. The value is
                     * given by `this.total`. Defaults to:
                     * 
                     * <pre>function() {
                     *     return this.total;
                     * }</pre>
                     * 
                     * @type {Function}
                     * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
                     *         Added units to stack total value
                     * @since 2.1.5
                     * @product highcharts
                     */
                    formatter: function() {
                        return H.numberFormat(this.total, -1);
                    },


                    /**
                     * CSS styles for the label.
                     * 
                     * In styled mode, the styles are set in the
                     * `.highcharts-stack-label` class.
                     * 
                     * @type {CSSObject}
                     * @sample {highcharts} highcharts/yaxis/stacklabels-style/
                     *         Red stack total labels
                     * @since 2.1.5
                     * @product highcharts
                     */
                    style: {
                        fontSize: '11px',
                        fontWeight: 'bold',
                        color: '#000000',
                        textOutline: '1px contrast'
                    }

                },


                /**
                 * The width of the grid lines extending the ticks across the plot
                 * area.
                 * 
                 * @productdesc {highmaps}
                 * In Highmaps, the grid lines are hidden by default.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/yaxis/gridlinewidth/ 2px lines
                 * @sample {highstock} stock/xaxis/gridlinewidth/ 2px lines
                 * @default 1
                 * @product highcharts highstock
                 */
                gridLineWidth: 1,

                /**
                 * The width of the line marking the axis itself.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/yaxis/linecolor/ A 1px line on Y axis
                 * @sample {highstock} stock/xaxis/linewidth/ A 2px line on X axis
                 * @default 0
                 * @product highcharts highstock
                 */
                lineWidth: 0
                // tickWidth: 0

            },

            /**
             * These options extend the defaultOptions for left axes.
             * 
             * @private
             * @type {Object}
             */
            defaultLeftAxisOptions: {
                labels: {
                    x: -15
                },
                title: {
                    rotation: 270
                }
            },

            /**
             * These options extend the defaultOptions for right axes.
             *
             * @private
             * @type {Object}
             */
            defaultRightAxisOptions: {
                labels: {
                    x: 15
                },
                title: {
                    rotation: 90
                }
            },

            /**
             * These options extend the defaultOptions for bottom axes.
             *
             * @private
             * @type {Object}
             */
            defaultBottomAxisOptions: {
                labels: {
                    autoRotation: [-45],
                    x: 0
                    // overflow: undefined,
                    // staggerLines: null
                },
                title: {
                    rotation: 0
                }
            },
            /**
             * These options extend the defaultOptions for top axes.
             *
             * @private
             * @type {Object}
             */
            defaultTopAxisOptions: {
                labels: {
                    autoRotation: [-45],
                    x: 0
                    // overflow: undefined
                    // staggerLines: null
                },
                title: {
                    rotation: 0
                }
            },

            /**
             * Overrideable function to initialize the axis. 
             *
             * @see {@link Axis}
             */
            init: function(chart, userOptions) {


                var isXAxis = userOptions.isX,
                    axis = this;


                /**
                 * The Chart that the axis belongs to.
                 *
                 * @name chart
                 * @memberOf Axis
                 * @type {Chart}
                 */
                axis.chart = chart;

                /**
                 * Whether the axis is horizontal.
                 *
                 * @name horiz
                 * @memberOf Axis
                 * @type {Boolean}
                 */
                axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;

                // Flag, isXAxis
                axis.isXAxis = isXAxis;

                /**
                 * The collection where the axis belongs, for example `xAxis`, `yAxis`
                 * or `colorAxis`. Corresponds to properties on Chart, for example
                 * {@link Chart.xAxis}.
                 *
                 * @name coll
                 * @memberOf Axis
                 * @type {String}
                 */
                axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');


                axis.opposite = userOptions.opposite; // needed in setOptions

                /**
                 * The side on which the axis is rendered. 0 is top, 1 is right, 2 is
                 * bottom and 3 is left.
                 *
                 * @name side
                 * @memberOf Axis
                 * @type {Number}
                 */
                axis.side = userOptions.side || (axis.horiz ?
                    (axis.opposite ? 0 : 2) : // top : bottom
                    (axis.opposite ? 1 : 3)); // right : left

                axis.setOptions(userOptions);


                var options = this.options,
                    type = options.type,
                    isDatetimeAxis = type === 'datetime';

                axis.labelFormatter = options.labels.formatter ||
                    axis.defaultLabelFormatter; // can be overwritten by dynamic format


                // Flag, stagger lines or not
                axis.userOptions = userOptions;

                axis.minPixelPadding = 0;


                /**
                 * Whether the axis is reversed. Based on the `axis.reversed`,
                 * option, but inverted charts have reversed xAxis by default.
                 *
                 * @name reversed
                 * @memberOf Axis
                 * @type {Boolean}
                 */
                axis.reversed = options.reversed;
                axis.visible = options.visible !== false;
                axis.zoomEnabled = options.zoomEnabled !== false;

                // Initial categories
                axis.hasNames = type === 'category' || options.categories === true;
                axis.categories = options.categories || axis.hasNames;
                axis.names = axis.names || []; // Preserve on update (#3830)

                // Placeholder for plotlines and plotbands groups
                axis.plotLinesAndBandsGroups = {};

                // Shorthand types
                axis.isLog = type === 'logarithmic';
                axis.isDatetimeAxis = isDatetimeAxis;
                axis.positiveValuesOnly = axis.isLog && !axis.allowNegativeLog;

                // Flag, if axis is linked to another axis
                axis.isLinked = defined(options.linkedTo);

                // Major ticks
                axis.ticks = {};
                axis.labelEdge = [];
                // Minor ticks
                axis.minorTicks = {};

                // List of plotLines/Bands
                axis.plotLinesAndBands = [];

                // Alternate bands
                axis.alternateBands = {};

                // Axis metrics
                axis.len = 0;
                axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
                axis.range = options.range;
                axis.offset = options.offset || 0;


                // Dictionary for stacks
                axis.stacks = {};
                axis.oldStacks = {};
                axis.stacksTouched = 0;


                /**
                 * The maximum value of the axis. In a logarithmic axis, this is the
                 * logarithm of the real value, and the real value can be obtained from
                 * {@link Axis#getExtremes}.
                 *
                 * @name max
                 * @memberOf Axis
                 * @type {Number}
                 */
                axis.max = null;
                /**
                 * The minimum value of the axis. In a logarithmic axis, this is the
                 * logarithm of the real value, and the real value can be obtained from
                 * {@link Axis#getExtremes}.
                 *
                 * @name min
                 * @memberOf Axis
                 * @type {Number}
                 */
                axis.min = null;


                /**
                 * The processed crosshair options.
                 *
                 * @name crosshair
                 * @memberOf Axis
                 * @type {AxisCrosshairOptions}
                 */
                axis.crosshair = pick(
                    options.crosshair,
                    splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1],
                    false
                );

                var events = axis.options.events;

                // Register. Don't add it again on Axis.update().
                if (inArray(axis, chart.axes) === -1) { // 
                    if (isXAxis) { // #2713
                        chart.axes.splice(chart.xAxis.length, 0, axis);
                    } else {
                        chart.axes.push(axis);
                    }

                    chart[axis.coll].push(axis);
                }

                /**
                 * All series associated to the axis.
                 *
                 * @name series
                 * @memberOf Axis
                 * @type {Array.<Series>}
                 */
                axis.series = axis.series || []; // populated by Series

                // Reversed axis
                if (
                    chart.inverted &&
                    !axis.isZAxis &&
                    isXAxis &&
                    axis.reversed === undefined
                ) {
                    axis.reversed = true;
                }

                // register event listeners
                objectEach(events, function(event, eventType) {
                    addEvent(axis, eventType, event);
                });

                // extend logarithmic axis
                axis.lin2log = options.linearToLogConverter || axis.lin2log;
                if (axis.isLog) {
                    axis.val2lin = axis.log2lin;
                    axis.lin2val = axis.lin2log;
                }
            },

            /**
             * Merge and set options.
             *
             * @private
             */
            setOptions: function(userOptions) {
                this.options = merge(
                    this.defaultOptions,
                    this.coll === 'yAxis' && this.defaultYAxisOptions, [
                        this.defaultTopAxisOptions,
                        this.defaultRightAxisOptions,
                        this.defaultBottomAxisOptions,
                        this.defaultLeftAxisOptions
                    ][this.side],
                    merge(
                        defaultOptions[this.coll], // if set in setOptions (#1053)
                        userOptions
                    )
                );
            },

            /**
             * The default label formatter. The context is a special config object for
             * the label. In apps, use the {@link
             * https://api.highcharts.com/highcharts/xAxis.labels.formatter|
             * labels.formatter} instead except when a modification is needed.
             *
             * @private
             */
            defaultLabelFormatter: function() {
                var axis = this.axis,
                    value = this.value,
                    categories = axis.categories,
                    dateTimeLabelFormat = this.dateTimeLabelFormat,
                    lang = defaultOptions.lang,
                    numericSymbols = lang.numericSymbols,
                    numSymMagnitude = lang.numericSymbolMagnitude || 1000,
                    i = numericSymbols && numericSymbols.length,
                    multi,
                    ret,
                    formatOption = axis.options.labels.format,

                    // make sure the same symbol is added for all labels on a linear
                    // axis
                    numericSymbolDetector = axis.isLog ?
                    Math.abs(value) :
                    axis.tickInterval;

                if (formatOption) {
                    ret = format(formatOption, this);

                } else if (categories) {
                    ret = value;

                } else if (dateTimeLabelFormat) { // datetime axis
                    ret = H.dateFormat(dateTimeLabelFormat, value);

                } else if (i && numericSymbolDetector >= 1000) {
                    // Decide whether we should add a numeric symbol like k (thousands)
                    // or M (millions). If we are to enable this in tooltip or other
                    // places as well, we can move this logic to the numberFormatter and
                    // enable it by a parameter.
                    while (i-- && ret === undefined) {
                        multi = Math.pow(numSymMagnitude, i + 1);
                        if (
                            // Only accept a numeric symbol when the distance is more 
                            // than a full unit. So for example if the symbol is k, we
                            // don't accept numbers like 0.5k.
                            numericSymbolDetector >= multi &&
                            // Accept one decimal before the symbol. Accepts 0.5k but
                            // not 0.25k. How does this work with the previous?
                            (value * 10) % multi === 0 &&
                            numericSymbols[i] !== null &&
                            value !== 0
                        ) { // #5480
                            ret = H.numberFormat(value / multi, -1) + numericSymbols[i];
                        }
                    }
                }

                if (ret === undefined) {
                    if (Math.abs(value) >= 10000) { // add thousands separators
                        ret = H.numberFormat(value, -1);
                    } else { // small numbers
                        ret = H.numberFormat(value, -1, undefined, ''); // #2466
                    }
                }

                return ret;
            },

            /**
             * Get the minimum and maximum for the series of each axis. The function
             * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
             *
             * @private
             */
            getSeriesExtremes: function() {
                var axis = this,
                    chart = axis.chart;
                axis.hasVisibleSeries = false;

                // Reset properties in case we're redrawing (#3353)
                axis.dataMin = axis.dataMax = axis.threshold = null;
                axis.softThreshold = !axis.isXAxis;

                if (axis.buildStacks) {
                    axis.buildStacks();
                }

                // loop through this axis' series
                each(axis.series, function(series) {

                    if (series.visible || !chart.options.chart.ignoreHiddenSeries) {

                        var seriesOptions = series.options,
                            xData,
                            threshold = seriesOptions.threshold,
                            seriesDataMin,
                            seriesDataMax;

                        axis.hasVisibleSeries = true;

                        // Validate threshold in logarithmic axes
                        if (axis.positiveValuesOnly && threshold <= 0) {
                            threshold = null;
                        }

                        // Get dataMin and dataMax for X axes
                        if (axis.isXAxis) {
                            xData = series.xData;
                            if (xData.length) {
                                // If xData contains values which is not numbers, then
                                // filter them out. To prevent performance hit, we only
                                // do this after we have already found seriesDataMin
                                // because in most cases all data is valid. #5234.
                                seriesDataMin = arrayMin(xData);
                                if (!isNumber(seriesDataMin) &&
                                    !(seriesDataMin instanceof Date) // #5010
                                ) {
                                    xData = grep(xData, function(x) {
                                        return isNumber(x);
                                    });
                                    // Do it again with valid data
                                    seriesDataMin = arrayMin(xData);
                                }

                                axis.dataMin = Math.min(
                                    pick(axis.dataMin, xData[0]),
                                    seriesDataMin
                                );
                                axis.dataMax = Math.max(
                                    pick(axis.dataMax, xData[0]),
                                    arrayMax(xData)
                                );

                            }

                            // Get dataMin and dataMax for Y axes, as well as handle
                            // stacking and processed data
                        } else {

                            // Get this particular series extremes
                            series.getExtremes();
                            seriesDataMax = series.dataMax;
                            seriesDataMin = series.dataMin;

                            // Get the dataMin and dataMax so far. If percentage is
                            // used, the min and max are always 0 and 100. If
                            // seriesDataMin and seriesDataMax is null, then series
                            // doesn't have active y data, we continue with nulls
                            if (defined(seriesDataMin) && defined(seriesDataMax)) {
                                axis.dataMin = Math.min(
                                    pick(axis.dataMin, seriesDataMin),
                                    seriesDataMin
                                );
                                axis.dataMax = Math.max(
                                    pick(axis.dataMax, seriesDataMax),
                                    seriesDataMax
                                );
                            }

                            // Adjust to threshold
                            if (defined(threshold)) {
                                axis.threshold = threshold;
                            }
                            // If any series has a hard threshold, it takes precedence
                            if (!seriesOptions.softThreshold ||
                                axis.positiveValuesOnly
                            ) {
                                axis.softThreshold = false;
                            }
                        }
                    }
                });
            },

            /**
             * Translate from axis value to pixel position on the chart, or back. Use
             * the `toPixels` and `toValue` functions in applications.
             *
             * @private
             */
            translate: function(
                val,
                backwards,
                cvsCoord,
                old,
                handleLog,
                pointPlacement
            ) {
                var axis = this.linkedParent || this, // #1417
                    sign = 1,
                    cvsOffset = 0,
                    localA = old ? axis.oldTransA : axis.transA,
                    localMin = old ? axis.oldMin : axis.min,
                    returnValue,
                    minPixelPadding = axis.minPixelPadding,
                    doPostTranslate = (
                        axis.isOrdinal ||
                        axis.isBroken ||
                        (axis.isLog && handleLog)
                    ) && axis.lin2val;

                if (!localA) {
                    localA = axis.transA;
                }

                // In vertical axes, the canvas coordinates start from 0 at the top like
                // in SVG.
                if (cvsCoord) {
                    sign *= -1; // canvas coordinates inverts the value
                    cvsOffset = axis.len;
                }

                // Handle reversed axis
                if (axis.reversed) {
                    sign *= -1;
                    cvsOffset -= sign * (axis.sector || axis.len);
                }

                // From pixels to value
                if (backwards) { // reverse translation

                    val = val * sign + cvsOffset;
                    val -= minPixelPadding;
                    returnValue = val / localA + localMin; // from chart pixel to value
                    if (doPostTranslate) { // log and ordinal axes
                        returnValue = axis.lin2val(returnValue);
                    }

                    // From value to pixels
                } else {
                    if (doPostTranslate) { // log and ordinal axes
                        val = axis.val2lin(val);
                    }
                    returnValue = isNumber(localMin) ?
                        (
                            sign * (val - localMin) * localA +
                            cvsOffset +
                            (sign * minPixelPadding) +
                            (isNumber(pointPlacement) ? localA * pointPlacement : 0)
                        ) :
                        undefined;
                }

                return returnValue;
            },

            /**
             * Translate a value in terms of axis units into pixels within the chart.
             * 
             * @param  {Number} value
             *         A value in terms of axis units.
             * @param  {Boolean} paneCoordinates
             *         Whether to return the pixel coordinate relative to the chart or
             *         just the axis/pane itself.
             * @return {Number} Pixel position of the value on the chart or axis.
             */
            toPixels: function(value, paneCoordinates) {
                return this.translate(value, false, !this.horiz, null, true) +
                    (paneCoordinates ? 0 : this.pos);
            },

            /**
             * Translate a pixel position along the axis to a value in terms of axis
             * units.
             * @param  {Number} pixel
             *         The pixel value coordinate.
             * @param  {Boolean} paneCoordiantes
             *         Whether the input pixel is relative to the chart or just the
             *         axis/pane itself.
             * @return {Number} The axis value.
             */
            toValue: function(pixel, paneCoordinates) {
                return this.translate(
                    pixel - (paneCoordinates ? 0 : this.pos),
                    true, !this.horiz,
                    null,
                    true
                );
            },

            /**
             * Create the path for a plot line that goes from the given value on
             * this axis, across the plot to the opposite side. Also used internally for
             * grid lines and crosshairs.
             * 
             * @param  {Number} value
             *         Axis value.
             * @param  {Number} [lineWidth=1]
             *         Used for calculation crisp line coordinates.
             * @param  {Boolean} [old=false]
             *         Use old coordinates (for resizing and rescaling).
             * @param  {Boolean} [force=false]
             *         If `false`, the function will return null when it falls outside
             *         the axis bounds.
             * @param  {Number} [translatedValue]
             *         If given, return the plot line path of a pixel position on the
             *         axis.
             *
             * @return {Array.<String|Number>}
             *         The SVG path definition for the plot line.
             */
            getPlotLinePath: function(value, lineWidth, old, force, translatedValue) {
                var axis = this,
                    chart = axis.chart,
                    axisLeft = axis.left,
                    axisTop = axis.top,
                    x1,
                    y1,
                    x2,
                    y2,
                    cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
                    cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
                    skip,
                    transB = axis.transB,
                    /**
                     * Check if x is between a and b. If not, either move to a/b or skip,
                     * depending on the force parameter.
                     */
                    between = function(x, a, b) {
                        if (x < a || x > b) {
                            if (force) {
                                x = Math.min(Math.max(a, x), b);
                            } else {
                                skip = true;
                            }
                        }
                        return x;
                    };

                translatedValue = pick(
                    translatedValue,
                    axis.translate(value, null, null, old)
                );
                x1 = x2 = Math.round(translatedValue + transB);
                y1 = y2 = Math.round(cHeight - translatedValue - transB);
                if (!isNumber(translatedValue)) { // no min or max
                    skip = true;
                    force = false; // #7175, don't force it when path is invalid
                } else if (axis.horiz) {
                    y1 = axisTop;
                    y2 = cHeight - axis.bottom;
                    x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
                } else {
                    x1 = axisLeft;
                    x2 = cWidth - axis.right;
                    y1 = y2 = between(y1, axisTop, axisTop + axis.height);
                }
                return skip && !force ?
                    null :
                    chart.renderer.crispLine(
                        ['M', x1, y1, 'L', x2, y2],
                        lineWidth || 1
                    );
            },

            /**
             * Internal function to et the tick positions of a linear axis to round
             * values like whole tens or every five.
             *
             * @param  {Number} tickInterval
             *         The normalized tick interval
             * @param  {Number} min
             *         Axis minimum.
             * @param  {Number} max
             *         Axis maximum.
             *
             * @return {Array.<Number>}
             *         An array of axis values where ticks should be placed.
             */
            getLinearTickPositions: function(tickInterval, min, max) {
                var pos,
                    lastPos,
                    roundedMin =
                    correctFloat(Math.floor(min / tickInterval) * tickInterval),
                    roundedMax =
                    correctFloat(Math.ceil(max / tickInterval) * tickInterval),
                    tickPositions = [];

                // For single points, add a tick regardless of the relative position
                // (#2662, #6274)
                if (this.single) {
                    return [min];
                }

                // Populate the intermediate values
                pos = roundedMin;
                while (pos <= roundedMax) {

                    // Place the tick on the rounded value
                    tickPositions.push(pos);

                    // Always add the raw tickInterval, not the corrected one.
                    pos = correctFloat(pos + tickInterval);

                    // If the interval is not big enough in the current min - max range
                    // to actually increase the loop variable, we need to break out to
                    // prevent endless loop. Issue #619
                    if (pos === lastPos) {
                        break;
                    }

                    // Record the last value
                    lastPos = pos;
                }
                return tickPositions;
            },

            /**
             * Resolve the new minorTicks/minorTickInterval options into the legacy
             * loosely typed minorTickInterval option.
             */
            getMinorTickInterval: function() {
                var options = this.options;

                if (options.minorTicks === true) {
                    return pick(options.minorTickInterval, 'auto');
                }
                if (options.minorTicks === false) {
                    return null;
                }
                return options.minorTickInterval;
            },

            /**
             * Internal function to return the minor tick positions. For logarithmic
             * axes, the same logic as for major ticks is reused.
             *
             * @return {Array.<Number>}
             *         An array of axis values where ticks should be placed.
             */
            getMinorTickPositions: function() {
                var axis = this,
                    options = axis.options,
                    tickPositions = axis.tickPositions,
                    minorTickInterval = axis.minorTickInterval,
                    minorTickPositions = [],
                    pos,
                    pointRangePadding = axis.pointRangePadding || 0,
                    min = axis.min - pointRangePadding, // #1498
                    max = axis.max + pointRangePadding, // #1498
                    range = max - min;

                // If minor ticks get too dense, they are hard to read, and may cause
                // long running script. So we don't draw them.
                if (range && range / minorTickInterval < axis.len / 3) { // #3875

                    if (axis.isLog) {
                        // For each interval in the major ticks, compute the minor ticks
                        // separately.
                        each(this.paddedTicks, function(pos, i, paddedTicks) {
                            if (i) {
                                minorTickPositions.push.apply(
                                    minorTickPositions,
                                    axis.getLogTickPositions(
                                        minorTickInterval,
                                        paddedTicks[i - 1],
                                        paddedTicks[i],
                                        true
                                    )
                                );
                            }
                        });

                    } else if (
                        axis.isDatetimeAxis &&
                        this.getMinorTickInterval() === 'auto'
                    ) { // #1314
                        minorTickPositions = minorTickPositions.concat(
                            axis.getTimeTicks(
                                axis.normalizeTimeTickInterval(minorTickInterval),
                                min,
                                max,
                                options.startOfWeek
                            )
                        );
                    } else {
                        for (
                            pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval
                        ) {
                            // Very, very, tight grid lines (#5771)
                            if (pos === minorTickPositions[0]) {
                                break;
                            }
                            minorTickPositions.push(pos);
                        }
                    }
                }

                if (minorTickPositions.length !== 0) {
                    axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
                }
                return minorTickPositions;
            },

            /**
             * Adjust the min and max for the minimum range. Keep in mind that the
             * series data is not yet processed, so we don't have information on data
             * cropping and grouping, or updated axis.pointRange or series.pointRange.
             * The data can't be processed until we have finally established min and
             * max.
             *
             * @private
             */
            adjustForMinRange: function() {
                var axis = this,
                    options = axis.options,
                    min = axis.min,
                    max = axis.max,
                    zoomOffset,
                    spaceAvailable,
                    closestDataRange,
                    i,
                    distance,
                    xData,
                    loopLength,
                    minArgs,
                    maxArgs,
                    minRange;

                // Set the automatic minimum range based on the closest point distance
                if (axis.isXAxis && axis.minRange === undefined && !axis.isLog) {

                    if (defined(options.min) || defined(options.max)) {
                        axis.minRange = null; // don't do this again

                    } else {

                        // Find the closest distance between raw data points, as opposed
                        // to closestPointRange that applies to processed points
                        // (cropped and grouped)
                        each(axis.series, function(series) {
                            xData = series.xData;
                            loopLength = series.xIncrement ? 1 : xData.length - 1;
                            for (i = loopLength; i > 0; i--) {
                                distance = xData[i] - xData[i - 1];
                                if (
                                    closestDataRange === undefined ||
                                    distance < closestDataRange
                                ) {
                                    closestDataRange = distance;
                                }
                            }
                        });
                        axis.minRange = Math.min(
                            closestDataRange * 5,
                            axis.dataMax - axis.dataMin
                        );
                    }
                }

                // if minRange is exceeded, adjust
                if (max - min < axis.minRange) {

                    spaceAvailable = axis.dataMax - axis.dataMin >= axis.minRange;
                    minRange = axis.minRange;
                    zoomOffset = (minRange - max + min) / 2;

                    // if min and max options have been set, don't go beyond it
                    minArgs = [min - zoomOffset, pick(options.min, min - zoomOffset)];
                    // If space is available, stay within the data range
                    if (spaceAvailable) {
                        minArgs[2] = axis.isLog ?
                            axis.log2lin(axis.dataMin) :
                            axis.dataMin;
                    }
                    min = arrayMax(minArgs);

                    maxArgs = [min + minRange, pick(options.max, min + minRange)];
                    // If space is availabe, stay within the data range
                    if (spaceAvailable) {
                        maxArgs[2] = axis.isLog ?
                            axis.log2lin(axis.dataMax) :
                            axis.dataMax;
                    }

                    max = arrayMin(maxArgs);

                    // now if the max is adjusted, adjust the min back
                    if (max - min < minRange) {
                        minArgs[0] = max - minRange;
                        minArgs[1] = pick(options.min, max - minRange);
                        min = arrayMax(minArgs);
                    }
                }

                // Record modified extremes
                axis.min = min;
                axis.max = max;
            },

            /**
             * Find the closestPointRange across all series.
             *
             * @private
             */
            getClosest: function() {
                var ret;

                if (this.categories) {
                    ret = 1;
                } else {
                    each(this.series, function(series) {
                        var seriesClosest = series.closestPointRange,
                            visible = series.visible ||
                            !series.chart.options.chart.ignoreHiddenSeries;

                        if (!series.noSharedTooltip &&
                            defined(seriesClosest) &&
                            visible
                        ) {
                            ret = defined(ret) ?
                                Math.min(ret, seriesClosest) :
                                seriesClosest;
                        }
                    });
                }
                return ret;
            },

            /**
             * When a point name is given and no x, search for the name in the existing
             * categories, or if categories aren't provided, search names or create a
             * new category (#2522).
             *
             * @private
             *
             * @param  {Point}
             *         The point to inspect.
             *
             * @return {Number}
             *         The X value that the point is given.
             */
            nameToX: function(point) {
                var explicitCategories = isArray(this.categories),
                    names = explicitCategories ? this.categories : this.names,
                    nameX = point.options.x,
                    x;

                point.series.requireSorting = false;

                if (!defined(nameX)) {
                    nameX = this.options.uniqueNames === false ?
                        point.series.autoIncrement() :
                        inArray(point.name, names);
                }
                if (nameX === -1) { // The name is not found in currenct categories
                    if (!explicitCategories) {
                        x = names.length;
                    }
                } else {
                    x = nameX;
                }

                // Write the last point's name to the names array
                if (x !== undefined) {
                    this.names[x] = point.name;
                }

                return x;
            },

            /**
             * When changes have been done to series data, update the axis.names.
             *
             * @private
             */
            updateNames: function() {
                var axis = this;

                if (this.names.length > 0) {
                    this.names.length = 0;
                    this.minRange = this.userMinRange; // Reset
                    each(this.series || [], function(series) {

                        // Reset incrementer (#5928)
                        series.xIncrement = null;

                        // When adding a series, points are not yet generated
                        if (!series.points || series.isDirtyData) {
                            series.processData();
                            series.generatePoints();
                        }

                        each(series.points, function(point, i) {
                            var x;
                            if (point.options) {
                                x = axis.nameToX(point);
                                if (x !== undefined && x !== point.x) {
                                    point.x = x;
                                    series.xData[i] = x;
                                }
                            }
                        });
                    });
                }
            },

            /**
             * Update translation information.
             *
             * @private
             */
            setAxisTranslation: function(saveOld) {
                var axis = this,
                    range = axis.max - axis.min,
                    pointRange = axis.axisPointRange || 0,
                    closestPointRange,
                    minPointOffset = 0,
                    pointRangePadding = 0,
                    linkedParent = axis.linkedParent,
                    ordinalCorrection,
                    hasCategories = !!axis.categories,
                    transA = axis.transA,
                    isXAxis = axis.isXAxis;

                // Adjust translation for padding. Y axis with categories need to go
                // through the same (#1784).
                if (isXAxis || hasCategories || pointRange) {

                    // Get the closest points
                    closestPointRange = axis.getClosest();

                    if (linkedParent) {
                        minPointOffset = linkedParent.minPointOffset;
                        pointRangePadding = linkedParent.pointRangePadding;
                    } else {
                        each(axis.series, function(series) {
                            var seriesPointRange = hasCategories ?
                                1 :
                                (
                                    isXAxis ?
                                    pick(
                                        series.options.pointRange,
                                        closestPointRange,
                                        0
                                    ) :
                                    (axis.axisPointRange || 0)
                                ), // #2806
                                pointPlacement = series.options.pointPlacement;

                            pointRange = Math.max(pointRange, seriesPointRange);

                            if (!axis.single) {
                                // minPointOffset is the value padding to the left of
                                // the axis in order to make room for points with a
                                // pointRange, typically columns. When the
                                // pointPlacement option is 'between' or 'on', this
                                // padding does not apply.
                                minPointOffset = Math.max(
                                    minPointOffset,
                                    isString(pointPlacement) ? 0 : seriesPointRange / 2
                                );

                                // Determine the total padding needed to the length of
                                // the axis to make room for the pointRange. If the
                                // series' pointPlacement is 'on', no padding is added.
                                pointRangePadding = Math.max(
                                    pointRangePadding,
                                    pointPlacement === 'on' ? 0 : seriesPointRange
                                );
                            }
                        });
                    }

                    // Record minPointOffset and pointRangePadding
                    ordinalCorrection = axis.ordinalSlope && closestPointRange ?
                        axis.ordinalSlope / closestPointRange :
                        1; // #988, #1853
                    axis.minPointOffset = minPointOffset =
                        minPointOffset * ordinalCorrection;
                    axis.pointRangePadding =
                        pointRangePadding = pointRangePadding * ordinalCorrection;

                    // pointRange means the width reserved for each point, like in a
                    // column chart
                    axis.pointRange = Math.min(pointRange, range);

                    // closestPointRange means the closest distance between points. In
                    // columns it is mostly equal to pointRange, but in lines pointRange
                    // is 0 while closestPointRange is some other value
                    if (isXAxis) {
                        axis.closestPointRange = closestPointRange;
                    }
                }

                // Secondary values
                if (saveOld) {
                    axis.oldTransA = transA;
                }
                axis.translationSlope = axis.transA = transA =
                    axis.options.staticScale ||
                    axis.len / ((range + pointRangePadding) || 1);

                // Translation addend
                axis.transB = axis.horiz ? axis.left : axis.bottom;
                axis.minPixelPadding = transA * minPointOffset;
            },

            minFromRange: function() {
                return this.max - this.range;
            },

            /**
             * Set the tick positions to round values and optionally extend the extremes
             * to the nearest tick.
             *
             * @private
             */
            setTickInterval: function(secondPass) {
                var axis = this,
                    chart = axis.chart,
                    options = axis.options,
                    isLog = axis.isLog,
                    log2lin = axis.log2lin,
                    isDatetimeAxis = axis.isDatetimeAxis,
                    isXAxis = axis.isXAxis,
                    isLinked = axis.isLinked,
                    maxPadding = options.maxPadding,
                    minPadding = options.minPadding,
                    length,
                    linkedParentExtremes,
                    tickIntervalOption = options.tickInterval,
                    minTickInterval,
                    tickPixelIntervalOption = options.tickPixelInterval,
                    categories = axis.categories,
                    threshold = axis.threshold,
                    softThreshold = axis.softThreshold,
                    thresholdMin,
                    thresholdMax,
                    hardMin,
                    hardMax;

                if (!isDatetimeAxis && !categories && !isLinked) {
                    this.getTickAmount();
                }

                // Min or max set either by zooming/setExtremes or initial options
                hardMin = pick(axis.userMin, options.min);
                hardMax = pick(axis.userMax, options.max);

                // Linked axis gets the extremes from the parent axis
                if (isLinked) {
                    axis.linkedParent = chart[axis.coll][options.linkedTo];
                    linkedParentExtremes = axis.linkedParent.getExtremes();
                    axis.min = pick(
                        linkedParentExtremes.min,
                        linkedParentExtremes.dataMin
                    );
                    axis.max = pick(
                        linkedParentExtremes.max,
                        linkedParentExtremes.dataMax
                    );
                    if (options.type !== axis.linkedParent.options.type) {
                        H.error(11, 1); // Can't link axes of different type
                    }

                    // Initial min and max from the extreme data values
                } else {

                    // Adjust to hard threshold
                    if (!softThreshold && defined(threshold)) {
                        if (axis.dataMin >= threshold) {
                            thresholdMin = threshold;
                            minPadding = 0;
                        } else if (axis.dataMax <= threshold) {
                            thresholdMax = threshold;
                            maxPadding = 0;
                        }
                    }

                    axis.min = pick(hardMin, thresholdMin, axis.dataMin);
                    axis.max = pick(hardMax, thresholdMax, axis.dataMax);

                }

                if (isLog) {
                    if (
                        axis.positiveValuesOnly &&
                        !secondPass &&
                        Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0
                    ) { // #978
                        H.error(10, 1); // Can't plot negative values on log axis
                    }
                    // The correctFloat cures #934, float errors on full tens. But it
                    // was too aggressive for #4360 because of conversion back to lin,
                    // therefore use precision 15.
                    axis.min = correctFloat(log2lin(axis.min), 15);
                    axis.max = correctFloat(log2lin(axis.max), 15);
                }

                // handle zoomed range
                if (axis.range && defined(axis.max)) {
                    axis.userMin = axis.min = hardMin =
                        Math.max(axis.dataMin, axis.minFromRange()); // #618, #6773
                    axis.userMax = hardMax = axis.max;

                    axis.range = null; // don't use it when running setExtremes
                }

                // Hook for Highstock Scroller. Consider combining with beforePadding.
                fireEvent(axis, 'foundExtremes');

                // Hook for adjusting this.min and this.max. Used by bubble series.
                if (axis.beforePadding) {
                    axis.beforePadding();
                }

                // adjust min and max for the minimum range
                axis.adjustForMinRange();

                // Pad the values to get clear of the chart's edges. To avoid
                // tickInterval taking the padding into account, we do this after
                // computing tick interval (#1337).
                if (!categories &&
                    !axis.axisPointRange &&
                    !axis.usePercentage &&
                    !isLinked &&
                    defined(axis.min) &&
                    defined(axis.max)
                ) {
                    length = axis.max - axis.min;
                    if (length) {
                        if (!defined(hardMin) && minPadding) {
                            axis.min -= length * minPadding;
                        }
                        if (!defined(hardMax) && maxPadding) {
                            axis.max += length * maxPadding;
                        }
                    }
                }

                // Handle options for floor, ceiling, softMin and softMax (#6359)
                if (isNumber(options.softMin)) {
                    axis.min = Math.min(axis.min, options.softMin);
                }
                if (isNumber(options.softMax)) {
                    axis.max = Math.max(axis.max, options.softMax);
                }
                if (isNumber(options.floor)) {
                    axis.min = Math.max(axis.min, options.floor);
                }
                if (isNumber(options.ceiling)) {
                    axis.max = Math.min(axis.max, options.ceiling);
                }


                // When the threshold is soft, adjust the extreme value only if the data
                // extreme and the padded extreme land on either side of the threshold.
                // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
                // for -1 because of the default minPadding and startOnTick options.
                // This is prevented by the softThreshold option.
                if (softThreshold && defined(axis.dataMin)) {
                    threshold = threshold || 0;
                    if (!defined(hardMin) &&
                        axis.min < threshold &&
                        axis.dataMin >= threshold
                    ) {
                        axis.min = threshold;

                    } else if (!defined(hardMax) &&
                        axis.max > threshold &&
                        axis.dataMax <= threshold
                    ) {
                        axis.max = threshold;
                    }
                }


                // get tickInterval
                if (
                    axis.min === axis.max ||
                    axis.min === undefined ||
                    axis.max === undefined
                ) {
                    axis.tickInterval = 1;

                } else if (
                    isLinked &&
                    !tickIntervalOption &&
                    tickPixelIntervalOption ===
                    axis.linkedParent.options.tickPixelInterval
                ) {
                    axis.tickInterval = tickIntervalOption =
                        axis.linkedParent.tickInterval;

                } else {
                    axis.tickInterval = pick(
                        tickIntervalOption,
                        this.tickAmount ?
                        ((axis.max - axis.min) / Math.max(this.tickAmount - 1, 1)) :
                        undefined,
                        // For categoried axis, 1 is default, for linear axis use
                        // tickPix
                        categories ?
                        1 :
                        // don't let it be more than the data range
                        (axis.max - axis.min) * tickPixelIntervalOption /
                        Math.max(axis.len, tickPixelIntervalOption)
                    );
                }

                // Now we're finished detecting min and max, crop and group series data.
                // This is in turn needed in order to find tick positions in ordinal axes.
                if (isXAxis && !secondPass) {
                    each(axis.series, function(series) {
                        series.processData(
                            axis.min !== axis.oldMin || axis.max !== axis.oldMax
                        );
                    });
                }

                // set the translation factor used in translate function
                axis.setAxisTranslation(true);

                // hook for ordinal axes and radial axes
                if (axis.beforeSetTickPositions) {
                    axis.beforeSetTickPositions();
                }

                // hook for extensions, used in Highstock ordinal axes
                if (axis.postProcessTickInterval) {
                    axis.tickInterval = axis.postProcessTickInterval(axis.tickInterval);
                }

                // In column-like charts, don't cramp in more ticks than there are
                // points (#1943, #4184)
                if (axis.pointRange && !tickIntervalOption) {
                    axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
                }

                // Before normalizing the tick interval, handle minimum tick interval.
                // This applies only if tickInterval is not defined.
                minTickInterval = pick(
                    options.minTickInterval,
                    axis.isDatetimeAxis && axis.closestPointRange
                );
                if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
                    axis.tickInterval = minTickInterval;
                }

                // for linear axes, get magnitude and normalize the interval
                if (!isDatetimeAxis && !isLog && !tickIntervalOption) {
                    axis.tickInterval = normalizeTickInterval(
                        axis.tickInterval,
                        null,
                        getMagnitude(axis.tickInterval),
                        // If the tick interval is between 0.5 and 5 and the axis max is
                        // in the order of thousands, chances are we are dealing with
                        // years. Don't allow decimals. #3363.
                        pick(
                            options.allowDecimals, !(
                                axis.tickInterval > 0.5 &&
                                axis.tickInterval < 5 &&
                                axis.max > 1000 &&
                                axis.max < 9999
                            )
                        ), !!this.tickAmount
                    );
                }

                // Prevent ticks from getting so close that we can't draw the labels
                if (!this.tickAmount) {
                    axis.tickInterval = axis.unsquish();
                }

                this.setTickPositions();
            },

            /**
             * Now we have computed the normalized tickInterval, get the tick positions
             */
            setTickPositions: function() {

                var options = this.options,
                    tickPositions,
                    tickPositionsOption = options.tickPositions,
                    minorTickIntervalOption = this.getMinorTickInterval(),
                    tickPositioner = options.tickPositioner,
                    startOnTick = options.startOnTick,
                    endOnTick = options.endOnTick;

                // Set the tickmarkOffset
                this.tickmarkOffset = (
                    this.categories &&
                    options.tickmarkPlacement === 'between' &&
                    this.tickInterval === 1
                ) ? 0.5 : 0; // #3202


                // get minorTickInterval
                this.minorTickInterval =
                    minorTickIntervalOption === 'auto' &&
                    this.tickInterval ?
                    this.tickInterval / 5 :
                    minorTickIntervalOption;

                // When there is only one point, or all points have the same value on
                // this axis, then min and max are equal and tickPositions.length is 0
                // or 1. In this case, add some padding in order to center the point,
                // but leave it with one tick. #1337.
                this.single =
                    this.min === this.max &&
                    defined(this.min) &&
                    !this.tickAmount &&
                    (
                        // Data is on integer (#6563)
                        parseInt(this.min, 10) === this.min ||

                        // Between integers and decimals are not allowed (#6274)
                        options.allowDecimals !== false
                    );

                // Find the tick positions. Work on a copy (#1565)
                this.tickPositions = tickPositions =
                    tickPositionsOption && tickPositionsOption.slice();
                if (!tickPositions) {

                    if (this.isDatetimeAxis) {
                        tickPositions = this.getTimeTicks(
                            this.normalizeTimeTickInterval(
                                this.tickInterval,
                                options.units
                            ),
                            this.min,
                            this.max,
                            options.startOfWeek,
                            this.ordinalPositions,
                            this.closestPointRange,
                            true
                        );
                    } else if (this.isLog) {
                        tickPositions = this.getLogTickPositions(
                            this.tickInterval,
                            this.min,
                            this.max
                        );
                    } else {
                        tickPositions = this.getLinearTickPositions(
                            this.tickInterval,
                            this.min,
                            this.max
                        );
                    }

                    // Too dense ticks, keep only the first and last (#4477)
                    if (tickPositions.length > this.len) {
                        tickPositions = [tickPositions[0], tickPositions.pop()];
                    }

                    this.tickPositions = tickPositions;

                    // Run the tick positioner callback, that allows modifying auto tick
                    // positions.
                    if (tickPositioner) {
                        tickPositioner = tickPositioner.apply(
                            this, [this.min, this.max]
                        );
                        if (tickPositioner) {
                            this.tickPositions = tickPositions = tickPositioner;
                        }
                    }

                }

                // Reset min/max or remove extremes based on start/end on tick
                this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
                this.trimTicks(tickPositions, startOnTick, endOnTick);
                if (!this.isLinked) {

                    // Substract half a unit (#2619, #2846, #2515, #3390),
                    // but not in case of multiple ticks (#6897)
                    if (this.single && tickPositions.length < 2) {
                        this.min -= 0.5;
                        this.max += 0.5;
                    }
                    if (!tickPositionsOption && !tickPositioner) {
                        this.adjustTickAmount();
                    }
                }
            },

            /**
             * Handle startOnTick and endOnTick by either adapting to padding min/max or
             * rounded min/max. Also handle single data points.
             *
             * @private
             */
            trimTicks: function(tickPositions, startOnTick, endOnTick) {
                var roundedMin = tickPositions[0],
                    roundedMax = tickPositions[tickPositions.length - 1],
                    minPointOffset = this.minPointOffset || 0;

                if (!this.isLinked) {
                    if (startOnTick && roundedMin !== -Infinity) { // #6502
                        this.min = roundedMin;
                    } else {
                        while (this.min - minPointOffset > tickPositions[0]) {
                            tickPositions.shift();
                        }
                    }

                    if (endOnTick) {
                        this.max = roundedMax;
                    } else {
                        while (this.max + minPointOffset <
                            tickPositions[tickPositions.length - 1]) {
                            tickPositions.pop();
                        }
                    }

                    // If no tick are left, set one tick in the middle (#3195)
                    if (tickPositions.length === 0 && defined(roundedMin)) {
                        tickPositions.push((roundedMax + roundedMin) / 2);
                    }
                }
            },

            /**
             * Check if there are multiple axes in the same pane.
             *
             * @private
             * @return {Boolean}
             *         True if there are other axes.
             */
            alignToOthers: function() {
                var others = {}, // Whether there is another axis to pair with this one
                    hasOther,
                    options = this.options;

                if (
                    // Only if alignTicks is true
                    this.chart.options.chart.alignTicks !== false &&
                    options.alignTicks !== false &&

                    // Don't try to align ticks on a log axis, they are not evenly
                    // spaced (#6021)
                    !this.isLog
                ) {
                    each(this.chart[this.coll], function(axis) {
                        var otherOptions = axis.options,
                            horiz = axis.horiz,
                            key = [
                                horiz ? otherOptions.left : otherOptions.top,
                                otherOptions.width,
                                otherOptions.height,
                                otherOptions.pane
                            ].join(',');


                        if (axis.series.length) { // #4442
                            if (others[key]) {
                                hasOther = true; // #4201
                            } else {
                                others[key] = 1;
                            }
                        }
                    });
                }
                return hasOther;
            },

            /**
             * Find the max ticks of either the x and y axis collection, and record it
             * in `this.tickAmount`.
             *
             * @private
             */
            getTickAmount: function() {
                var options = this.options,
                    tickAmount = options.tickAmount,
                    tickPixelInterval = options.tickPixelInterval;

                if (!defined(options.tickInterval) &&
                    this.len < tickPixelInterval &&
                    !this.isRadial &&
                    !this.isLog &&
                    options.startOnTick &&
                    options.endOnTick
                ) {
                    tickAmount = 2;
                }

                if (!tickAmount && this.alignToOthers()) {
                    // Add 1 because 4 tick intervals require 5 ticks (including first
                    // and last)
                    tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
                }

                // For tick amounts of 2 and 3, compute five ticks and remove the
                // intermediate ones. This prevents the axis from adding ticks that are
                // too far away from the data extremes.
                if (tickAmount < 4) {
                    this.finalTickAmt = tickAmount;
                    tickAmount = 5;
                }

                this.tickAmount = tickAmount;
            },

            /**
             * When using multiple axes, adjust the number of ticks to match the highest
             * number of ticks in that group.
             *
             * @private
             */
            adjustTickAmount: function() {
                var tickInterval = this.tickInterval,
                    tickPositions = this.tickPositions,
                    tickAmount = this.tickAmount,
                    finalTickAmt = this.finalTickAmt,
                    currentTickAmount = tickPositions && tickPositions.length,
                    i,
                    len;

                if (currentTickAmount < tickAmount) {
                    while (tickPositions.length < tickAmount) {
                        tickPositions.push(correctFloat(
                            tickPositions[tickPositions.length - 1] + tickInterval
                        ));
                    }
                    this.transA *= (currentTickAmount - 1) / (tickAmount - 1);
                    this.max = tickPositions[tickPositions.length - 1];

                    // We have too many ticks, run second pass to try to reduce ticks
                } else if (currentTickAmount > tickAmount) {
                    this.tickInterval *= 2;
                    this.setTickPositions();
                }

                // The finalTickAmt property is set in getTickAmount
                if (defined(finalTickAmt)) {
                    i = len = tickPositions.length;
                    while (i--) {
                        if (
                            // Remove every other tick
                            (finalTickAmt === 3 && i % 2 === 1) ||
                            // Remove all but first and last
                            (finalTickAmt <= 2 && i > 0 && i < len - 1)
                        ) {
                            tickPositions.splice(i, 1);
                        }
                    }
                    this.finalTickAmt = undefined;
                }
            },

            /**
             * Set the scale based on data min and max, user set min and max or options.
             * 
             * @private
             */
            setScale: function() {
                var axis = this,
                    isDirtyData,
                    isDirtyAxisLength;

                axis.oldMin = axis.min;
                axis.oldMax = axis.max;
                axis.oldAxisLength = axis.len;

                // set the new axisLength
                axis.setAxisSize();
                isDirtyAxisLength = axis.len !== axis.oldAxisLength;

                // is there new data?
                each(axis.series, function(series) {
                    if (
                        series.isDirtyData ||
                        series.isDirty ||
                        // When x axis is dirty, we need new data extremes for y as well
                        series.xAxis.isDirty
                    ) {
                        isDirtyData = true;
                    }
                });

                // do we really need to go through all this?
                if (
                    isDirtyAxisLength ||
                    isDirtyData ||
                    axis.isLinked ||
                    axis.forceRedraw ||
                    axis.userMin !== axis.oldUserMin ||
                    axis.userMax !== axis.oldUserMax ||
                    axis.alignToOthers()
                ) {

                    if (axis.resetStacks) {
                        axis.resetStacks();
                    }

                    axis.forceRedraw = false;

                    // get data extremes if needed
                    axis.getSeriesExtremes();

                    // get fixed positions based on tickInterval
                    axis.setTickInterval();

                    // record old values to decide whether a rescale is necessary later
                    // on (#540)
                    axis.oldUserMin = axis.userMin;
                    axis.oldUserMax = axis.userMax;

                    // Mark as dirty if it is not already set to dirty and extremes have
                    // changed. #595.
                    if (!axis.isDirty) {
                        axis.isDirty =
                            isDirtyAxisLength ||
                            axis.min !== axis.oldMin ||
                            axis.max !== axis.oldMax;
                    }
                } else if (axis.cleanStacks) {
                    axis.cleanStacks();
                }
            },

            /**
             * Set the minimum and maximum of the axes after render time. If the
             * `startOnTick` and `endOnTick` options are true, the minimum and maximum
             * values are rounded off to the nearest tick. To prevent this, these
             * options can be set to false before calling setExtremes. Also, setExtremes
             * will not allow a range lower than the `minRange` option, which by default
             * is the range of five points.
             * 
             * @param  {Number} [newMin]
             *         The new minimum value.
             * @param  {Number} [newMax]
             *         The new maximum value.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart or wait for an explicit call to 
             *         {@link Highcharts.Chart#redraw}
             * @param  {AnimationOptions} [animation=true]
             *         Enable or modify animations.
             * @param  {Object} [eventArguments]
             *         Arguments to be accessed in event handler.
             *
             * @sample highcharts/members/axis-setextremes/
             *         Set extremes from a button
             * @sample highcharts/members/axis-setextremes-datetime/
             *         Set extremes on a datetime axis
             * @sample highcharts/members/axis-setextremes-off-ticks/
             *         Set extremes off ticks
             * @sample stock/members/axis-setextremes/
             *         Set extremes in Highstock
             * @sample maps/members/axis-setextremes/
             *         Set extremes in Highmaps
             */
            setExtremes: function(newMin, newMax, redraw, animation, eventArguments) {
                var axis = this,
                    chart = axis.chart;

                redraw = pick(redraw, true); // defaults to true

                each(axis.series, function(serie) {
                    delete serie.kdTree;
                });

                // Extend the arguments with min and max
                eventArguments = extend(eventArguments, {
                    min: newMin,
                    max: newMax
                });

                // Fire the event
                fireEvent(axis, 'setExtremes', eventArguments, function() {

                    axis.userMin = newMin;
                    axis.userMax = newMax;
                    axis.eventArgs = eventArguments;

                    if (redraw) {
                        chart.redraw(animation);
                    }
                });
            },

            /**
             * Overridable method for zooming chart. Pulled out in a separate method to
             * allow overriding in stock charts.
             *
             * @private
             */
            zoom: function(newMin, newMax) {
                var dataMin = this.dataMin,
                    dataMax = this.dataMax,
                    options = this.options,
                    min = Math.min(dataMin, pick(options.min, dataMin)),
                    max = Math.max(dataMax, pick(options.max, dataMax));

                if (newMin !== this.min || newMax !== this.max) { // #5790

                    // Prevent pinch zooming out of range. Check for defined is for
                    // #1946. #1734.
                    if (!this.allowZoomOutside) {
                        // #6014, sometimes newMax will be smaller than min (or newMin
                        // will be larger than max).
                        if (defined(dataMin)) {
                            if (newMin < min) {
                                newMin = min;
                            }
                            if (newMin > max) {
                                newMin = max;
                            }
                        }
                        if (defined(dataMax)) {
                            if (newMax < min) {
                                newMax = min;
                            }
                            if (newMax > max) {
                                newMax = max;
                            }
                        }
                    }

                    // In full view, displaying the reset zoom button is not required
                    this.displayBtn = newMin !== undefined || newMax !== undefined;

                    // Do it
                    this.setExtremes(
                        newMin,
                        newMax,
                        false,
                        undefined, {
                            trigger: 'zoom'
                        }
                    );
                }

                return true;
            },

            /**
             * Update the axis metrics.
             *
             * @private
             */
            setAxisSize: function() {
                var chart = this.chart,
                    options = this.options,
                    // [top, right, bottom, left]
                    offsets = options.offsets || [0, 0, 0, 0],
                    horiz = this.horiz,

                    // Check for percentage based input values. Rounding fixes problems
                    // with column overflow and plot line filtering (#4898, #4899)
                    width = this.width = Math.round(H.relativeLength(
                        pick(
                            options.width,
                            chart.plotWidth - offsets[3] + offsets[1]
                        ),
                        chart.plotWidth
                    )),
                    height = this.height = Math.round(H.relativeLength(
                        pick(
                            options.height,
                            chart.plotHeight - offsets[0] + offsets[2]
                        ),
                        chart.plotHeight
                    )),
                    top = this.top = Math.round(H.relativeLength(
                        pick(options.top, chart.plotTop + offsets[0]),
                        chart.plotHeight,
                        chart.plotTop
                    )),
                    left = this.left = Math.round(H.relativeLength(
                        pick(options.left, chart.plotLeft + offsets[3]),
                        chart.plotWidth,
                        chart.plotLeft
                    ));

                // Expose basic values to use in Series object and navigator
                this.bottom = chart.chartHeight - height - top;
                this.right = chart.chartWidth - width - left;

                // Direction agnostic properties
                this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
                this.pos = horiz ? left : top; // distance from SVG origin
            },

            /**
             * The returned object literal from the {@link Highcharts.Axis#getExtremes}
             * function. 
             * @typedef {Object} Extremes
             * @property {Number} dataMax
             *         The maximum value of the axis' associated series.
             * @property {Number} dataMin
             *         The minimum value of the axis' associated series.
             * @property {Number} max
             *         The maximum axis value, either automatic or set manually. If the
             *         `max` option is not set, `maxPadding` is 0 and `endOnTick` is
             *         false, this value will be the same as `dataMax`.
             * @property {Number} min
             *         The minimum axis value, either automatic or set manually. If the
             *         `min` option is not set, `minPadding` is 0 and `startOnTick` is
             *         false, this value will be the same as `dataMin`.
             */
            /**
             * Get the current extremes for the axis.
             *
             * @returns {Extremes}
             * An object containing extremes information.
             * 
             * @sample  highcharts/members/axis-getextremes/
             *          Report extremes by click on a button
             * @sample  maps/members/axis-getextremes/
             *          Get extremes in Highmaps
             */
            getExtremes: function() {
                var axis = this,
                    isLog = axis.isLog,
                    lin2log = axis.lin2log;

                return {
                    min: isLog ? correctFloat(lin2log(axis.min)) : axis.min,
                    max: isLog ? correctFloat(lin2log(axis.max)) : axis.max,
                    dataMin: axis.dataMin,
                    dataMax: axis.dataMax,
                    userMin: axis.userMin,
                    userMax: axis.userMax
                };
            },

            /**
             * Get the zero plane either based on zero or on the min or max value.
             * Used in bar and area plots.
             *
             * @param  {Number} threshold
             *         The threshold in axis values.
             *
             * @return {Number}
             *         The translated threshold position in terms of pixels, and
             *         corrected to stay within the axis bounds.
             */
            getThreshold: function(threshold) {
                var axis = this,
                    isLog = axis.isLog,
                    lin2log = axis.lin2log,
                    realMin = isLog ? lin2log(axis.min) : axis.min,
                    realMax = isLog ? lin2log(axis.max) : axis.max;

                if (threshold === null) {
                    threshold = realMin;
                } else if (realMin > threshold) {
                    threshold = realMin;
                } else if (realMax < threshold) {
                    threshold = realMax;
                }

                return axis.translate(threshold, 0, 1, 0, 1);
            },

            /**
             * Compute auto alignment for the axis label based on which side the axis is
             * on and the given rotation for the label.
             *
             * @param  {Number} rotation
             *         The rotation in degrees as set by either the `rotation` or 
             *         `autoRotation` options.
             * @private
             */
            autoLabelAlign: function(rotation) {
                var ret,
                    angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360;

                if (angle > 15 && angle < 165) {
                    ret = 'right';
                } else if (angle > 195 && angle < 345) {
                    ret = 'left';
                } else {
                    ret = 'center';
                }
                return ret;
            },

            /**
             * Get the tick length and width for the axis based on axis options.
             *
             * @private
             * 
             * @param  {String} prefix
             *         'tick' or 'minorTick'
             * @return {Array.<Number>}
             *         An array of tickLength and tickWidth
             */
            tickSize: function(prefix) {
                var options = this.options,
                    tickLength = options[prefix + 'Length'],
                    tickWidth = pick(
                        options[prefix + 'Width'],
                        prefix === 'tick' && this.isXAxis ? 1 : 0 // X axis default 1
                    );

                if (tickWidth && tickLength) {
                    // Negate the length
                    if (options[prefix + 'Position'] === 'inside') {
                        tickLength = -tickLength;
                    }
                    return [tickLength, tickWidth];
                }

            },

            /**
             * Return the size of the labels.
             *
             * @private
             */
            labelMetrics: function() {
                var index = this.tickPositions && this.tickPositions[0] || 0;
                return this.chart.renderer.fontMetrics(
                    this.options.labels.style && this.options.labels.style.fontSize,
                    this.ticks[index] && this.ticks[index].label
                );
            },

            /**
             * Prevent the ticks from getting so close we can't draw the labels. On a
             * horizontal axis, this is handled by rotating the labels, removing ticks
             * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
             *
             * @private
             */
            unsquish: function() {
                var labelOptions = this.options.labels,
                    horiz = this.horiz,
                    tickInterval = this.tickInterval,
                    newTickInterval = tickInterval,
                    slotSize = this.len / (
                        ((this.categories ? 1 : 0) + this.max - this.min) / tickInterval
                    ),
                    rotation,
                    rotationOption = labelOptions.rotation,
                    labelMetrics = this.labelMetrics(),
                    step,
                    bestScore = Number.MAX_VALUE,
                    autoRotation,
                    // Return the multiple of tickInterval that is needed to avoid
                    // collision
                    getStep = function(spaceNeeded) {
                        var step = spaceNeeded / (slotSize || 1);
                        step = step > 1 ? Math.ceil(step) : 1;
                        return step * tickInterval;
                    };

                if (horiz) {
                    autoRotation = !labelOptions.staggerLines && !labelOptions.step && ( // #3971
                        defined(rotationOption) ? [rotationOption] :
                        slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation
                    );

                    if (autoRotation) {

                        // Loop over the given autoRotation options, and determine which gives the best score. The
                        // best score is that with the lowest number of steps and a rotation closest to horizontal.
                        each(autoRotation, function(rot) {
                            var score;

                            if (rot === rotationOption || (rot && rot >= -90 && rot <= 90)) { // #3891

                                step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));

                                score = step + Math.abs(rot / 360);

                                if (score < bestScore) {
                                    bestScore = score;
                                    rotation = rot;
                                    newTickInterval = step;
                                }
                            }
                        });
                    }

                } else if (!labelOptions.step) { // #4411
                    newTickInterval = getStep(labelMetrics.h);
                }

                this.autoRotation = autoRotation;
                this.labelRotation = pick(rotation, rotationOption);

                return newTickInterval;
            },

            /**
             * Get the general slot width for labels/categories on this axis. This may
             * change between the pre-render (from Axis.getOffset) and the final tick
             * rendering and placement.
             *
             * @private
             * @return {Number}
             *         The pixel width allocated to each axis label.
             */
            getSlotWidth: function() {
                // #5086, #1580, #1931
                var chart = this.chart,
                    horiz = this.horiz,
                    labelOptions = this.options.labels,
                    slotCount = Math.max(
                        this.tickPositions.length - (this.categories ? 0 : 1),
                        1
                    ),
                    marginLeft = chart.margin[3];

                return (
                    horiz &&
                    (labelOptions.step || 0) < 2 &&
                    !labelOptions.rotation && // #4415
                    ((this.staggerLines || 1) * this.len) / slotCount
                ) || (!horiz && (
                    // #7028
                    (labelOptions.style && parseInt(labelOptions.style.width, 10)) ||
                    (marginLeft && (marginLeft - chart.spacing[3])) ||
                    chart.chartWidth * 0.33
                ));

            },

            /**
             * Render the axis labels and determine whether ellipsis or rotation need
             * to be applied.
             *
             * @private
             */
            renderUnsquish: function() {
                var chart = this.chart,
                    renderer = chart.renderer,
                    tickPositions = this.tickPositions,
                    ticks = this.ticks,
                    labelOptions = this.options.labels,
                    horiz = this.horiz,
                    slotWidth = this.getSlotWidth(),
                    innerWidth = Math.max(1, Math.round(slotWidth - 2 * (labelOptions.padding || 5))),
                    attr = {},
                    labelMetrics = this.labelMetrics(),
                    textOverflowOption = labelOptions.style && labelOptions.style.textOverflow,
                    css,
                    maxLabelLength = 0,
                    label,
                    i,
                    pos;

                // Set rotation option unless it is "auto", like in gauges
                if (!isString(labelOptions.rotation)) {
                    attr.rotation = labelOptions.rotation || 0; // #4443
                }

                // Get the longest label length
                each(tickPositions, function(tick) {
                    tick = ticks[tick];
                    if (tick && tick.labelLength > maxLabelLength) {
                        maxLabelLength = tick.labelLength;
                    }
                });
                this.maxLabelLength = maxLabelLength;


                // Handle auto rotation on horizontal axis
                if (this.autoRotation) {

                    // Apply rotation only if the label is too wide for the slot, and
                    // the label is wider than its height.
                    if (maxLabelLength > innerWidth && maxLabelLength > labelMetrics.h) {
                        attr.rotation = this.labelRotation;
                    } else {
                        this.labelRotation = 0;
                    }

                    // Handle word-wrap or ellipsis on vertical axis
                } else if (slotWidth) {
                    // For word-wrap or ellipsis
                    css = {
                        width: innerWidth + 'px'
                    };

                    if (!textOverflowOption) {
                        css.textOverflow = 'clip';

                        // On vertical axis, only allow word wrap if there is room for more lines.
                        i = tickPositions.length;
                        while (!horiz && i--) {
                            pos = tickPositions[i];
                            label = ticks[pos].label;
                            if (label) {
                                // Reset ellipsis in order to get the correct bounding box (#4070)
                                if (label.styles && label.styles.textOverflow === 'ellipsis') {
                                    label.css({
                                        textOverflow: 'clip'
                                    });

                                    // Set the correct width in order to read the bounding box height (#4678, #5034)
                                } else if (ticks[pos].labelLength > slotWidth) {
                                    label.css({
                                        width: slotWidth + 'px'
                                    });
                                }

                                if (label.getBBox().height > this.len / tickPositions.length - (labelMetrics.h - labelMetrics.f)) {
                                    label.specCss = {
                                        textOverflow: 'ellipsis'
                                    };
                                }
                            }
                        }
                    }
                }


                // Add ellipsis if the label length is significantly longer than ideal
                if (attr.rotation) {
                    css = {
                        width: (maxLabelLength > chart.chartHeight * 0.5 ? chart.chartHeight * 0.33 : chart.chartHeight) + 'px'
                    };
                    if (!textOverflowOption) {
                        css.textOverflow = 'ellipsis';
                    }
                }

                // Set the explicit or automatic label alignment
                this.labelAlign = labelOptions.align || this.autoLabelAlign(this.labelRotation);
                if (this.labelAlign) {
                    attr.align = this.labelAlign;
                }

                // Apply general and specific CSS
                each(tickPositions, function(pos) {
                    var tick = ticks[pos],
                        label = tick && tick.label;
                    if (label) {
                        label.attr(attr); // This needs to go before the CSS in old IE (#4502)
                        if (css) {
                            label.css(merge(css, label.specCss));
                        }
                        delete label.specCss;
                        tick.rotation = attr.rotation;
                    }
                });

                // Note: Why is this not part of getLabelPosition?
                this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
            },

            /**
             * Return true if the axis has associated data.
             *
             * @return {Boolean}
             *         True if the axis has associated visible series and those series
             *         have either valid data points or explicit `min` and `max`
             *         settings.
             */
            hasData: function() {
                return (
                    this.hasVisibleSeries ||
                    (defined(this.min) && defined(this.max) && !!this.tickPositions)
                );
            },

            /**
             * Adds the title defined in axis.options.title.
             * @param {Boolean} display - whether or not to display the title
             */
            addTitle: function(display) {
                var axis = this,
                    renderer = axis.chart.renderer,
                    horiz = axis.horiz,
                    opposite = axis.opposite,
                    options = axis.options,
                    axisTitleOptions = options.title,
                    textAlign;

                if (!axis.axisTitle) {
                    textAlign = axisTitleOptions.textAlign;
                    if (!textAlign) {
                        textAlign = (horiz ? {
                            low: 'left',
                            middle: 'center',
                            high: 'right'
                        } : {
                            low: opposite ? 'right' : 'left',
                            middle: 'center',
                            high: opposite ? 'left' : 'right'
                        })[axisTitleOptions.align];
                    }
                    axis.axisTitle = renderer.text(
                            axisTitleOptions.text,
                            0,
                            0,
                            axisTitleOptions.useHTML
                        )
                        .attr({
                            zIndex: 7,
                            rotation: axisTitleOptions.rotation || 0,
                            align: textAlign
                        })
                        .addClass('highcharts-axis-title')

                        .css(axisTitleOptions.style)

                        .add(axis.axisGroup);
                    axis.axisTitle.isNew = true;
                }

                // Max width defaults to the length of the axis

                if (!axisTitleOptions.style.width && !axis.isRadial) {

                    axis.axisTitle.css({
                        width: axis.len
                    });

                }



                // hide or show the title depending on whether showEmpty is set
                axis.axisTitle[display ? 'show' : 'hide'](true);
            },

            /**
             * Generates a tick for initial positioning.
             *
             * @private
             * @param  {number} pos
             *         The tick position in axis values.
             * @param  {number} i
             *         The index of the tick in {@link Axis.tickPositions}.
             */
            generateTick: function(pos) {
                var ticks = this.ticks;

                if (!ticks[pos]) {
                    ticks[pos] = new Tick(this, pos);
                } else {
                    ticks[pos].addLabel(); // update labels depending on tick interval
                }
            },

            /**
             * Render the tick labels to a preliminary position to get their sizes.
             *
             * @private
             */
            getOffset: function() {
                var axis = this,
                    chart = axis.chart,
                    renderer = chart.renderer,
                    options = axis.options,
                    tickPositions = axis.tickPositions,
                    ticks = axis.ticks,
                    horiz = axis.horiz,
                    side = axis.side,
                    invertedSide = chart.inverted && !axis.isZAxis ? [1, 0, 3, 2][side] : side,
                    hasData,
                    showAxis,
                    titleOffset = 0,
                    titleOffsetOption,
                    titleMargin = 0,
                    axisTitleOptions = options.title,
                    labelOptions = options.labels,
                    labelOffset = 0, // reset
                    labelOffsetPadded,
                    axisOffset = chart.axisOffset,
                    clipOffset = chart.clipOffset,
                    clip,
                    directionFactor = [-1, 1, 1, -1][side],
                    className = options.className,
                    axisParent = axis.axisParent, // Used in color axis
                    lineHeightCorrection,
                    tickSize = this.tickSize('tick');

                // For reuse in Axis.render
                hasData = axis.hasData();
                axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);

                // Set/reset staggerLines
                axis.staggerLines = axis.horiz && labelOptions.staggerLines;

                // Create the axisGroup and gridGroup elements on first iteration
                if (!axis.axisGroup) {
                    axis.gridGroup = renderer.g('grid')
                        .attr({
                            zIndex: options.gridZIndex || 1
                        })
                        .addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' + (className || ''))
                        .add(axisParent);
                    axis.axisGroup = renderer.g('axis')
                        .attr({
                            zIndex: options.zIndex || 2
                        })
                        .addClass('highcharts-' + this.coll.toLowerCase() + ' ' + (className || ''))
                        .add(axisParent);
                    axis.labelGroup = renderer.g('axis-labels')
                        .attr({
                            zIndex: labelOptions.zIndex || 7
                        })
                        .addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' + (className || ''))
                        .add(axisParent);
                }

                if (hasData || axis.isLinked) {

                    // Generate ticks
                    each(tickPositions, function(pos, i) {
                        // i is not used here, but may be used in overrides
                        axis.generateTick(pos, i);
                    });

                    axis.renderUnsquish();


                    // Left side must be align: right and right side must have align: left for labels
                    if (labelOptions.reserveSpace !== false && (side === 0 || side === 2 || {
                            1: 'left',
                            3: 'right'
                        }[side] === axis.labelAlign || axis.labelAlign === 'center')) {
                        each(tickPositions, function(pos) {

                            // get the highest offset
                            labelOffset = Math.max(
                                ticks[pos].getLabelSize(),
                                labelOffset
                            );
                        });
                    }

                    if (axis.staggerLines) {
                        labelOffset *= axis.staggerLines;
                        axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
                    }


                } else { // doesn't have data
                    objectEach(ticks, function(tick, n) {
                        tick.destroy();
                        delete ticks[n];
                    });
                }

                if (axisTitleOptions && axisTitleOptions.text && axisTitleOptions.enabled !== false) {
                    axis.addTitle(showAxis);

                    if (showAxis && axisTitleOptions.reserveSpace !== false) {
                        axis.titleOffset = titleOffset =
                            axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
                        titleOffsetOption = axisTitleOptions.offset;
                        titleMargin = defined(titleOffsetOption) ? 0 : pick(axisTitleOptions.margin, horiz ? 5 : 10);
                    }
                }

                // Render the axis line
                axis.renderLine();

                // handle automatic or user set offset
                axis.offset = directionFactor * pick(options.offset, axisOffset[side]);

                axis.tickRotCorr = axis.tickRotCorr || {
                    x: 0,
                    y: 0
                }; // polar
                if (side === 0) {
                    lineHeightCorrection = -axis.labelMetrics().h;
                } else if (side === 2) {
                    lineHeightCorrection = axis.tickRotCorr.y;
                } else {
                    lineHeightCorrection = 0;
                }

                // Find the padded label offset
                labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
                if (labelOffset) {
                    labelOffsetPadded -= lineHeightCorrection;
                    labelOffsetPadded += directionFactor * (horiz ? pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) : labelOptions.x);
                }
                axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);

                axisOffset[side] = Math.max(
                    axisOffset[side],
                    axis.axisTitleMargin + titleOffset + directionFactor * axis.offset,
                    labelOffsetPadded, // #3027
                    hasData && tickPositions.length && tickSize ?
                    tickSize[0] + directionFactor * axis.offset :
                    0 // #4866
                );

                // Decide the clipping needed to keep the graph inside the plot area and axis lines
                clip = options.offset ? 0 : Math.floor(axis.axisLine.strokeWidth() / 2) * 2; // #4308, #4371
                clipOffset[invertedSide] = Math.max(clipOffset[invertedSide], clip);
            },

            /**
             * Internal function to get the path for the axis line. Extended for polar
             * charts.
             *
             * @param  {Number} lineWidth
             *         The line width in pixels.
             * @return {Array}
             *         The SVG path definition in array form.
             */
            getLinePath: function(lineWidth) {
                var chart = this.chart,
                    opposite = this.opposite,
                    offset = this.offset,
                    horiz = this.horiz,
                    lineLeft = this.left + (opposite ? this.width : 0) + offset,
                    lineTop = chart.chartHeight - this.bottom -
                    (opposite ? this.height : 0) + offset;

                if (opposite) {
                    lineWidth *= -1; // crispify the other way - #1480, #1687
                }

                return chart.renderer
                    .crispLine([
                        'M',
                        horiz ?
                        this.left :
                        lineLeft,
                        horiz ?
                        lineTop :
                        this.top,
                        'L',
                        horiz ?
                        chart.chartWidth - this.right :
                        lineLeft,
                        horiz ?
                        lineTop :
                        chart.chartHeight - this.bottom
                    ], lineWidth);
            },

            /**
             * Render the axis line. Called internally when rendering and redrawing the
             * axis.
             */
            renderLine: function() {
                if (!this.axisLine) {
                    this.axisLine = this.chart.renderer.path()
                        .addClass('highcharts-axis-line')
                        .add(this.axisGroup);


                    this.axisLine.attr({
                        stroke: this.options.lineColor,
                        'stroke-width': this.options.lineWidth,
                        zIndex: 7
                    });

                }
            },

            /**
             * Position the axis title.
             *
             * @private
             *
             * @return {Object}
             *         X and Y positions for the title.
             */
            getTitlePosition: function() {
                // compute anchor points for each of the title align options
                var horiz = this.horiz,
                    axisLeft = this.left,
                    axisTop = this.top,
                    axisLength = this.len,
                    axisTitleOptions = this.options.title,
                    margin = horiz ? axisLeft : axisTop,
                    opposite = this.opposite,
                    offset = this.offset,
                    xOption = axisTitleOptions.x || 0,
                    yOption = axisTitleOptions.y || 0,
                    axisTitle = this.axisTitle,
                    fontMetrics = this.chart.renderer.fontMetrics(
                        axisTitleOptions.style && axisTitleOptions.style.fontSize,
                        axisTitle
                    ),
                    // The part of a multiline text that is below the baseline of the
                    // first line. Subtract 1 to preserve pixel-perfectness from the 
                    // old behaviour (v5.0.12), where only one line was allowed.
                    textHeightOvershoot = Math.max(
                        axisTitle.getBBox(null, 0).height - fontMetrics.h - 1,
                        0
                    ),

                    // the position in the length direction of the axis
                    alongAxis = {
                        low: margin + (horiz ? 0 : axisLength),
                        middle: margin + axisLength / 2,
                        high: margin + (horiz ? axisLength : 0)
                    }[axisTitleOptions.align],

                    // the position in the perpendicular direction of the axis
                    offAxis = (horiz ? axisTop + this.height : axisLeft) +
                    (horiz ? 1 : -1) * // horizontal axis reverses the margin
                    (opposite ? -1 : 1) * // so does opposite axes
                    this.axisTitleMargin + [-textHeightOvershoot, // top
                        textHeightOvershoot, // right
                        fontMetrics.f, // bottom
                        -textHeightOvershoot // left
                    ][this.side];


                return {
                    x: horiz ?
                        alongAxis + xOption : offAxis + (opposite ? this.width : 0) + offset + xOption,
                    y: horiz ?
                        offAxis + yOption - (opposite ? this.height : 0) + offset : alongAxis + yOption
                };
            },

            /**
             * Render a minor tick into the given position. If a minor tick already 
             * exists in this position, move it.
             * 
             * @param  {number} pos
             *         The position in axis values.
             */
            renderMinorTick: function(pos) {
                var slideInTicks = this.chart.hasRendered && isNumber(this.oldMin),
                    minorTicks = this.minorTicks;

                if (!minorTicks[pos]) {
                    minorTicks[pos] = new Tick(this, pos, 'minor');
                }

                // Render new ticks in old position
                if (slideInTicks && minorTicks[pos].isNew) {
                    minorTicks[pos].render(null, true);
                }

                minorTicks[pos].render(null, false, 1);
            },

            /**
             * Render a major tick into the given position. If a tick already exists
             * in this position, move it.
             * 
             * @param  {number} pos
             *         The position in axis values.
             * @param  {number} i
             *         The tick index.
             */
            renderTick: function(pos, i) {
                var isLinked = this.isLinked,
                    ticks = this.ticks,
                    slideInTicks = this.chart.hasRendered && isNumber(this.oldMin);

                // Linked axes need an extra check to find out if
                if (!isLinked || (pos >= this.min && pos <= this.max)) {

                    if (!ticks[pos]) {
                        ticks[pos] = new Tick(this, pos);
                    }

                    // render new ticks in old position
                    if (slideInTicks && ticks[pos].isNew) {
                        ticks[pos].render(i, true, 0.1);
                    }

                    ticks[pos].render(i);
                }
            },

            /**
             * Render the axis.
             *
             * @private
             */
            render: function() {
                var axis = this,
                    chart = axis.chart,
                    renderer = chart.renderer,
                    options = axis.options,
                    isLog = axis.isLog,
                    lin2log = axis.lin2log,
                    isLinked = axis.isLinked,
                    tickPositions = axis.tickPositions,
                    axisTitle = axis.axisTitle,
                    ticks = axis.ticks,
                    minorTicks = axis.minorTicks,
                    alternateBands = axis.alternateBands,
                    stackLabelOptions = options.stackLabels,
                    alternateGridColor = options.alternateGridColor,
                    tickmarkOffset = axis.tickmarkOffset,
                    axisLine = axis.axisLine,
                    showAxis = axis.showAxis,
                    animation = animObject(renderer.globalAnimation),
                    from,
                    to;

                // Reset
                axis.labelEdge.length = 0;
                axis.overlap = false;

                // Mark all elements inActive before we go over and mark the active ones
                each([ticks, minorTicks, alternateBands], function(coll) {
                    objectEach(coll, function(tick) {
                        tick.isActive = false;
                    });
                });

                // If the series has data draw the ticks. Else only the line and title
                if (axis.hasData() || isLinked) {

                    // minor ticks
                    if (axis.minorTickInterval && !axis.categories) {
                        each(axis.getMinorTickPositions(), function(pos) {
                            axis.renderMinorTick(pos);
                        });
                    }

                    // Major ticks. Pull out the first item and render it last so that
                    // we can get the position of the neighbour label. #808.
                    if (tickPositions.length) { // #1300
                        each(tickPositions, function(pos, i) {
                            axis.renderTick(pos, i);
                        });
                        // In a categorized axis, the tick marks are displayed between labels. So
                        // we need to add a tick mark and grid line at the left edge of the X axis.
                        if (tickmarkOffset && (axis.min === 0 || axis.single)) {
                            if (!ticks[-1]) {
                                ticks[-1] = new Tick(axis, -1, null, true);
                            }
                            ticks[-1].render(-1);
                        }

                    }

                    // alternate grid color
                    if (alternateGridColor) {
                        each(tickPositions, function(pos, i) {
                            to = tickPositions[i + 1] !== undefined ? tickPositions[i + 1] + tickmarkOffset : axis.max - tickmarkOffset;
                            if (i % 2 === 0 && pos < axis.max && to <= axis.max + (chart.polar ? -tickmarkOffset : tickmarkOffset)) { // #2248, #4660
                                if (!alternateBands[pos]) {
                                    alternateBands[pos] = new H.PlotLineOrBand(axis);
                                }
                                from = pos + tickmarkOffset; // #949
                                alternateBands[pos].options = {
                                    from: isLog ? lin2log(from) : from,
                                    to: isLog ? lin2log(to) : to,
                                    color: alternateGridColor
                                };
                                alternateBands[pos].render();
                                alternateBands[pos].isActive = true;
                            }
                        });
                    }

                    // custom plot lines and bands
                    if (!axis._addedPlotLB) { // only first time
                        each((options.plotLines || []).concat(options.plotBands || []), function(plotLineOptions) {
                            axis.addPlotBandOrLine(plotLineOptions);
                        });
                        axis._addedPlotLB = true;
                    }

                } // end if hasData

                // Remove inactive ticks
                each([ticks, minorTicks, alternateBands], function(coll) {
                    var i,
                        forDestruction = [],
                        delay = animation.duration,
                        destroyInactiveItems = function() {
                            i = forDestruction.length;
                            while (i--) {
                                // When resizing rapidly, the same items may be destroyed in different timeouts,
                                // or the may be reactivated
                                if (coll[forDestruction[i]] && !coll[forDestruction[i]].isActive) {
                                    coll[forDestruction[i]].destroy();
                                    delete coll[forDestruction[i]];
                                }
                            }

                        };

                    objectEach(coll, function(tick, pos) {
                        if (!tick.isActive) {
                            // Render to zero opacity
                            tick.render(pos, false, 0);
                            tick.isActive = false;
                            forDestruction.push(pos);
                        }
                    });

                    // When the objects are finished fading out, destroy them
                    syncTimeout(
                        destroyInactiveItems,
                        coll === alternateBands || !chart.hasRendered || !delay ? 0 : delay
                    );
                });

                // Set the axis line path
                if (axisLine) {
                    axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
                        d: this.getLinePath(axisLine.strokeWidth())
                    });
                    axisLine.isPlaced = true;

                    // Show or hide the line depending on options.showEmpty
                    axisLine[showAxis ? 'show' : 'hide'](true);
                }

                if (axisTitle && showAxis) {
                    var titleXy = axis.getTitlePosition();
                    if (isNumber(titleXy.y)) {
                        axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
                        axisTitle.isNew = false;
                    } else {
                        axisTitle.attr('y', -9999);
                        axisTitle.isNew = true;
                    }
                }

                // Stacked totals:
                if (stackLabelOptions && stackLabelOptions.enabled) {
                    axis.renderStackTotals();
                }
                // End stacked totals

                axis.isDirty = false;
            },

            /**
             * Redraw the axis to reflect changes in the data or axis extremes. Called
             * internally from {@link Chart#redraw}.
             *
             * @private
             */
            redraw: function() {

                if (this.visible) {
                    // render the axis
                    this.render();

                    // move plot lines and bands
                    each(this.plotLinesAndBands, function(plotLine) {
                        plotLine.render();
                    });
                }

                // mark associated series as dirty and ready for redraw
                each(this.series, function(series) {
                    series.isDirty = true;
                });

            },

            // Properties to survive after destroy, needed for Axis.update (#4317,
            // #5773, #5881).
            keepProps: ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'],

            /**
             * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
             * to fully remove the axis.
             *
             * @private
             * @param  {Boolean} keepEvents
             *         Whether to preserve events, used internally in Axis.update.
             */
            destroy: function(keepEvents) {
                var axis = this,
                    stacks = axis.stacks,
                    plotLinesAndBands = axis.plotLinesAndBands,
                    plotGroup,
                    i;

                // Remove the events
                if (!keepEvents) {
                    removeEvent(axis);
                }

                // Destroy each stack total
                objectEach(stacks, function(stack, stackKey) {
                    destroyObjectProperties(stack);

                    stacks[stackKey] = null;
                });

                // Destroy collections
                each([axis.ticks, axis.minorTicks, axis.alternateBands], function(coll) {
                    destroyObjectProperties(coll);
                });
                if (plotLinesAndBands) {
                    i = plotLinesAndBands.length;
                    while (i--) { // #1975
                        plotLinesAndBands[i].destroy();
                    }
                }

                // Destroy local variables
                each(['stackTotalGroup', 'axisLine', 'axisTitle', 'axisGroup', 'gridGroup', 'labelGroup', 'cross'], function(prop) {
                    if (axis[prop]) {
                        axis[prop] = axis[prop].destroy();
                    }
                });

                // Destroy each generated group for plotlines and plotbands
                for (plotGroup in axis.plotLinesAndBandsGroups) {
                    axis.plotLinesAndBandsGroups[plotGroup] = axis.plotLinesAndBandsGroups[plotGroup].destroy();
                }

                // Delete all properties and fall back to the prototype.
                objectEach(axis, function(val, key) {
                    if (inArray(key, axis.keepProps) === -1) {
                        delete axis[key];
                    }
                });
            },

            /**
             * Internal function to draw a crosshair.
             *
             * @param  {PointerEvent} [e]
             *         The event arguments from the modified pointer event, extended 
             *         with `chartX` and `chartY`
             * @param  {Point} [point]
             *         The Point object if the crosshair snaps to points.
             */
            drawCrosshair: function(e, point) {

                var path,
                    options = this.crosshair,
                    snap = pick(options.snap, true),
                    pos,
                    categorized,
                    graphic = this.cross;

                // Use last available event when updating non-snapped crosshairs without
                // mouse interaction (#5287)
                if (!e) {
                    e = this.cross && this.cross.e;
                }

                if (
                    // Disabled in options
                    !this.crosshair ||
                    // Snap
                    ((defined(point) || !snap) === false)
                ) {
                    this.hideCrosshair();
                } else {

                    // Get the path
                    if (!snap) {
                        pos = e && (this.horiz ? e.chartX - this.pos : this.len - e.chartY + this.pos);
                    } else if (defined(point)) {
                        pos = this.isXAxis ? point.plotX : this.len - point.plotY; // #3834
                    }

                    if (defined(pos)) {
                        path = this.getPlotLinePath(
                            // First argument, value, only used on radial
                            point && (this.isXAxis ? point.x : pick(point.stackY, point.y)),
                            null,
                            null,
                            null,
                            pos // Translated position
                        ) || null; // #3189
                    }

                    if (!defined(path)) {
                        this.hideCrosshair();
                        return;
                    }

                    categorized = this.categories && !this.isRadial;

                    // Draw the cross
                    if (!graphic) {
                        this.cross = graphic = this.chart.renderer
                            .path()
                            .addClass('highcharts-crosshair highcharts-crosshair-' +
                                (categorized ? 'category ' : 'thin ') + options.className)
                            .attr({
                                zIndex: pick(options.zIndex, 2)
                            })
                            .add();


                        // Presentational attributes
                        graphic.attr({
                            'stroke': options.color || (categorized ? color('#ccd6eb').setOpacity(0.25).get() : '#cccccc'),
                            'stroke-width': pick(options.width, 1)
                        }).css({
                            'pointer-events': 'none'
                        });
                        if (options.dashStyle) {
                            graphic.attr({
                                dashstyle: options.dashStyle
                            });
                        }


                    }

                    graphic.show().attr({
                        d: path
                    });

                    if (categorized && !options.width) {
                        graphic.attr({
                            'stroke-width': this.transA
                        });
                    }
                    this.cross.e = e;
                }
            },

            /**
             *	Hide the crosshair if visible.
             */
            hideCrosshair: function() {
                if (this.cross) {
                    this.cross.hide();
                }
            }
        }); // end Axis

        H.Axis = Axis;
        return Axis;
    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var Axis = H.Axis,
            Date = H.Date,
            dateFormat = H.dateFormat,
            defaultOptions = H.defaultOptions,
            defined = H.defined,
            each = H.each,
            extend = H.extend,
            getMagnitude = H.getMagnitude,
            getTZOffset = H.getTZOffset,
            normalizeTickInterval = H.normalizeTickInterval,
            pick = H.pick,
            timeUnits = H.timeUnits;
        /**
         * Set the tick positions to a time unit that makes sense, for example
         * on the first of each month or on every Monday. Return an array
         * with the time positions. Used in datetime axes as well as for grouping
         * data on a datetime axis.
         *
         * @param {Object} normalizedInterval The interval in axis values (ms) and the count
         * @param {Number} min The minimum in axis values
         * @param {Number} max The maximum in axis values
         * @param {Number} startOfWeek
         */
        Axis.prototype.getTimeTicks = function(normalizedInterval, min, max, startOfWeek) {
            var tickPositions = [],
                i,
                higherRanks = {},
                useUTC = defaultOptions.global.useUTC,
                minYear, // used in months and years as a basis for Date.UTC()
                // When crossing DST, use the max. Resolves #6278.
                minDate = new Date(min - Math.max(getTZOffset(min), getTZOffset(max))),
                makeTime = Date.hcMakeTime,
                interval = normalizedInterval.unitRange,
                count = normalizedInterval.count,
                baseOffset, // #6797
                variableDayLength;

            if (defined(min)) { // #1300
                minDate[Date.hcSetMilliseconds](interval >= timeUnits.second ? 0 : // #3935
                    count * Math.floor(minDate.getMilliseconds() / count)); // #3652, #3654

                if (interval >= timeUnits.second) { // second
                    minDate[Date.hcSetSeconds](interval >= timeUnits.minute ? 0 : // #3935
                        count * Math.floor(minDate.getSeconds() / count));
                }

                if (interval >= timeUnits.minute) { // minute
                    minDate[Date.hcSetMinutes](interval >= timeUnits.hour ? 0 :
                        count * Math.floor(minDate[Date.hcGetMinutes]() / count));
                }

                if (interval >= timeUnits.hour) { // hour
                    minDate[Date.hcSetHours](interval >= timeUnits.day ? 0 :
                        count * Math.floor(minDate[Date.hcGetHours]() / count));
                }

                if (interval >= timeUnits.day) { // day
                    minDate[Date.hcSetDate](interval >= timeUnits.month ? 1 :
                        count * Math.floor(minDate[Date.hcGetDate]() / count));
                }

                if (interval >= timeUnits.month) { // month
                    minDate[Date.hcSetMonth](interval >= timeUnits.year ? 0 :
                        count * Math.floor(minDate[Date.hcGetMonth]() / count));
                    minYear = minDate[Date.hcGetFullYear]();
                }

                if (interval >= timeUnits.year) { // year
                    minYear -= minYear % count;
                    minDate[Date.hcSetFullYear](minYear);
                }

                // week is a special case that runs outside the hierarchy
                if (interval === timeUnits.week) {
                    // get start of current week, independent of count
                    minDate[Date.hcSetDate](minDate[Date.hcGetDate]() - minDate[Date.hcGetDay]() +
                        pick(startOfWeek, 1));
                }


                // Get basics for variable time spans
                minYear = minDate[Date.hcGetFullYear]();
                var minMonth = minDate[Date.hcGetMonth](),
                    minDateDate = minDate[Date.hcGetDate](),
                    minHours = minDate[Date.hcGetHours]();


                // Handle local timezone offset
                if (Date.hcTimezoneOffset || Date.hcGetTimezoneOffset) {

                    // Detect whether we need to take the DST crossover into
                    // consideration. If we're crossing over DST, the day length may be
                    // 23h or 25h and we need to compute the exact clock time for each
                    // tick instead of just adding hours. This comes at a cost, so first
                    // we found out if it is needed. #4951.
                    variableDayLength =
                        (!useUTC || !!Date.hcGetTimezoneOffset) &&
                        (
                            // Long range, assume we're crossing over.
                            max - min > 4 * timeUnits.month ||
                            // Short range, check if min and max are in different time 
                            // zones.
                            getTZOffset(min) !== getTZOffset(max)
                        );

                    // Adjust minDate to the offset date
                    minDate = minDate.getTime();
                    baseOffset = getTZOffset(minDate);
                    minDate = new Date(minDate + baseOffset);
                }


                // Iterate and add tick positions at appropriate values
                var time = minDate.getTime();
                i = 1;
                while (time < max) {
                    tickPositions.push(time);

                    // if the interval is years, use Date.UTC to increase years
                    if (interval === timeUnits.year) {
                        time = makeTime(minYear + i * count, 0);

                        // if the interval is months, use Date.UTC to increase months
                    } else if (interval === timeUnits.month) {
                        time = makeTime(minYear, minMonth + i * count);

                        // if we're using global time, the interval is not fixed as it jumps
                        // one hour at the DST crossover
                    } else if (
                        variableDayLength &&
                        (interval === timeUnits.day || interval === timeUnits.week)
                    ) {
                        time = makeTime(minYear, minMonth, minDateDate +
                            i * count * (interval === timeUnits.day ? 1 : 7));

                    } else if (variableDayLength && interval === timeUnits.hour) {
                        // corrected by the start date time zone offset (baseOffset)
                        // to hide duplicated label (#6797)
                        time = makeTime(minYear, minMonth, minDateDate, minHours +
                            i * count, 0, 0, baseOffset) - baseOffset;

                        // else, the interval is fixed and we use simple addition
                    } else {
                        time += interval * count;
                    }

                    i++;
                }

                // push the last time
                tickPositions.push(time);


                // Handle higher ranks. Mark new days if the time is on midnight
                // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold to 
                // prevent looping over dense data grouping (#6156).
                if (interval <= timeUnits.hour && tickPositions.length < 10000) {
                    each(tickPositions, function(time) {
                        if (
                            // Speed optimization, no need to run dateFormat unless
                            // we're on a full or half hour
                            time % 1800000 === 0 &&
                            // Check for local or global midnight
                            dateFormat('%H%M%S%L', time) === '000000000'
                        ) {
                            higherRanks[time] = 'day';
                        }
                    });
                }
            }


            // record information on the chosen unit - for dynamic label formatter
            tickPositions.info = extend(normalizedInterval, {
                higherRanks: higherRanks,
                totalRange: interval * count
            });

            return tickPositions;
        };

        /**
         * Get a normalized tick interval for dates. Returns a configuration object with
         * unit range (interval), count and name. Used to prepare data for getTimeTicks.
         * Previously this logic was part of getTimeTicks, but as getTimeTicks now runs
         * of segments in stock charts, the normalizing logic was extracted in order to
         * prevent it for running over again for each segment having the same interval.
         * #662, #697.
         */
        Axis.prototype.normalizeTimeTickInterval = function(tickInterval, unitsOption) {
            var units = unitsOption || [
                    [
                        'millisecond', // unit name
                        [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
                    ],
                    [
                        'second', [1, 2, 5, 10, 15, 30]
                    ],
                    [
                        'minute', [1, 2, 5, 10, 15, 30]
                    ],
                    [
                        'hour', [1, 2, 3, 4, 6, 8, 12]
                    ],
                    [
                        'day', [1, 2]
                    ],
                    [
                        'week', [1, 2]
                    ],
                    [
                        'month', [1, 2, 3, 4, 6]
                    ],
                    [
                        'year',
                        null
                    ]
                ],
                unit = units[units.length - 1], // default unit is years
                interval = timeUnits[unit[0]],
                multiples = unit[1],
                count,
                i;

            // loop through the units to find the one that best fits the tickInterval
            for (i = 0; i < units.length; i++) {
                unit = units[i];
                interval = timeUnits[unit[0]];
                multiples = unit[1];


                if (units[i + 1]) {
                    // lessThan is in the middle between the highest multiple and the next unit.
                    var lessThan = (interval * multiples[multiples.length - 1] +
                        timeUnits[units[i + 1][0]]) / 2;

                    // break and keep the current unit
                    if (tickInterval <= lessThan) {
                        break;
                    }
                }
            }

            // prevent 2.5 years intervals, though 25, 250 etc. are allowed
            if (interval === timeUnits.year && tickInterval < 5 * interval) {
                multiples = [1, 2, 5];
            }

            // get the count
            count = normalizeTickInterval(
                tickInterval / interval,
                multiples,
                unit[0] === 'year' ? Math.max(getMagnitude(tickInterval / interval), 1) : 1 // #1913, #2360
            );

            return {
                unitRange: interval,
                count: count,
                unitName: unit[0]
            };
        };

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var Axis = H.Axis,
            getMagnitude = H.getMagnitude,
            map = H.map,
            normalizeTickInterval = H.normalizeTickInterval,
            pick = H.pick;
        /**
         * Methods defined on the Axis prototype
         */

        /**
         * Set the tick positions of a logarithmic axis
         */
        Axis.prototype.getLogTickPositions = function(interval, min, max, minor) {
            var axis = this,
                options = axis.options,
                axisLength = axis.len,
                lin2log = axis.lin2log,
                log2lin = axis.log2lin,
                // Since we use this method for both major and minor ticks,
                // use a local variable and return the result
                positions = [];

            // Reset
            if (!minor) {
                axis._minorAutoInterval = null;
            }

            // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
            if (interval >= 0.5) {
                interval = Math.round(interval);
                positions = axis.getLinearTickPositions(interval, min, max);

                // Second case: We need intermediary ticks. For example
                // 1, 2, 4, 6, 8, 10, 20, 40 etc.
            } else if (interval >= 0.08) {
                var roundedMin = Math.floor(min),
                    intermediate,
                    i,
                    j,
                    len,
                    pos,
                    lastPos,
                    break2;

                if (interval > 0.3) {
                    intermediate = [1, 2, 4];
                } else if (interval > 0.15) { // 0.2 equals five minor ticks per 1, 10, 100 etc
                    intermediate = [1, 2, 4, 6, 8];
                } else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
                    intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
                }

                for (i = roundedMin; i < max + 1 && !break2; i++) {
                    len = intermediate.length;
                    for (j = 0; j < len && !break2; j++) {
                        pos = log2lin(lin2log(i) * intermediate[j]);
                        if (pos > min && (!minor || lastPos <= max) && lastPos !== undefined) { // #1670, lastPos is #3113
                            positions.push(lastPos);
                        }

                        if (lastPos > max) {
                            break2 = true;
                        }
                        lastPos = pos;
                    }
                }

                // Third case: We are so deep in between whole logarithmic values that
                // we might as well handle the tick positions like a linear axis. For
                // example 1.01, 1.02, 1.03, 1.04.
            } else {
                var realMin = lin2log(min),
                    realMax = lin2log(max),
                    tickIntervalOption = minor ?
                    this.getMinorTickInterval() :
                    options.tickInterval,
                    filteredTickIntervalOption = tickIntervalOption === 'auto' ? null : tickIntervalOption,
                    tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
                    totalPixelLength = minor ? axisLength / axis.tickPositions.length : axisLength;

                interval = pick(
                    filteredTickIntervalOption,
                    axis._minorAutoInterval,
                    (realMax - realMin) * tickPixelIntervalOption / (totalPixelLength || 1)
                );

                interval = normalizeTickInterval(
                    interval,
                    null,
                    getMagnitude(interval)
                );

                positions = map(axis.getLinearTickPositions(
                    interval,
                    realMin,
                    realMax
                ), log2lin);

                if (!minor) {
                    axis._minorAutoInterval = interval / 5;
                }
            }

            // Set the axis-level tickInterval variable
            if (!minor) {
                axis.tickInterval = interval;
            }
            return positions;
        };

        Axis.prototype.log2lin = function(num) {
            return Math.log(num) / Math.LN10;
        };

        Axis.prototype.lin2log = function(num) {
            return Math.pow(10, num);
        };

    }(Highcharts));
    (function(H, Axis) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var arrayMax = H.arrayMax,
            arrayMin = H.arrayMin,
            defined = H.defined,
            destroyObjectProperties = H.destroyObjectProperties,
            each = H.each,
            erase = H.erase,
            merge = H.merge,
            pick = H.pick;
        /*
         * The object wrapper for plot lines and plot bands
         * @param {Object} options
         */
        H.PlotLineOrBand = function(axis, options) {
            this.axis = axis;

            if (options) {
                this.options = options;
                this.id = options.id;
            }
        };

        H.PlotLineOrBand.prototype = {

            /**
             * Render the plot line or plot band. If it is already existing,
             * move it.
             */
            render: function() {
                var plotLine = this,
                    axis = plotLine.axis,
                    horiz = axis.horiz,
                    options = plotLine.options,
                    optionsLabel = options.label,
                    label = plotLine.label,
                    to = options.to,
                    from = options.from,
                    value = options.value,
                    isBand = defined(from) && defined(to),
                    isLine = defined(value),
                    svgElem = plotLine.svgElem,
                    isNew = !svgElem,
                    path = [],
                    color = options.color,
                    zIndex = pick(options.zIndex, 0),
                    events = options.events,
                    attribs = {
                        'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
                            (options.className || '')
                    },
                    groupAttribs = {},
                    renderer = axis.chart.renderer,
                    groupName = isBand ? 'bands' : 'lines',
                    group,
                    log2lin = axis.log2lin;

                // logarithmic conversion
                if (axis.isLog) {
                    from = log2lin(from);
                    to = log2lin(to);
                    value = log2lin(value);
                }


                // Set the presentational attributes
                if (isLine) {
                    attribs = {
                        stroke: color,
                        'stroke-width': options.width
                    };
                    if (options.dashStyle) {
                        attribs.dashstyle = options.dashStyle;
                    }

                } else if (isBand) { // plot band
                    if (color) {
                        attribs.fill = color;
                    }
                    if (options.borderWidth) {
                        attribs.stroke = options.borderColor;
                        attribs['stroke-width'] = options.borderWidth;
                    }
                }


                // Grouping and zIndex
                groupAttribs.zIndex = zIndex;
                groupName += '-' + zIndex;

                group = axis.plotLinesAndBandsGroups[groupName];
                if (!group) {
                    axis.plotLinesAndBandsGroups[groupName] = group =
                        renderer.g('plot-' + groupName)
                        .attr(groupAttribs).add();
                }

                // Create the path
                if (isNew) {
                    plotLine.svgElem = svgElem =
                        renderer
                        .path()
                        .attr(attribs).add(group);
                }


                // Set the path or return
                if (isLine) {
                    path = axis.getPlotLinePath(value, svgElem.strokeWidth());
                } else if (isBand) { // plot band
                    path = axis.getPlotBandPath(from, to, options);
                } else {
                    return;
                }


                // common for lines and bands
                if (isNew && path && path.length) {
                    svgElem.attr({
                        d: path
                    });

                    // events
                    if (events) {
                        H.objectEach(events, function(event, eventType) {
                            svgElem.on(eventType, function(e) {
                                events[eventType].apply(plotLine, [e]);
                            });
                        });
                    }
                } else if (svgElem) {
                    if (path) {
                        svgElem.show();
                        svgElem.animate({
                            d: path
                        });
                    } else {
                        svgElem.hide();
                        if (label) {
                            plotLine.label = label = label.destroy();
                        }
                    }
                }

                // the plot band/line label
                if (
                    optionsLabel &&
                    defined(optionsLabel.text) &&
                    path &&
                    path.length &&
                    axis.width > 0 &&
                    axis.height > 0 &&
                    !path.flat
                ) {
                    // apply defaults
                    optionsLabel = merge({
                        align: horiz && isBand && 'center',
                        x: horiz ? !isBand && 4 : 10,
                        verticalAlign: !horiz && isBand && 'middle',
                        y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
                        rotation: horiz && !isBand && 90
                    }, optionsLabel);

                    this.renderLabel(optionsLabel, path, isBand, zIndex);

                } else if (label) { // move out of sight
                    label.hide();
                }

                // chainable
                return plotLine;
            },

            /**
             * Render and align label for plot line or band.
             */
            renderLabel: function(optionsLabel, path, isBand, zIndex) {
                var plotLine = this,
                    label = plotLine.label,
                    renderer = plotLine.axis.chart.renderer,
                    attribs,
                    xBounds,
                    yBounds,
                    x,
                    y;

                // add the SVG element
                if (!label) {
                    attribs = {
                        align: optionsLabel.textAlign || optionsLabel.align,
                        rotation: optionsLabel.rotation,
                        'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
                            '-label ' + (optionsLabel.className || '')
                    };

                    attribs.zIndex = zIndex;

                    plotLine.label = label = renderer.text(
                            optionsLabel.text,
                            0,
                            0,
                            optionsLabel.useHTML
                        )
                        .attr(attribs)
                        .add();


                    label.css(optionsLabel.style);

                }

                // get the bounding box and align the label
                // #3000 changed to better handle choice between plotband or plotline
                xBounds = path.xBounds || [path[1], path[4], (isBand ? path[6] : path[1])];
                yBounds = path.yBounds || [path[2], path[5], (isBand ? path[7] : path[2])];

                x = arrayMin(xBounds);
                y = arrayMin(yBounds);

                label.align(optionsLabel, false, {
                    x: x,
                    y: y,
                    width: arrayMax(xBounds) - x,
                    height: arrayMax(yBounds) - y
                });
                label.show();
            },

            /**
             * Remove the plot line or band
             */
            destroy: function() {
                // remove it from the lookup
                erase(this.axis.plotLinesAndBands, this);

                delete this.axis;
                destroyObjectProperties(this);
            }
        };

        /**
         * Object with members for extending the Axis prototype
         * @todo Extend directly instead of adding object to Highcharts first
         */

        H.extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {

            /**
             * Internal function to create the SVG path definition for a plot band.
             *
             * @param  {Number} from
             *         The axis value to start from.
             * @param  {Number} to
             *         The axis value to end on.
             *
             * @return {Array.<String|Number>}
             *         The SVG path definition in array form.
             */
            getPlotBandPath: function(from, to) {
                var toPath = this.getPlotLinePath(to, null, null, true),
                    path = this.getPlotLinePath(from, null, null, true),
                    // #4964 check if chart is inverted or plotband is on yAxis 
                    horiz = this.horiz,
                    plus = 1,
                    outside =
                    (from < this.min && to < this.min) ||
                    (from > this.max && to > this.max);

                if (path && toPath) {

                    // Flat paths don't need labels (#3836)
                    if (outside) {
                        path.flat = path.toString() === toPath.toString();
                        plus = 0;
                    }

                    // Add 1 pixel, when coordinates are the same
                    path.push(
                        horiz && toPath[4] === path[4] ? toPath[4] + plus : toPath[4], !horiz && toPath[5] === path[5] ? toPath[5] + plus : toPath[5],
                        horiz && toPath[1] === path[1] ? toPath[1] + plus : toPath[1], !horiz && toPath[2] === path[2] ? toPath[2] + plus : toPath[2],
                        'z'
                    );
                } else { // outside the axis area
                    path = null;
                }

                return path;
            },

            /**
             * Add a plot band after render time.
             *
             * @param  {AxisPlotBandsOptions} options
             *         A configuration object for the plot band, as defined in {@link
             *         https://api.highcharts.com/highcharts/xAxis.plotBands|
             *         xAxis.plotBands}.
             * @return {Object}
             *         The added plot band.
             * @sample highcharts/members/axis-addplotband/
             *         Toggle the plot band from a button
             */
            addPlotBand: function(options) {
                return this.addPlotBandOrLine(options, 'plotBands');
            },

            /**
             * Add a plot line after render time.
             * 
             * @param  {AxisPlotLinesOptions} options
             *         A configuration object for the plot line, as defined in {@link
             *         https://api.highcharts.com/highcharts/xAxis.plotLines|
             *         xAxis.plotLines}.
             * @return {Object}
             *         The added plot line.
             * @sample highcharts/members/axis-addplotline/
             *         Toggle the plot line from a button
             */
            addPlotLine: function(options) {
                return this.addPlotBandOrLine(options, 'plotLines');
            },

            /**
             * Add a plot band or plot line after render time. Called from addPlotBand
             * and addPlotLine internally.
             *
             * @private
             * @param  options {AxisPlotLinesOptions|AxisPlotBandsOptions}
             *         The plotBand or plotLine configuration object.
             */
            addPlotBandOrLine: function(options, coll) {
                var obj = new H.PlotLineOrBand(this, options).render(),
                    userOptions = this.userOptions;

                if (obj) { // #2189
                    // Add it to the user options for exporting and Axis.update
                    if (coll) {
                        userOptions[coll] = userOptions[coll] || [];
                        userOptions[coll].push(options);
                    }
                    this.plotLinesAndBands.push(obj);
                }

                return obj;
            },

            /**
             * Remove a plot band or plot line from the chart by id. Called internally
             * from `removePlotBand` and `removePlotLine`.
             *
             * @private
             * @param {String} id
             */
            removePlotBandOrLine: function(id) {
                var plotLinesAndBands = this.plotLinesAndBands,
                    options = this.options,
                    userOptions = this.userOptions,
                    i = plotLinesAndBands.length;
                while (i--) {
                    if (plotLinesAndBands[i].id === id) {
                        plotLinesAndBands[i].destroy();
                    }
                }
                each([
                    options.plotLines || [],
                    userOptions.plotLines || [],
                    options.plotBands || [],
                    userOptions.plotBands || []
                ], function(arr) {
                    i = arr.length;
                    while (i--) {
                        if (arr[i].id === id) {
                            erase(arr, arr[i]);
                        }
                    }
                });
            },

            /**
             * Remove a plot band by its id.
             * 
             * @param  {String} id
             *         The plot band's `id` as given in the original configuration
             *         object or in the `addPlotBand` option.
             * @sample highcharts/members/axis-removeplotband/
             *         Remove plot band by id
             * @sample highcharts/members/axis-addplotband/
             *         Toggle the plot band from a button
             */
            removePlotBand: function(id) {
                this.removePlotBandOrLine(id);
            },

            /**
             * Remove a plot line by its id.
             * @param  {String} id
             *         The plot line's `id` as given in the original configuration
             *         object or in the `addPlotLine` option.
             * @sample highcharts/xaxis/plotlines-id/
             *         Remove plot line by id
             * @sample highcharts/members/axis-addplotline/
             *         Toggle the plot line from a button
             */
            removePlotLine: function(id) {
                this.removePlotBandOrLine(id);
            }
        });

    }(Highcharts, Axis));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var dateFormat = H.dateFormat,
            each = H.each,
            extend = H.extend,
            format = H.format,
            isNumber = H.isNumber,
            map = H.map,
            merge = H.merge,
            pick = H.pick,
            splat = H.splat,
            syncTimeout = H.syncTimeout,
            timeUnits = H.timeUnits;
        /**
         * The tooltip object
         * @param {Object} chart The chart instance
         * @param {Object} options Tooltip options
         */
        H.Tooltip = function() {
            this.init.apply(this, arguments);
        };

        H.Tooltip.prototype = {

            init: function(chart, options) {

                // Save the chart and options
                this.chart = chart;
                this.options = options;

                // List of crosshairs
                this.crosshairs = [];

                // Current values of x and y when animating
                this.now = {
                    x: 0,
                    y: 0
                };

                // The tooltip is initially hidden
                this.isHidden = true;



                // Public property for getting the shared state.
                this.split = options.split && !chart.inverted;
                this.shared = options.shared || this.split;

            },

            /**
             * Destroy the single tooltips in a split tooltip.
             * If the tooltip is active then it is not destroyed, unless forced to.
             * @param  {boolean} force Force destroy all tooltips.
             * @return {undefined}
             */
            cleanSplit: function(force) {
                each(this.chart.series, function(series) {
                    var tt = series && series.tt;
                    if (tt) {
                        if (!tt.isActive || force) {
                            series.tt = tt.destroy();
                        } else {
                            tt.isActive = false;
                        }
                    }
                });
            },




            /**
             * Create the Tooltip label element if it doesn't exist, then return the
             * label.
             */
            getLabel: function() {

                var renderer = this.chart.renderer,
                    options = this.options;

                if (!this.label) {
                    // Create the label
                    if (this.split) {
                        this.label = renderer.g('tooltip');
                    } else {
                        this.label = renderer.label(
                                '',
                                0,
                                0,
                                options.shape || 'callout',
                                null,
                                null,
                                options.useHTML,
                                null,
                                'tooltip'
                            )
                            .attr({
                                padding: options.padding,
                                r: options.borderRadius
                            });


                        this.label
                            .attr({
                                'fill': options.backgroundColor,
                                'stroke-width': options.borderWidth
                            })
                            // #2301, #2657
                            .css(options.style)
                            .shadow(options.shadow);

                    }



                    this.label
                        .attr({
                            zIndex: 8
                        })
                        .add();
                }
                return this.label;
            },

            update: function(options) {
                this.destroy();
                // Update user options (#6218)
                merge(true, this.chart.options.tooltip.userOptions, options);
                this.init(this.chart, merge(true, this.options, options));
            },

            /**
             * Destroy the tooltip and its elements.
             */
            destroy: function() {
                // Destroy and clear local variables
                if (this.label) {
                    this.label = this.label.destroy();
                }
                if (this.split && this.tt) {
                    this.cleanSplit(this.chart, true);
                    this.tt = this.tt.destroy();
                }
                clearTimeout(this.hideTimer);
                clearTimeout(this.tooltipTimeout);
            },

            /**
             * Provide a soft movement for the tooltip
             *
             * @param {Number} x
             * @param {Number} y
             * @private
             */
            move: function(x, y, anchorX, anchorY) {
                var tooltip = this,
                    now = tooltip.now,
                    animate = tooltip.options.animation !== false &&
                    !tooltip.isHidden &&
                    // When we get close to the target position, abort animation and
                    // land on the right place (#3056)
                    (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
                    skipAnchor = tooltip.followPointer || tooltip.len > 1;

                // Get intermediate values for animation
                extend(now, {
                    x: animate ? (2 * now.x + x) / 3 : x,
                    y: animate ? (now.y + y) / 2 : y,
                    anchorX: skipAnchor ?
                        undefined : animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
                    anchorY: skipAnchor ?
                        undefined : animate ? (now.anchorY + anchorY) / 2 : anchorY
                });

                // Move to the intermediate value
                tooltip.getLabel().attr(now);


                // Run on next tick of the mouse tracker
                if (animate) {

                    // Never allow two timeouts
                    clearTimeout(this.tooltipTimeout);

                    // Set the fixed interval ticking for the smooth tooltip
                    this.tooltipTimeout = setTimeout(function() {
                        // The interval function may still be running during destroy,
                        // so check that the chart is really there before calling.
                        if (tooltip) {
                            tooltip.move(x, y, anchorX, anchorY);
                        }
                    }, 32);

                }
            },

            /**
             * Hide the tooltip
             */
            hide: function(delay) {
                var tooltip = this;
                // disallow duplicate timers (#1728, #1766)
                clearTimeout(this.hideTimer);
                delay = pick(delay, this.options.hideDelay, 500);
                if (!this.isHidden) {
                    this.hideTimer = syncTimeout(function() {
                        tooltip.getLabel()[delay ? 'fadeOut' : 'hide']();
                        tooltip.isHidden = true;
                    }, delay);
                }
            },

            /**
             * Extendable method to get the anchor position of the tooltip
             * from a point or set of points
             */
            getAnchor: function(points, mouseEvent) {
                var ret,
                    chart = this.chart,
                    inverted = chart.inverted,
                    plotTop = chart.plotTop,
                    plotLeft = chart.plotLeft,
                    plotX = 0,
                    plotY = 0,
                    yAxis,
                    xAxis;

                points = splat(points);

                // Pie uses a special tooltipPos
                ret = points[0].tooltipPos;

                // When tooltip follows mouse, relate the position to the mouse
                if (this.followPointer && mouseEvent) {
                    if (mouseEvent.chartX === undefined) {
                        mouseEvent = chart.pointer.normalize(mouseEvent);
                    }
                    ret = [
                        mouseEvent.chartX - chart.plotLeft,
                        mouseEvent.chartY - plotTop
                    ];
                }
                // When shared, use the average position
                if (!ret) {
                    each(points, function(point) {
                        yAxis = point.series.yAxis;
                        xAxis = point.series.xAxis;
                        plotX += point.plotX +
                            (!inverted && xAxis ? xAxis.left - plotLeft : 0);
                        plotY +=
                            (
                                point.plotLow ?
                                (point.plotLow + point.plotHigh) / 2 :
                                point.plotY
                            ) +
                            (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
                    });

                    plotX /= points.length;
                    plotY /= points.length;

                    ret = [
                        inverted ? chart.plotWidth - plotY : plotX,
                        this.shared && !inverted && points.length > 1 && mouseEvent ?
                        // place shared tooltip next to the mouse (#424)
                        mouseEvent.chartY - plotTop :
                        inverted ? chart.plotHeight - plotX : plotY
                    ];
                }

                return map(ret, Math.round);
            },

            /**
             * Place the tooltip in a chart without spilling over
             * and not covering the point it self.
             */
            getPosition: function(boxWidth, boxHeight, point) {

                var chart = this.chart,
                    distance = this.distance,
                    ret = {},
                    h = point.h || 0, // #4117
                    swapped,
                    first = ['y', chart.chartHeight, boxHeight,
                        point.plotY + chart.plotTop, chart.plotTop,
                        chart.plotTop + chart.plotHeight
                    ],
                    second = ['x', chart.chartWidth, boxWidth,
                        point.plotX + chart.plotLeft, chart.plotLeft,
                        chart.plotLeft + chart.plotWidth
                    ],
                    // The far side is right or bottom
                    preferFarSide = !this.followPointer && pick(
                        point.ttBelow, !chart.inverted === !!point.negative
                    ), // #4984

                    /**
                     * Handle the preferred dimension. When the preferred dimension is
                     * tooltip on top or bottom of the point, it will look for space
                     * there.
                     */
                    firstDimension = function(
                        dim,
                        outerSize,
                        innerSize,
                        point,
                        min,
                        max
                    ) {
                        var roomLeft = innerSize < point - distance,
                            roomRight = point + distance + innerSize < outerSize,
                            alignedLeft = point - distance - innerSize,
                            alignedRight = point + distance;

                        if (preferFarSide && roomRight) {
                            ret[dim] = alignedRight;
                        } else if (!preferFarSide && roomLeft) {
                            ret[dim] = alignedLeft;
                        } else if (roomLeft) {
                            ret[dim] = Math.min(
                                max - innerSize,
                                alignedLeft - h < 0 ? alignedLeft : alignedLeft - h
                            );
                        } else if (roomRight) {
                            ret[dim] = Math.max(
                                min,
                                alignedRight + h + innerSize > outerSize ?
                                alignedRight :
                                alignedRight + h
                            );
                        } else {
                            return false;
                        }
                    },
                    /**
                     * Handle the secondary dimension. If the preferred dimension is
                     * tooltip on top or bottom of the point, the second dimension is to
                     * align the tooltip above the point, trying to align center but
                     * allowing left or right align within the chart box.
                     */
                    secondDimension = function(dim, outerSize, innerSize, point) {
                        var retVal;

                        // Too close to the edge, return false and swap dimensions
                        if (point < distance || point > outerSize - distance) {
                            retVal = false;
                            // Align left/top
                        } else if (point < innerSize / 2) {
                            ret[dim] = 1;
                            // Align right/bottom
                        } else if (point > outerSize - innerSize / 2) {
                            ret[dim] = outerSize - innerSize - 2;
                            // Align center
                        } else {
                            ret[dim] = point - innerSize / 2;
                        }
                        return retVal;
                    },
                    /**
                     * Swap the dimensions
                     */
                    swap = function(count) {
                        var temp = first;
                        first = second;
                        second = temp;
                        swapped = count;
                    },
                    run = function() {
                        if (firstDimension.apply(0, first) !== false) {
                            if (
                                secondDimension.apply(0, second) === false &&
                                !swapped
                            ) {
                                swap(true);
                                run();
                            }
                        } else if (!swapped) {
                            swap(true);
                            run();
                        } else {
                            ret.x = ret.y = 0;
                        }
                    };

                // Under these conditions, prefer the tooltip on the side of the point
                if (chart.inverted || this.len > 1) {
                    swap();
                }
                run();

                return ret;

            },

            /**
             * In case no user defined formatter is given, this will be used. Note that
             * the context here is an object holding point, series, x, y etc.
             *
             * @returns {String|Array<String>}
             */
            defaultFormatter: function(tooltip) {
                var items = this.points || splat(this),
                    s;

                // Build the header
                s = [tooltip.tooltipFooterHeaderFormatter(items[0])];

                // build the values
                s = s.concat(tooltip.bodyFormatter(items));

                // footer
                s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));

                return s;
            },

            /**
             * Refresh the tooltip's text and position.
             * @param {Object|Array} pointOrPoints Rither a point or an array of points
             */
            refresh: function(pointOrPoints, mouseEvent) {
                var tooltip = this,
                    label,
                    options = tooltip.options,
                    x,
                    y,
                    point = pointOrPoints,
                    anchor,
                    textConfig = {},
                    text,
                    pointConfig = [],
                    formatter = options.formatter || tooltip.defaultFormatter,
                    shared = tooltip.shared,
                    currentSeries;

                if (!options.enabled) {
                    return;
                }

                clearTimeout(this.hideTimer);

                // get the reference point coordinates (pie charts use tooltipPos)
                tooltip.followPointer = splat(point)[0].series.tooltipOptions
                    .followPointer;
                anchor = tooltip.getAnchor(point, mouseEvent);
                x = anchor[0];
                y = anchor[1];

                // shared tooltip, array is sent over
                if (shared && !(point.series && point.series.noSharedTooltip)) {
                    each(point, function(item) {
                        item.setState('hover');

                        pointConfig.push(item.getLabelConfig());
                    });

                    textConfig = {
                        x: point[0].category,
                        y: point[0].y
                    };
                    textConfig.points = pointConfig;
                    point = point[0];

                    // single point tooltip
                } else {
                    textConfig = point.getLabelConfig();
                }
                this.len = pointConfig.length; // #6128
                text = formatter.call(textConfig, tooltip);

                // register the current series
                currentSeries = point.series;
                this.distance = pick(currentSeries.tooltipOptions.distance, 16);

                // update the inner HTML
                if (text === false) {
                    this.hide();
                } else {

                    label = tooltip.getLabel();

                    // show it
                    if (tooltip.isHidden) {
                        label.attr({
                            opacity: 1
                        }).show();
                    }

                    // update text
                    if (tooltip.split) {
                        this.renderSplit(text, pointOrPoints);
                    } else {

                        // Prevent the tooltip from flowing over the chart box (#6659)

                        if (!options.style.width) {

                            label.css({
                                width: this.chart.spacingBox.width
                            });

                        }


                        label.attr({
                            text: text && text.join ? text.join('') : text
                        });

                        // Set the stroke color of the box to reflect the point
                        label.removeClass(/highcharts-color-[\d]+/g)
                            .addClass(
                                'highcharts-color-' +
                                pick(point.colorIndex, currentSeries.colorIndex)
                            );


                        label.attr({
                            stroke: (
                                options.borderColor ||
                                point.color ||
                                currentSeries.color ||
                                '#666666'
                            )
                        });


                        tooltip.updatePosition({
                            plotX: x,
                            plotY: y,
                            negative: point.negative,
                            ttBelow: point.ttBelow,
                            h: anchor[2] || 0
                        });
                    }

                    this.isHidden = false;
                }
            },

            /**
             * Render the split tooltip. Loops over each point's text and adds
             * a label next to the point, then uses the distribute function to 
             * find best non-overlapping positions.
             */
            renderSplit: function(labels, points) {
                var tooltip = this,
                    boxes = [],
                    chart = this.chart,
                    ren = chart.renderer,
                    rightAligned = true,
                    options = this.options,
                    headerHeight = 0,
                    tooltipLabel = this.getLabel();

                // Graceful degradation for legacy formatters
                if (H.isString(labels)) {
                    labels = [false, labels];
                }
                // Create the individual labels for header and points, ignore footer
                each(labels.slice(0, points.length + 1), function(str, i) {
                    if (str !== false) {
                        var point = points[i - 1] ||
                            // Item 0 is the header. Instead of this, we could also
                            // use the crosshair label
                            {
                                isHeader: true,
                                plotX: points[0].plotX
                            },
                            owner = point.series || tooltip,
                            tt = owner.tt,
                            series = point.series || {},
                            colorClass = 'highcharts-color-' + pick(
                                point.colorIndex,
                                series.colorIndex,
                                'none'
                            ),
                            target,
                            x,
                            bBox,
                            boxWidth;

                        // Store the tooltip referance on the series
                        if (!tt) {
                            owner.tt = tt = ren.label(null, null, null, 'callout')
                                .addClass('highcharts-tooltip-box ' + colorClass)
                                .attr({
                                    'padding': options.padding,
                                    'r': options.borderRadius,

                                    'fill': options.backgroundColor,
                                    'stroke': (
                                        options.borderColor ||
                                        point.color ||
                                        series.color ||
                                        '#333333'
                                    ),
                                    'stroke-width': options.borderWidth

                                })
                                .add(tooltipLabel);
                        }

                        tt.isActive = true;
                        tt.attr({
                            text: str
                        });

                        tt.css(options.style)
                            .shadow(options.shadow);


                        // Get X position now, so we can move all to the other side in
                        // case of overflow
                        bBox = tt.getBBox();
                        boxWidth = bBox.width + tt.strokeWidth();
                        if (point.isHeader) {
                            headerHeight = bBox.height;
                            x = Math.max(
                                0, // No left overflow
                                Math.min(
                                    point.plotX + chart.plotLeft - boxWidth / 2,
                                    // No right overflow (#5794)
                                    chart.chartWidth - boxWidth
                                )
                            );
                        } else {
                            x = point.plotX + chart.plotLeft -
                                pick(options.distance, 16) - boxWidth;
                        }


                        // If overflow left, we don't use this x in the next loop
                        if (x < 0) {
                            rightAligned = false;
                        }

                        // Prepare for distribution
                        target = (point.series && point.series.yAxis &&
                            point.series.yAxis.pos) + (point.plotY || 0);
                        target -= chart.plotTop;
                        boxes.push({
                            target: point.isHeader ?
                                chart.plotHeight + headerHeight : target,
                            rank: point.isHeader ? 1 : 0,
                            size: owner.tt.getBBox().height + 1,
                            point: point,
                            x: x,
                            tt: tt
                        });
                    }
                });

                // Clean previous run (for missing points)
                this.cleanSplit();

                // Distribute and put in place
                H.distribute(boxes, chart.plotHeight + headerHeight);
                each(boxes, function(box) {
                    var point = box.point,
                        series = point.series;

                    // Put the label in place
                    box.tt.attr({
                        visibility: box.pos === undefined ? 'hidden' : 'inherit',
                        x: (rightAligned || point.isHeader ?
                            box.x :
                            point.plotX + chart.plotLeft + pick(options.distance, 16)),
                        y: box.pos + chart.plotTop,
                        anchorX: point.isHeader ?
                            point.plotX + chart.plotLeft : point.plotX + series.xAxis.pos,
                        anchorY: point.isHeader ?
                            box.pos + chart.plotTop - 15 : point.plotY + series.yAxis.pos
                    });
                });
            },

            /**
             * Find the new position and perform the move
             */
            updatePosition: function(point) {
                var chart = this.chart,
                    label = this.getLabel(),
                    pos = (this.options.positioner || this.getPosition).call(
                        this,
                        label.width,
                        label.height,
                        point
                    );

                // do the move
                this.move(
                    Math.round(pos.x),
                    Math.round(pos.y || 0), // can be undefined (#3977) 
                    point.plotX + chart.plotLeft,
                    point.plotY + chart.plotTop
                );
            },

            /**
             * Get the optimal date format for a point, based on a range.
             * @param  {number} range - The time range
             * @param  {number|Date} date - The date of the point in question
             * @param  {number} startOfWeek - An integer representing the first day of
             * the week, where 0 is Sunday
             * @param  {Object} dateTimeLabelFormats - A map of time units to formats
             * @return {string} - the optimal date format for a point
             */
            getDateFormat: function(range, date, startOfWeek, dateTimeLabelFormats) {
                var dateStr = dateFormat('%m-%d %H:%M:%S.%L', date),
                    format,
                    n,
                    blank = '01-01 00:00:00.000',
                    strpos = {
                        millisecond: 15,
                        second: 12,
                        minute: 9,
                        hour: 6,
                        day: 3
                    },
                    lastN = 'millisecond'; // for sub-millisecond data, #4223
                for (n in timeUnits) {

                    // If the range is exactly one week and we're looking at a
                    // Sunday/Monday, go for the week format
                    if (
                        range === timeUnits.week &&
                        +dateFormat('%w', date) === startOfWeek &&
                        dateStr.substr(6) === blank.substr(6)
                    ) {
                        n = 'week';
                        break;
                    }

                    // The first format that is too great for the range
                    if (timeUnits[n] > range) {
                        n = lastN;
                        break;
                    }

                    // If the point is placed every day at 23:59, we need to show
                    // the minutes as well. #2637.
                    if (
                        strpos[n] &&
                        dateStr.substr(strpos[n]) !== blank.substr(strpos[n])
                    ) {
                        break;
                    }

                    // Weeks are outside the hierarchy, only apply them on
                    // Mondays/Sundays like in the first condition
                    if (n !== 'week') {
                        lastN = n;
                    }
                }

                if (n) {
                    format = dateTimeLabelFormats[n];
                }

                return format;
            },

            /**
             * Get the best X date format based on the closest point range on the axis.
             */
            getXDateFormat: function(point, options, xAxis) {
                var xDateFormat,
                    dateTimeLabelFormats = options.dateTimeLabelFormats,
                    closestPointRange = xAxis && xAxis.closestPointRange;

                if (closestPointRange) {
                    xDateFormat = this.getDateFormat(
                        closestPointRange,
                        point.x,
                        xAxis.options.startOfWeek,
                        dateTimeLabelFormats
                    );
                } else {
                    xDateFormat = dateTimeLabelFormats.day;
                }

                return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
            },

            /**
             * Format the footer/header of the tooltip
             * #3397: abstraction to enable formatting of footer and header
             */
            tooltipFooterHeaderFormatter: function(labelConfig, isFooter) {
                var footOrHead = isFooter ? 'footer' : 'header',
                    series = labelConfig.series,
                    tooltipOptions = series.tooltipOptions,
                    xDateFormat = tooltipOptions.xDateFormat,
                    xAxis = series.xAxis,
                    isDateTime = (
                        xAxis &&
                        xAxis.options.type === 'datetime' &&
                        isNumber(labelConfig.key)
                    ),
                    formatString = tooltipOptions[footOrHead + 'Format'];

                // Guess the best date format based on the closest point distance (#568,
                // #3418)
                if (isDateTime && !xDateFormat) {
                    xDateFormat = this.getXDateFormat(
                        labelConfig,
                        tooltipOptions,
                        xAxis
                    );
                }

                // Insert the footer date format if any
                if (isDateTime && xDateFormat) {
                    each(
                        (labelConfig.point && labelConfig.point.tooltipDateKeys) || ['key'],
                        function(key) {
                            formatString = formatString.replace(
                                '{point.' + key + '}',
                                '{point.' + key + ':' + xDateFormat + '}'
                            );
                        }
                    );
                }

                return format(formatString, {
                    point: labelConfig,
                    series: series
                });
            },

            /**
             * Build the body (lines) of the tooltip by iterating over the items and
             * returning one entry for each item, abstracting this functionality allows
             * to easily overwrite and extend it.
             */
            bodyFormatter: function(items) {
                return map(items, function(item) {
                    var tooltipOptions = item.series.tooltipOptions;
                    return (
                        tooltipOptions.pointFormatter ||
                        item.point.tooltipFormatter
                    ).call(
                        item.point,
                        tooltipOptions[(item.point.formatPrefix || 'point') + 'Format']
                    );
                });
            }

        };

    }(Highcharts));
    (function(Highcharts) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var H = Highcharts,
            addEvent = H.addEvent,
            attr = H.attr,
            charts = H.charts,
            color = H.color,
            css = H.css,
            defined = H.defined,
            each = H.each,
            extend = H.extend,
            find = H.find,
            fireEvent = H.fireEvent,
            isObject = H.isObject,
            offset = H.offset,
            pick = H.pick,
            removeEvent = H.removeEvent,
            splat = H.splat,
            Tooltip = H.Tooltip;

        /**
         * The mouse and touch tracker object. Each {@link Chart} item has one
         * assosiated Pointer item that can be accessed from the  {@link Chart.pointer}
         * property.
         *
         * @class
         * @param  {Chart} chart
         *         The Chart instance.
         * @param  {Options} options
         *         The root options object. The pointer uses options from the chart and
         *         tooltip structures.
         */
        Highcharts.Pointer = function(chart, options) {
            this.init(chart, options);
        };

        Highcharts.Pointer.prototype = {
            /**
             * Initialize the Pointer.
             *
             * @private
             */
            init: function(chart, options) {

                // Store references
                this.options = options;
                this.chart = chart;

                // Do we need to handle click on a touch device?
                this.runChartClick = options.chart.events && !!options.chart.events.click;

                this.pinchDown = [];
                this.lastValidTouch = {};

                if (Tooltip) {
                    chart.tooltip = new Tooltip(chart, options.tooltip);
                    this.followTouchMove = pick(options.tooltip.followTouchMove, true);
                }

                this.setDOMEvents();
            },

            /**
             * Resolve the zoomType option, this is reset on all touch start and mouse
             * down events.
             *
             * @private
             */
            zoomOption: function(e) {
                var chart = this.chart,
                    options = chart.options.chart,
                    zoomType = options.zoomType || '',
                    inverted = chart.inverted,
                    zoomX,
                    zoomY;

                // Look for the pinchType option
                if (/touch/.test(e.type)) {
                    zoomType = pick(options.pinchType, zoomType);
                }

                this.zoomX = zoomX = /x/.test(zoomType);
                this.zoomY = zoomY = /y/.test(zoomType);
                this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
                this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
                this.hasZoom = zoomX || zoomY;
            },

            /**
             * @typedef  {Object} PointerEvent
             *           A native browser mouse or touch event, extended with position
             *           information relative to the {@link Chart.container}.
             * @property {Number} chartX
             *           The X coordinate of the pointer interaction relative to the
             *           chart.
             * @property {Number} chartY
             *           The Y coordinate of the pointer interaction relative to the 
             *           chart.
             * 
             */
            /**
             * Takes a browser event object and extends it with custom Highcharts
             * properties `chartX` and `chartY` in order to work on the internal 
             * coordinate system.
             * 
             * @param  {Object} e
             *         The event object in standard browsers.
             *
             * @return {PointerEvent}
             *         A browser event with extended properties `chartX` and `chartY`.
             */
            normalize: function(e, chartPosition) {
                var ePos;

                // iOS (#2757)
                ePos = e.touches ? (e.touches.length ? e.touches.item(0) : e.changedTouches[0]) : e;

                // Get mouse position
                if (!chartPosition) {
                    this.chartPosition = chartPosition = offset(this.chart.container);
                }

                return extend(e, {
                    chartX: Math.round(ePos.pageX - chartPosition.left),
                    chartY: Math.round(ePos.pageY - chartPosition.top)
                });
            },

            /**
             * Get the click position in terms of axis values.
             *
             * @param  {PointerEvent} e
             *         A pointer event, extended with `chartX` and `chartY`
             *         properties.
             */
            getCoordinates: function(e) {
                var coordinates = {
                    xAxis: [],
                    yAxis: []
                };

                each(this.chart.axes, function(axis) {
                    coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
                        axis: axis,
                        value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
                    });
                });
                return coordinates;
            },
            /**
             * Finds the closest point to a set of coordinates, using the k-d-tree
             * algorithm.
             *
             * @param  {Array.<Series>} series
             *         All the series to search in.
             * @param  {boolean} shared
             *         Whether it is a shared tooltip or not.
             * @param  {object} coordinates
             *         Chart coordinates of the pointer.
             * @param  {number} coordinates.chartX
             * @param  {number} coordinates.chartY
             *
             * @return {Point|undefined} The point closest to given coordinates.
             */
            findNearestKDPoint: function(series, shared, coordinates) {
                var closest,
                    sort = function(p1, p2) {
                        var isCloserX = p1.distX - p2.distX,
                            isCloser = p1.dist - p2.dist,
                            isAbove =
                            (p2.series.group && p2.series.group.zIndex) -
                            (p1.series.group && p1.series.group.zIndex),
                            result;

                        // We have two points which are not in the same place on xAxis
                        // and shared tooltip:
                        if (isCloserX !== 0 && shared) { // #5721
                            result = isCloserX;
                            // Points are not exactly in the same place on x/yAxis:
                        } else if (isCloser !== 0) {
                            result = isCloser;
                            // The same xAxis and yAxis position, sort by z-index:
                        } else if (isAbove !== 0) {
                            result = isAbove;
                            // The same zIndex, sort by array index:
                        } else {
                            result = p1.series.index > p2.series.index ? -1 : 1;
                        }
                        return result;
                    };
                each(series, function(s) {
                    var noSharedTooltip = s.noSharedTooltip && shared,
                        compareX = (!noSharedTooltip &&
                            s.options.findNearestPointBy.indexOf('y') < 0
                        ),
                        point = s.searchPoint(
                            coordinates,
                            compareX
                        );
                    if (
                        // Check that we actually found a point on the series.
                        isObject(point, true) &&
                        // Use the new point if it is closer.
                        (!isObject(closest, true) || (sort(closest, point) > 0))
                    ) {
                        closest = point;
                    }
                });
                return closest;
            },
            getPointFromEvent: function(e) {
                var target = e.target,
                    point;

                while (target && !point) {
                    point = target.point;
                    target = target.parentNode;
                }
                return point;
            },

            getChartCoordinatesFromPoint: function(point, inverted) {
                var series = point.series,
                    xAxis = series.xAxis,
                    yAxis = series.yAxis;

                if (xAxis && yAxis) {
                    return inverted ? {
                        chartX: xAxis.len + xAxis.pos - point.clientX,
                        chartY: yAxis.len + yAxis.pos - point.plotY
                    } : {
                        chartX: point.clientX + xAxis.pos,
                        chartY: point.plotY + yAxis.pos
                    };
                }
            },

            /**
             * Calculates what is the current hovered point/points and series.
             *
             * @private
             *
             * @param  {undefined|Point} existingHoverPoint
             *         The point currrently beeing hovered.
             * @param  {undefined|Series} existingHoverSeries
             *         The series currently beeing hovered.
             * @param  {Array.<Series>} series
             *         All the series in the chart.
             * @param  {boolean} isDirectTouch
             *         Is the pointer directly hovering the point.
             * @param  {boolean} shared
             *         Whether it is a shared tooltip or not.
             * @param  {object} coordinates
             *         Chart coordinates of the pointer.
             * @param  {number} coordinates.chartX
             * @param  {number} coordinates.chartY
             * 
             * @return {object}
             *         Object containing resulting hover data.
             */
            getHoverData: function(
                existingHoverPoint,
                existingHoverSeries,
                series,
                isDirectTouch,
                shared,
                coordinates,
                params
            ) {
                var hoverPoint,
                    hoverPoints = [],
                    hoverSeries = existingHoverSeries,
                    isBoosting = params && params.isBoosting,
                    useExisting = !!(isDirectTouch && existingHoverPoint),
                    notSticky = hoverSeries && !hoverSeries.stickyTracking,
                    filter = function(s) {
                        return (
                            s.visible &&
                            !(!shared && s.directTouch) && // #3821
                            pick(s.options.enableMouseTracking, true)
                        );
                    },
                    // Which series to look in for the hover point
                    searchSeries = notSticky ?
                    // Only search on hovered series if it has stickyTracking false
                    [hoverSeries] :
                    // Filter what series to look in.
                    H.grep(series, function(s) {
                        return filter(s) && s.stickyTracking;
                    });

                // Use existing hovered point or find the one closest to coordinates.
                hoverPoint = useExisting ?
                    existingHoverPoint :
                    this.findNearestKDPoint(searchSeries, shared, coordinates);

                // Assign hover series
                hoverSeries = hoverPoint && hoverPoint.series;

                // If we have a hoverPoint, assign hoverPoints.
                if (hoverPoint) {
                    // When tooltip is shared, it displays more than one point
                    if (shared && !hoverSeries.noSharedTooltip) {
                        searchSeries = H.grep(series, function(s) {
                            return filter(s) && !s.noSharedTooltip;
                        });

                        // Get all points with the same x value as the hoverPoint
                        each(searchSeries, function(s) {
                            var point = find(s.points, function(p) {
                                return p.x === hoverPoint.x && !p.isNull;
                            });
                            if (isObject(point)) {
                                /*
                                 * Boost returns a minimal point. Convert it to a usable
                                 * point for tooltip and states.
                                 */
                                if (isBoosting) {
                                    point = s.getPoint(point);
                                }
                                hoverPoints.push(point);
                            }
                        });
                    } else {
                        hoverPoints.push(hoverPoint);
                    }
                }
                return {
                    hoverPoint: hoverPoint,
                    hoverSeries: hoverSeries,
                    hoverPoints: hoverPoints
                };
            },
            /**
             * With line type charts with a single tracker, get the point closest to the
             * mouse. Run Point.onMouseOver and display tooltip for the point or points.
             *
             * @private
             */
            runPointActions: function(e, p) {
                var pointer = this,
                    chart = pointer.chart,
                    series = chart.series,
                    tooltip = chart.tooltip && chart.tooltip.options.enabled ?
                    chart.tooltip :
                    undefined,
                    shared = tooltip ? tooltip.shared : false,
                    hoverPoint = p || chart.hoverPoint,
                    hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
                    // onMouseOver or already hovering a series with directTouch
                    isDirectTouch = !!p || (
                        (hoverSeries && hoverSeries.directTouch) &&
                        pointer.isDirectTouch
                    ),
                    hoverData = this.getHoverData(
                        hoverPoint,
                        hoverSeries,
                        series,
                        isDirectTouch,
                        shared,
                        e, {
                            isBoosting: chart.isBoosting
                        }
                    ),
                    useSharedTooltip,
                    followPointer,
                    anchor,
                    points;

                // Update variables from hoverData.
                hoverPoint = hoverData.hoverPoint;
                points = hoverData.hoverPoints;
                hoverSeries = hoverData.hoverSeries;
                followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer;
                useSharedTooltip = shared && hoverSeries && !hoverSeries.noSharedTooltip;

                // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
                // #3926, #4200
                if (
                    hoverPoint &&
                    // !(hoverSeries && hoverSeries.directTouch) &&
                    (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))
                ) {
                    each(chart.hoverPoints || [], function(p) {
                        if (H.inArray(p, points) === -1) {
                            p.setState();
                        }
                    });
                    // Do mouseover on all points (#3919, #3985, #4410, #5622)
                    each(points || [], function(p) {
                        p.setState('hover');
                    });
                    // set normal state to previous series
                    if (chart.hoverSeries !== hoverSeries) {
                        hoverSeries.onMouseOver();
                    }

                    // If tracking is on series in stead of on each point, 
                    // fire mouseOver on hover point. // #4448
                    if (chart.hoverPoint) {
                        chart.hoverPoint.firePointEvent('mouseOut');
                    }

                    // Hover point may have been destroyed in the event handlers (#7127)
                    if (!hoverPoint.series) {
                        return;
                    }

                    hoverPoint.firePointEvent('mouseOver');
                    chart.hoverPoints = points;
                    chart.hoverPoint = hoverPoint;
                    // Draw tooltip if necessary
                    if (tooltip) {
                        tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
                    }
                    // Update positions (regardless of kdpoint or hoverPoint)
                } else if (followPointer && tooltip && !tooltip.isHidden) {
                    anchor = tooltip.getAnchor([{}], e);
                    tooltip.updatePosition({
                        plotX: anchor[0],
                        plotY: anchor[1]
                    });
                }

                // Start the event listener to pick up the tooltip and crosshairs
                if (!pointer.unDocMouseMove) {
                    pointer.unDocMouseMove = addEvent(
                        chart.container.ownerDocument,
                        'mousemove',
                        function(e) {
                            var chart = charts[H.hoverChartIndex];
                            if (chart) {
                                chart.pointer.onDocumentMouseMove(e);
                            }
                        }
                    );
                }

                // Issues related to crosshair #4927, #5269 #5066, #5658
                each(chart.axes, function drawAxisCrosshair(axis) {
                    var snap = pick(axis.crosshair.snap, true),
                        point = !snap ?
                        undefined :
                        H.find(points, function(p) {
                            return p.series[axis.coll] === axis;
                        });

                    // Axis has snapping crosshairs, and one of the hover points belongs
                    // to axis. Always call drawCrosshair when it is not snap.
                    if (point || !snap) {
                        axis.drawCrosshair(e, point);
                        // Axis has snapping crosshairs, but no hover point belongs to axis
                    } else {
                        axis.hideCrosshair();
                    }
                });
            },

            /**
             * Reset the tracking by hiding the tooltip, the hover series state and the
             * hover point
             *
             * @param allowMove {Boolean}
             *        Instead of destroying the tooltip altogether, allow moving it if
             *        possible.
             */
            reset: function(allowMove, delay) {
                var pointer = this,
                    chart = pointer.chart,
                    hoverSeries = chart.hoverSeries,
                    hoverPoint = chart.hoverPoint,
                    hoverPoints = chart.hoverPoints,
                    tooltip = chart.tooltip,
                    tooltipPoints = tooltip && tooltip.shared ? hoverPoints : hoverPoint;

                // Check if the points have moved outside the plot area (#1003, #4736, #5101)
                if (allowMove && tooltipPoints) {
                    each(splat(tooltipPoints), function(point) {
                        if (point.series.isCartesian && point.plotX === undefined) {
                            allowMove = false;
                        }
                    });
                }

                // Just move the tooltip, #349
                if (allowMove) {
                    if (tooltip && tooltipPoints) {
                        tooltip.refresh(tooltipPoints);
                        if (hoverPoint) { // #2500
                            hoverPoint.setState(hoverPoint.state, true);
                            each(chart.axes, function(axis) {
                                if (axis.crosshair) {
                                    axis.drawCrosshair(null, hoverPoint);
                                }
                            });
                        }
                    }

                    // Full reset
                } else {

                    if (hoverPoint) {
                        hoverPoint.onMouseOut();
                    }

                    if (hoverPoints) {
                        each(hoverPoints, function(point) {
                            point.setState();
                        });
                    }

                    if (hoverSeries) {
                        hoverSeries.onMouseOut();
                    }

                    if (tooltip) {
                        tooltip.hide(delay);
                    }

                    if (pointer.unDocMouseMove) {
                        pointer.unDocMouseMove = pointer.unDocMouseMove();
                    }

                    // Remove crosshairs
                    each(chart.axes, function(axis) {
                        axis.hideCrosshair();
                    });

                    pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
                }
            },

            /**
             * Scale series groups to a certain scale and translation.
             *
             * @private
             */
            scaleGroups: function(attribs, clip) {

                var chart = this.chart,
                    seriesAttribs;

                // Scale each series
                each(chart.series, function(series) {
                    seriesAttribs = attribs || series.getPlotBox(); // #1701
                    if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
                        series.group.attr(seriesAttribs);
                        if (series.markerGroup) {
                            series.markerGroup.attr(seriesAttribs);
                            series.markerGroup.clip(clip ? chart.clipRect : null);
                        }
                        if (series.dataLabelsGroup) {
                            series.dataLabelsGroup.attr(seriesAttribs);
                        }
                    }
                });

                // Clip
                chart.clipRect.attr(clip || chart.clipBox);
            },

            /**
             * Start a drag operation.
             *
             * @private
             */
            dragStart: function(e) {
                var chart = this.chart;

                // Record the start position
                chart.mouseIsDown = e.type;
                chart.cancelClick = false;
                chart.mouseDownX = this.mouseDownX = e.chartX;
                chart.mouseDownY = this.mouseDownY = e.chartY;
            },

            /**
             * Perform a drag operation in response to a mousemove event while the mouse
             * is down.
             *
             * @private
             */
            drag: function(e) {

                var chart = this.chart,
                    chartOptions = chart.options.chart,
                    chartX = e.chartX,
                    chartY = e.chartY,
                    zoomHor = this.zoomHor,
                    zoomVert = this.zoomVert,
                    plotLeft = chart.plotLeft,
                    plotTop = chart.plotTop,
                    plotWidth = chart.plotWidth,
                    plotHeight = chart.plotHeight,
                    clickedInside,
                    size,
                    selectionMarker = this.selectionMarker,
                    mouseDownX = this.mouseDownX,
                    mouseDownY = this.mouseDownY,
                    panKey = chartOptions.panKey && e[chartOptions.panKey + 'Key'];

                // If the device supports both touch and mouse (like IE11), and we are touch-dragging
                // inside the plot area, don't handle the mouse event. #4339.
                if (selectionMarker && selectionMarker.touch) {
                    return;
                }

                // If the mouse is outside the plot area, adjust to cooordinates
                // inside to prevent the selection marker from going outside
                if (chartX < plotLeft) {
                    chartX = plotLeft;
                } else if (chartX > plotLeft + plotWidth) {
                    chartX = plotLeft + plotWidth;
                }

                if (chartY < plotTop) {
                    chartY = plotTop;
                } else if (chartY > plotTop + plotHeight) {
                    chartY = plotTop + plotHeight;
                }

                // determine if the mouse has moved more than 10px
                this.hasDragged = Math.sqrt(
                    Math.pow(mouseDownX - chartX, 2) +
                    Math.pow(mouseDownY - chartY, 2)
                );

                if (this.hasDragged > 10) {
                    clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);

                    // make a selection
                    if (chart.hasCartesianSeries && (this.zoomX || this.zoomY) && clickedInside && !panKey) {
                        if (!selectionMarker) {
                            this.selectionMarker = selectionMarker = chart.renderer.rect(
                                    plotLeft,
                                    plotTop,
                                    zoomHor ? 1 : plotWidth,
                                    zoomVert ? 1 : plotHeight,
                                    0
                                )
                                .attr({

                                    fill: chartOptions.selectionMarkerFill || color('#335cad').setOpacity(0.25).get(),

                                    'class': 'highcharts-selection-marker',
                                    'zIndex': 7
                                })
                                .add();
                        }
                    }

                    // adjust the width of the selection marker
                    if (selectionMarker && zoomHor) {
                        size = chartX - mouseDownX;
                        selectionMarker.attr({
                            width: Math.abs(size),
                            x: (size > 0 ? 0 : size) + mouseDownX
                        });
                    }
                    // adjust the height of the selection marker
                    if (selectionMarker && zoomVert) {
                        size = chartY - mouseDownY;
                        selectionMarker.attr({
                            height: Math.abs(size),
                            y: (size > 0 ? 0 : size) + mouseDownY
                        });
                    }

                    // panning
                    if (clickedInside && !selectionMarker && chartOptions.panning) {
                        chart.pan(e, chartOptions.panning);
                    }
                }
            },

            /**
             * On mouse up or touch end across the entire document, drop the selection.
             *
             * @private
             */
            drop: function(e) {
                var pointer = this,
                    chart = this.chart,
                    hasPinched = this.hasPinched;

                if (this.selectionMarker) {
                    var selectionData = {
                            originalEvent: e, // #4890
                            xAxis: [],
                            yAxis: []
                        },
                        selectionBox = this.selectionMarker,
                        selectionLeft = selectionBox.attr ? selectionBox.attr('x') : selectionBox.x,
                        selectionTop = selectionBox.attr ? selectionBox.attr('y') : selectionBox.y,
                        selectionWidth = selectionBox.attr ? selectionBox.attr('width') : selectionBox.width,
                        selectionHeight = selectionBox.attr ? selectionBox.attr('height') : selectionBox.height,
                        runZoom;

                    // a selection has been made
                    if (this.hasDragged || hasPinched) {

                        // record each axis' min and max
                        each(chart.axes, function(axis) {
                            if (axis.zoomEnabled && defined(axis.min) && (hasPinched || pointer[{
                                    xAxis: 'zoomX',
                                    yAxis: 'zoomY'
                                }[axis.coll]])) { // #859, #3569
                                var horiz = axis.horiz,
                                    minPixelPadding = e.type === 'touchend' ? axis.minPixelPadding : 0, // #1207, #3075
                                    selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) + minPixelPadding),
                                    selectionMax = axis.toValue((horiz ? selectionLeft + selectionWidth : selectionTop + selectionHeight) - minPixelPadding);

                                selectionData[axis.coll].push({
                                    axis: axis,
                                    min: Math.min(selectionMin, selectionMax), // for reversed axes
                                    max: Math.max(selectionMin, selectionMax)
                                });
                                runZoom = true;
                            }
                        });
                        if (runZoom) {
                            fireEvent(chart, 'selection', selectionData, function(args) {
                                chart.zoom(extend(args, hasPinched ? {
                                    animation: false
                                } : null));
                            });
                        }

                    }
                    this.selectionMarker = this.selectionMarker.destroy();

                    // Reset scaling preview
                    if (hasPinched) {
                        this.scaleGroups();
                    }
                }

                // Reset all
                if (chart) { // it may be destroyed on mouse up - #877
                    css(chart.container, {
                        cursor: chart._cursor
                    });
                    chart.cancelClick = this.hasDragged > 10; // #370
                    chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
                    this.pinchDown = [];
                }
            },

            onContainerMouseDown: function(e) {

                e = this.normalize(e);

                this.zoomOption(e);

                // issue #295, dragging not always working in Firefox
                if (e.preventDefault) {
                    e.preventDefault();
                }

                this.dragStart(e);
            },



            onDocumentMouseUp: function(e) {
                if (charts[H.hoverChartIndex]) {
                    charts[H.hoverChartIndex].pointer.drop(e);
                }
            },

            /**
             * Special handler for mouse move that will hide the tooltip when the mouse
             * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
             * always fire.
             *
             * @private
             */
            onDocumentMouseMove: function(e) {
                var chart = this.chart,
                    chartPosition = this.chartPosition;

                e = this.normalize(e, chartPosition);

                // If we're outside, hide the tooltip
                if (chartPosition && !this.inClass(e.target, 'highcharts-tracker') &&
                    !chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
                    this.reset();
                }
            },

            /**
             * When mouse leaves the container, hide the tooltip.
             *
             * @private
             */
            onContainerMouseLeave: function(e) {
                var chart = charts[H.hoverChartIndex];
                if (chart && (e.relatedTarget || e.toElement)) { // #4886, MS Touch end fires mouseleave but with no related target
                    chart.pointer.reset();
                    chart.pointer.chartPosition = null; // also reset the chart position, used in #149 fix
                }
            },

            // The mousemove, touchmove and touchstart event handler
            onContainerMouseMove: function(e) {

                var chart = this.chart;

                if (!defined(H.hoverChartIndex) || !charts[H.hoverChartIndex] || !charts[H.hoverChartIndex].mouseIsDown) {
                    H.hoverChartIndex = chart.index;
                }

                e = this.normalize(e);
                e.returnValue = false; // #2251, #3224

                if (chart.mouseIsDown === 'mousedown') {
                    this.drag(e);
                }

                // Show the tooltip and run mouse over events (#977)
                if ((this.inClass(e.target, 'highcharts-tracker') ||
                        chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) && !chart.openMenu) {
                    this.runPointActions(e);
                }
            },

            /**
             * Utility to detect whether an element has, or has a parent with, a specific
             * class name. Used on detection of tracker objects and on deciding whether
             * hovering the tooltip should cause the active series to mouse out.
             *
             * @param  {SVGDOMElement|HTMLDOMElement} element
             *         The element to investigate.
             * @param  {String} className
             *         The class name to look for.
             *
             * @return {Boolean}
             *         True if either the element or one of its parents has the given
             *         class name.
             */
            inClass: function(element, className) {
                var elemClassName;
                while (element) {
                    elemClassName = attr(element, 'class');
                    if (elemClassName) {
                        if (elemClassName.indexOf(className) !== -1) {
                            return true;
                        }
                        if (elemClassName.indexOf('highcharts-container') !== -1) {
                            return false;
                        }
                    }
                    element = element.parentNode;
                }
            },

            onTrackerMouseOut: function(e) {
                var series = this.chart.hoverSeries,
                    relatedTarget = e.relatedTarget || e.toElement;

                this.isDirectTouch = false;

                if (
                    series &&
                    relatedTarget &&
                    !series.stickyTracking &&
                    !this.inClass(relatedTarget, 'highcharts-tooltip') &&
                    (!this.inClass(
                            relatedTarget,
                            'highcharts-series-' + series.index
                        ) || // #2499, #4465
                        !this.inClass(relatedTarget, 'highcharts-tracker') // #5553
                    )
                ) {
                    series.onMouseOut();
                }
            },

            onContainerClick: function(e) {
                var chart = this.chart,
                    hoverPoint = chart.hoverPoint,
                    plotLeft = chart.plotLeft,
                    plotTop = chart.plotTop;

                e = this.normalize(e);

                if (!chart.cancelClick) {

                    // On tracker click, fire the series and point events. #783, #1583
                    if (hoverPoint && this.inClass(e.target, 'highcharts-tracker')) {

                        // the series click event
                        fireEvent(hoverPoint.series, 'click', extend(e, {
                            point: hoverPoint
                        }));

                        // the point click event
                        if (chart.hoverPoint) { // it may be destroyed (#1844)
                            hoverPoint.firePointEvent('click', e);
                        }

                        // When clicking outside a tracker, fire a chart event
                    } else {
                        extend(e, this.getCoordinates(e));

                        // fire a click event in the chart
                        if (chart.isInsidePlot(e.chartX - plotLeft, e.chartY - plotTop)) {
                            fireEvent(chart, 'click', e);
                        }
                    }


                }
            },

            /**
             * Set the JS DOM events on the container and document. This method should contain
             * a one-to-one assignment between methods and their handlers. Any advanced logic should
             * be moved to the handler reflecting the event's name.
             *
             * @private
             */
            setDOMEvents: function() {

                var pointer = this,
                    container = pointer.chart.container,
                    ownerDoc = container.ownerDocument;

                container.onmousedown = function(e) {
                    pointer.onContainerMouseDown(e);
                };
                container.onmousemove = function(e) {
                    pointer.onContainerMouseMove(e);
                };
                container.onclick = function(e) {
                    pointer.onContainerClick(e);
                };
                addEvent(container, 'mouseleave', pointer.onContainerMouseLeave);
                if (H.chartCount === 1) {
                    addEvent(
                        ownerDoc,
                        'mouseup',
                        pointer.onDocumentMouseUp
                    );
                }
                if (H.hasTouch) {
                    container.ontouchstart = function(e) {
                        pointer.onContainerTouchStart(e);
                    };
                    container.ontouchmove = function(e) {
                        pointer.onContainerTouchMove(e);
                    };
                    if (H.chartCount === 1) {
                        addEvent(
                            ownerDoc,
                            'touchend',
                            pointer.onDocumentTouchEnd
                        );
                    }
                }

            },

            /**
             * Destroys the Pointer object and disconnects DOM events.
             */
            destroy: function() {
                var pointer = this,
                    ownerDoc = this.chart.container.ownerDocument;

                if (pointer.unDocMouseMove) {
                    pointer.unDocMouseMove();
                }

                removeEvent(
                    pointer.chart.container,
                    'mouseleave',
                    pointer.onContainerMouseLeave
                );
                if (!H.chartCount) {
                    removeEvent(ownerDoc, 'mouseup', pointer.onDocumentMouseUp);
                    if (H.hasTouch) {
                        removeEvent(ownerDoc, 'touchend', pointer.onDocumentTouchEnd);
                    }
                }

                // memory and CPU leak
                clearInterval(pointer.tooltipTimeout);

                H.objectEach(pointer, function(val, prop) {
                    pointer[prop] = null;
                });
            }
        };

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var charts = H.charts,
            each = H.each,
            extend = H.extend,
            map = H.map,
            noop = H.noop,
            pick = H.pick,
            Pointer = H.Pointer;

        /* Support for touch devices */
        extend(Pointer.prototype, /** @lends Pointer.prototype */ {

            /**
             * Run translation operations
             */
            pinchTranslate: function(
                pinchDown,
                touches,
                transform,
                selectionMarker,
                clip,
                lastValidTouch
            ) {
                if (this.zoomHor) {
                    this.pinchTranslateDirection(
                        true,
                        pinchDown,
                        touches,
                        transform,
                        selectionMarker,
                        clip,
                        lastValidTouch
                    );
                }
                if (this.zoomVert) {
                    this.pinchTranslateDirection(
                        false,
                        pinchDown,
                        touches,
                        transform,
                        selectionMarker,
                        clip,
                        lastValidTouch
                    );
                }
            },

            /**
             * Run translation operations for each direction (horizontal and vertical)
             * independently
             */
            pinchTranslateDirection: function(horiz, pinchDown, touches, transform,
                selectionMarker, clip, lastValidTouch, forcedScale) {
                var chart = this.chart,
                    xy = horiz ? 'x' : 'y',
                    XY = horiz ? 'X' : 'Y',
                    sChartXY = 'chart' + XY,
                    wh = horiz ? 'width' : 'height',
                    plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')],
                    selectionWH,
                    selectionXY,
                    clipXY,
                    scale = forcedScale || 1,
                    inverted = chart.inverted,
                    bounds = chart.bounds[horiz ? 'h' : 'v'],
                    singleTouch = pinchDown.length === 1,
                    touch0Start = pinchDown[0][sChartXY],
                    touch0Now = touches[0][sChartXY],
                    touch1Start = !singleTouch && pinchDown[1][sChartXY],
                    touch1Now = !singleTouch && touches[1][sChartXY],
                    outOfBounds,
                    transformScale,
                    scaleKey,
                    setScale = function() {
                        // Don't zoom if fingers are too close on this axis
                        if (!singleTouch && Math.abs(touch0Start - touch1Start) > 20) {
                            scale = forcedScale ||
                                Math.abs(touch0Now - touch1Now) /
                                Math.abs(touch0Start - touch1Start);
                        }

                        clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
                        selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] /
                            scale;
                    };

                // Set the scale, first pass
                setScale();

                // The clip position (x or y) is altered if out of bounds, the selection
                // position is not
                selectionXY = clipXY;

                // Out of bounds
                if (selectionXY < bounds.min) {
                    selectionXY = bounds.min;
                    outOfBounds = true;
                } else if (selectionXY + selectionWH > bounds.max) {
                    selectionXY = bounds.max - selectionWH;
                    outOfBounds = true;
                }

                // Is the chart dragged off its bounds, determined by dataMin and
                // dataMax?
                if (outOfBounds) {

                    // Modify the touchNow position in order to create an elastic drag
                    // movement. This indicates to the user that the chart is responsive
                    // but can't be dragged further.
                    touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
                    if (!singleTouch) {
                        touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
                    }

                    // Set the scale, second pass to adapt to the modified touchNow
                    // positions
                    setScale();

                } else {
                    lastValidTouch[xy] = [touch0Now, touch1Now];
                }

                // Set geometry for clipping, selection and transformation
                if (!inverted) {
                    clip[xy] = clipXY - plotLeftTop;
                    clip[wh] = selectionWH;
                }
                scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
                transformScale = inverted ? 1 / scale : scale;

                selectionMarker[wh] = selectionWH;
                selectionMarker[xy] = selectionXY;
                transform[scaleKey] = scale;
                transform['translate' + XY] = (transformScale * plotLeftTop) +
                    (touch0Now - (transformScale * touch0Start));
            },

            /**
             * Handle touch events with two touches
             */
            pinch: function(e) {

                var self = this,
                    chart = self.chart,
                    pinchDown = self.pinchDown,
                    touches = e.touches,
                    touchesLength = touches.length,
                    lastValidTouch = self.lastValidTouch,
                    hasZoom = self.hasZoom,
                    selectionMarker = self.selectionMarker,
                    transform = {},
                    fireClickEvent = touchesLength === 1 &&
                    ((self.inClass(e.target, 'highcharts-tracker') &&
                        chart.runTrackerClick) || self.runChartClick),
                    clip = {};

                // Don't initiate panning until the user has pinched. This prevents us
                // from blocking page scrolling as users scroll down a long page
                // (#4210).
                if (touchesLength > 1) {
                    self.initiated = true;
                }

                // On touch devices, only proceed to trigger click if a handler is
                // defined
                if (hasZoom && self.initiated && !fireClickEvent) {
                    e.preventDefault();
                }

                // Normalize each touch
                map(touches, function(e) {
                    return self.normalize(e);
                });

                // Register the touch start position
                if (e.type === 'touchstart') {
                    each(touches, function(e, i) {
                        pinchDown[i] = {
                            chartX: e.chartX,
                            chartY: e.chartY
                        };
                    });
                    lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
                        pinchDown[1].chartX
                    ];
                    lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
                        pinchDown[1].chartY
                    ];

                    // Identify the data bounds in pixels
                    each(chart.axes, function(axis) {
                        if (axis.zoomEnabled) {
                            var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
                                minPixelPadding = axis.minPixelPadding,
                                min = axis.toPixels(
                                    pick(axis.options.min, axis.dataMin)
                                ),
                                max = axis.toPixels(
                                    pick(axis.options.max, axis.dataMax)
                                ),
                                absMin = Math.min(min, max),
                                absMax = Math.max(min, max);

                            // Store the bounds for use in the touchmove handler
                            bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
                            bounds.max = Math.max(
                                axis.pos + axis.len,
                                absMax + minPixelPadding
                            );
                        }
                    });
                    self.res = true; // reset on next move

                    // Optionally move the tooltip on touchmove
                } else if (self.followTouchMove && touchesLength === 1) {
                    this.runPointActions(self.normalize(e));

                    // Event type is touchmove, handle panning and pinching
                } else if (pinchDown.length) { // can be 0 when releasing, if touchend
                    // fires first


                    // Set the marker
                    if (!selectionMarker) {
                        self.selectionMarker = selectionMarker = extend({
                            destroy: noop,
                            touch: true
                        }, chart.plotBox);
                    }

                    self.pinchTranslate(
                        pinchDown,
                        touches,
                        transform,
                        selectionMarker,
                        clip,
                        lastValidTouch
                    );

                    self.hasPinched = hasZoom;

                    // Scale and translate the groups to provide visual feedback during
                    // pinching
                    self.scaleGroups(transform, clip);

                    if (self.res) {
                        self.res = false;
                        this.reset(false, 0);
                    }
                }
            },

            /**
             * General touch handler shared by touchstart and touchmove.
             */
            touch: function(e, start) {
                var chart = this.chart,
                    hasMoved,
                    pinchDown,
                    isInside;

                if (chart.index !== H.hoverChartIndex) {
                    this.onContainerMouseLeave({
                        relatedTarget: true
                    });
                }
                H.hoverChartIndex = chart.index;

                if (e.touches.length === 1) {

                    e = this.normalize(e);

                    isInside = chart.isInsidePlot(
                        e.chartX - chart.plotLeft,
                        e.chartY - chart.plotTop
                    );
                    if (isInside && !chart.openMenu) {

                        // Run mouse events and display tooltip etc
                        if (start) {
                            this.runPointActions(e);
                        }

                        // Android fires touchmove events after the touchstart even if
                        // the finger hasn't moved, or moved only a pixel or two. In iOS
                        // however, the touchmove doesn't fire unless the finger moves
                        // more than ~4px. So we emulate this behaviour in Android by
                        // checking how much it moved, and cancelling on small
                        // distances. #3450.
                        if (e.type === 'touchmove') {
                            pinchDown = this.pinchDown;
                            hasMoved = pinchDown[0] ? Math.sqrt( // #5266
                                Math.pow(pinchDown[0].chartX - e.chartX, 2) +
                                Math.pow(pinchDown[0].chartY - e.chartY, 2)
                            ) >= 4 : false;
                        }

                        if (pick(hasMoved, true)) {
                            this.pinch(e);
                        }

                    } else if (start) {
                        // Hide the tooltip on touching outside the plot area (#1203)
                        this.reset();
                    }

                } else if (e.touches.length === 2) {
                    this.pinch(e);
                }
            },

            onContainerTouchStart: function(e) {
                this.zoomOption(e);
                this.touch(e, true);
            },

            onContainerTouchMove: function(e) {
                this.touch(e);
            },

            onDocumentTouchEnd: function(e) {
                if (charts[H.hoverChartIndex]) {
                    charts[H.hoverChartIndex].pointer.drop(e);
                }
            }

        });

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var addEvent = H.addEvent,
            charts = H.charts,
            css = H.css,
            doc = H.doc,
            extend = H.extend,
            hasTouch = H.hasTouch,
            noop = H.noop,
            Pointer = H.Pointer,
            removeEvent = H.removeEvent,
            win = H.win,
            wrap = H.wrap;

        if (!hasTouch && (win.PointerEvent || win.MSPointerEvent)) {

            // The touches object keeps track of the points being touched at all times
            var touches = {},
                hasPointerEvent = !!win.PointerEvent,
                getWebkitTouches = function() {
                    var fake = [];
                    fake.item = function(i) {
                        return this[i];
                    };
                    H.objectEach(touches, function(touch) {
                        fake.push({
                            pageX: touch.pageX,
                            pageY: touch.pageY,
                            target: touch.target
                        });
                    });
                    return fake;
                },
                translateMSPointer = function(e, method, wktype, func) {
                    var p;
                    if ((e.pointerType === 'touch' || e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
                        func(e);
                        p = charts[H.hoverChartIndex].pointer;
                        p[method]({
                            type: wktype,
                            target: e.currentTarget,
                            preventDefault: noop,
                            touches: getWebkitTouches()
                        });
                    }
                };

            /**
             * Extend the Pointer prototype with methods for each event handler and more
             */
            extend(Pointer.prototype, /** @lends Pointer.prototype */ {
                onContainerPointerDown: function(e) {
                    translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function(e) {
                        touches[e.pointerId] = {
                            pageX: e.pageX,
                            pageY: e.pageY,
                            target: e.currentTarget
                        };
                    });
                },
                onContainerPointerMove: function(e) {
                    translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function(e) {
                        touches[e.pointerId] = {
                            pageX: e.pageX,
                            pageY: e.pageY
                        };
                        if (!touches[e.pointerId].target) {
                            touches[e.pointerId].target = e.currentTarget;
                        }
                    });
                },
                onDocumentPointerUp: function(e) {
                    translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function(e) {
                        delete touches[e.pointerId];
                    });
                },

                /**
                 * Add or remove the MS Pointer specific events
                 */
                batchMSEvents: function(fn) {
                    fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
                    fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
                    fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
                }
            });

            // Disable default IE actions for pinch and such on chart element
            wrap(Pointer.prototype, 'init', function(proceed, chart, options) {
                proceed.call(this, chart, options);
                if (this.hasZoom) { // #4014
                    css(chart.container, {
                        '-ms-touch-action': 'none',
                        'touch-action': 'none'
                    });
                }
            });

            // Add IE specific touch events to chart
            wrap(Pointer.prototype, 'setDOMEvents', function(proceed) {
                proceed.apply(this);
                if (this.hasZoom || this.followTouchMove) {
                    this.batchMSEvents(addEvent);
                }
            });
            // Destroy MS events also
            wrap(Pointer.prototype, 'destroy', function(proceed) {
                this.batchMSEvents(removeEvent);
                proceed.call(this);
            });
        }

    }(Highcharts));
    (function(Highcharts) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var H = Highcharts,

            addEvent = H.addEvent,
            css = H.css,
            discardElement = H.discardElement,
            defined = H.defined,
            each = H.each,
            isFirefox = H.isFirefox,
            marginNames = H.marginNames,
            merge = H.merge,
            pick = H.pick,
            setAnimation = H.setAnimation,
            stableSort = H.stableSort,
            win = H.win,
            wrap = H.wrap;

        /**
         * The overview of the chart's series. The legend object is instanciated
         * internally in the chart constructor, and available from `chart.legend`. Each
         * chart has only one legend.
         * 
         * @class
         */
        Highcharts.Legend = function(chart, options) {
            this.init(chart, options);
        };

        Highcharts.Legend.prototype = {

            /**
             * Initialize the legend.
             *
             * @private
             */
            init: function(chart, options) {

                this.chart = chart;

                this.setOptions(options);

                if (options.enabled) {

                    // Render it
                    this.render();

                    // move checkboxes
                    addEvent(this.chart, 'endResize', function() {
                        this.legend.positionCheckboxes();
                    });
                }
            },

            setOptions: function(options) {

                var padding = pick(options.padding, 8);

                this.options = options;


                this.itemStyle = options.itemStyle;
                this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);

                this.itemMarginTop = options.itemMarginTop || 0;
                this.padding = padding;
                this.initialItemY = padding - 5; // 5 is pixels above the text
                this.maxItemWidth = 0;
                this.itemHeight = 0;
                this.symbolWidth = pick(options.symbolWidth, 16);
                this.pages = [];

            },

            /**
             * Update the legend with new options. Equivalent to running `chart.update`
             * with a legend configuration option.
             * @param  {LegendOptions} options
             *         Legend options.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart.
             *
             * @sample highcharts/legend/legend-update/
             *         Legend update
             */
            update: function(options, redraw) {
                var chart = this.chart;

                this.setOptions(merge(true, this.options, options));
                this.destroy();
                chart.isDirtyLegend = chart.isDirtyBox = true;
                if (pick(redraw, true)) {
                    chart.redraw();
                }
            },

            /**
             * Set the colors for the legend item.
             *
             * @private
             * @param  {Series|Point} item
             *         A Series or Point instance
             * @param  {Boolean} visible
             *         Dimmed or colored
             */
            colorizeItem: function(item, visible) {
                item.legendGroup[visible ? 'removeClass' : 'addClass'](
                    'highcharts-legend-item-hidden'
                );


                var legend = this,
                    options = legend.options,
                    legendItem = item.legendItem,
                    legendLine = item.legendLine,
                    legendSymbol = item.legendSymbol,
                    hiddenColor = legend.itemHiddenStyle.color,
                    textColor = visible ? options.itemStyle.color : hiddenColor,
                    symbolColor = visible ? (item.color || hiddenColor) : hiddenColor,
                    markerOptions = item.options && item.options.marker,
                    symbolAttr = {
                        fill: symbolColor
                    };

                if (legendItem) {
                    legendItem.css({
                        fill: textColor,
                        color: textColor // #1553, oldIE
                    });
                }
                if (legendLine) {
                    legendLine.attr({
                        stroke: symbolColor
                    });
                }

                if (legendSymbol) {

                    // Apply marker options
                    if (markerOptions && legendSymbol.isMarker) { // #585
                        symbolAttr = item.pointAttribs();
                        if (!visible) {
                            symbolAttr.stroke = symbolAttr.fill = hiddenColor; // #6769
                        }
                    }

                    legendSymbol.attr(symbolAttr);
                }

            },

            /**
             * Position the legend item.
             *
             * @private
             * @param {Series|Point} item
             *        The item to position
             */
            positionItem: function(item) {
                var legend = this,
                    options = legend.options,
                    symbolPadding = options.symbolPadding,
                    ltr = !options.rtl,
                    legendItemPos = item._legendItemPos,
                    itemX = legendItemPos[0],
                    itemY = legendItemPos[1],
                    checkbox = item.checkbox,
                    legendGroup = item.legendGroup;

                if (legendGroup && legendGroup.element) {
                    legendGroup.translate(
                        ltr ?
                        itemX :
                        legend.legendWidth - itemX - 2 * symbolPadding - 4,
                        itemY
                    );
                }

                if (checkbox) {
                    checkbox.x = itemX;
                    checkbox.y = itemY;
                }
            },

            /**
             * Destroy a single legend item, used internally on removing series items.
             * 
             * @param {Series|Point} item
             *        The item to remove
             */
            destroyItem: function(item) {
                var checkbox = item.checkbox;

                // destroy SVG elements
                each(
                    ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'],
                    function(key) {
                        if (item[key]) {
                            item[key] = item[key].destroy();
                        }
                    }
                );

                if (checkbox) {
                    discardElement(item.checkbox);
                }
            },

            /**
             * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
             * must be called after destruction.
             */
            destroy: function() {
                function destroyItems(key) {
                    if (this[key]) {
                        this[key] = this[key].destroy();
                    }
                }

                // Destroy items
                each(this.getAllItems(), function(item) {
                    each(['legendItem', 'legendGroup'], destroyItems, item);
                });

                // Destroy legend elements
                each([
                    'clipRect',
                    'up',
                    'down',
                    'pager',
                    'nav',
                    'box',
                    'title',
                    'group'
                ], destroyItems, this);
                this.display = null; // Reset in .render on update.
            },

            /**
             * Position the checkboxes after the width is determined.
             *
             * @private
             */
            positionCheckboxes: function(scrollOffset) {
                var alignAttr = this.group && this.group.alignAttr,
                    translateY,
                    clipHeight = this.clipHeight || this.legendHeight,
                    titleHeight = this.titleHeight;

                if (alignAttr) {
                    translateY = alignAttr.translateY;
                    each(this.allItems, function(item) {
                        var checkbox = item.checkbox,
                            top;

                        if (checkbox) {
                            top = translateY + titleHeight + checkbox.y +
                                (scrollOffset || 0) + 3;
                            css(checkbox, {
                                left: (alignAttr.translateX + item.checkboxOffset +
                                    checkbox.x - 20) + 'px',
                                top: top + 'px',
                                display: top > translateY - 6 && top < translateY +
                                    clipHeight - 6 ? '' : 'none'
                            });
                        }
                    });
                }
            },

            /**
             * Render the legend title on top of the legend.
             *
             * @private
             */
            renderTitle: function() {
                var options = this.options,
                    padding = this.padding,
                    titleOptions = options.title,
                    titleHeight = 0,
                    bBox;

                if (titleOptions.text) {
                    if (!this.title) {
                        this.title = this.chart.renderer.label(
                                titleOptions.text,
                                padding - 3,
                                padding - 4,
                                null,
                                null,
                                null,
                                options.useHTML,
                                null,
                                'legend-title'
                            )
                            .attr({
                                zIndex: 1
                            })

                            .css(titleOptions.style)

                            .add(this.group);
                    }
                    bBox = this.title.getBBox();
                    titleHeight = bBox.height;
                    this.offsetWidth = bBox.width; // #1717
                    this.contentGroup.attr({
                        translateY: titleHeight
                    });
                }
                this.titleHeight = titleHeight;
            },

            /**
             * Set the legend item text.
             *
             * @param  {Series|Point} item
             *         The item for which to update the text in the legend.
             */
            setText: function(item) {
                var options = this.options;
                item.legendItem.attr({
                    text: options.labelFormat ?
                        H.format(options.labelFormat, item) : options.labelFormatter.call(item)
                });
            },

            /**
             * Render a single specific legend item. Called internally from the `render`
             * function.
             *
             * @private
             * @param {Series|Point} item
             *        The item to render.
             */
            renderItem: function(item) {
                var legend = this,
                    chart = legend.chart,
                    renderer = chart.renderer,
                    options = legend.options,
                    horizontal = options.layout === 'horizontal',
                    symbolWidth = legend.symbolWidth,
                    symbolPadding = options.symbolPadding,

                    itemStyle = legend.itemStyle,
                    itemHiddenStyle = legend.itemHiddenStyle,

                    padding = legend.padding,
                    itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
                    ltr = !options.rtl,
                    itemHeight,
                    widthOption = options.width,
                    itemMarginBottom = options.itemMarginBottom || 0,
                    itemMarginTop = legend.itemMarginTop,
                    bBox,
                    itemWidth,
                    li = item.legendItem,
                    isSeries = !item.series,
                    series = !isSeries && item.series.drawLegendSymbol ?
                    item.series :
                    item,
                    seriesOptions = series.options,
                    showCheckbox = legend.createCheckboxForItem &&
                    seriesOptions &&
                    seriesOptions.showCheckbox,
                    // full width minus text width
                    itemExtraWidth = symbolWidth + symbolPadding + itemDistance +
                    (showCheckbox ? 20 : 0),
                    useHTML = options.useHTML,
                    fontSize = 12,
                    itemClassName = item.options.className;

                if (!li) { // generate it once, later move it

                    // Generate the group box, a group to hold the symbol and text. Text
                    // is to be appended in Legend class.
                    item.legendGroup = renderer.g('legend-item')
                        .addClass(
                            'highcharts-' + series.type + '-series ' +
                            'highcharts-color-' + item.colorIndex +
                            (itemClassName ? ' ' + itemClassName : '') +
                            (isSeries ? ' highcharts-series-' + item.index : '')
                        )
                        .attr({
                            zIndex: 1
                        })
                        .add(legend.scrollGroup);

                    // Generate the list item text and add it to the group
                    item.legendItem = li = renderer.text(
                            '',
                            ltr ? symbolWidth + symbolPadding : -symbolPadding,
                            legend.baseline || 0,
                            useHTML
                        )

                        // merge to prevent modifying original (#1021)
                        .css(merge(item.visible ? itemStyle : itemHiddenStyle))

                        .attr({
                            align: ltr ? 'left' : 'right',
                            zIndex: 2
                        })
                        .add(item.legendGroup);

                    // Get the baseline for the first item - the font size is equal for
                    // all
                    if (!legend.baseline) {

                        fontSize = itemStyle.fontSize;

                        legend.fontMetrics = renderer.fontMetrics(
                            fontSize,
                            li
                        );
                        legend.baseline = legend.fontMetrics.f + 3 + itemMarginTop;
                        li.attr('y', legend.baseline);
                    }

                    // Draw the legend symbol inside the group box
                    legend.symbolHeight = options.symbolHeight || legend.fontMetrics.f;
                    series.drawLegendSymbol(legend, item);

                    if (legend.setItemEvents) {
                        legend.setItemEvents(item, li, useHTML);
                    }

                    // add the HTML checkbox on top
                    if (showCheckbox) {
                        legend.createCheckboxForItem(item);
                    }
                }

                // Colorize the items
                legend.colorizeItem(item, item.visible);

                // Take care of max width and text overflow (#6659)

                if (!itemStyle.width) {

                    li.css({
                        width: (
                            options.itemWidth ||
                            options.width ||
                            chart.spacingBox.width
                        ) - itemExtraWidth
                    });

                }


                // Always update the text
                legend.setText(item);

                // calculate the positions for the next line
                bBox = li.getBBox();

                itemWidth = item.checkboxOffset =
                    options.itemWidth ||
                    item.legendItemWidth ||
                    bBox.width + itemExtraWidth;
                legend.itemHeight = itemHeight = Math.round(
                    item.legendItemHeight || bBox.height || legend.symbolHeight
                );

                // If the item exceeds the width, start a new line
                if (
                    horizontal &&
                    legend.itemX - padding + itemWidth > (
                        widthOption || (
                            chart.spacingBox.width - 2 * padding - options.x
                        )
                    )
                ) {
                    legend.itemX = padding;
                    legend.itemY += itemMarginTop + legend.lastLineHeight +
                        itemMarginBottom;
                    legend.lastLineHeight = 0; // reset for next line (#915, #3976)
                }

                // If the item exceeds the height, start a new column
                /*
                if (!horizontal && legend.itemY + options.y +
                		itemHeight > chart.chartHeight - spacingTop - spacingBottom) {
                	legend.itemY = legend.initialItemY;
                	legend.itemX += legend.maxItemWidth;
                	legend.maxItemWidth = 0;
                }
                */

                // Set the edge positions
                legend.maxItemWidth = Math.max(legend.maxItemWidth, itemWidth);
                legend.lastItemY = itemMarginTop + legend.itemY + itemMarginBottom;
                legend.lastLineHeight = Math.max( // #915
                    itemHeight,
                    legend.lastLineHeight
                );

                // cache the position of the newly generated or reordered items
                item._legendItemPos = [legend.itemX, legend.itemY];

                // advance
                if (horizontal) {
                    legend.itemX += itemWidth;

                } else {
                    legend.itemY += itemMarginTop + itemHeight + itemMarginBottom;
                    legend.lastLineHeight = itemHeight;
                }

                // the width of the widest item
                legend.offsetWidth = widthOption || Math.max(
                    (
                        horizontal ? legend.itemX - padding - (item.checkbox ?
                            // decrease by itemDistance only when no checkbox #4853
                            0 :
                            itemDistance
                        ) : itemWidth
                    ) + padding,
                    legend.offsetWidth
                );
            },

            /**
             * Get all items, which is one item per series for most series and one
             * item per point for pie series and its derivatives.
             *
             * @return {Array.<Series|Point>}
             *         The current items in the legend.
             */
            getAllItems: function() {
                var allItems = [];
                each(this.chart.series, function(series) {
                    var seriesOptions = series && series.options;

                    // Handle showInLegend. If the series is linked to another series,
                    // defaults to false.
                    if (series && pick(
                            seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? undefined : false, true
                        )) {

                        // Use points or series for the legend item depending on
                        // legendType
                        allItems = allItems.concat(
                            series.legendItems ||
                            (
                                seriesOptions.legendType === 'point' ?
                                series.data :
                                series
                            )
                        );
                    }
                });
                return allItems;
            },

            /**
             * Adjust the chart margins by reserving space for the legend on only one
             * side of the chart. If the position is set to a corner, top or bottom is
             * reserved for horizontal legends and left or right for vertical ones.
             *
             * @private
             */
            adjustMargins: function(margin, spacing) {
                var chart = this.chart,
                    options = this.options,
                    // Use the first letter of each alignment option in order to detect
                    // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
                    alignment = options.align.charAt(0) +
                    options.verticalAlign.charAt(0) +
                    options.layout.charAt(0);

                if (!options.floating) {

                    each([
                        /(lth|ct|rth)/,
                        /(rtv|rm|rbv)/,
                        /(rbh|cb|lbh)/,
                        /(lbv|lm|ltv)/
                    ], function(alignments, side) {
                        if (alignments.test(alignment) && !defined(margin[side])) {
                            // Now we have detected on which side of the chart we should
                            // reserve space for the legend
                            chart[marginNames[side]] = Math.max(
                                chart[marginNames[side]],
                                (
                                    chart.legend[
                                        (side + 1) % 2 ? 'legendHeight' : 'legendWidth'
                                    ] + [1, -1, -1, 1][side] * options[
                                        (side % 2) ? 'x' : 'y'
                                    ] +
                                    pick(options.margin, 12) +
                                    spacing[side]
                                )
                            );
                        }
                    });
                }
            },

            /**
             * Render the legend. This method can be called both before and after
             * `chart.render`. If called after, it will only rearrange items instead
             * of creating new ones. Called internally on initial render and after
             * redraws.
             */
            render: function() {
                var legend = this,
                    chart = legend.chart,
                    renderer = chart.renderer,
                    legendGroup = legend.group,
                    allItems,
                    display,
                    legendWidth,
                    legendHeight,
                    box = legend.box,
                    options = legend.options,
                    padding = legend.padding;

                legend.itemX = padding;
                legend.itemY = legend.initialItemY;
                legend.offsetWidth = 0;
                legend.lastItemY = 0;

                if (!legendGroup) {
                    legend.group = legendGroup = renderer.g('legend')
                        .attr({
                            zIndex: 7
                        })
                        .add();
                    legend.contentGroup = renderer.g()
                        .attr({
                            zIndex: 1
                        }) // above background
                        .add(legendGroup);
                    legend.scrollGroup = renderer.g()
                        .add(legend.contentGroup);
                }

                legend.renderTitle();

                // add each series or point
                allItems = legend.getAllItems();

                // sort by legendIndex
                stableSort(allItems, function(a, b) {
                    return ((a.options && a.options.legendIndex) || 0) -
                        ((b.options && b.options.legendIndex) || 0);
                });

                // reversed legend
                if (options.reversed) {
                    allItems.reverse();
                }

                legend.allItems = allItems;
                legend.display = display = !!allItems.length;

                // render the items
                legend.lastLineHeight = 0;
                each(allItems, function(item) {
                    legend.renderItem(item);
                });

                // Get the box
                legendWidth = (options.width || legend.offsetWidth) + padding;
                legendHeight = legend.lastItemY + legend.lastLineHeight +
                    legend.titleHeight;
                legendHeight = legend.handleOverflow(legendHeight);
                legendHeight += padding;

                // Draw the border and/or background
                if (!box) {
                    legend.box = box = renderer.rect()
                        .addClass('highcharts-legend-box')
                        .attr({
                            r: options.borderRadius
                        })
                        .add(legendGroup);
                    box.isNew = true;
                }


                // Presentational
                box
                    .attr({
                        stroke: options.borderColor,
                        'stroke-width': options.borderWidth || 0,
                        fill: options.backgroundColor || 'none'
                    })
                    .shadow(options.shadow);


                if (legendWidth > 0 && legendHeight > 0) {
                    box[box.isNew ? 'attr' : 'animate'](
                        box.crisp({
                            x: 0,
                            y: 0,
                            width: legendWidth,
                            height: legendHeight
                        }, box.strokeWidth())
                    );
                    box.isNew = false;
                }

                // hide the border if no items
                box[display ? 'show' : 'hide']();



                legend.legendWidth = legendWidth;
                legend.legendHeight = legendHeight;

                // Now that the legend width and height are established, put the items
                // in the final position
                each(allItems, function(item) {
                    legend.positionItem(item);
                });

                if (display) {
                    legendGroup.align(merge(options, {
                        width: legendWidth,
                        height: legendHeight
                    }), true, 'spacingBox');
                }

                if (!chart.isResizing) {
                    this.positionCheckboxes();
                }
            },

            /**
             * Set up the overflow handling by adding navigation with up and down arrows
             * below the legend.
             *
             * @private
             */
            handleOverflow: function(legendHeight) {
                var legend = this,
                    chart = this.chart,
                    renderer = chart.renderer,
                    options = this.options,
                    optionsY = options.y,
                    alignTop = options.verticalAlign === 'top',
                    padding = this.padding,
                    spaceHeight = chart.spacingBox.height +
                    (alignTop ? -optionsY : optionsY) - padding,
                    maxHeight = options.maxHeight,
                    clipHeight,
                    clipRect = this.clipRect,
                    navOptions = options.navigation,
                    animation = pick(navOptions.animation, true),
                    arrowSize = navOptions.arrowSize || 12,
                    nav = this.nav,
                    pages = this.pages,
                    lastY,
                    allItems = this.allItems,
                    clipToHeight = function(height) {
                        if (typeof height === 'number') {
                            clipRect.attr({
                                height: height
                            });
                        } else if (clipRect) { // Reset (#5912)
                            legend.clipRect = clipRect.destroy();
                            legend.contentGroup.clip();
                        }

                        // useHTML
                        if (legend.contentGroup.div) {
                            legend.contentGroup.div.style.clip = height ?
                                'rect(' + padding + 'px,9999px,' +
                                (padding + height) + 'px,0)' :
                                'auto';
                        }
                    };


                // Adjust the height
                if (
                    options.layout === 'horizontal' &&
                    options.verticalAlign !== 'middle' &&
                    !options.floating
                ) {
                    spaceHeight /= 2;
                }
                if (maxHeight) {
                    spaceHeight = Math.min(spaceHeight, maxHeight);
                }

                // Reset the legend height and adjust the clipping rectangle
                pages.length = 0;
                if (legendHeight > spaceHeight && navOptions.enabled !== false) {

                    this.clipHeight = clipHeight =
                        Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
                    this.currentPage = pick(this.currentPage, 1);
                    this.fullHeight = legendHeight;

                    // Fill pages with Y positions so that the top of each a legend item
                    // defines the scroll top for each page (#2098)
                    each(allItems, function(item, i) {
                        var y = item._legendItemPos[1],
                            h = Math.round(item.legendItem.getBBox().height),
                            len = pages.length;

                        if (!len || (y - pages[len - 1] > clipHeight &&
                                (lastY || y) !== pages[len - 1])) {
                            pages.push(lastY || y);
                            len++;
                        }

                        if (i === allItems.length - 1 &&
                            y + h - pages[len - 1] > clipHeight) {
                            pages.push(y);
                        }
                        if (y !== lastY) {
                            lastY = y;
                        }
                    });

                    // Only apply clipping if needed. Clipping causes blurred legend in
                    // PDF export (#1787)
                    if (!clipRect) {
                        clipRect = legend.clipRect =
                            renderer.clipRect(0, padding, 9999, 0);
                        legend.contentGroup.clip(clipRect);
                    }

                    clipToHeight(clipHeight);

                    // Add navigation elements
                    if (!nav) {
                        this.nav = nav = renderer.g()
                            .attr({
                                zIndex: 1
                            })
                            .add(this.group);

                        this.up = renderer
                            .symbol(
                                'triangle',
                                0,
                                0,
                                arrowSize,
                                arrowSize
                            )
                            .on('click', function() {
                                legend.scroll(-1, animation);
                            })
                            .add(nav);

                        this.pager = renderer.text('', 15, 10)
                            .addClass('highcharts-legend-navigation')

                            .css(navOptions.style)

                            .add(nav);

                        this.down = renderer
                            .symbol(
                                'triangle-down',
                                0,
                                0,
                                arrowSize,
                                arrowSize
                            )
                            .on('click', function() {
                                legend.scroll(1, animation);
                            })
                            .add(nav);
                    }

                    // Set initial position
                    legend.scroll(0);

                    legendHeight = spaceHeight;

                    // Reset
                } else if (nav) {
                    clipToHeight();
                    this.nav = nav.destroy(); // #6322
                    this.scrollGroup.attr({
                        translateY: 1
                    });
                    this.clipHeight = 0; // #1379
                }

                return legendHeight;
            },

            /**
             * Scroll the legend by a number of pages.
             * @param  {Number} scrollBy
             *         The number of pages to scroll.
             * @param  {AnimationOptions} animation
             *         Whether and how to apply animation.
             */
            scroll: function(scrollBy, animation) {
                var pages = this.pages,
                    pageCount = pages.length,
                    currentPage = this.currentPage + scrollBy,
                    clipHeight = this.clipHeight,
                    navOptions = this.options.navigation,
                    pager = this.pager,
                    padding = this.padding,
                    scrollOffset;

                // When resizing while looking at the last page
                if (currentPage > pageCount) {
                    currentPage = pageCount;
                }

                if (currentPage > 0) {

                    if (animation !== undefined) {
                        setAnimation(animation, this.chart);
                    }

                    this.nav.attr({
                        translateX: padding,
                        translateY: clipHeight + this.padding + 7 + this.titleHeight,
                        visibility: 'visible'
                    });
                    this.up.attr({
                        'class': currentPage === 1 ?
                            'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
                    });
                    pager.attr({
                        text: currentPage + '/' + pageCount
                    });
                    this.down.attr({
                        'x': 18 + this.pager.getBBox().width, // adjust to text width
                        'class': currentPage === pageCount ?
                            'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
                    });


                    this.up
                        .attr({
                            fill: currentPage === 1 ?
                                navOptions.inactiveColor : navOptions.activeColor
                        })
                        .css({
                            cursor: currentPage === 1 ? 'default' : 'pointer'
                        });
                    this.down
                        .attr({
                            fill: currentPage === pageCount ?
                                navOptions.inactiveColor : navOptions.activeColor
                        })
                        .css({
                            cursor: currentPage === pageCount ? 'default' : 'pointer'
                        });


                    scrollOffset = -pages[currentPage - 1] + this.initialItemY;

                    this.scrollGroup.animate({
                        translateY: scrollOffset
                    });

                    this.currentPage = currentPage;
                    this.positionCheckboxes(scrollOffset);
                }

            }

        };

        /*
         * LegendSymbolMixin
         */

        H.LegendSymbolMixin = {

            /**
             * Get the series' symbol in the legend
             *
             * @param {Object} legend The legend object
             * @param {Object} item The series (this) or point
             */
            drawRectangle: function(legend, item) {
                var options = legend.options,
                    symbolHeight = legend.symbolHeight,
                    square = options.squareSymbol,
                    symbolWidth = square ? symbolHeight : legend.symbolWidth;

                item.legendSymbol = this.chart.renderer.rect(
                        square ? (legend.symbolWidth - symbolHeight) / 2 : 0,
                        legend.baseline - symbolHeight + 1, // #3988
                        symbolWidth,
                        symbolHeight,
                        pick(legend.options.symbolRadius, symbolHeight / 2)
                    )
                    .addClass('highcharts-point')
                    .attr({
                        zIndex: 3
                    }).add(item.legendGroup);

            },

            /**
             * Get the series' symbol in the legend. This method should be overridable
             * to create custom symbols through
             * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
             *
             * @param {Object} legend The legend object
             */
            drawLineMarker: function(legend) {

                var options = this.options,
                    markerOptions = options.marker,
                    radius,
                    legendSymbol,
                    symbolWidth = legend.symbolWidth,
                    symbolHeight = legend.symbolHeight,
                    generalRadius = symbolHeight / 2,
                    renderer = this.chart.renderer,
                    legendItemGroup = this.legendGroup,
                    verticalCenter = legend.baseline -
                    Math.round(legend.fontMetrics.b * 0.3),
                    attr = {};

                // Draw the line

                attr = {
                    'stroke-width': options.lineWidth || 0
                };
                if (options.dashStyle) {
                    attr.dashstyle = options.dashStyle;
                }


                this.legendLine = renderer.path([
                        'M',
                        0,
                        verticalCenter,
                        'L',
                        symbolWidth,
                        verticalCenter
                    ])
                    .addClass('highcharts-graph')
                    .attr(attr)
                    .add(legendItemGroup);

                // Draw the marker
                if (markerOptions && markerOptions.enabled !== false) {

                    // Do not allow the marker to be larger than the symbolHeight
                    radius = Math.min(
                        pick(markerOptions.radius, generalRadius),
                        generalRadius
                    );

                    // Restrict symbol markers size
                    if (this.symbol.indexOf('url') === 0) {
                        markerOptions = merge(markerOptions, {
                            width: symbolHeight,
                            height: symbolHeight
                        });
                        radius = 0;
                    }

                    this.legendSymbol = legendSymbol = renderer.symbol(
                            this.symbol,
                            (symbolWidth / 2) - radius,
                            verticalCenter - radius,
                            2 * radius,
                            2 * radius,
                            markerOptions
                        )
                        .addClass('highcharts-point')
                        .add(legendItemGroup);
                    legendSymbol.isMarker = true;
                }
            }
        };

        // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
        // and for #2580, a similar drawing flaw in Firefox 26.
        // Explore if there's a general cause for this. The problem may be related
        // to nested group elements, as the legend item texts are within 4 group
        // elements.
        if (/Trident\/7\.0/.test(win.navigator.userAgent) || isFirefox) {
            wrap(Highcharts.Legend.prototype, 'positionItem', function(proceed, item) {
                var legend = this,
                    // If chart destroyed in sync, this is undefined (#2030)
                    runPositionItem = function() {
                        if (item._legendItemPos) {
                            proceed.call(legend, item);
                        }
                    };

                // Do it now, for export and to get checkbox placement
                runPositionItem();

                // Do it after to work around the core issue
                setTimeout(runPositionItem);
            });
        }

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var addEvent = H.addEvent,
            animate = H.animate,
            animObject = H.animObject,
            attr = H.attr,
            doc = H.doc,
            Axis = H.Axis, // @todo add as requirement
            createElement = H.createElement,
            defaultOptions = H.defaultOptions,
            discardElement = H.discardElement,
            charts = H.charts,
            css = H.css,
            defined = H.defined,
            each = H.each,
            extend = H.extend,
            find = H.find,
            fireEvent = H.fireEvent,
            grep = H.grep,
            isNumber = H.isNumber,
            isObject = H.isObject,
            isString = H.isString,
            Legend = H.Legend, // @todo add as requirement
            marginNames = H.marginNames,
            merge = H.merge,
            objectEach = H.objectEach,
            Pointer = H.Pointer, // @todo add as requirement
            pick = H.pick,
            pInt = H.pInt,
            removeEvent = H.removeEvent,
            seriesTypes = H.seriesTypes,
            splat = H.splat,
            svg = H.svg,
            syncTimeout = H.syncTimeout,
            win = H.win;
        /**
         * The Chart class. The recommended constructor is {@link Highcharts#chart}.
         * @class Highcharts.Chart
         * @param  {String|HTMLDOMElement} renderTo
         *         The DOM element to render to, or its id.
         * @param  {Options} options
         *         The chart options structure.
         * @param  {Function} [callback]
         *         Function to run when the chart has loaded and and all external images
         *         are loaded. Defining a {@link
         *         https://api.highcharts.com/highcharts/chart.events.load|chart.event.load}
         *         handler is equivalent.
         *
         * @example
         * var chart = Highcharts.chart('container', {
         * 	   title: {
         * 	   	   text: 'My chart'
         * 	   },
         * 	   series: [{
         * 	       data: [1, 3, 2, 4]
         * 	   }]
         * })
         */
        var Chart = H.Chart = function() {
            this.getArgs.apply(this, arguments);
        };

        /**
         * Factory function for basic charts. 
         *
         * @function #chart
         * @memberOf Highcharts
         * @param  {String|HTMLDOMElement} renderTo - The DOM element to render to, or
         * its id.
         * @param  {Options} options - The chart options structure.
         * @param  {Function} [callback] - Function to run when the chart has loaded and
         * and all external images are loaded. Defining a {@link
         * https://api.highcharts.com/highcharts/chart.events.load|chart.event.load}
         * handler is equivalent.
         * @return {Highcharts.Chart} - Returns the Chart object.
         *
         * @example
         * // Render a chart in to div#container
         * var chart = Highcharts.chart('container', {
         *     title: {
         *         text: 'My chart'
         *     },
         *     series: [{
         *         data: [1, 3, 2, 4]
         *     }]
         * });
         */
        H.chart = function(a, b, c) {
            return new Chart(a, b, c);
        };

        extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {

            // Hook for adding callbacks in modules
            callbacks: [],

            /**
             * Handle the arguments passed to the constructor.
             *
             * @private
             * @returns {Array} Arguments without renderTo
             */
            getArgs: function() {
                var args = [].slice.call(arguments);

                // Remove the optional first argument, renderTo, and
                // set it on this.
                if (isString(args[0]) || args[0].nodeName) {
                    this.renderTo = args.shift();
                }
                this.init(args[0], args[1]);
            },

            /**
             * Overridable function that initializes the chart. The constructor's
             * arguments are passed on directly.
             */
            init: function(userOptions, callback) {

                // Handle regular options
                var options,
                    type,
                    seriesOptions = userOptions.series, // skip merging data points to increase performance
                    userPlotOptions = userOptions.plotOptions || {};

                userOptions.series = null;
                options = merge(defaultOptions, userOptions); // do the merge

                // Override (by copy of user options) or clear tooltip options
                // in chart.options.plotOptions (#6218)
                for (type in options.plotOptions) {
                    options.plotOptions[type].tooltip = (
                        userPlotOptions[type] &&
                        merge(userPlotOptions[type].tooltip) // override by copy
                    ) || undefined; // or clear
                }
                // User options have higher priority than default options (#6218).
                // In case of exporting: path is changed
                options.tooltip.userOptions = (userOptions.chart &&
                        userOptions.chart.forExport && userOptions.tooltip.userOptions) ||
                    userOptions.tooltip;

                options.series = userOptions.series = seriesOptions; // set back the series data
                this.userOptions = userOptions;

                var optionsChart = options.chart;

                var chartEvents = optionsChart.events;

                this.margin = [];
                this.spacing = [];

                this.bounds = {
                    h: {},
                    v: {}
                }; // Pixel data bounds for touch zoom

                // An array of functions that returns labels that should be considered
                // for anti-collision
                this.labelCollectors = [];

                this.callback = callback;
                this.isResizing = 0;

                /**
                 * The options structure for the chart. It contains members for the sub
                 * elements like series, legend, tooltip etc.
                 *
                 * @memberof Highcharts.Chart
                 * @name options
                 * @type {Options}
                 */
                this.options = options;
                /**
                 * All the axes in the chart.
                 *
                 * @memberof Highcharts.Chart
                 * @name axes
                 * @see  Highcharts.Chart.xAxis
                 * @see  Highcharts.Chart.yAxis
                 * @type {Array.<Highcharts.Axis>}
                 */
                this.axes = [];

                /**
                 * All the current series in the chart.
                 *
                 * @memberof Highcharts.Chart
                 * @name series
                 * @type {Array.<Highcharts.Series>}
                 */
                this.series = [];

                /**
                 * The chart title. The title has an `update` method that allows
                 * modifying the options directly or indirectly via `chart.update`.
                 *
                 * @memberof Highcharts.Chart
                 * @name title
                 * @type Object
                 *
                 * @sample highcharts/members/title-update/
                 *         Updating titles
                 */

                /**
                 * The chart subtitle. The subtitle has an `update` method that allows
                 * modifying the options directly or indirectly via `chart.update`.
                 *
                 * @memberof Highcharts.Chart
                 * @name subtitle
                 * @type Object
                 */



                this.hasCartesianSeries = optionsChart.showAxes;

                var chart = this;

                // Add the chart to the global lookup
                chart.index = charts.length;

                charts.push(chart);
                H.chartCount++;

                // Chart event handlers
                if (chartEvents) {
                    objectEach(chartEvents, function(event, eventType) {
                        addEvent(chart, eventType, event);
                    });
                }

                /**
                 * A collection of the X axes in the chart.
                 * @type {Array.<Highcharts.Axis>}
                 * @name xAxis
                 * @memberOf Highcharts.Chart
                 */
                chart.xAxis = [];
                /**
                 * A collection of the Y axes in the chart.
                 * @type {Array.<Highcharts.Axis>}
                 * @name yAxis
                 * @memberOf Highcharts.Chart
                 */
                chart.yAxis = [];

                chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;

                chart.firstRender();
            },

            /**
             * Internal function to unitialize an individual series.
             *
             * @private
             */
            initSeries: function(options) {
                var chart = this,
                    optionsChart = chart.options.chart,
                    type = options.type || optionsChart.type || optionsChart.defaultSeriesType,
                    series,
                    Constr = seriesTypes[type];

                // No such series type
                if (!Constr) {
                    H.error(17, true);
                }

                series = new Constr();
                series.init(this, options);
                return series;
            },

            /**
             * Order all series above a given index. When series are added and ordered
             * by configuration, only the last series is handled (#248, #1123, #2456,
             * #6112). This function is called on series initialization and destroy.
             *
             * @private
             *
             * @param  {number} fromIndex
             *         If this is given, only the series above this index are handled.
             */
            orderSeries: function(fromIndex) {
                var series = this.series,
                    i = fromIndex || 0;
                for (; i < series.length; i++) {
                    if (series[i]) {
                        series[i].index = i;
                        series[i].name = series[i].name ||
                            'Series ' + (series[i].index + 1);
                    }
                }
            },

            /**
             * Check whether a given point is within the plot area.
             *
             * @param  {Number} plotX
             *         Pixel x relative to the plot area.
             * @param  {Number} plotY
             *         Pixel y relative to the plot area.
             * @param  {Boolean} inverted
             *         Whether the chart is inverted.
             *
             * @return {Boolean}
             *         Returns true if the given point is inside the plot area.
             */
            isInsidePlot: function(plotX, plotY, inverted) {
                var x = inverted ? plotY : plotX,
                    y = inverted ? plotX : plotY;

                return x >= 0 &&
                    x <= this.plotWidth &&
                    y >= 0 &&
                    y <= this.plotHeight;
            },

            /**
             * Redraw the chart after changes have been done to the data, axis extremes
             * chart size or chart elements. All methods for updating axes, series or
             * points have a parameter for redrawing the chart. This is `true` by
             * default. But in many cases you want to do more than one operation on the
             * chart before redrawing, for example add a number of points. In those
             * cases it is a waste of resources to redraw the chart for each new point
             * added. So you add the points and call `chart.redraw()` after.
             *
             * @param  {AnimationOptions} animation
             *         If or how to apply animation to the redraw.
             */
            redraw: function(animation) {
                var chart = this,
                    axes = chart.axes,
                    series = chart.series,
                    pointer = chart.pointer,
                    legend = chart.legend,
                    redrawLegend = chart.isDirtyLegend,
                    hasStackedSeries,
                    hasDirtyStacks,
                    hasCartesianSeries = chart.hasCartesianSeries,
                    isDirtyBox = chart.isDirtyBox,
                    i,
                    serie,
                    renderer = chart.renderer,
                    isHiddenChart = renderer.isHidden(),
                    afterRedraw = [];

                // Handle responsive rules, not only on resize (#6130)
                if (chart.setResponsive) {
                    chart.setResponsive(false);
                }

                H.setAnimation(animation, chart);

                if (isHiddenChart) {
                    chart.temporaryDisplay();
                }

                // Adjust title layout (reflow multiline text)
                chart.layOutTitles();

                // link stacked series
                i = series.length;
                while (i--) {
                    serie = series[i];

                    if (serie.options.stacking) {
                        hasStackedSeries = true;

                        if (serie.isDirty) {
                            hasDirtyStacks = true;
                            break;
                        }
                    }
                }
                if (hasDirtyStacks) { // mark others as dirty
                    i = series.length;
                    while (i--) {
                        serie = series[i];
                        if (serie.options.stacking) {
                            serie.isDirty = true;
                        }
                    }
                }

                // Handle updated data in the series
                each(series, function(serie) {
                    if (serie.isDirty) {
                        if (serie.options.legendType === 'point') {
                            if (serie.updateTotals) {
                                serie.updateTotals();
                            }
                            redrawLegend = true;
                        }
                    }
                    if (serie.isDirtyData) {
                        fireEvent(serie, 'updatedData');
                    }
                });

                // handle added or removed series
                if (redrawLegend && legend.options.enabled) { // series or pie points are added or removed
                    // draw legend graphics
                    legend.render();

                    chart.isDirtyLegend = false;
                }

                // reset stacks
                if (hasStackedSeries) {
                    chart.getStacks();
                }


                if (hasCartesianSeries) {
                    // set axes scales
                    each(axes, function(axis) {
                        axis.updateNames();
                        axis.setScale();
                    });
                }

                chart.getMargins(); // #3098

                if (hasCartesianSeries) {
                    // If one axis is dirty, all axes must be redrawn (#792, #2169)
                    each(axes, function(axis) {
                        if (axis.isDirty) {
                            isDirtyBox = true;
                        }
                    });

                    // redraw axes
                    each(axes, function(axis) {

                        // Fire 'afterSetExtremes' only if extremes are set
                        var key = axis.min + ',' + axis.max;
                        if (axis.extKey !== key) { // #821, #4452
                            axis.extKey = key;
                            afterRedraw.push(function() { // prevent a recursive call to chart.redraw() (#1119)
                                fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
                                delete axis.eventArgs;
                            });
                        }
                        if (isDirtyBox || hasStackedSeries) {
                            axis.redraw();
                        }
                    });
                }

                // the plot areas size has changed
                if (isDirtyBox) {
                    chart.drawChartBox();
                }

                // Fire an event before redrawing series, used by the boost module to
                // clear previous series renderings.
                fireEvent(chart, 'predraw');

                // redraw affected series
                each(series, function(serie) {
                    if ((isDirtyBox || serie.isDirty) && serie.visible) {
                        serie.redraw();
                    }
                    // Set it here, otherwise we will have unlimited 'updatedData' calls
                    // for a hidden series after setData(). Fixes #6012
                    serie.isDirtyData = false;
                });

                // move tooltip or reset
                if (pointer) {
                    pointer.reset(true);
                }

                // redraw if canvas
                renderer.draw();

                // Fire the events
                fireEvent(chart, 'redraw');
                fireEvent(chart, 'render');

                if (isHiddenChart) {
                    chart.temporaryDisplay(true);
                }

                // Fire callbacks that are put on hold until after the redraw
                each(afterRedraw, function(callback) {
                    callback.call();
                });
            },

            /**
             * Get an axis, series or point object by `id` as given in the configuration
             * options. Returns `undefined` if no item is found.
             * @param id {String} The id as given in the configuration options.
             * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
             *         The retrieved item.
             * @sample highcharts/plotoptions/series-id/
             *         Get series by id
             */
            get: function(id) {

                var ret,
                    series = this.series,
                    i;

                function itemById(item) {
                    return item.id === id || (item.options && item.options.id === id);
                }

                ret =
                    // Search axes
                    find(this.axes, itemById) ||

                    // Search series
                    find(this.series, itemById);

                // Search points
                for (i = 0; !ret && i < series.length; i++) {
                    ret = find(series[i].points || [], itemById);
                }

                return ret;
            },

            /**
             * Create the Axis instances based on the config options.
             *
             * @private
             */
            getAxes: function() {
                var chart = this,
                    options = this.options,
                    xAxisOptions = options.xAxis = splat(options.xAxis || {}),
                    yAxisOptions = options.yAxis = splat(options.yAxis || {}),
                    optionsArray;

                // make sure the options are arrays and add some members
                each(xAxisOptions, function(axis, i) {
                    axis.index = i;
                    axis.isX = true;
                });

                each(yAxisOptions, function(axis, i) {
                    axis.index = i;
                });

                // concatenate all axis options into one array
                optionsArray = xAxisOptions.concat(yAxisOptions);

                each(optionsArray, function(axisOptions) {
                    new Axis(chart, axisOptions); // eslint-disable-line no-new
                });
            },


            /**
             * Returns an array of all currently selected points in the chart. Points
             * can be selected by clicking or programmatically by the {@link
             * Highcharts.Point#select} function.
             *
             * @return {Array.<Highcharts.Point>}
             *         The currently selected points.
             *
             * @sample highcharts/plotoptions/series-allowpointselect-line/
             *         Get selected points
             */
            getSelectedPoints: function() {
                var points = [];
                each(this.series, function(serie) {
                    // series.data - for points outside of viewed range (#6445)
                    points = points.concat(grep(serie.data || [], function(point) {
                        return point.selected;
                    }));
                });
                return points;
            },

            /**
             * Returns an array of all currently selected series in the chart. Series
             * can be selected either programmatically by the {@link
             * Highcharts.Series#select} function or by checking the checkbox next to
             * the legend item if {@link
             * https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox|
             * series.showCheckBox} is true.
             * 
             * @return {Array.<Highcharts.Series>}
             *         The currently selected series.
             *
             * @sample highcharts/members/chart-getselectedseries/
             *         Get selected series
             */
            getSelectedSeries: function() {
                return grep(this.series, function(serie) {
                    return serie.selected;
                });
            },

            /**
             * Set a new title or subtitle for the chart.
             *
             * @param  titleOptions {TitleOptions}
             *         New title options. The title text itself is set by the
             *         `titleOptions.text` property.
             * @param  subtitleOptions {SubtitleOptions}
             *         New subtitle options. The subtitle text itself is set by the
             *         `subtitleOptions.text` property.
             * @param  redraw {Boolean}
             *         Whether to redraw the chart or wait for a later call to 
             *         `chart.redraw()`.
             *
             * @sample highcharts/members/chart-settitle/ Set title text and styles
             *
             */
            setTitle: function(titleOptions, subtitleOptions, redraw) {
                var chart = this,
                    options = chart.options,
                    chartTitleOptions,
                    chartSubtitleOptions;

                chartTitleOptions = options.title = merge(

                    // Default styles
                    {
                        style: {
                            color: '#333333',
                            fontSize: options.isStock ? '16px' : '18px' // #2944
                        }
                    },

                    options.title,
                    titleOptions
                );
                chartSubtitleOptions = options.subtitle = merge(

                    // Default styles
                    {
                        style: {
                            color: '#666666'
                        }
                    },

                    options.subtitle,
                    subtitleOptions
                );

                // add title and subtitle
                each([
                    ['title', titleOptions, chartTitleOptions],
                    ['subtitle', subtitleOptions, chartSubtitleOptions]
                ], function(arr, i) {
                    var name = arr[0],
                        title = chart[name],
                        titleOptions = arr[1],
                        chartTitleOptions = arr[2];

                    if (title && titleOptions) {
                        chart[name] = title = title.destroy(); // remove old
                    }

                    if (chartTitleOptions && chartTitleOptions.text && !title) {
                        chart[name] = chart.renderer.text(
                                chartTitleOptions.text,
                                0,
                                0,
                                chartTitleOptions.useHTML
                            )
                            .attr({
                                align: chartTitleOptions.align,
                                'class': 'highcharts-' + name,
                                zIndex: chartTitleOptions.zIndex || 4
                            })
                            .add();

                        // Update methods, shortcut to Chart.setTitle
                        chart[name].update = function(o) {
                            chart.setTitle(!i && o, i && o);
                        };


                        // Presentational
                        chart[name].css(chartTitleOptions.style);


                    }
                });
                chart.layOutTitles(redraw);
            },

            /**
             * Internal function to lay out the chart titles and cache the full offset
             * height for use in `getMargins`. The result is stored in 
             * `this.titleOffset`.
             *
             * @private
             */
            layOutTitles: function(redraw) {
                var titleOffset = 0,
                    requiresDirtyBox,
                    renderer = this.renderer,
                    spacingBox = this.spacingBox;

                // Lay out the title and the subtitle respectively
                each(['title', 'subtitle'], function(key) {
                    var title = this[key],
                        titleOptions = this.options[key],
                        offset = key === 'title' ? -3 :
                        // Floating subtitle (#6574)
                        titleOptions.verticalAlign ? 0 : titleOffset + 2,
                        titleSize;

                    if (title) {

                        titleSize = titleOptions.style.fontSize;

                        titleSize = renderer.fontMetrics(titleSize, title).b;

                        title
                            .css({
                                width: (titleOptions.width ||
                                    spacingBox.width + titleOptions.widthAdjust) + 'px'
                            })
                            .align(extend({
                                y: offset + titleSize
                            }, titleOptions), false, 'spacingBox');

                        if (!titleOptions.floating && !titleOptions.verticalAlign) {
                            titleOffset = Math.ceil(
                                titleOffset +
                                // Skip the cache for HTML (#3481)
                                title.getBBox(titleOptions.useHTML).height
                            );
                        }
                    }
                }, this);

                requiresDirtyBox = this.titleOffset !== titleOffset;
                this.titleOffset = titleOffset; // used in getMargins

                if (!this.isDirtyBox && requiresDirtyBox) {
                    this.isDirtyBox = requiresDirtyBox;
                    // Redraw if necessary (#2719, #2744)
                    if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
                        this.redraw();
                    }
                }
            },

            /**
             * Internal function to get the chart width and height according to options
             * and container size. Sets {@link Chart.chartWidth} and {@link
             * Chart.chartHeight}.
             */
            getChartSize: function() {
                var chart = this,
                    optionsChart = chart.options.chart,
                    widthOption = optionsChart.width,
                    heightOption = optionsChart.height,
                    renderTo = chart.renderTo;

                // Get inner width and height
                if (!defined(widthOption)) {
                    chart.containerWidth = H.getStyle(renderTo, 'width');
                }
                if (!defined(heightOption)) {
                    chart.containerHeight = H.getStyle(renderTo, 'height');
                }

                /**
                 * The current pixel width of the chart.
                 *
                 * @name chartWidth
                 * @memberOf Chart
                 * @type {Number}
                 */
                chart.chartWidth = Math.max( // #1393
                    0,
                    widthOption || chart.containerWidth || 600 // #1460
                );
                /**
                 * The current pixel height of the chart.
                 *
                 * @name chartHeight
                 * @memberOf Chart
                 * @type {Number}
                 */
                chart.chartHeight = Math.max(
                    0,
                    H.relativeLength(
                        heightOption,
                        chart.chartWidth
                    ) ||
                    (chart.containerHeight > 1 ? chart.containerHeight : 400)
                );
            },

            /**
             * If the renderTo element has no offsetWidth, most likely one or more of
             * its parents are hidden. Loop up the DOM tree to temporarily display the
             * parents, then save the original display properties, and when the true
             * size is retrieved, reset them. Used on first render and on redraws.
             *
             * @private
             * 
             * @param  {Boolean} revert
             *         Revert to the saved original styles.
             */
            temporaryDisplay: function(revert) {
                var node = this.renderTo,
                    tempStyle;
                if (!revert) {
                    while (node && node.style) {

                        // When rendering to a detached node, it needs to be temporarily
                        // attached in order to read styling and bounding boxes (#5783,
                        // #7024).
                        if (!doc.body.contains(node) && !node.parentNode) {
                            node.hcOrigDetached = true;
                            doc.body.appendChild(node);
                        }
                        if (
                            H.getStyle(node, 'display', false) === 'none' ||
                            node.hcOricDetached
                        ) {
                            node.hcOrigStyle = {
                                display: node.style.display,
                                height: node.style.height,
                                overflow: node.style.overflow
                            };
                            tempStyle = {
                                display: 'block',
                                overflow: 'hidden'
                            };
                            if (node !== this.renderTo) {
                                tempStyle.height = 0;
                            }

                            H.css(node, tempStyle);

                            // If it still doesn't have an offset width after setting
                            // display to block, it probably has an !important priority
                            // #2631, 6803
                            if (!node.offsetWidth) {
                                node.style.setProperty('display', 'block', 'important');
                            }
                        }
                        node = node.parentNode;

                        if (node === doc.body) {
                            break;
                        }
                    }
                } else {
                    while (node && node.style) {
                        if (node.hcOrigStyle) {
                            H.css(node, node.hcOrigStyle);
                            delete node.hcOrigStyle;
                        }
                        if (node.hcOrigDetached) {
                            doc.body.removeChild(node);
                            node.hcOrigDetached = false;
                        }
                        node = node.parentNode;
                    }
                }
            },

            /**
             * Set the {@link Chart.container|chart container's} class name, in
             * addition to `highcharts-container`. 
             */
            setClassName: function(className) {
                this.container.className = 'highcharts-container ' + (className || '');
            },

            /**
             * Get the containing element, determine the size and create the inner
             * container div to hold the chart.
             *
             * @private
             */
            getContainer: function() {
                var chart = this,
                    container,
                    options = chart.options,
                    optionsChart = options.chart,
                    chartWidth,
                    chartHeight,
                    renderTo = chart.renderTo,
                    indexAttrName = 'data-highcharts-chart',
                    oldChartIndex,
                    Ren,
                    containerId = H.uniqueKey(),
                    containerStyle,
                    key;

                if (!renderTo) {
                    chart.renderTo = renderTo = optionsChart.renderTo;
                }

                if (isString(renderTo)) {
                    chart.renderTo = renderTo = doc.getElementById(renderTo);
                }

                // Display an error if the renderTo is wrong
                if (!renderTo) {
                    H.error(13, true);
                }

                // If the container already holds a chart, destroy it. The check for
                // hasRendered is there because web pages that are saved to disk from
                // the browser, will preserve the data-highcharts-chart attribute and
                // the SVG contents, but not an interactive chart. So in this case,
                // charts[oldChartIndex] will point to the wrong chart if any (#2609).
                oldChartIndex = pInt(attr(renderTo, indexAttrName));
                if (
                    isNumber(oldChartIndex) &&
                    charts[oldChartIndex] &&
                    charts[oldChartIndex].hasRendered
                ) {
                    charts[oldChartIndex].destroy();
                }

                // Make a reference to the chart from the div
                attr(renderTo, indexAttrName, chart.index);

                // remove previous chart
                renderTo.innerHTML = '';

                // If the container doesn't have an offsetWidth, it has or is a child of
                // a node that has display:none. We need to temporarily move it out to a
                // visible state to determine the size, else the legend and tooltips
                // won't render properly. The skipClone option is used in sparklines as
                // a micro optimization, saving about 1-2 ms each chart.
                if (!optionsChart.skipClone && !renderTo.offsetWidth) {
                    chart.temporaryDisplay();
                }

                // get the width and height
                chart.getChartSize();
                chartWidth = chart.chartWidth;
                chartHeight = chart.chartHeight;

                // Create the inner container

                containerStyle = extend({
                    position: 'relative',
                    overflow: 'hidden', // needed for context menu (avoid scrollbars)
                    // and content overflow in IE
                    width: chartWidth + 'px',
                    height: chartHeight + 'px',
                    textAlign: 'left',
                    lineHeight: 'normal', // #427
                    zIndex: 0, // #1072
                    '-webkit-tap-highlight-color': 'rgba(0,0,0,0)'
                }, optionsChart.style);


                /**
                 * The containing HTML element of the chart. The container is
                 * dynamically inserted into the element given as the `renderTo`
                 * parameterin the {@link Highcharts#chart} constructor.
                 *
                 * @memberOf Highcharts.Chart
                 * @type {HTMLDOMElement}
                 */
                container = createElement(
                    'div', {
                        id: containerId
                    },
                    containerStyle,
                    renderTo
                );
                chart.container = container;

                // cache the cursor (#1650)
                chart._cursor = container.style.cursor;

                // Initialize the renderer
                Ren = H[optionsChart.renderer] || H.Renderer;

                /**
                 * The renderer instance of the chart. Each chart instance has only one
                 * associated renderer.
                 * @type {SVGRenderer}
                 * @name renderer
                 * @memberOf Chart
                 */
                chart.renderer = new Ren(
                    container,
                    chartWidth,
                    chartHeight,
                    null,
                    optionsChart.forExport,
                    options.exporting && options.exporting.allowHTML
                );


                chart.setClassName(optionsChart.className);

                chart.renderer.setStyle(optionsChart.style);


                // Add a reference to the charts index
                chart.renderer.chartIndex = chart.index;
            },

            /**
             * Calculate margins by rendering axis labels in a preliminary position.
             * Title, subtitle and legend have already been rendered at this stage, but
             * will be moved into their final positions.
             *
             * @private
             */
            getMargins: function(skipAxes) {
                var chart = this,
                    spacing = chart.spacing,
                    margin = chart.margin,
                    titleOffset = chart.titleOffset;

                chart.resetMargins();

                // Adjust for title and subtitle
                if (titleOffset && !defined(margin[0])) {
                    chart.plotTop = Math.max(
                        chart.plotTop,
                        titleOffset + chart.options.title.margin + spacing[0]
                    );
                }

                // Adjust for legend
                if (chart.legend && chart.legend.display) {
                    chart.legend.adjustMargins(margin, spacing);
                }

                // adjust for scroller
                if (chart.extraMargin) {
                    chart[chart.extraMargin.type] =
                        (chart[chart.extraMargin.type] || 0) + chart.extraMargin.value;
                }

                // adjust for rangeSelector 
                if (chart.adjustPlotArea) {
                    chart.adjustPlotArea();
                }

                if (!skipAxes) {
                    this.getAxisMargins();
                }
            },

            getAxisMargins: function() {

                var chart = this,
                    // [top, right, bottom, left]
                    axisOffset = chart.axisOffset = [0, 0, 0, 0],
                    margin = chart.margin;

                // pre-render axes to get labels offset width
                if (chart.hasCartesianSeries) {
                    each(chart.axes, function(axis) {
                        if (axis.visible) {
                            axis.getOffset();
                        }
                    });
                }

                // Add the axis offsets
                each(marginNames, function(m, side) {
                    if (!defined(margin[side])) {
                        chart[m] += axisOffset[side];
                    }
                });

                chart.setChartSize();

            },

            /**
             * Reflows the chart to its container. By default, the chart reflows
             * automatically to its container following a `window.resize` event, as per
             * the {@link https://api.highcharts/highcharts/chart.reflow|chart.reflow}
             * option. However, there are no reliable events for div resize, so if the
             * container is resized without a window resize event, this must be called
             * explicitly.
             *
             * @param  {Object} e
             *         Event arguments. Used primarily when the function is called
             *         internally as a response to window resize.
             *
             * @sample highcharts/members/chart-reflow/
             *         Resize div and reflow
             * @sample highcharts/chart/events-container/
             *         Pop up and reflow
             */
            reflow: function(e) {
                var chart = this,
                    optionsChart = chart.options.chart,
                    renderTo = chart.renderTo,
                    hasUserSize = (
                        defined(optionsChart.width) &&
                        defined(optionsChart.height)
                    ),
                    width = optionsChart.width || H.getStyle(renderTo, 'width'),
                    height = optionsChart.height || H.getStyle(renderTo, 'height'),
                    target = e ? e.target : win;

                // Width and height checks for display:none. Target is doc in IE8 and
                // Opera, win in Firefox, Chrome and IE9.
                if (!hasUserSize &&
                    !chart.isPrinting &&
                    width &&
                    height &&
                    (target === win || target === doc)
                ) {
                    if (
                        width !== chart.containerWidth ||
                        height !== chart.containerHeight
                    ) {
                        clearTimeout(chart.reflowTimeout);
                        // When called from window.resize, e is set, else it's called
                        // directly (#2224)
                        chart.reflowTimeout = syncTimeout(function() {
                            // Set size, it may have been destroyed in the meantime
                            // (#1257)
                            if (chart.container) {
                                chart.setSize(undefined, undefined, false);
                            }
                        }, e ? 100 : 0);
                    }
                    chart.containerWidth = width;
                    chart.containerHeight = height;
                }
            },

            /**
             * Add the event handlers necessary for auto resizing, depending on the 
             * `chart.events.reflow` option.
             *
             * @private
             */
            initReflow: function() {
                var chart = this,
                    unbind;

                unbind = addEvent(win, 'resize', function(e) {
                    chart.reflow(e);
                });
                addEvent(chart, 'destroy', unbind);

                // The following will add listeners to re-fit the chart before and after
                // printing (#2284). However it only works in WebKit. Should have worked
                // in Firefox, but not supported in IE.
                /*
                if (win.matchMedia) {
                	win.matchMedia('print').addListener(function reflow() {
                		chart.reflow();
                	});
                }
                */
            },

            /**
             * Resize the chart to a given width and height. In order to set the width
             * only, the height argument may be skipped. To set the height only, pass
             * `undefined for the width.
             * @param  {Number|undefined|null} [width]
             *         The new pixel width of the chart. Since v4.2.6, the argument can
             *         be `undefined` in order to preserve the current value (when
             *         setting height only), or `null` to adapt to the width of the
             *         containing element.
             * @param  {Number|undefined|null} [height]
             *         The new pixel height of the chart. Since v4.2.6, the argument can
             *         be `undefined` in order to preserve the current value, or `null`
             *         in order to adapt to the height of the containing element.
             * @param  {AnimationOptions} [animation=true]
             *         Whether and how to apply animation.
             *
             * @sample highcharts/members/chart-setsize-button/
             *         Test resizing from buttons
             * @sample highcharts/members/chart-setsize-jquery-resizable/
             *         Add a jQuery UI resizable
             * @sample stock/members/chart-setsize/
             *         Highstock with UI resizable
             */
            setSize: function(width, height, animation) {
                var chart = this,
                    renderer = chart.renderer,
                    globalAnimation;

                // Handle the isResizing counter
                chart.isResizing += 1;

                // set the animation for the current process
                H.setAnimation(animation, chart);

                chart.oldChartHeight = chart.chartHeight;
                chart.oldChartWidth = chart.chartWidth;
                if (width !== undefined) {
                    chart.options.chart.width = width;
                }
                if (height !== undefined) {
                    chart.options.chart.height = height;
                }
                chart.getChartSize();

                // Resize the container with the global animation applied if enabled
                // (#2503)

                globalAnimation = renderer.globalAnimation;
                (globalAnimation ? animate : css)(chart.container, {
                    width: chart.chartWidth + 'px',
                    height: chart.chartHeight + 'px'
                }, globalAnimation);


                chart.setChartSize(true);
                renderer.setSize(chart.chartWidth, chart.chartHeight, animation);

                // handle axes
                each(chart.axes, function(axis) {
                    axis.isDirty = true;
                    axis.setScale();
                });

                chart.isDirtyLegend = true; // force legend redraw
                chart.isDirtyBox = true; // force redraw of plot and chart border

                chart.layOutTitles(); // #2857
                chart.getMargins();

                chart.redraw(animation);


                chart.oldChartHeight = null;
                fireEvent(chart, 'resize');

                // Fire endResize and set isResizing back. If animation is disabled,
                // fire without delay
                syncTimeout(function() {
                    if (chart) {
                        fireEvent(chart, 'endResize', null, function() {
                            chart.isResizing -= 1;
                        });
                    }
                }, animObject(globalAnimation).duration);
            },

            /**
             * Set the public chart properties. This is done before and after the
             * pre-render to determine margin sizes.
             *
             * @private
             */
            setChartSize: function(skipAxes) {
                var chart = this,
                    inverted = chart.inverted,
                    renderer = chart.renderer,
                    chartWidth = chart.chartWidth,
                    chartHeight = chart.chartHeight,
                    optionsChart = chart.options.chart,
                    spacing = chart.spacing,
                    clipOffset = chart.clipOffset,
                    clipX,
                    clipY,
                    plotLeft,
                    plotTop,
                    plotWidth,
                    plotHeight,
                    plotBorderWidth;

                /**
                 * The current left position of the plot area in pixels.
                 *
                 * @name plotLeft
                 * @memberOf Chart
                 * @type {Number}
                 */
                chart.plotLeft = plotLeft = Math.round(chart.plotLeft);

                /**
                 * The current top position of the plot area in pixels.
                 *
                 * @name plotTop
                 * @memberOf Chart
                 * @type {Number}
                 */
                chart.plotTop = plotTop = Math.round(chart.plotTop);

                /**
                 * The current width of the plot area in pixels.
                 *
                 * @name plotWidth
                 * @memberOf Chart
                 * @type {Number}
                 */
                chart.plotWidth = plotWidth = Math.max(
                    0,
                    Math.round(chartWidth - plotLeft - chart.marginRight)
                );

                /**
                 * The current height of the plot area in pixels.
                 *
                 * @name plotHeight
                 * @memberOf Chart
                 * @type {Number}
                 */
                chart.plotHeight = plotHeight = Math.max(
                    0,
                    Math.round(chartHeight - plotTop - chart.marginBottom)
                );

                chart.plotSizeX = inverted ? plotHeight : plotWidth;
                chart.plotSizeY = inverted ? plotWidth : plotHeight;

                chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;

                // Set boxes used for alignment
                chart.spacingBox = renderer.spacingBox = {
                    x: spacing[3],
                    y: spacing[0],
                    width: chartWidth - spacing[3] - spacing[1],
                    height: chartHeight - spacing[0] - spacing[2]
                };
                chart.plotBox = renderer.plotBox = {
                    x: plotLeft,
                    y: plotTop,
                    width: plotWidth,
                    height: plotHeight
                };

                plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
                clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
                clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
                chart.clipBox = {
                    x: clipX,
                    y: clipY,
                    width: Math.floor(
                        chart.plotSizeX -
                        Math.max(plotBorderWidth, clipOffset[1]) / 2 -
                        clipX
                    ),
                    height: Math.max(
                        0,
                        Math.floor(
                            chart.plotSizeY -
                            Math.max(plotBorderWidth, clipOffset[2]) / 2 -
                            clipY
                        )
                    )
                };

                if (!skipAxes) {
                    each(chart.axes, function(axis) {
                        axis.setAxisSize();
                        axis.setAxisTranslation();
                    });
                }
            },

            /**
             * Initial margins before auto size margins are applied.
             *
             * @private
             */
            resetMargins: function() {
                var chart = this,
                    chartOptions = chart.options.chart;

                // Create margin and spacing array
                each(['margin', 'spacing'], function splashArrays(target) {
                    var value = chartOptions[target],
                        values = isObject(value) ? value : [value, value, value, value];

                    each(['Top', 'Right', 'Bottom', 'Left'], function(sideName, side) {
                        chart[target][side] = pick(
                            chartOptions[target + sideName],
                            values[side]
                        );
                    });
                });

                // Set margin names like chart.plotTop, chart.plotLeft,
                // chart.marginRight, chart.marginBottom.
                each(marginNames, function(m, side) {
                    chart[m] = pick(chart.margin[side], chart.spacing[side]);
                });
                chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
                chart.clipOffset = [0, 0, 0, 0];
            },

            /**
             * Internal function to draw or redraw the borders and backgrounds for chart
             * and plot area.
             *
             * @private
             */
            drawChartBox: function() {
                var chart = this,
                    optionsChart = chart.options.chart,
                    renderer = chart.renderer,
                    chartWidth = chart.chartWidth,
                    chartHeight = chart.chartHeight,
                    chartBackground = chart.chartBackground,
                    plotBackground = chart.plotBackground,
                    plotBorder = chart.plotBorder,
                    chartBorderWidth,

                    plotBGImage = chart.plotBGImage,
                    chartBackgroundColor = optionsChart.backgroundColor,
                    plotBackgroundColor = optionsChart.plotBackgroundColor,
                    plotBackgroundImage = optionsChart.plotBackgroundImage,

                    mgn,
                    bgAttr,
                    plotLeft = chart.plotLeft,
                    plotTop = chart.plotTop,
                    plotWidth = chart.plotWidth,
                    plotHeight = chart.plotHeight,
                    plotBox = chart.plotBox,
                    clipRect = chart.clipRect,
                    clipBox = chart.clipBox,
                    verb = 'animate';

                // Chart area
                if (!chartBackground) {
                    chart.chartBackground = chartBackground = renderer.rect()
                        .addClass('highcharts-background')
                        .add();
                    verb = 'attr';
                }


                // Presentational
                chartBorderWidth = optionsChart.borderWidth || 0;
                mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);

                bgAttr = {
                    fill: chartBackgroundColor || 'none'
                };

                if (chartBorderWidth || chartBackground['stroke-width']) { // #980
                    bgAttr.stroke = optionsChart.borderColor;
                    bgAttr['stroke-width'] = chartBorderWidth;
                }
                chartBackground
                    .attr(bgAttr)
                    .shadow(optionsChart.shadow);

                chartBackground[verb]({
                    x: mgn / 2,
                    y: mgn / 2,
                    width: chartWidth - mgn - chartBorderWidth % 2,
                    height: chartHeight - mgn - chartBorderWidth % 2,
                    r: optionsChart.borderRadius
                });

                // Plot background
                verb = 'animate';
                if (!plotBackground) {
                    verb = 'attr';
                    chart.plotBackground = plotBackground = renderer.rect()
                        .addClass('highcharts-plot-background')
                        .add();
                }
                plotBackground[verb](plotBox);


                // Presentational attributes for the background
                plotBackground
                    .attr({
                        fill: plotBackgroundColor || 'none'
                    })
                    .shadow(optionsChart.plotShadow);

                // Create the background image
                if (plotBackgroundImage) {
                    if (!plotBGImage) {
                        chart.plotBGImage = renderer.image(
                            plotBackgroundImage,
                            plotLeft,
                            plotTop,
                            plotWidth,
                            plotHeight
                        ).add();
                    } else {
                        plotBGImage.animate(plotBox);
                    }
                }


                // Plot clip
                if (!clipRect) {
                    chart.clipRect = renderer.clipRect(clipBox);
                } else {
                    clipRect.animate({
                        width: clipBox.width,
                        height: clipBox.height
                    });
                }

                // Plot area border
                verb = 'animate';
                if (!plotBorder) {
                    verb = 'attr';
                    chart.plotBorder = plotBorder = renderer.rect()
                        .addClass('highcharts-plot-border')
                        .attr({
                            zIndex: 1 // Above the grid
                        })
                        .add();
                }


                // Presentational
                plotBorder.attr({
                    stroke: optionsChart.plotBorderColor,
                    'stroke-width': optionsChart.plotBorderWidth || 0,
                    fill: 'none'
                });


                plotBorder[verb](plotBorder.crisp({
                    x: plotLeft,
                    y: plotTop,
                    width: plotWidth,
                    height: plotHeight
                }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;

                // reset
                chart.isDirtyBox = false;
            },

            /**
             * Detect whether a certain chart property is needed based on inspecting its
             * options and series. This mainly applies to the chart.inverted property,
             * and in extensions to the chart.angular and chart.polar properties.
             *
             * @private
             */
            propFromSeries: function() {
                var chart = this,
                    optionsChart = chart.options.chart,
                    klass,
                    seriesOptions = chart.options.series,
                    i,
                    value;


                each(['inverted', 'angular', 'polar'], function(key) {

                    // The default series type's class
                    klass = seriesTypes[optionsChart.type ||
                        optionsChart.defaultSeriesType];

                    // Get the value from available chart-wide properties
                    value =
                        optionsChart[key] || // It is set in the options
                        (klass && klass.prototype[key]); // The default series class
                    // requires it

                    // 4. Check if any the chart's series require it
                    i = seriesOptions && seriesOptions.length;
                    while (!value && i--) {
                        klass = seriesTypes[seriesOptions[i].type];
                        if (klass && klass.prototype[key]) {
                            value = true;
                        }
                    }

                    // Set the chart property
                    chart[key] = value;
                });

            },

            /**
             * Internal function to link two or more series together, based on the 
             * `linkedTo` option. This is done from `Chart.render`, and after
             * `Chart.addSeries` and `Series.remove`.
             *
             * @private
             */
            linkSeries: function() {
                var chart = this,
                    chartSeries = chart.series;

                // Reset links
                each(chartSeries, function(series) {
                    series.linkedSeries.length = 0;
                });

                // Apply new links
                each(chartSeries, function(series) {
                    var linkedTo = series.options.linkedTo;
                    if (isString(linkedTo)) {
                        if (linkedTo === ':previous') {
                            linkedTo = chart.series[series.index - 1];
                        } else {
                            linkedTo = chart.get(linkedTo);
                        }
                        // #3341 avoid mutual linking
                        if (linkedTo && linkedTo.linkedParent !== series) {
                            linkedTo.linkedSeries.push(series);
                            series.linkedParent = linkedTo;
                            series.visible = pick(
                                series.options.visible,
                                linkedTo.options.visible,
                                series.visible
                            ); // #3879
                        }
                    }
                });
            },

            /**
             * Render series for the chart.
             *
             * @private
             */
            renderSeries: function() {
                each(this.series, function(serie) {
                    serie.translate();
                    serie.render();
                });
            },

            /**
             * Render labels for the chart.
             *
             * @private
             */
            renderLabels: function() {
                var chart = this,
                    labels = chart.options.labels;
                if (labels.items) {
                    each(labels.items, function(label) {
                        var style = extend(labels.style, label.style),
                            x = pInt(style.left) + chart.plotLeft,
                            y = pInt(style.top) + chart.plotTop + 12;

                        // delete to prevent rewriting in IE
                        delete style.left;
                        delete style.top;

                        chart.renderer.text(
                                label.html,
                                x,
                                y
                            )
                            .attr({
                                zIndex: 2
                            })
                            .css(style)
                            .add();

                    });
                }
            },

            /**
             * Render all graphics for the chart. Runs internally on initialization.
             *
             * @private
             */
            render: function() {
                var chart = this,
                    axes = chart.axes,
                    renderer = chart.renderer,
                    options = chart.options,
                    tempWidth,
                    tempHeight,
                    redoHorizontal,
                    redoVertical;

                // Title
                chart.setTitle();


                // Legend
                chart.legend = new Legend(chart, options.legend);

                // Get stacks
                if (chart.getStacks) {
                    chart.getStacks();
                }

                // Get chart margins
                chart.getMargins(true);
                chart.setChartSize();

                // Record preliminary dimensions for later comparison
                tempWidth = chart.plotWidth;
                tempHeight = chart.plotHeight = chart.plotHeight - 21; // 21 is the most common correction for X axis labels

                // Get margins by pre-rendering axes
                each(axes, function(axis) {
                    axis.setScale();
                });
                chart.getAxisMargins();

                // If the plot area size has changed significantly, calculate tick positions again
                redoHorizontal = tempWidth / chart.plotWidth > 1.1;
                redoVertical = tempHeight / chart.plotHeight > 1.05; // Height is more sensitive

                if (redoHorizontal || redoVertical) {

                    each(axes, function(axis) {
                        if ((axis.horiz && redoHorizontal) || (!axis.horiz && redoVertical)) {
                            axis.setTickInterval(true); // update to reflect the new margins
                        }
                    });
                    chart.getMargins(); // second pass to check for new labels
                }

                // Draw the borders and backgrounds
                chart.drawChartBox();


                // Axes
                if (chart.hasCartesianSeries) {
                    each(axes, function(axis) {
                        if (axis.visible) {
                            axis.render();
                        }
                    });
                }

                // The series
                if (!chart.seriesGroup) {
                    chart.seriesGroup = renderer.g('series-group')
                        .attr({
                            zIndex: 3
                        })
                        .add();
                }
                chart.renderSeries();

                // Labels
                chart.renderLabels();

                // Credits
                chart.addCredits();

                // Handle responsiveness
                if (chart.setResponsive) {
                    chart.setResponsive();
                }

                // Set flag
                chart.hasRendered = true;

            },

            /**
             * Set a new credits label for the chart.
             *
             * @param  {CreditOptions} options
             *         A configuration object for the new credits.
             * @sample highcharts/credits/credits-update/ Add and update credits
             */
            addCredits: function(credits) {
                var chart = this;

                credits = merge(true, this.options.credits, credits);
                if (credits.enabled && !this.credits) {

                    /**
                     * The chart's credits label. The label has an `update` method that
                     * allows setting new options as per the {@link
                     * https://api.highcharts.com/highcharts/credits|
                     * credits options set}.
                     *
                     * @memberof Highcharts.Chart
                     * @name credits
                     * @type {Highcharts.SVGElement}
                     */
                    this.credits = this.renderer.text(
                            credits.text + (this.mapCredits || ''),
                            0,
                            0
                        )
                        .addClass('highcharts-credits')
                        .on('click', function() {
                            if (credits.href) {
                                win.location.href = credits.href;
                            }
                        })
                        .attr({
                            align: credits.position.align,
                            zIndex: 8
                        })

                        .css(credits.style)

                        .add()
                        .align(credits.position);

                    // Dynamically update
                    this.credits.update = function(options) {
                        chart.credits = chart.credits.destroy();
                        chart.addCredits(options);
                    };
                }
            },

            /**
             * Remove the chart and purge memory. This method is called internally
             * before adding a second chart into the same container, as well as on
             * window unload to prevent leaks.
             *
             * @sample highcharts/members/chart-destroy/
             *         Destroy the chart from a button
             * @sample stock/members/chart-destroy/
             *         Destroy with Highstock
             */
            destroy: function() {
                var chart = this,
                    axes = chart.axes,
                    series = chart.series,
                    container = chart.container,
                    i,
                    parentNode = container && container.parentNode;

                // fire the chart.destoy event
                fireEvent(chart, 'destroy');

                // Delete the chart from charts lookup array
                if (chart.renderer.forExport) {
                    H.erase(charts, chart); // #6569
                } else {
                    charts[chart.index] = undefined;
                }
                H.chartCount--;
                chart.renderTo.removeAttribute('data-highcharts-chart');

                // remove events
                removeEvent(chart);

                // ==== Destroy collections:
                // Destroy axes
                i = axes.length;
                while (i--) {
                    axes[i] = axes[i].destroy();
                }

                // Destroy scroller & scroller series before destroying base series
                if (this.scroller && this.scroller.destroy) {
                    this.scroller.destroy();
                }

                // Destroy each series
                i = series.length;
                while (i--) {
                    series[i] = series[i].destroy();
                }

                // ==== Destroy chart properties:
                each([
                    'title', 'subtitle', 'chartBackground', 'plotBackground',
                    'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
                    'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
                    'renderer'
                ], function(name) {
                    var prop = chart[name];

                    if (prop && prop.destroy) {
                        chart[name] = prop.destroy();
                    }
                });

                // remove container and all SVG
                if (container) { // can break in IE when destroyed before finished loading
                    container.innerHTML = '';
                    removeEvent(container);
                    if (parentNode) {
                        discardElement(container);
                    }

                }

                // clean it all up
                objectEach(chart, function(val, key) {
                    delete chart[key];
                });

            },


            /**
             * VML namespaces can't be added until after complete. Listening
             * for Perini's doScroll hack is not enough.
             *
             * @private
             */
            isReadyToRender: function() {
                var chart = this;

                // Note: win == win.top is required
                if ((!svg && (win == win.top && doc.readyState !== 'complete'))) { // eslint-disable-line eqeqeq
                    doc.attachEvent('onreadystatechange', function() {
                        doc.detachEvent('onreadystatechange', chart.firstRender);
                        if (doc.readyState === 'complete') {
                            chart.firstRender();
                        }
                    });
                    return false;
                }
                return true;
            },

            /**
             * Prepare for first rendering after all data are loaded.
             *
             * @private
             */
            firstRender: function() {
                var chart = this,
                    options = chart.options;

                // Check whether the chart is ready to render
                if (!chart.isReadyToRender()) {
                    return;
                }

                // Create the container
                chart.getContainer();

                // Run an early event after the container and renderer are established
                fireEvent(chart, 'init');


                chart.resetMargins();
                chart.setChartSize();

                // Set the common chart properties (mainly invert) from the given series
                chart.propFromSeries();

                // get axes
                chart.getAxes();

                // Initialize the series
                each(options.series || [], function(serieOptions) {
                    chart.initSeries(serieOptions);
                });

                chart.linkSeries();

                // Run an event after axes and series are initialized, but before render. At this stage,
                // the series data is indexed and cached in the xData and yData arrays, so we can access
                // those before rendering. Used in Highstock.
                fireEvent(chart, 'beforeRender');

                // depends on inverted and on margins being set
                if (Pointer) {

                    /**
                     * The Pointer that keeps track of mouse and touch interaction.
                     *
                     * @memberof Chart
                     * @name pointer
                     * @type Pointer
                     */
                    chart.pointer = new Pointer(chart, options);
                }

                chart.render();

                // Fire the load event if there are no external images
                if (!chart.renderer.imgCount && chart.onload) {
                    chart.onload();
                }

                // If the chart was rendered outside the top container, put it back in (#3679)
                chart.temporaryDisplay(true);

            },

            /** 
             * Internal function that runs on chart load, async if any images are loaded
             * in the chart. Runs the callbacks and triggers the `load` and `render`
             * events.
             *
             * @private
             */
            onload: function() {

                // Run callbacks
                each([this.callback].concat(this.callbacks), function(fn) {
                    if (fn && this.index !== undefined) { // Chart destroyed in its own callback (#3600)
                        fn.apply(this, [this]);
                    }
                }, this);

                fireEvent(this, 'load');
                fireEvent(this, 'render');


                // Set up auto resize, check for not destroyed (#6068)
                if (defined(this.index) && this.options.chart.reflow !== false) {
                    this.initReflow();
                }

                // Don't run again
                this.onload = null;
            }

        }); // end Chart

    }(Highcharts));
    (function(Highcharts) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var Point,
            H = Highcharts,

            each = H.each,
            extend = H.extend,
            erase = H.erase,
            fireEvent = H.fireEvent,
            format = H.format,
            isArray = H.isArray,
            isNumber = H.isNumber,
            pick = H.pick,
            removeEvent = H.removeEvent;

        /**
         * The Point object. The point objects are generated from the `series.data` 
         * configuration objects or raw numbers. They can be accessed from the
         * `Series.points` array. Other ways to instaniate points are through {@link
         * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
         *
         * @class
         */

        Highcharts.Point = Point = function() {};
        Highcharts.Point.prototype = {

            /**
             * Initialize the point. Called internally based on the `series.data`
             * option.
             * @param  {Series} series
             *         The series object containing this point.
             * @param  {Number|Array|Object} options
             *         The data in either number, array or object format.
             * @param  {Number} x Optionally, the X value of the point.
             * @return {Point} The Point instance.
             */
            init: function(series, options, x) {

                var point = this,
                    colors,
                    colorCount = series.chart.options.chart.colorCount,
                    colorIndex;

                /**
                 * The series object associated with the point.
                 *
                 * @name series
                 * @memberof Highcharts.Point
                 * @type Highcharts.Series
                 */
                point.series = series;


                /**
                 * The point's current color.
                 * @name color
                 * @memberof Highcharts.Point
                 * @type {Color}
                 */
                point.color = series.color; // #3445

                point.applyOptions(options, x);

                if (series.options.colorByPoint) {

                    colors = series.options.colors || series.chart.options.colors;
                    point.color = point.color || colors[series.colorCounter];
                    colorCount = colors.length;

                    colorIndex = series.colorCounter;
                    series.colorCounter++;
                    // loop back to zero
                    if (series.colorCounter === colorCount) {
                        series.colorCounter = 0;
                    }
                } else {
                    colorIndex = series.colorIndex;
                }
                point.colorIndex = pick(point.colorIndex, colorIndex);

                series.chart.pointCount++;
                return point;
            },
            /**
             * Apply the options containing the x and y data and possible some extra
             * properties. Called on point init or from point.update.
             *
             * @private
             * @param {Object} options The point options as defined in series.data.
             * @param {Number} x Optionally, the X value.
             * @returns {Object} The Point instance.
             */
            applyOptions: function(options, x) {
                var point = this,
                    series = point.series,
                    pointValKey = series.options.pointValKey || series.pointValKey;

                options = Point.prototype.optionsToObject.call(this, options);

                // copy options directly to point
                extend(point, options);
                point.options = point.options ? extend(point.options, options) : options;

                // Since options are copied into the Point instance, some accidental options must be shielded (#5681)
                if (options.group) {
                    delete point.group;
                }

                // For higher dimension series types. For instance, for ranges, point.y is mapped to point.low.
                if (pointValKey) {
                    point.y = point[pointValKey];
                }
                point.isNull = pick(
                    point.isValid && !point.isValid(),
                    point.x === null || !isNumber(point.y, true)
                ); // #3571, check for NaN

                // The point is initially selected by options (#5777)
                if (point.selected) {
                    point.state = 'select';
                }

                // If no x is set by now, get auto incremented value. All points must have an
                // x value, however the y value can be null to create a gap in the series
                if ('name' in point && x === undefined && series.xAxis && series.xAxis.hasNames) {
                    point.x = series.xAxis.nameToX(point);
                }
                if (point.x === undefined && series) {
                    if (x === undefined) {
                        point.x = series.autoIncrement(point);
                    } else {
                        point.x = x;
                    }
                }

                return point;
            },

            /**
             * Transform number or array configs into objects. Used internally to unify
             * the different configuration formats for points. For example, a simple
             * number `10` in a line series will be transformed to `{ y: 10 }`, and an
             * array config like `[1, 10]` in a scatter series will be transformed to
             * `{ x: 1, y: 10 }`.
             *
             * @param  {Number|Array|Object} options
             *         The input options
             * @return {Object} Transformed options.
             */
            optionsToObject: function(options) {
                var ret = {},
                    series = this.series,
                    keys = series.options.keys,
                    pointArrayMap = keys || series.pointArrayMap || ['y'],
                    valueCount = pointArrayMap.length,
                    firstItemType,
                    i = 0,
                    j = 0;

                if (isNumber(options) || options === null) {
                    ret[pointArrayMap[0]] = options;

                } else if (isArray(options)) {
                    // with leading x value
                    if (!keys && options.length > valueCount) {
                        firstItemType = typeof options[0];
                        if (firstItemType === 'string') {
                            ret.name = options[0];
                        } else if (firstItemType === 'number') {
                            ret.x = options[0];
                        }
                        i++;
                    }
                    while (j < valueCount) {
                        if (!keys || options[i] !== undefined) { // Skip undefined positions for keys
                            ret[pointArrayMap[j]] = options[i];
                        }
                        i++;
                        j++;
                    }
                } else if (typeof options === 'object') {
                    ret = options;

                    // This is the fastest way to detect if there are individual point dataLabels that need
                    // to be considered in drawDataLabels. These can only occur in object configs.
                    if (options.dataLabels) {
                        series._hasPointLabels = true;
                    }

                    // Same approach as above for markers
                    if (options.marker) {
                        series._hasPointMarkers = true;
                    }
                }
                return ret;
            },

            /**
             * Get the CSS class names for individual points. Used internally where the
             * returned value is set on every point.
             * 
             * @returns {String} The class names.
             */
            getClassName: function() {
                return 'highcharts-point' +
                    (this.selected ? ' highcharts-point-select' : '') +
                    (this.negative ? ' highcharts-negative' : '') +
                    (this.isNull ? ' highcharts-null-point' : '') +
                    (this.colorIndex !== undefined ? ' highcharts-color-' +
                        this.colorIndex : '') +
                    (this.options.className ? ' ' + this.options.className : '') +
                    (this.zone && this.zone.className ? ' ' +
                        this.zone.className.replace('highcharts-negative', '') : '');
            },

            /**
             * In a series with `zones`, return the zone that the point belongs to.
             *
             * @return {Object}
             *         The zone item.
             */
            getZone: function() {
                var series = this.series,
                    zones = series.zones,
                    zoneAxis = series.zoneAxis || 'y',
                    i = 0,
                    zone;

                zone = zones[i];
                while (this[zoneAxis] >= zone.value) {
                    zone = zones[++i];
                }

                if (zone && zone.color && !this.options.color) {
                    this.color = zone.color;
                }

                return zone;
            },

            /**
             * Destroy a point to clear memory. Its reference still stays in
             * `series.data`.
             *
             * @private
             */
            destroy: function() {
                var point = this,
                    series = point.series,
                    chart = series.chart,
                    hoverPoints = chart.hoverPoints,
                    prop;

                chart.pointCount--;

                if (hoverPoints) {
                    point.setState();
                    erase(hoverPoints, point);
                    if (!hoverPoints.length) {
                        chart.hoverPoints = null;
                    }

                }
                if (point === chart.hoverPoint) {
                    point.onMouseOut();
                }

                // remove all events
                if (point.graphic || point.dataLabel) { // removeEvent and destroyElements are performance expensive
                    removeEvent(point);
                    point.destroyElements();
                }

                if (point.legendItem) { // pies have legend items
                    chart.legend.destroyItem(point);
                }

                for (prop in point) {
                    point[prop] = null;
                }


            },

            /**
             * Destroy SVG elements associated with the point.
             *
             * @private
             */
            destroyElements: function() {
                var point = this,
                    props = ['graphic', 'dataLabel', 'dataLabelUpper', 'connector', 'shadowGroup'],
                    prop,
                    i = 6;
                while (i--) {
                    prop = props[i];
                    if (point[prop]) {
                        point[prop] = point[prop].destroy();
                    }
                }
            },

            /**
             * Return the configuration hash needed for the data label and tooltip
             * formatters.
             *
             * @returns {Object}
             *          Abstract object used in formatters and formats.
             */
            getLabelConfig: function() {
                return {
                    x: this.category,
                    y: this.y,
                    color: this.color,
                    colorIndex: this.colorIndex,
                    key: this.name || this.category,
                    series: this.series,
                    point: this,
                    percentage: this.percentage,
                    total: this.total || this.stackTotal
                };
            },

            /**
             * Extendable method for formatting each point's tooltip line.
             *
             * @param  {String} pointFormat
             *         The point format.
             * @return {String}
             *         A string to be concatenated in to the common tooltip text.
             */
            tooltipFormatter: function(pointFormat) {

                // Insert options for valueDecimals, valuePrefix, and valueSuffix
                var series = this.series,
                    seriesTooltipOptions = series.tooltipOptions,
                    valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''),
                    valuePrefix = seriesTooltipOptions.valuePrefix || '',
                    valueSuffix = seriesTooltipOptions.valueSuffix || '';

                // Loop over the point array map and replace unformatted values with sprintf formatting markup
                each(series.pointArrayMap || ['y'], function(key) {
                    key = '{point.' + key; // without the closing bracket
                    if (valuePrefix || valueSuffix) {
                        pointFormat = pointFormat.replace(key + '}', valuePrefix + key + '}' + valueSuffix);
                    }
                    pointFormat = pointFormat.replace(key + '}', key + ':,.' + valueDecimals + 'f}');
                });

                return format(pointFormat, {
                    point: this,
                    series: this.series
                });
            },

            /**
             * Fire an event on the Point object.
             *
             * @private
             * @param {String} eventType
             * @param {Object} eventArgs Additional event arguments
             * @param {Function} defaultFunction Default event handler
             */
            firePointEvent: function(eventType, eventArgs, defaultFunction) {
                var point = this,
                    series = this.series,
                    seriesOptions = series.options;

                // load event handlers on demand to save time on mouseover/out
                if (seriesOptions.point.events[eventType] || (point.options && point.options.events && point.options.events[eventType])) {
                    this.importEvents();
                }

                // add default handler if in selection mode
                if (eventType === 'click' && seriesOptions.allowPointSelect) {
                    defaultFunction = function(event) {
                        // Control key is for Windows, meta (= Cmd key) for Mac, Shift for Opera
                        if (point.select) { // Could be destroyed by prior event handlers (#2911)
                            point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
                        }
                    };
                }

                fireEvent(this, eventType, eventArgs, defaultFunction);
            },

            /**
             * For certain series types, like pie charts, where individual points can
             * be shown or hidden. 
             *
             * @name visible
             * @memberOf Highcharts.Point
             * @type {Boolean}
             */
            visible: true
        };

        /**
         * For categorized axes this property holds the category name for the 
         * point. For other axes it holds the X value.
         *
         * @name category
         * @memberOf Highcharts.Point
         * @type {String|Number}
         */

        /**
         * The percentage for points in a stacked series or pies.
         *
         * @name percentage
         * @memberOf Highcharts.Point
         * @type {Number}
         */

        /**
         * The total of values in either a stack for stacked series, or a pie in a pie
         * series.
         *
         * @name total
         * @memberOf Highcharts.Point
         * @type {Number}
         */

        /**
         * The x value of the point.
         *
         * @name x
         * @memberOf Highcharts.Point
         * @type {Number}
         */

        /**
         * The y value of the point.
         *
         * @name y
         * @memberOf Highcharts.Point
         * @type {Number}
         */

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var addEvent = H.addEvent,
            animObject = H.animObject,
            arrayMax = H.arrayMax,
            arrayMin = H.arrayMin,
            correctFloat = H.correctFloat,
            Date = H.Date,
            defaultOptions = H.defaultOptions,
            defaultPlotOptions = H.defaultPlotOptions,
            defined = H.defined,
            each = H.each,
            erase = H.erase,
            extend = H.extend,
            fireEvent = H.fireEvent,
            grep = H.grep,
            isArray = H.isArray,
            isNumber = H.isNumber,
            isString = H.isString,
            LegendSymbolMixin = H.LegendSymbolMixin, // @todo add as a requirement
            merge = H.merge,
            objectEach = H.objectEach,
            pick = H.pick,
            Point = H.Point, // @todo  add as a requirement
            removeEvent = H.removeEvent,
            splat = H.splat,
            SVGElement = H.SVGElement,
            syncTimeout = H.syncTimeout,
            win = H.win;

        /**
         * This is the base series prototype that all other series types inherit from.
         * A new series is initialized either through the
         * {@link https://api.highcharts.com/highcharts/series|series} option structure,
         * or after the chart is initialized, through
         * {@link Highcharts.Chart#addSeries}.
         *
         * The object can be accessed in a number of ways. All series and point event
         * handlers give a reference to the `series` object. The chart object has a
         * {@link Highcharts.Chart.series|series} property that is a collection of all
         * the chart's series. The point objects and axis objects also have the same
         * reference.
         *
         * Another way to reference the series programmatically is by `id`. Add an id
         * in the series configuration options, and get the series object by {@link
         * Highcharts.Chart#get}.
         *
         * Configuration options for the series are given in three levels. Options for
         * all series in a chart are given in the
         * {@link https://api.highcharts.com/highcharts/plotOptions.series|
         * plotOptions.series} object. Then options for all series of a specific type
         * are given in the plotOptions of that type, for example `plotOptions.line`.
         * Next, options for one single series are given in the series array, or as
         * arguements to `chart.addSeries`.
         *
         * The data in the series is stored in various arrays.
         *
         * - First, `series.options.data` contains all the original config options for
         * each point whether added by options or methods like `series.addPoint`.
         * - Next, `series.data` contains those values converted to points, but in case
         * the series data length exceeds the `cropThreshold`, or if the data is
         * grouped, `series.data` doesn't contain all the points. It only contains the
         * points that have been created on demand.
         * - Then there's `series.points` that contains all currently visible point
         * objects. In case of cropping, the cropped-away points are not part of this
         * array. The `series.points` array starts at `series.cropStart` compared to
         * `series.data` and `series.options.data`. If however the series data is
         * grouped, these can't be correlated one to one.
         * - `series.xData` and `series.processedXData` contain clean x values,
         * equivalent to `series.data` and `series.points`.
         * - `series.yData` and `series.processedYData` contain clean y values,
         * equivalent to `series.data` and `series.points`.
         *
         * @class Highcharts.Series
         * @param  {Highcharts.Chart} chart
         *         The chart instance.
         * @param  {Options.plotOptions.series} options
         *         The series options.
         *
         */

        /**
         * General options for all series types.
         * @optionparent plotOptions.series
         */
        H.Series = H.seriesType('line', null, { // base series options

            /**
             * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
             * of a line graph. Round means that lines are rounded in the ends and
             * bends.
             * 
             * @validvalue ["round", "butt", "square"]
             * @type {String}
             * @default round
             * @since 3.0.7
             * @apioption plotOptions.line.linecap
             */

            /**
             * Pixel with of the graph line.
             * 
             * @type {Number}
             * @see In styled mode, the line stroke-width can be set with the
             * `.highcharts-graph` class name.
             * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
             *         On all series
             * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
             *         On one single series
             * @default 2
             * @product highcharts highstock
             */
            lineWidth: 2,


            /**
             * For some series, there is a limit that shuts down initial animation
             * by default when the total number of points in the chart is too high.
             * For example, for a column chart and its derivatives, animation doesn't
             * run if there is more than 250 points totally. To disable this cap, set
             * `animationLimit` to `Infinity`.
             * 
             * @type {Number}
             * @apioption plotOptions.series.animationLimit
             */

            /**
             * Allow this series' points to be selected by clicking on the graphic 
             * (columns, point markers, pie slices, map areas etc).
             *
             * @see [Chart#getSelectedPoints]
             *      (../class-reference/Highcharts.Chart#getSelectedPoints).
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
             *         Line
             * @sample {highcharts}
             *         highcharts/plotoptions/series-allowpointselect-column/
             *         Column
             * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
             *         Pie
             * @sample {highmaps} maps/plotoptions/series-allowpointselect/
             *         Map area
             * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
             *         Map bubble
             * @default false
             * @since 1.2.0
             */
            allowPointSelect: false,



            /**
             * If true, a checkbox is displayed next to the legend item to allow
             * selecting the series. The state of the checkbox is determined by
             * the `selected` option.
             *
             * @productdesc {highmaps}
             * Note that if a `colorAxis` is defined, the color axis is represented in
             * the legend, not the series.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
             *         Show select box
             * @default false
             * @since 1.2.0
             */
            showCheckbox: false,



            /**
             * Enable or disable the initial animation when a series is displayed.
             * The animation can also be set as a configuration object. Please
             * note that this option only applies to the initial animation of the
             * series itself. For other animations, see [chart.animation](#chart.
             * animation) and the animation parameter under the API methods. The
             * following properties are supported:
             * 
             * <dl>
             * 
             * <dt>duration</dt>
             * 
             * <dd>The duration of the animation in milliseconds.</dd>
             * 
             * <dt>easing</dt>
             * 
             * <dd>A string reference to an easing function set on the `Math` object.
             * See the _Custom easing function_ demo below.</dd>
             * 
             * </dl>
             * 
             * Due to poor performance, animation is disabled in old IE browsers
             * for several chart types.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
             *         Animation disabled
             * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
             *         Slower animation
             * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
             *         Custom easing function
             * @sample {highstock} stock/plotoptions/animation-slower/
             *         Slower animation
             * @sample {highstock} stock/plotoptions/animation-easing/
             *         Custom easing function
             * @sample {highmaps} maps/plotoptions/series-animation-true/
             *         Animation enabled on map series
             * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
             *         Disabled on mapbubble series
             * @default {highcharts} true
             * @default {highstock} true
             * @default {highmaps} false
             */
            animation: {
                duration: 1000
            },

            /**
             * A class name to apply to the series' graphical elements.
             * 
             * @type {String}
             * @since 5.0.0
             * @apioption plotOptions.series.className
             */

            /**
             * The main color of the series. In line type series it applies to the
             * line and the point markers unless otherwise specified. In bar type
             * series it applies to the bars unless a color is specified per point.
             * The default value is pulled from the `options.colors` array.
             * 
             * In styled mode, the color can be defined by the
             * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
             * color can be set with the `.highcharts-series`, `.highcharts-color-{n}`,
             * `.highcharts-{type}-series` or `.highcharts-series-{n}` class, or
             * individual classes given by the `className` option.
             *
             * @productdesc {highmaps}
             * In maps, the series color is rarely used, as most choropleth maps use the
             * color to denote the value of each point. The series color can however be
             * used in a map with multiple series holding categorized data.
             * 
             * @type {Color}
             * @sample {highcharts} highcharts/plotoptions/series-color-general/
             *         General plot option
             * @sample {highcharts} highcharts/plotoptions/series-color-specific/
             *         One specific series
             * @sample {highcharts} highcharts/plotoptions/series-color-area/
             *         Area color
             * @sample {highmaps} maps/demo/category-map/
             *         Category map by multiple series
             * @apioption plotOptions.series.color
             */

            /**
             * Styled mode only. A specific color index to use for the series, so its
             * graphic representations are given the class name `highcharts-color-
             * {n}`.
             * 
             * @type {Number}
             * @since 5.0.0
             * @apioption plotOptions.series.colorIndex
             */


            /**
             * Whether to connect a graph line across null points, or render a gap
             * between the two points on either side of the null.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
             *         False by default
             * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
             *         True
             * @product highcharts highstock
             * @apioption plotOptions.series.connectNulls
             */


            /**
             * You can set the cursor to "pointer" if you have click events attached
             * to the series, to signal to the user that the points and lines can
             * be clicked.
             * 
             * @validvalue [null, "default", "none", "help", "pointer", "crosshair"]
             * @type {String}
             * @see In styled mode, the series cursor can be set with the same classes
             * as listed under [series.color](#plotOptions.series.color).
             * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
             *         On line graph
             * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
             *         On columns
             * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
             *         On scatter markers
             * @sample {highstock} stock/plotoptions/cursor/
             *         Pointer on a line graph
             * @sample {highmaps} maps/plotoptions/series-allowpointselect/
             *         Map area
             * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
             *         Map bubble
             * @apioption plotOptions.series.cursor
             */


            /**
             * A name for the dash style to use for the graph, or for some series types
             * the outline of each shape. The value for the `dashStyle` include:
             * 
             * *   Solid
             * *   ShortDash
             * *   ShortDot
             * *   ShortDashDot
             * *   ShortDashDotDot
             * *   Dot
             * *   Dash
             * *   LongDash
             * *   DashDot
             * *   LongDashDot
             * *   LongDashDotDot
             * 
             * @validvalue ["Solid", "ShortDash", "ShortDot", "ShortDashDot",
             *             "ShortDashDotDot", "Dot", "Dash" ,"LongDash", "DashDot",
             *             "LongDashDot", "LongDashDotDot"]
             * @type {String}
             * @see In styled mode, the [stroke dash-array](http://jsfiddle.net/gh/get/
             * library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/
             * series-dashstyle/) can be set with the same classes as listed under
             * [series.color](#plotOptions.series.color).
             * 
             * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
             *         Possible values demonstrated
             * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
             *         Chart suitable for printing in black and white
             * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
             *         Possible values demonstrated
             * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
             *         Possible values demonstrated
             * @sample {highmaps} maps/plotoptions/series-dashstyle/
             *         Dotted borders on a map
             * @default Solid
             * @since 2.1
             * @apioption plotOptions.series.dashStyle
             */

            /**
             * Requires the Accessibility module.
             * 
             * A description of the series to add to the screen reader information
             * about the series.
             * 
             * @type {String}
             * @default undefined
             * @since 5.0.0
             * @apioption plotOptions.series.description
             */





            /**
             * Enable or disable the mouse tracking for a specific series. This
             * includes point tooltips and click events on graphs and points. For
             * large datasets it improves performance.
             * 
             * @type {Boolean}
             * @sample {highcharts}
             *         highcharts/plotoptions/series-enablemousetracking-false/
             *         No mouse tracking
             * @sample {highmaps}
             *         maps/plotoptions/series-enablemousetracking-false/
             *         No mouse tracking
             * @default true
             * @apioption plotOptions.series.enableMouseTracking
             */

            /**
             * By default, series are exposed to screen readers as regions. By enabling
             * this option, the series element itself will be exposed in the same
             * way as the data points. This is useful if the series is not used
             * as a grouping entity in the chart, but you still want to attach a
             * description to the series.
             * 
             * Requires the Accessibility module.
             * 
             * @type {Boolean}
             * @sample highcharts/accessibility/art-grants/
             *         Accessible data visualization
             * @default undefined
             * @since 5.0.12
             * @apioption plotOptions.series.exposeElementToA11y
             */

            /**
             * Whether to use the Y extremes of the total chart width or only the
             * zoomed area when zooming in on parts of the X axis. By default, the
             * Y axis adjusts to the min and max of the visible data. Cartesian
             * series only.
             * 
             * @type {Boolean}
             * @default false
             * @since 4.1.6
             * @product highcharts highstock
             * @apioption plotOptions.series.getExtremesFromAll
             */

            /**
             * An id for the series. This can be used after render time to get a
             * pointer to the series object through `chart.get()`.
             * 
             * @type {String}
             * @sample {highcharts} highcharts/plotoptions/series-id/ Get series by id
             * @since 1.2.0
             * @apioption series.id
             */

            /**
             * The index of the series in the chart, affecting the internal index
             * in the `chart.series` array, the visible Z index as well as the order
             * in the legend.
             * 
             * @type {Number}
             * @default undefined
             * @since 2.3.0
             * @apioption series.index
             */

            /**
             * An array specifying which option maps to which key in the data point
             * array. This makes it convenient to work with unstructured data arrays
             * from different sources.
             * 
             * @type {Array<String>}
             * @see [series.data](#series.line.data)
             * @sample {highcharts|highstock} highcharts/series/data-keys/
             *         An extended data array with keys
             * @since 4.1.6
             * @product highcharts highstock
             * @apioption plotOptions.series.keys
             */

            /**
             * The sequential index of the series in the legend.
             * 
             * @sample {highcharts|highstock} highcharts/series/legendindex/
             *         Legend in opposite order
             * @type {Number}
             * @see [legend.reversed](#legend.reversed), [yAxis.reversedStacks](#yAxis.
             * reversedStacks)
             * @apioption series.legendIndex
             */

            /**
             * The line cap used for line ends and line joins on the graph.
             * 
             * @validvalue ["round", "square"]
             * @type {String}
             * @default round
             * @product highcharts highstock
             * @apioption plotOptions.series.linecap
             */

            /**
             * The [id](#series.id) of another series to link to. Additionally,
             * the value can be ":previous" to link to the previous series. When
             * two series are linked, only the first one appears in the legend.
             * Toggling the visibility of this also toggles the linked series.
             * 
             * @type {String}
             * @sample {highcharts} highcharts/demo/arearange-line/ Linked series
             * @sample {highstock} highcharts/demo/arearange-line/ Linked series
             * @since 3.0
             * @product highcharts highstock
             * @apioption plotOptions.series.linkedTo
             */

            /**
             * The name of the series as shown in the legend, tooltip etc.
             * 
             * @type {String}
             * @sample {highcharts} highcharts/series/name/ Series name
             * @sample {highmaps} maps/demo/category-map/ Series name
             * @apioption series.name
             */

            /**
             * The color for the parts of the graph or points that are below the
             * [threshold](#plotOptions.series.threshold).
             * 
             * @type {Color}
             * @see In styled mode, a negative color is applied by setting this
             * option to `true` combined with the `.highcharts-negative` class name.
             * 
             * @sample {highcharts} highcharts/plotoptions/series-negative-color/
             *         Spline, area and column
             * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
             *         Arearange
             * @sample {highcharts} highcharts/css/series-negative-color/
             *         Styled mode
             * @sample {highstock} highcharts/plotoptions/series-negative-color/
             *         Spline, area and column
             * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
             *         Arearange
             * @sample {highmaps} highcharts/plotoptions/series-negative-color/
             *         Spline, area and column
             * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
             *         Arearange
             * @default null
             * @since 3.0
             * @apioption plotOptions.series.negativeColor
             */

            /**
             * Same as [accessibility.pointDescriptionFormatter](#accessibility.
             * pointDescriptionFormatter), but for an individual series. Overrides
             * the chart wide configuration.
             * 
             * @type {Function}
             * @since 5.0.12
             * @apioption plotOptions.series.pointDescriptionFormatter
             */

            /**
             * If no x values are given for the points in a series, `pointInterval`
             * defines the interval of the x values. For example, if a series contains
             * one value every decade starting from year 0, set `pointInterval` to
             * `10`. In true `datetime` axes, the `pointInterval` is set in
             * milliseconds.
             * 
             * It can be also be combined with `pointIntervalUnit` to draw irregular
             * time intervals.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
             *         Datetime X axis
             * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
             *         Using pointStart and pointInterval
             * @default 1
             * @product highcharts highstock
             * @apioption plotOptions.series.pointInterval
             */

            /**
             * On datetime series, this allows for setting the
             * [pointInterval](#plotOptions.series.pointInterval) to irregular time 
             * units, `day`, `month` and `year`. A day is usually the same as 24 hours,
             * but `pointIntervalUnit` also takes the DST crossover into consideration
             * when dealing with local time. Combine this option with `pointInterval`
             * to draw weeks, quarters, 6 months, 10 years etc.
             * 
             * @validvalue [null, "day", "month", "year"]
             * @type {String}
             * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
             *         One point a month
             * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
             *         One point a month
             * @since 4.1.0
             * @product highcharts highstock
             * @apioption plotOptions.series.pointIntervalUnit
             */

            /**
             * Possible values: `null`, `"on"`, `"between"`.
             * 
             * In a column chart, when pointPlacement is `"on"`, the point will
             * not create any padding of the X axis. In a polar column chart this
             * means that the first column points directly north. If the pointPlacement
             * is `"between"`, the columns will be laid out between ticks. This
             * is useful for example for visualising an amount between two points
             * in time or in a certain sector of a polar chart.
             * 
             * Since Highcharts 3.0.2, the point placement can also be numeric,
             * where 0 is on the axis value, -0.5 is between this value and the
             * previous, and 0.5 is between this value and the next. Unlike the
             * textual options, numeric point placement options won't affect axis
             * padding.
             * 
             * Note that pointPlacement needs a [pointRange](#plotOptions.series.
             * pointRange) to work. For column series this is computed, but for
             * line-type series it needs to be set.
             * 
             * Defaults to `null` in cartesian charts, `"between"` in polar charts.
             * 
             * @validvalue [null, "on", "between"]
             * @type {String|Number}
             * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
             * @sample {highcharts|highstock}
             *         highcharts/plotoptions/series-pointplacement-between/
             *         Between in a column chart
             * @sample {highcharts|highstock}
             *         highcharts/plotoptions/series-pointplacement-numeric/
             *         Numeric placement for custom layout
             * @default null
             * @since 2.3.0
             * @product highcharts highstock
             * @apioption plotOptions.series.pointPlacement
             */

            /**
             * If no x values are given for the points in a series, pointStart defines
             * on what value to start. For example, if a series contains one yearly
             * value starting from 1945, set pointStart to 1945.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
             *         Linear
             * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
             *         Datetime
             * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
             *         Using pointStart and pointInterval
             * @default 0
             * @product highcharts highstock
             * @apioption plotOptions.series.pointStart
             */

            /**
             * Whether to select the series initially. If `showCheckbox` is true,
             * the checkbox next to the series name in the legend will be checked for a
             * selected series.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-selected/
             *         One out of two series selected
             * @default false
             * @since 1.2.0
             * @apioption plotOptions.series.selected
             */

            /**
             * Whether to apply a drop shadow to the graph line. Since 2.3 the shadow
             * can be an object configuration containing `color`, `offsetX`, `offsetY`,
             *  `opacity` and `width`.
             * 
             * @type {Boolean|Object}
             * @sample {highcharts} highcharts/plotoptions/series-shadow/ Shadow enabled
             * @default false
             * @apioption plotOptions.series.shadow
             */

            /**
             * Whether to display this particular series or series type in the legend.
             * The default value is `true` for standalone series, `false` for linked
             * series.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
             *         One series in the legend, one hidden
             * @default true
             * @apioption plotOptions.series.showInLegend
             */

            /**
             * If set to `True`, the accessibility module will skip past the points
             * in this series for keyboard navigation.
             * 
             * @type {Boolean}
             * @since 5.0.12
             * @apioption plotOptions.series.skipKeyboardNavigation
             */

            /**
             * This option allows grouping series in a stacked chart. The stack
             * option can be a string or a number or anything else, as long as the
             * grouped series' stack options match each other.
             * 
             * @type {String}
             * @sample {highcharts} highcharts/series/stack/ Stacked and grouped columns
             * @default null
             * @since 2.1
             * @product highcharts highstock
             * @apioption series.stack
             */

            /**
             * Whether to stack the values of each series on top of each other.
             * Possible values are `null` to disable, `"normal"` to stack by value or
             * `"percent"`. When stacking is enabled, data must be sorted in ascending
             * X order. A special stacking option is with the streamgraph series type,
             * where the stacking option is set to `"stream"`.
             * 
             * @validvalue [null, "normal", "percent"]
             * @type {String}
             * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
             * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
             *         Line
             * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
             *         Column
             * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
             *         Bar
             * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
             *         Area
             * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
             *         Line
             * @sample {highcharts}
             *         highcharts/plotoptions/series-stacking-percent-column/
             *         Column
             * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
             *         Bar
             * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
             *         Area
             * @sample {highstock} stock/plotoptions/stacking/
             *         Area
             * @default null
             * @product highcharts highstock
             * @apioption plotOptions.series.stacking
             */

            /**
             * Whether to apply steps to the line. Possible values are `left`, `center`
             * and `right`.
             * 
             * @validvalue [null, "left", "center", "right"]
             * @type {String}
             * @sample {highcharts} highcharts/plotoptions/line-step/
             *         Different step line options
             * @sample {highcharts} highcharts/plotoptions/area-step/
             *         Stepped, stacked area
             * @sample {highstock} stock/plotoptions/line-step/
             *         Step line
             * @default {highcharts} null
             * @default {highstock} false
             * @since 1.2.5
             * @product highcharts highstock
             * @apioption plotOptions.series.step
             */

            /**
             * The threshold, also called zero level or base level. For line type
             * series this is only used in conjunction with
             * [negativeColor](#plotOptions.series.negativeColor).
             * 
             * @type {Number}
             * @see [softThreshold](#plotOptions.series.softThreshold).
             * @default 0
             * @since 3.0
             * @product highcharts highstock
             * @apioption plotOptions.series.threshold
             */

            /**
             * The type of series, for example `line` or `column`.
             * 
             * @validvalue [null, "line", "spline", "column", "area", "areaspline",
             *       "pie", "arearange", "areasplinerange", "boxplot", "bubble",
             *       "columnrange", "errorbar", "funnel", "gauge", "scatter",
             *       "waterfall"]
             * @type {String}
             * @sample {highcharts} highcharts/series/type/
             *         Line and column in the same chart
             * @sample {highmaps} maps/demo/mapline-mappoint/
             *         Multiple types in the same map
             * @apioption series.type
             */

            /**
             * Set the initial visibility of the series.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-visible/
             *         Two series, one hidden and one visible
             * @sample {highstock} stock/plotoptions/series-visibility/
             *         Hidden series
             * @default true
             * @apioption plotOptions.series.visible
             */

            /**
             * When using dual or multiple x axes, this number defines which xAxis
             * the particular series is connected to. It refers to either the [axis
             * id](#xAxis.id) or the index of the axis in the xAxis array, with
             * 0 being the first.
             * 
             * @type {Number|String}
             * @default 0
             * @product highcharts highstock
             * @apioption series.xAxis
             */

            /**
             * When using dual or multiple y axes, this number defines which yAxis
             * the particular series is connected to. It refers to either the [axis
             * id](#yAxis.id) or the index of the axis in the yAxis array, with
             * 0 being the first.
             * 
             * @type {Number|String}
             * @sample {highcharts} highcharts/series/yaxis/
             *         Apply the column series to the secondary Y axis
             * @default 0
             * @product highcharts highstock
             * @apioption series.yAxis
             */

            /**
             * Defines the Axis on which the zones are applied.
             * 
             * @type {String}
             * @see [zones](#plotOptions.series.zones)
             * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
             *         Zones on the X-Axis
             * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
             *         Zones on the X-Axis
             * @default y
             * @since 4.1.0
             * @product highcharts highstock
             * @apioption plotOptions.series.zoneAxis
             */

            /**
             * Define the visual z index of the series.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
             *         With no z index, the series defined last are on top
             * @sample {highcharts} highcharts/plotoptions/series-zindex/
             *         With a z index, the series with the highest z index is on top
             * @sample {highstock} highcharts/plotoptions/series-zindex-default/
             *         With no z index, the series defined last are on top
             * @sample {highstock} highcharts/plotoptions/series-zindex/
             *         With a z index, the series with the highest z index is on top
             * @product highcharts highstock
             * @apioption series.zIndex
             */

            /**
             * General event handlers for the series items. These event hooks can also
             * be attached to the series at run time using the `Highcharts.addEvent`
             * function.
             */
            events: {

                /**
                 * Fires after the series has finished its initial animation, or in
                 * case animation is disabled, immediately as the series is displayed.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-events-afteranimate/
                 *         Show label after animate
                 * @sample {highstock}
                 *         highcharts/plotoptions/series-events-afteranimate/
                 *         Show label after animate
                 * @since 4.0
                 * @product highcharts highstock
                 * @apioption plotOptions.series.events.afterAnimate
                 */

                /**
                 * Fires when the checkbox next to the series' name in the legend is
                 * clicked. One parameter, `event`, is passed to the function. The state
                 * of the checkbox is found by `event.checked`. The checked item is
                 * found by `event.item`. Return `false` to prevent the default action
                 * which is to toggle the select state of the series.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-events-checkboxclick/
                 *         Alert checkbox status
                 * @since 1.2.0
                 * @apioption plotOptions.series.events.checkboxClick
                 */

                /**
                 * Fires when the series is clicked. One parameter, `event`, is passed
                 * to the function, containing common event information. Additionally,
                 * `event.point` holds a pointer to the nearest point on the graph.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts} highcharts/plotoptions/series-events-click/
                 *         Alert click info
                 * @sample {highstock} stock/plotoptions/series-events-click/
                 *         Alert click info
                 * @sample {highmaps} maps/plotoptions/series-events-click/
                 *         Display click info in subtitle
                 * @apioption plotOptions.series.events.click
                 */

                /**
                 * Fires when the series is hidden after chart generation time, either
                 * by clicking the legend item or by calling `.hide()`.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts} highcharts/plotoptions/series-events-hide/
                 *         Alert when the series is hidden by clicking the legend item
                 * @since 1.2.0
                 * @apioption plotOptions.series.events.hide
                 */

                /**
                 * Fires when the legend item belonging to the series is clicked. One
                 * parameter, `event`, is passed to the function. The default action
                 * is to toggle the visibility of the series. This can be prevented
                 * by returning `false` or calling `event.preventDefault()`.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-events-legenditemclick/
                 *         Confirm hiding and showing
                 * @apioption plotOptions.series.events.legendItemClick
                 */

                /**
                 * Fires when the mouse leaves the graph. One parameter, `event`, is
                 * passed to the function, containing common event information. If the
                 * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
                 * doesn't happen before the mouse enters another graph or leaves the
                 * plot area.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-events-mouseover-sticky/
                 *         With sticky tracking    by default
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-events-mouseover-no-sticky/
                 *         Without sticky tracking
                 * @apioption plotOptions.series.events.mouseOut
                 */

                /**
                 * Fires when the mouse enters the graph. One parameter, `event`, is
                 * passed to the function, containing common event information.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-events-mouseover-sticky/
                 *         With sticky tracking by default
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-events-mouseover-no-sticky/
                 *         Without sticky tracking
                 * @apioption plotOptions.series.events.mouseOver
                 */

                /**
                 * Fires when the series is shown after chart generation time, either
                 * by clicking the legend item or by calling `.show()`.
                 * 
                 * @type {Function}
                 * @context Series
                 * @sample {highcharts} highcharts/plotoptions/series-events-show/
                 *         Alert when the series is shown by clicking the legend item.
                 * @since 1.2.0
                 * @apioption plotOptions.series.events.show
                 */

            },



            /**
             * Options for the point markers of line-like series. Properties like
             * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
             * of the markers. Other series types, like column series, don't have
             * markers, but have visual options on the series level instead.
             * 
             * In styled mode, the markers can be styled with the `.highcharts-point`,
             * `.highcharts-point-hover` and `.highcharts-point-select`
             * class names.
             * 
             * @product highcharts highstock
             */
            marker: {



                /**
                 * The width of the point marker's outline.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
                 *         2px blue marker
                 * @default 0
                 * @product highcharts highstock
                 */
                lineWidth: 0,


                /**
                 * The color of the point marker's outline. When `null`, the series'
                 * or point's color is used.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
                 *         Inherit from series color (null)
                 * @product highcharts highstock
                 */
                lineColor: '#ffffff',

                /**
                 * The fill color of the point marker. When `null`, the series' or
                 * point's color is used.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
                 *         White fill
                 * @default null
                 * @product highcharts highstock
                 * @apioption plotOptions.series.marker.fillColor
                 */



                /**
                 * Enable or disable the point marker. If `null`, the markers are hidden
                 * when the data is dense, and shown for more widespread data points.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
                 *         Disabled markers
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-marker-enabled-false/
                 *         Disabled in normal state but enabled on hover
                 * @sample {highstock} stock/plotoptions/series-marker/
                 *         Enabled markers
                 * @default {highcharts} null
                 * @default {highstock} false
                 * @product highcharts highstock
                 * @apioption plotOptions.series.marker.enabled
                 */

                /**
                 * Image markers only. Set the image width explicitly. When using this
                 * option, a `width` must also be set.
                 * 
                 * @type {Number}
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-marker-width-height/
                 *         Fixed width and height
                 * @sample {highstock}
                 *         highcharts/plotoptions/series-marker-width-height/
                 *         Fixed width and height
                 * @default null
                 * @since 4.0.4
                 * @product highcharts highstock
                 * @apioption plotOptions.series.marker.height
                 */

                /**
                 * A predefined shape or symbol for the marker. When null, the symbol
                 * is pulled from options.symbols. Other possible values are "circle",
                 * "square", "diamond", "triangle" and "triangle-down".
                 * 
                 * Additionally, the URL to a graphic can be given on this form:
                 * "url(graphic.png)". Note that for the image to be applied to exported
                 * charts, its URL needs to be accessible by the export server.
                 * 
                 * Custom callbacks for symbol path generation can also be added to
                 * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
                 * used by its method name, as shown in the demo.
                 * 
                 * @validvalue [null, "circle", "square", "diamond", "triangle",
                 *         "triangle-down"]
                 * @type {String}
                 * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
                 *         Predefined, graphic and custom markers
                 * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
                 *         Predefined, graphic and custom markers
                 * @default null
                 * @product highcharts highstock
                 * @apioption plotOptions.series.marker.symbol
                 */

                /**
                 * The radius of the point marker.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
                 *         Bigger markers
                 * @default 4
                 * @product highcharts highstock
                 */
                radius: 4,

                /**
                 * Image markers only. Set the image width explicitly. When using this
                 * option, a `height` must also be set.
                 * 
                 * @type {Number}
                 * @sample {highcharts}
                 *         highcharts/plotoptions/series-marker-width-height/
                 *         Fixed width and height
                 * @sample {highstock}
                 *         highcharts/plotoptions/series-marker-width-height/
                 *         Fixed width and height
                 * @default null
                 * @since 4.0.4
                 * @product highcharts highstock
                 * @apioption plotOptions.series.marker.width
                 */


                /**
                 * States for a single point marker.
                 * @product highcharts highstock
                 */
                states: {
                    /**
                     * The hover state for a single point marker.
                     * @product highcharts highstock
                     */
                    hover: {

                        /**
                         * Animation when hovering over the marker.
                         */
                        animation: {
                            duration: 50
                        },

                        /**
                         * Enable or disable the point marker.
                         * 
                         * @type {Boolean}
                         * @sample {highcharts}
                         *         highcharts/plotoptions/series-marker-states-hover-enabled/
                         *         Disabled hover state
                         * @default true
                         * @product highcharts highstock
                         */
                        enabled: true,

                        /**
                         * The fill color of the marker in hover state.
                         * 
                         * @type {Color}
                         * @default null
                         * @product highcharts highstock
                         * @apioption plotOptions.series.marker.states.hover.fillColor
                         */

                        /**
                         * The color of the point marker's outline. When `null`, the
                         * series' or point's color is used.
                         * 
                         * @type {Color}
                         * @sample {highcharts}
                         *         highcharts/plotoptions/series-marker-states-hover-linecolor/
                         *         White fill color, black line color
                         * @default #ffffff
                         * @product highcharts highstock
                         * @apioption plotOptions.series.marker.states.hover.lineColor
                         */

                        /**
                         * The width of the point marker's outline.
                         * 
                         * @type {Number}
                         * @sample {highcharts}
                         *         highcharts/plotoptions/series-marker-states-hover-linewidth/
                         *         3px line width
                         * @default 0
                         * @product highcharts highstock
                         * @apioption plotOptions.series.marker.states.hover.lineWidth
                         */

                        /**
                         * The radius of the point marker. In hover state, it defaults to the
                         * normal state's radius + 2 as per the [radiusPlus](#plotOptions.series.
                         * marker.states.hover.radiusPlus) option.
                         * 
                         * @type {Number}
                         * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/ 10px radius
                         * @product highcharts highstock
                         * @apioption plotOptions.series.marker.states.hover.radius
                         */

                        /**
                         * The number of pixels to increase the radius of the hovered point.
                         * 
                         * @type {Number}
                         * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/ 5 pixels greater radius on hover
                         * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/ 5 pixels greater radius on hover
                         * @default 2
                         * @since 4.0.3
                         * @product highcharts highstock
                         */
                        radiusPlus: 2,



                        /**
                         * The additional line width for a hovered point.
                         * 
                         * @type {Number}
                         * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/ 2 pixels wider on hover
                         * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/ 2 pixels wider on hover
                         * @default 1
                         * @since 4.0.3
                         * @product highcharts highstock
                         */
                        lineWidthPlus: 1

                    },




                    /**
                     * The appearance of the point marker when selected. In order to
                     * allow a point to be selected, set the `series.allowPointSelect`
                     * option to true.
                     * 
                     * @product highcharts highstock
                     */
                    select: {

                        /**
                         * Enable or disable visible feedback for selection.
                         * 
                         * @type {Boolean}
                         * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
                         *         Disabled select state
                         * @default true
                         * @product highcharts highstock
                         * @apioption plotOptions.series.marker.states.select.enabled
                         */

                        /**
                         * The fill color of the point marker.
                         * 
                         * @type {Color}
                         * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
                         *         Solid red discs for selected points
                         * @default null
                         * @product highcharts highstock
                         */
                        fillColor: '#cccccc',



                        /**
                         * The color of the point marker's outline. When `null`, the series'
                         * or point's color is used.
                         * 
                         * @type {Color}
                         * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
                         *         Red line color for selected points
                         * @default #000000
                         * @product highcharts highstock
                         */
                        lineColor: '#000000',



                        /**
                         * The width of the point marker's outline.
                         * 
                         * @type {Number}
                         * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
                         *         3px line width for selected points
                         * @default 0
                         * @product highcharts highstock
                         */
                        lineWidth: 2

                        /**
                         * The radius of the point marker. In hover state, it defaults to the
                         * normal state's radius + 2.
                         * 
                         * @type {Number}
                         * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
                         *         10px radius for selected points
                         * @product highcharts highstock
                         * @apioption plotOptions.series.marker.states.select.radius
                         */

                    }

                }
            },



            /**
             * Properties for each single point.
             */
            point: {


                /**
                 * Events for each single point.
                 */
                events: {

                    /**
                     * Fires when a point is clicked. One parameter, `event`, is passed
                     * to the function, containing common event information.
                     * 
                     * If the `series.allowPointSelect` option is true, the default action
                     * for the point's click event is to toggle the point's select state.
                     *  Returning `false` cancels this action.
                     * 
                     * @type {Function}
                     * @context Point
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-click/ Click marker to alert values
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/ Click column
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/ Go to URL
                     * @sample {highmaps} maps/plotoptions/series-point-events-click/ Click marker to display values
                     * @sample {highmaps} maps/plotoptions/series-point-events-click-url/ Go to URL
                     * @apioption plotOptions.series.point.events.click
                     */

                    /**
                     * Fires when the mouse leaves the area close to the point. One parameter,
                     * `event`, is passed to the function, containing common event information.
                     * 
                     * @type {Function}
                     * @context Point
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/ Show values in the chart's corner on mouse over
                     * @apioption plotOptions.series.point.events.mouseOut
                     */

                    /**
                     * Fires when the mouse enters the area close to the point. One parameter,
                     * `event`, is passed to the function, containing common event information.
                     * 
                     * @type {Function}
                     * @context Point
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/ Show values in the chart's corner on mouse over
                     * @apioption plotOptions.series.point.events.mouseOver
                     */

                    /**
                     * Fires when the point is removed using the `.remove()` method. One
                     * parameter, `event`, is passed to the function. Returning `false`
                     * cancels the operation.
                     * 
                     * @type {Function}
                     * @context Point
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/ Remove point and confirm
                     * @since 1.2.0
                     * @apioption plotOptions.series.point.events.remove
                     */

                    /**
                     * Fires when the point is selected either programmatically or following
                     * a click on the point. One parameter, `event`, is passed to the function.
                     *  Returning `false` cancels the operation.
                     * 
                     * @type {Function}
                     * @context Point
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-select/ Report the last selected point
                     * @sample {highmaps} maps/plotoptions/series-allowpointselect/ Report select and unselect
                     * @since 1.2.0
                     * @apioption plotOptions.series.point.events.select
                     */

                    /**
                     * Fires when the point is unselected either programmatically or following
                     * a click on the point. One parameter, `event`, is passed to the function.
                     *  Returning `false` cancels the operation.
                     * 
                     * @type {Function}
                     * @context Point
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/ Report the last unselected point
                     * @sample {highmaps} maps/plotoptions/series-allowpointselect/ Report select and unselect
                     * @since 1.2.0
                     * @apioption plotOptions.series.point.events.unselect
                     */

                    /**
                     * Fires when the point is updated programmatically through the `.update()`
                     * method. One parameter, `event`, is passed to the function. The new
                     * point options can be accessed through `event.options`. Returning
                     * `false` cancels the operation.
                     * 
                     * @type {Function}
                     * @context Point
                     * @sample {highcharts} highcharts/plotoptions/series-point-events-update/ Confirm point updating
                     * @since 1.2.0
                     * @apioption plotOptions.series.point.events.update
                     */

                }
            },



            /**
             * Options for the series data labels, appearing next to each data
             * point.
             * 
             * In styled mode, the data labels can be styled wtih the `.highcharts-data-label-box` and `.highcharts-data-label` class names ([see example](http://jsfiddle.
             * net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-
             * datalabels)).
             */
            dataLabels: {


                /**
                 * The alignment of the data label compared to the point. If `right`,
                 * the right side of the label should be touching the point. For
                 * points with an extent, like columns, the alignments also dictates
                 * how to align it inside the box, as given with the [inside](#plotOptions.
                 * column.dataLabels.inside) option. Can be one of "left", "center"
                 * or "right".
                 * 
                 * @validvalue ["left", "center", "right"]
                 * @type {String}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/ Left aligned
                 * @default center
                 */
                align: 'center',


                /**
                 * Whether to allow data labels to overlap. To make the labels less
                 * sensitive for overlapping, the [dataLabels.padding](#plotOptions.
                 * series.dataLabels.padding) can be set to 0.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/ Don't allow overlap
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-allowoverlap-false/ Don't allow overlap
                 * @sample {highmaps} highcharts/plotoptions/series-datalabels-allowoverlap-false/ Don't allow overlap
                 * @default false
                 * @since 4.1.0
                 * @apioption plotOptions.series.dataLabels.allowOverlap
                 */


                /**
                 * The border radius in pixels for the data label.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highmaps} maps/plotoptions/series-datalabels-box/ Data labels box options
                 * @default 0
                 * @since 2.2.1
                 * @apioption plotOptions.series.dataLabels.borderRadius
                 */


                /**
                 * The border width in pixels for the data label.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @default 0
                 * @since 2.2.1
                 * @apioption plotOptions.series.dataLabels.borderWidth
                 */

                /**
                 * A class name for the data label. Particularly in styled mode, this can
                 * be used to give each series' or point's data label unique styling.
                 * In addition to this option, a default color class name is added
                 * so that we can give the labels a [contrast text shadow](http://jsfiddle.
                 * net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/data-
                 * label-contrast/).
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/css/series-datalabels/ Styling by CSS
                 * @sample {highstock} highcharts/css/series-datalabels/ Styling by CSS
                 * @sample {highmaps} highcharts/css/series-datalabels/ Styling by CSS
                 * @since 5.0.0
                 * @apioption plotOptions.series.dataLabels.className
                 */

                /**
                 * The text color for the data labels. Defaults to `null`. For certain series
                 * types, like column or map, the data labels can be drawn inside the points.
                 * In this case the data label will be drawn with maximum contrast by default.
                 * Additionally, it will be given a `text-outline` style with the opposite
                 * color, to further increase the contrast. This can be overridden by setting
                 * the `text-outline` style to `none` in the `dataLabels.style` option.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
                 *         Red data labels
                 * @sample {highmaps} maps/demo/color-axis/
                 *         White data labels
                 * @apioption plotOptions.series.dataLabels.color
                 */

                /**
                 * Whether to hide data labels that are outside the plot area. By default,
                 * the data label is moved inside the plot area according to the [overflow](#plotOptions.
                 * series.dataLabels.overflow) option.
                 * 
                 * @type {Boolean}
                 * @default true
                 * @since 2.3.3
                 * @apioption plotOptions.series.dataLabels.crop
                 */

                /**
                 * Whether to defer displaying the data labels until the initial series
                 * animation has finished.
                 * 
                 * @type {Boolean}
                 * @default true
                 * @since 4.0
                 * @product highcharts highstock
                 * @apioption plotOptions.series.dataLabels.defer
                 */

                /**
                 * Enable or disable the data labels.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/ Data labels enabled
                 * @sample {highmaps} maps/demo/color-axis/ Data labels enabled
                 * @default false
                 * @apioption plotOptions.series.dataLabels.enabled
                 */

                /**
                 * A [format string](http://www.highcharts.com/docs/chart-concepts/labels-
                 * and-string-formatting) for the data label. Available variables are
                 * the same as for `formatter`.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/ Add a unit
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-format/ Add a unit
                 * @sample {highmaps} maps/plotoptions/series-datalabels-format/ Formatted value in the data label
                 * @default {highcharts} {y}
                 * @default {highstock} {y}
                 * @default {highmaps} {point.value}
                 * @since 3.0
                 * @apioption plotOptions.series.dataLabels.format
                 */

                /**
                 * Callback JavaScript function to format the data label. Note that
                 * if a `format` is defined, the format takes precedence and the formatter
                 * is ignored. Available data are:
                 * 
                 * <table>
                 * 
                 * <tbody>
                 * 
                 * <tr>
                 * 
                 * <td>`this.percentage`</td>
                 * 
                 * <td>Stacked series and pies only. The point's percentage of the
                 * total.</td>
                 * 
                 * </tr>
                 * 
                 * <tr>
                 * 
                 * <td>`this.point`</td>
                 * 
                 * <td>The point object. The point name, if defined, is available
                 * through `this.point.name`.</td>
                 * 
                 * </tr>
                 * 
                 * <tr>
                 * 
                 * <td>`this.series`:</td>
                 * 
                 * <td>The series object. The series name is available through `this.
                 * series.name`.</td>
                 * 
                 * </tr>
                 * 
                 * <tr>
                 * 
                 * <td>`this.total`</td>
                 * 
                 * <td>Stacked series only. The total value at this point's x value.
                 * </td>
                 * 
                 * </tr>
                 * 
                 * <tr>
                 * 
                 * <td>`this.x`:</td>
                 * 
                 * <td>The x value.</td>
                 * 
                 * </tr>
                 * 
                 * <tr>
                 * 
                 * <td>`this.y`:</td>
                 * 
                 * <td>The y value.</td>
                 * 
                 * </tr>
                 * 
                 * </tbody>
                 * 
                 * </table>
                 * 
                 * @type {Function}
                 * @sample {highmaps} maps/plotoptions/series-datalabels-format/ Formatted value
                 */
                formatter: function() {
                    return this.y === null ? '' : H.numberFormat(this.y, -1);
                },



                /**
                 * Styles for the label. The default `color` setting is `"contrast"`,
                 * which is a pseudo color that Highcharts picks up and applies the
                 * maximum contrast to the underlying point item, for example the
                 * bar in a bar chart.
                 * 
                 * The `textOutline` is a pseudo property that
                 * applies an outline of the given width with the given color, which
                 * by default is the maximum contrast to the text. So a bright text
                 * color will result in a black text outline for maximum readability
                 * on a mixed background. In some cases, especially with grayscale
                 * text, the text outline doesn't work well, in which cases it can
                 * be disabled by setting it to `"none"`. When `useHTML` is true, the
                 * `textOutline` will not be picked up. In this, case, the same effect
                 * can be acheived through the `text-shadow` CSS property.
                 * 
                 * @type {CSSObject}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
                 *         Bold labels
                 * @sample {highmaps} maps/demo/color-axis/ Bold labels
                 * @default {"color": "contrast", "fontSize": "11px", "fontWeight": "bold", "textOutline": "1px contrast" }
                 * @since 4.1.0
                 */
                style: {
                    fontSize: '11px',
                    fontWeight: 'bold',
                    color: 'contrast',
                    textOutline: '1px contrast'
                },

                /**
                 * The background color or gradient for the data label.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highmaps} maps/plotoptions/series-datalabels-box/ Data labels box options
                 * @since 2.2.1
                 * @apioption plotOptions.series.dataLabels.backgroundColor
                 */

                /**
                 * The border color for the data label. Defaults to `undefined`.
                 * 
                 * @type {Color}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @default undefined
                 * @since 2.2.1
                 * @apioption plotOptions.series.dataLabels.borderColor
                 */

                /**
                 * The shadow of the box. Works best with `borderWidth` or `backgroundColor`.
                 * Since 2.3 the shadow can be an object configuration containing `color`,
                 *  `offsetX`, `offsetY`, `opacity` and `width`.
                 * 
                 * @type {Boolean|Object}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @default false
                 * @since 2.2.1
                 * @apioption plotOptions.series.dataLabels.shadow
                 */


                /**
                 * For points with an extent, like columns or map areas, whether to align the data
                 * label inside the box or to the actual value point. Defaults to `false`
                 * in most cases, `true` in stacked columns.
                 * 
                 * @type {Boolean}
                 * @since 3.0
                 * @apioption plotOptions.series.dataLabels.inside
                 */

                /**
                 * How to handle data labels that flow outside the plot area. The default
                 * is `justify`, which aligns them inside the plot area. For columns
                 * and bars, this means it will be moved inside the bar. To display
                 * data labels outside the plot area, set `crop` to `false` and `overflow`
                 * to `"none"`.
                 * 
                 * @validvalue ["justify", "none"]
                 * @type {String}
                 * @default justify
                 * @since 3.0.6
                 * @apioption plotOptions.series.dataLabels.overflow
                 */

                /**
                 * Text rotation in degrees. Note that due to a more complex structure,
                 * backgrounds, borders and padding will be lost on a rotated data
                 * label.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/ Vertical labels
                 * @default 0
                 * @apioption plotOptions.series.dataLabels.rotation
                 */

                /**
                 * The vertical alignment of a data label. Can be one of `top`, `middle`
                 * or `bottom`. The default value depends on the data, for instance
                 * in a column chart, the label is above positive values and below
                 * negative values.
                 * 
                 * @validvalue ["top", "middle", "bottom"]
                 * @type {String}
                 * @since 2.3.3
                 */
                verticalAlign: 'bottom', // above singular point


                /**
                 * The x position offset of the label relative to the point.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/ Vertical and positioned
                 * @default 0
                 */
                x: 0,


                /**
                 * The y position offset of the label relative to the point.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/ Vertical and positioned
                 * @default -6
                 */
                y: 0,


                /**
                 * When either the `borderWidth` or the `backgroundColor` is set,
                 * this is the padding within the box.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-box/ Data labels box options
                 * @sample {highmaps} maps/plotoptions/series-datalabels-box/ Data labels box options
                 * @default {highcharts} 5
                 * @default {highstock} 5
                 * @default {highmaps} 0
                 * @since 2.2.1
                 */
                padding: 5

                /**
                 * The name of a symbol to use for the border around the label. Symbols
                 * are predefined functions on the Renderer object.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/ A callout for annotations
                 * @sample {highstock} highcharts/plotoptions/series-datalabels-shape/ A callout for annotations
                 * @sample {highmaps} highcharts/plotoptions/series-datalabels-shape/ A callout for annotations (Highcharts demo)
                 * @default square
                 * @since 4.1.2
                 * @apioption plotOptions.series.dataLabels.shape
                 */

                /**
                 * The Z index of the data labels. The default Z index puts it above
                 * the series. Use a Z index of 2 to display it behind the series.
                 * 
                 * @type {Number}
                 * @default 6
                 * @since 2.3.5
                 * @apioption plotOptions.series.dataLabels.zIndex
                 */
            },
            // draw points outside the plot area when the number of points is less than
            // this



            /**
             * When the series contains less points than the crop threshold, all
             * points are drawn, even if the points fall outside the visible plot
             * area at the current zoom. The advantage of drawing all points (including
             * markers and columns), is that animation is performed on updates.
             * On the other hand, when the series contains more points than the
             * crop threshold, the series data is cropped to only contain points
             * that fall within the plot area. The advantage of cropping away invisible
             * points is to increase performance on large series.
             * 
             * @type {Number}
             * @default 300
             * @since 2.2
             * @product highcharts highstock
             */
            cropThreshold: 300,



            /**
             * The width of each point on the x axis. For example in a column chart
             * with one value each day, the pointRange would be 1 day (= 24 * 3600
             * * 1000 milliseconds). This is normally computed automatically, but
             * this option can be used to override the automatic value.
             * 
             * @type {Number}
             * @default 0
             * @product highstock
             */
            pointRange: 0,

            /**
             * When this is true, the series will not cause the Y axis to cross
             * the zero plane (or [threshold](#plotOptions.series.threshold) option)
             * unless the data actually crosses the plane.
             * 
             * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
             * 3 will make the Y axis show negative values according to the `minPadding`
             * option. If `softThreshold` is `true`, the Y axis starts at 0.
             * 
             * @type {Boolean}
             * @default true
             * @since 4.1.9
             * @product highcharts highstock
             */
            softThreshold: true,



            /**
             * A wrapper object for all the series options in specific states.
             * 
             * @type {plotOptions.series.states}
             */
            states: {


                /**
                 * Options for the hovered series. These settings override the normal
                 * state options when a series is moused over or touched.
                 *
                 */
                hover: {

                    /**
                     * Enable separate styles for the hovered series to visualize that the
                     * user hovers either the series itself or the legend. .
                     * 
                     * @type {Boolean}
                     * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/ Line
                     * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/ Column
                     * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/ Pie
                     * @default true
                     * @since 1.2
                     * @apioption plotOptions.series.states.hover.enabled
                     */


                    /**
                     * Animation setting for hovering the graph in line-type series.
                     * 
                     * @type {Boolean|Object}
                     * @default { "duration": 50 }
                     * @since 5.0.8
                     * @product highcharts
                     */
                    animation: {
                        /**
                         * The duration of the hover animation in milliseconds. By
                         * default the hover state animates quickly in, and slowly back
                         * to normal.
                         */
                        duration: 50
                    },

                    /**
                     * Pixel with of the graph line. By default this property is
                     * undefined, and the `lineWidthPlus` property dictates how much
                     * to increase the linewidth from normal state.
                     * 
                     * @type {Number}
                     * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
                     *         5px line on hover
                     * @default undefined
                     * @product highcharts highstock
                     * @apioption plotOptions.series.states.hover.lineWidth
                     */


                    /**
                     * The additional line width for the graph of a hovered series.
                     * 
                     * @type {Number}
                     * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
                     *         5 pixels wider
                     * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
                     *         5 pixels wider
                     * @default 1
                     * @since 4.0.3
                     * @product highcharts highstock
                     */
                    lineWidthPlus: 1,



                    /**
                     * In Highcharts 1.0, the appearance of all markers belonging to
                     * the hovered series. For settings on the hover state of the individual
                     * point, see [marker.states.hover](#plotOptions.series.marker.states.
                     * hover).
                     * 
                     * @extends plotOptions.series.marker
                     * @deprecated
                     * @product highcharts highstock
                     */
                    marker: {
                        // lineWidth: base + 1,
                        // radius: base + 1
                    },



                    /**
                     * Options for the halo appearing around the hovered point in line-
                     * type series as well as outside the hovered slice in pie charts.
                     * By default the halo is filled by the current point or series
                     * color with an opacity of 0.25\. The halo can be disabled by setting
                     * the `halo` option to `false`.
                     * 
                     * In styled mode, the halo is styled with the `.highcharts-halo` class, with colors inherited from `.highcharts-color-{n}`.
                     * 
                     * @type {Object}
                     * @sample {highcharts} highcharts/plotoptions/halo/ Halo options
                     * @sample {highstock} highcharts/plotoptions/halo/ Halo options
                     * @since 4.0
                     * @product highcharts highstock
                     */
                    halo: {

                        /**
                         * A collection of SVG attributes to override the appearance of the
                         * halo, for example `fill`, `stroke` and `stroke-width`.
                         * 
                         * @type {Object}
                         * @since 4.0
                         * @product highcharts highstock
                         * @apioption plotOptions.series.states.hover.halo.attributes
                         */


                        /**
                         * The pixel size of the halo. For point markers this is the radius
                         * of the halo. For pie slices it is the width of the halo outside
                         * the slice. For bubbles it defaults to 5 and is the width of the
                         * halo outside the bubble.
                         * 
                         * @type {Number}
                         * @default 10
                         * @since 4.0
                         * @product highcharts highstock
                         */
                        size: 10,




                        /**
                         * Opacity for the halo unless a specific fill is overridden using
                         * the `attributes` setting. Note that Highcharts is only able to
                         * apply opacity to colors of hex or rgb(a) formats.
                         * 
                         * @type {Number}
                         * @default 0.25
                         * @since 4.0
                         * @product highcharts highstock
                         */
                        opacity: 0.25

                    }
                },


                /**
                 * Specific options for point in selected states, after being selected
                 * by [allowPointSelect](#plotOptions.series.allowPointSelect) or
                 * programmatically.
                 * 
                 * @type {Object}
                 * @extends plotOptions.series.states.hover
                 * @excluding brightness
                 * @sample {highmaps} maps/plotoptions/series-allowpointselect/
                 *         Allow point select demo
                 * @product highmaps
                 */
                select: {
                    marker: {}
                }
            },



            /**
             * Sticky tracking of mouse events. When true, the `mouseOut` event
             * on a series isn't triggered until the mouse moves over another series,
             * or out of the plot area. When false, the `mouseOut` event on a
             * series is triggered when the mouse leaves the area around the series'
             * graph or markers. This also implies the tooltip when not shared. When
             * `stickyTracking` is false and `tooltip.shared` is false, the tooltip will
             * be hidden when moving the mouse between series. Defaults to true for line
             * and area type series, but to false for columns, pies etc.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
             *         True by default
             * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
             *         False
             * @default {highcharts} true
             * @default {highstock} true
             * @default {highmaps} false
             * @since 2.0
             */
            stickyTracking: true,

            /**
             * A configuration object for the tooltip rendering of each single series.
             * Properties are inherited from [tooltip](#tooltip), but only the
             * following properties can be defined on a series level.
             * 
             * @type {Object}
             * @extends tooltip
             * @excluding animation,backgroundColor,borderColor,borderRadius,borderWidth,crosshairs,enabled,formatter,positioner,shadow,shared,shape,snap,style,useHTML
             * @since 2.3
             * @apioption plotOptions.series.tooltip
             */

            /**
             * When a series contains a data array that is longer than this, only
             * one dimensional arrays of numbers, or two dimensional arrays with
             * x and y values are allowed. Also, only the first point is tested,
             * and the rest are assumed to be the same format. This saves expensive
             * data checking and indexing in long series. Set it to `0` disable.
             * 
             * @type {Number}
             * @default 1000
             * @since 2.2
             * @product highcharts highstock
             */
            turboThreshold: 1000,

            /**
             * An array defining zones within a series. Zones can be applied to
             * the X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
             * option.
             * 
             * In styled mode, the color zones are styled with the `.highcharts-
             * zone-{n}` class, or custom classed from the `className` option ([view
             * live demo](http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-
             * zones/)).
             * 
             * @type {Array}
             * @see [zoneAxis](#plotOptions.series.zoneAxis)
             * @sample {highcharts} highcharts/series/color-zones-simple/ Color zones
             * @sample {highstock} highcharts/series/color-zones-simple/ Color zones
             * @since 4.1.0
             * @product highcharts highstock
             * @apioption plotOptions.series.zones
             */

            /**
             * Styled mode only. A custom class name for the zone.
             * 
             * @type {String}
             * @sample {highcharts} highcharts/css/color-zones/ Zones styled by class name
             * @sample {highstock} highcharts/css/color-zones/ Zones styled by class name
             * @sample {highmaps} highcharts/css/color-zones/ Zones styled by class name
             * @since 5.0.0
             * @apioption plotOptions.series.zones.className
             */

            /**
             * Defines the color of the series.
             * 
             * @type {Color}
             * @see [series color](#plotOptions.series.color)
             * @since 4.1.0
             * @product highcharts highstock
             * @apioption plotOptions.series.zones.color
             */

            /**
             * A name for the dash style to use for the graph.
             * 
             * @type {String}
             * @see [series.dashStyle](#plotOptions.series.dashStyle)
             * @sample {highcharts} highcharts/series/color-zones-dashstyle-dot/
             *         Dashed line indicates prognosis
             * @sample {highstock} highcharts/series/color-zones-dashstyle-dot/
             *         Dashed line indicates prognosis
             * @since 4.1.0
             * @product highcharts highstock
             * @apioption plotOptions.series.zones.dashStyle
             */

            /**
             * Defines the fill color for the series (in area type series)
             * 
             * @type {Color}
             * @see [fillColor](#plotOptions.area.fillColor)
             * @since 4.1.0
             * @product highcharts highstock
             * @apioption plotOptions.series.zones.fillColor
             */

            /**
             * The value up to where the zone extends, if undefined the zones stretches
             * to the last value in the series.
             * 
             * @type {Number}
             * @default undefined
             * @since 4.1.0
             * @product highcharts highstock
             * @apioption plotOptions.series.zones.value
             */



            /**
             * Determines whether the series should look for the nearest point
             * in both dimensions or just the x-dimension when hovering the series.
             * Defaults to `'xy'` for scatter series and `'x'` for most other
             * series. If the data has duplicate x-values, it is recommended to
             * set this to `'xy'` to allow hovering over all points.
             * 
             * Applies only to series types using nearest neighbor search (not
             * direct hover) for tooltip.
             * 
             * @validvalue ['x', 'xy']
             * @type {String}
             * @sample {highcharts} highcharts/series/findnearestpointby/
             *         Different hover behaviors
             * @sample {highstock} highcharts/series/findnearestpointby/
             *         Different hover behaviors
             * @sample {highmaps} highcharts/series/findnearestpointby/
             *         Different hover behaviors
             * @since 5.0.10
             */
            findNearestPointBy: 'x'

        }, /** @lends Highcharts.Series.prototype */ {
            isCartesian: true,
            pointClass: Point,
            sorted: true, // requires the data to be sorted
            requireSorting: true,
            directTouch: false,
            axisTypes: ['xAxis', 'yAxis'],
            colorCounter: 0,
            // each point's x and y values are stored in this.xData and this.yData
            parallelArrays: ['x', 'y'],
            coll: 'series',
            init: function(chart, options) {
                var series = this,
                    events,
                    chartSeries = chart.series,
                    lastSeries;

                /**
                 * Read only. The chart that the series belongs to.
                 *
                 * @name chart
                 * @memberOf Series
                 * @type {Chart}
                 */
                series.chart = chart;

                /**
                 * Read only. The series' type, like "line", "area", "column" etc. The
                 * type in the series options anc can be altered using {@link
                 * Series#update}.
                 *
                 * @name type
                 * @memberOf Series
                 * @type String
                 */

                /**
                 * Read only. The series' current options. To update, use {@link
                 * Series#update}.
                 *
                 * @name options
                 * @memberOf Series
                 * @type SeriesOptions
                 */
                series.options = options = series.setOptions(options);
                series.linkedSeries = [];

                // bind the axes
                series.bindAxes();

                // set some variables
                extend(series, {
                    /**
                     * The series name as given in the options. Defaults to
                     * "Series {n}".
                     *
                     * @name name
                     * @memberOf Series
                     * @type {String}
                     */
                    name: options.name,
                    state: '',
                    /**
                     * Read only. The series' visibility state as set by {@link
                     * Series#show}, {@link Series#hide}, or in the initial
                     * configuration.
                     *
                     * @name visible
                     * @memberOf Series
                     * @type {Boolean}
                     */
                    visible: options.visible !== false, // true by default
                    /**
                     * Read only. The series' selected state as set by {@link
                     * Highcharts.Series#select}.
                     *
                     * @name selected
                     * @memberOf Series
                     * @type {Boolean}
                     */
                    selected: options.selected === true // false by default
                });

                // register event listeners
                events = options.events;

                objectEach(events, function(event, eventType) {
                    addEvent(series, eventType, event);
                });
                if (
                    (events && events.click) ||
                    (
                        options.point &&
                        options.point.events &&
                        options.point.events.click
                    ) ||
                    options.allowPointSelect
                ) {
                    chart.runTrackerClick = true;
                }

                series.getColor();
                series.getSymbol();

                // Set the data
                each(series.parallelArrays, function(key) {
                    series[key + 'Data'] = [];
                });
                series.setData(options.data, false);

                // Mark cartesian
                if (series.isCartesian) {
                    chart.hasCartesianSeries = true;
                }

                // Get the index and register the series in the chart. The index is one
                // more than the current latest series index (#5960).
                if (chartSeries.length) {
                    lastSeries = chartSeries[chartSeries.length - 1];
                }
                series._i = pick(lastSeries && lastSeries._i, -1) + 1;

                // Insert the series and re-order all series above the insertion point.
                chart.orderSeries(this.insert(chartSeries));
            },

            /**
             * Insert the series in a collection with other series, either the chart
             * series or yAxis series, in the correct order according to the index
             * option. Used internally when adding series.
             *
             * @private
             * @param   {Array.<Series>} collection
             *          A collection of series, like `chart.series` or `xAxis.series`.
             * @returns {Number} The index of the series in the collection.
             */
            insert: function(collection) {
                var indexOption = this.options.index,
                    i;

                // Insert by index option
                if (isNumber(indexOption)) {
                    i = collection.length;
                    while (i--) {
                        // Loop down until the interted element has higher index
                        if (indexOption >=
                            pick(collection[i].options.index, collection[i]._i)) {
                            collection.splice(i + 1, 0, this);
                            break;
                        }
                    }
                    if (i === -1) {
                        collection.unshift(this);
                    }
                    i = i + 1;

                    // Or just push it to the end
                } else {
                    collection.push(this);
                }
                return pick(i, collection.length - 1);
            },

            /**
             * Set the xAxis and yAxis properties of cartesian series, and register the
             * series in the `axis.series` array.
             *
             * @private
             */
            bindAxes: function() {
                var series = this,
                    seriesOptions = series.options,
                    chart = series.chart,
                    axisOptions;

                // repeat for xAxis and yAxis
                each(series.axisTypes || [], function(AXIS) {

                    // loop through the chart's axis objects
                    each(chart[AXIS], function(axis) {
                        axisOptions = axis.options;

                        // apply if the series xAxis or yAxis option mathches the number
                        // of the axis, or if undefined, use the first axis
                        if (
                            seriesOptions[AXIS] === axisOptions.index ||
                            (
                                seriesOptions[AXIS] !== undefined &&
                                seriesOptions[AXIS] === axisOptions.id
                            ) ||
                            (
                                seriesOptions[AXIS] === undefined &&
                                axisOptions.index === 0
                            )
                        ) {

                            // register this series in the axis.series lookup
                            series.insert(axis.series);

                            // set this series.xAxis or series.yAxis reference
                            /**
                             * Read only. The unique xAxis object associated with the
                             * series.
                             *
                             * @name xAxis
                             * @memberOf Series
                             * @type Axis
                             */
                            /**
                             * Read only. The unique yAxis object associated with the
                             * series.
                             *
                             * @name yAxis
                             * @memberOf Series
                             * @type Axis
                             */
                            series[AXIS] = axis;

                            // mark dirty for redraw
                            axis.isDirty = true;
                        }
                    });

                    // The series needs an X and an Y axis
                    if (!series[AXIS] && series.optionalAxis !== AXIS) {
                        H.error(18, true);
                    }

                });
            },

            /**
             * For simple series types like line and column, the data values are held in
             * arrays like xData and yData for quick lookup to find extremes and more.
             * For multidimensional series like bubble and map, this can be extended
             * with arrays like zData and valueData by adding to the
             * `series.parallelArrays` array.
             *
             * @private
             */
            updateParallelArrays: function(point, i) {
                var series = point.series,
                    args = arguments,
                    fn = isNumber(i) ?
                    // Insert the value in the given position
                    function(key) {
                        var val = key === 'y' && series.toYData ?
                            series.toYData(point) :
                            point[key];
                        series[key + 'Data'][i] = val;
                    } :
                    // Apply the method specified in i with the following arguments
                    // as arguments
                    function(key) {
                        Array.prototype[i].apply(
                            series[key + 'Data'],
                            Array.prototype.slice.call(args, 2)
                        );
                    };

                each(series.parallelArrays, fn);
            },

            /**
             * Return an auto incremented x value based on the pointStart and
             * pointInterval options. This is only used if an x value is not given for
             * the point that calls autoIncrement.
             *
             * @private
             */
            autoIncrement: function() {

                var options = this.options,
                    xIncrement = this.xIncrement,
                    date,
                    pointInterval,
                    pointIntervalUnit = options.pointIntervalUnit;

                xIncrement = pick(xIncrement, options.pointStart, 0);

                this.pointInterval = pointInterval = pick(
                    this.pointInterval,
                    options.pointInterval,
                    1
                );

                // Added code for pointInterval strings
                if (pointIntervalUnit) {
                    date = new Date(xIncrement);

                    if (pointIntervalUnit === 'day') {
                        date = +date[Date.hcSetDate](
                            date[Date.hcGetDate]() + pointInterval
                        );
                    } else if (pointIntervalUnit === 'month') {
                        date = +date[Date.hcSetMonth](
                            date[Date.hcGetMonth]() + pointInterval
                        );
                    } else if (pointIntervalUnit === 'year') {
                        date = +date[Date.hcSetFullYear](
                            date[Date.hcGetFullYear]() + pointInterval
                        );
                    }
                    pointInterval = date - xIncrement;

                }

                this.xIncrement = xIncrement + pointInterval;
                return xIncrement;
            },

            /**
             * Set the series options by merging from the options tree. Called
             * internally on initiating and updating series. This function will not
             * redraw the series. For API usage, use {@link Series#update}.
             * 
             * @param  {Options.plotOptions.series} itemOptions
             *         The series options.
             */
            setOptions: function(itemOptions) {
                var chart = this.chart,
                    chartOptions = chart.options,
                    plotOptions = chartOptions.plotOptions,
                    userOptions = chart.userOptions || {},
                    userPlotOptions = userOptions.plotOptions || {},
                    typeOptions = plotOptions[this.type],
                    options,
                    zones;

                this.userOptions = itemOptions;

                // General series options take precedence over type options because
                // otherwise, default type options like column.animation would be
                // overwritten by the general option. But issues have been raised here
                // (#3881), and the solution may be to distinguish between default
                // option and userOptions like in the tooltip below.
                options = merge(
                    typeOptions,
                    plotOptions.series,
                    itemOptions
                );

                // The tooltip options are merged between global and series specific
                // options. Importance order asscendingly:
                // globals: (1)tooltip, (2)plotOptions.series, (3)plotOptions[this.type]
                // init userOptions with possible later updates: 4-6 like 1-3 and
                // (7)this series options
                this.tooltipOptions = merge(
                    defaultOptions.tooltip, // 1
                    defaultOptions.plotOptions.series &&
                    defaultOptions.plotOptions.series.tooltip, // 2
                    defaultOptions.plotOptions[this.type].tooltip, // 3
                    chartOptions.tooltip.userOptions, // 4
                    plotOptions.series && plotOptions.series.tooltip, // 5
                    plotOptions[this.type].tooltip, // 6
                    itemOptions.tooltip // 7
                );

                // When shared tooltip, stickyTracking is true by default,
                // unless user says otherwise.
                this.stickyTracking = pick(
                    itemOptions.stickyTracking,
                    userPlotOptions[this.type] &&
                    userPlotOptions[this.type].stickyTracking,
                    userPlotOptions.series && userPlotOptions.series.stickyTracking,
                    (
                        this.tooltipOptions.shared && !this.noSharedTooltip ?
                        true :
                        options.stickyTracking
                    )
                );

                // Delete marker object if not allowed (#1125)
                if (typeOptions.marker === null) {
                    delete options.marker;
                }

                // Handle color zones
                this.zoneAxis = options.zoneAxis;
                zones = this.zones = (options.zones || []).slice();
                if (
                    (options.negativeColor || options.negativeFillColor) &&
                    !options.zones
                ) {
                    zones.push({
                        value: options[this.zoneAxis + 'Threshold'] ||
                            options.threshold ||
                            0,
                        className: 'highcharts-negative',

                        color: options.negativeColor,
                        fillColor: options.negativeFillColor

                    });
                }
                if (zones.length) { // Push one extra zone for the rest
                    if (defined(zones[zones.length - 1].value)) {
                        zones.push({

                            color: this.color,
                            fillColor: this.fillColor

                        });
                    }
                }
                return options;
            },

            getCyclic: function(prop, value, defaults) {
                var i,
                    chart = this.chart,
                    userOptions = this.userOptions,
                    indexName = prop + 'Index',
                    counterName = prop + 'Counter',
                    len = defaults ? defaults.length : pick(
                        chart.options.chart[prop + 'Count'],
                        chart[prop + 'Count']
                    ),
                    setting;

                if (!value) {
                    // Pick up either the colorIndex option, or the _colorIndex after
                    // Series.update()
                    setting = pick(
                        userOptions[indexName],
                        userOptions['_' + indexName]
                    );
                    if (defined(setting)) { // after Series.update()
                        i = setting;
                    } else {
                        // #6138
                        if (!chart.series.length) {
                            chart[counterName] = 0;
                        }
                        userOptions['_' + indexName] = i = chart[counterName] % len;
                        chart[counterName] += 1;
                    }
                    if (defaults) {
                        value = defaults[i];
                    }
                }
                // Set the colorIndex
                if (i !== undefined) {
                    this[indexName] = i;
                }
                this[prop] = value;
            },

            /**
             * Get the series' color based on either the options or pulled from global
             * options.
             *
             * @return  {Color} The series color.
             */

            getColor: function() {
                if (this.options.colorByPoint) {
                    // #4359, selected slice got series.color even when colorByPoint was
                    // set.
                    this.options.color = null;
                } else {
                    this.getCyclic(
                        'color',
                        this.options.color || defaultPlotOptions[this.type].color,
                        this.chart.options.colors
                    );
                }
            },

            /**
             * Get the series' symbol based on either the options or pulled from global
             * options.
             */
            getSymbol: function() {
                var seriesMarkerOption = this.options.marker;

                this.getCyclic(
                    'symbol',
                    seriesMarkerOption.symbol,
                    this.chart.options.symbols
                );
            },

            drawLegendSymbol: LegendSymbolMixin.drawLineMarker,

            /**
             * Apply a new set of data to the series and optionally redraw it. The new
             * data array is passed by reference (except in case of `updatePoints`), and
             * may later be mutated when updating the chart data.
             *
             * Note the difference in behaviour when setting the same amount of points,
             * or a different amount of points, as handled by the `updatePoints`
             * parameter.
             *
             * @param  {SeriesDataOptions} data
             *         Takes an array of data in the same format as described under
             *         `series.typedata` for the given series type.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after the series is altered. If doing
             *         more operations on the chart, it is a good idea to set redraw to
             *         false and call {@link Chart#redraw} after.
             * @param  {AnimationOptions} [animation]
             *         When the updated data is the same length as the existing data,
             *         points will be updated by default, and animation visualizes how
             *         the points are changed. Set false to disable animation, or a
             *         configuration object to set duration or easing.
             * @param  {Boolean} [updatePoints=true]
             *         When the updated data is the same length as the existing data,
             *         points will be updated instead of replaced. This allows updating
             *         with animation and performs better. In this case, the original
             *         array is not passed by reference. Set false to prevent.
             *
             * @sample highcharts/members/series-setdata/
             *         Set new data from a button
             * @sample highcharts/members/series-setdata-pie/
             *         Set data in a pie
             * @sample stock/members/series-setdata/
             *         Set new data in Highstock
             * @sample maps/members/series-setdata/
             *         Set new data in Highmaps
             */
            setData: function(data, redraw, animation, updatePoints) {
                var series = this,
                    oldData = series.points,
                    oldDataLength = (oldData && oldData.length) || 0,
                    dataLength,
                    options = series.options,
                    chart = series.chart,
                    firstPoint = null,
                    xAxis = series.xAxis,
                    i,
                    turboThreshold = options.turboThreshold,
                    pt,
                    xData = this.xData,
                    yData = this.yData,
                    pointArrayMap = series.pointArrayMap,
                    valueCount = pointArrayMap && pointArrayMap.length;

                data = data || [];
                dataLength = data.length;
                redraw = pick(redraw, true);

                // If the point count is the same as is was, just run Point.update which
                // is cheaper, allows animation, and keeps references to points.
                if (
                    updatePoints !== false &&
                    dataLength &&
                    oldDataLength === dataLength &&
                    !series.cropped &&
                    !series.hasGroupedData &&
                    series.visible
                ) {
                    each(data, function(point, i) {
                        // .update doesn't exist on a linked, hidden series (#3709)
                        if (oldData[i].update && point !== options.data[i]) {
                            oldData[i].update(point, false, null, false);
                        }
                    });

                } else {

                    // Reset properties
                    series.xIncrement = null;

                    series.colorCounter = 0; // for series with colorByPoint (#1547)

                    // Update parallel arrays
                    each(this.parallelArrays, function(key) {
                        series[key + 'Data'].length = 0;
                    });

                    // In turbo mode, only one- or twodimensional arrays of numbers are
                    // allowed. The first value is tested, and we assume that all the
                    // rest are defined the same way. Although the 'for' loops are
                    // similar, they are repeated inside each if-else conditional for
                    // max performance.
                    if (turboThreshold && dataLength > turboThreshold) {

                        // find the first non-null point
                        i = 0;
                        while (firstPoint === null && i < dataLength) {
                            firstPoint = data[i];
                            i++;
                        }


                        if (isNumber(firstPoint)) { // assume all points are numbers
                            for (i = 0; i < dataLength; i++) {
                                xData[i] = this.autoIncrement();
                                yData[i] = data[i];
                            }

                            // Assume all points are arrays when first point is
                        } else if (isArray(firstPoint)) {
                            if (valueCount) { // [x, low, high] or [x, o, h, l, c]
                                for (i = 0; i < dataLength; i++) {
                                    pt = data[i];
                                    xData[i] = pt[0];
                                    yData[i] = pt.slice(1, valueCount + 1);
                                }
                            } else { // [x, y]
                                for (i = 0; i < dataLength; i++) {
                                    pt = data[i];
                                    xData[i] = pt[0];
                                    yData[i] = pt[1];
                                }
                            }
                        } else {
                            // Highcharts expects configs to be numbers or arrays in
                            // turbo mode
                            H.error(12);
                        }
                    } else {
                        for (i = 0; i < dataLength; i++) {
                            if (data[i] !== undefined) { // stray commas in oldIE
                                pt = {
                                    series: series
                                };
                                series.pointClass.prototype.applyOptions.apply(
                                    pt, [data[i]]
                                );
                                series.updateParallelArrays(pt, i);
                            }
                        }
                    }

                    // Forgetting to cast strings to numbers is a common caveat when
                    // handling CSV or JSON
                    if (yData && isString(yData[0])) {
                        H.error(14, true);
                    }

                    series.data = [];
                    series.options.data = series.userOptions.data = data;

                    // destroy old points
                    i = oldDataLength;
                    while (i--) {
                        if (oldData[i] && oldData[i].destroy) {
                            oldData[i].destroy();
                        }
                    }

                    // reset minRange (#878)
                    if (xAxis) {
                        xAxis.minRange = xAxis.userMinRange;
                    }

                    // redraw
                    series.isDirty = chart.isDirtyBox = true;
                    series.isDirtyData = !!oldData;
                    animation = false;
                }

                // Typically for pie series, points need to be processed and generated
                // prior to rendering the legend
                if (options.legendType === 'point') {
                    this.processData();
                    this.generatePoints();
                }

                if (redraw) {
                    chart.redraw(animation);
                }
            },

            /**
             * Internal function to process the data by cropping away unused data points
             * if the series is longer than the crop threshold. This saves computing
             * time for large series. In Highstock, this function is extended to
             * provide data grouping.
             *
             * @private
             * @param  {Boolean} force
             *         Force data grouping.
             */
            processData: function(force) {
                var series = this,
                    processedXData = series.xData, // copied during slice operation
                    processedYData = series.yData,
                    dataLength = processedXData.length,
                    croppedData,
                    cropStart = 0,
                    cropped,
                    distance,
                    closestPointRange,
                    xAxis = series.xAxis,
                    i, // loop variable
                    options = series.options,
                    cropThreshold = options.cropThreshold,
                    getExtremesFromAll =
                    series.getExtremesFromAll ||
                    options.getExtremesFromAll, // #4599
                    isCartesian = series.isCartesian,
                    xExtremes,
                    val2lin = xAxis && xAxis.val2lin,
                    isLog = xAxis && xAxis.isLog,
                    min,
                    max;

                // If the series data or axes haven't changed, don't go through this.
                // Return false to pass the message on to override methods like in data
                // grouping.
                if (
                    isCartesian &&
                    !series.isDirty &&
                    !xAxis.isDirty &&
                    !series.yAxis.isDirty &&
                    !force
                ) {
                    return false;
                }

                if (xAxis) {
                    xExtremes = xAxis.getExtremes(); // corrected for log axis (#3053)
                    min = xExtremes.min;
                    max = xExtremes.max;
                }

                // optionally filter out points outside the plot area
                if (
                    isCartesian &&
                    series.sorted &&
                    !getExtremesFromAll &&
                    (!cropThreshold || dataLength > cropThreshold || series.forceCrop)
                ) {

                    // it's outside current extremes
                    if (
                        processedXData[dataLength - 1] < min ||
                        processedXData[0] > max
                    ) {
                        processedXData = [];
                        processedYData = [];

                        // only crop if it's actually spilling out
                    } else if (
                        processedXData[0] < min ||
                        processedXData[dataLength - 1] > max
                    ) {
                        croppedData = this.cropData(
                            series.xData,
                            series.yData,
                            min,
                            max
                        );
                        processedXData = croppedData.xData;
                        processedYData = croppedData.yData;
                        cropStart = croppedData.start;
                        cropped = true;
                    }
                }


                // Find the closest distance between processed points
                i = processedXData.length || 1;
                while (--i) {
                    distance = isLog ?
                        val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
                        processedXData[i] - processedXData[i - 1];

                    if (
                        distance > 0 &&
                        (
                            closestPointRange === undefined ||
                            distance < closestPointRange
                        )
                    ) {
                        closestPointRange = distance;

                        // Unsorted data is not supported by the line tooltip, as well as
                        // data grouping and navigation in Stock charts (#725) and width
                        // calculation of columns (#1900)
                    } else if (distance < 0 && series.requireSorting) {
                        H.error(15);
                    }
                }

                // Record the properties
                series.cropped = cropped; // undefined or true
                series.cropStart = cropStart;
                series.processedXData = processedXData;
                series.processedYData = processedYData;

                series.closestPointRange = closestPointRange;

            },

            /**
             * Iterate over xData and crop values between min and max. Returns object
             * containing crop start/end cropped xData with corresponding part of yData,
             * dataMin and dataMax within the cropped range.
             *
             * @private
             */
            cropData: function(xData, yData, min, max) {
                var dataLength = xData.length,
                    cropStart = 0,
                    cropEnd = dataLength,
                    // line-type series need one point outside
                    cropShoulder = pick(this.cropShoulder, 1),
                    i,
                    j;

                // iterate up to find slice start
                for (i = 0; i < dataLength; i++) {
                    if (xData[i] >= min) {
                        cropStart = Math.max(0, i - cropShoulder);
                        break;
                    }
                }

                // proceed to find slice end
                for (j = i; j < dataLength; j++) {
                    if (xData[j] > max) {
                        cropEnd = j + cropShoulder;
                        break;
                    }
                }

                return {
                    xData: xData.slice(cropStart, cropEnd),
                    yData: yData.slice(cropStart, cropEnd),
                    start: cropStart,
                    end: cropEnd
                };
            },


            /**
             * Generate the data point after the data has been processed by cropping
             * away unused points and optionally grouped in Highcharts Stock.
             *
             * @private
             */
            generatePoints: function() {
                var series = this,
                    options = series.options,
                    dataOptions = options.data,
                    data = series.data,
                    dataLength,
                    processedXData = series.processedXData,
                    processedYData = series.processedYData,
                    PointClass = series.pointClass,
                    processedDataLength = processedXData.length,
                    cropStart = series.cropStart || 0,
                    cursor,
                    hasGroupedData = series.hasGroupedData,
                    keys = options.keys,
                    point,
                    points = [],
                    i;

                if (!data && !hasGroupedData) {
                    var arr = [];
                    arr.length = dataOptions.length;
                    data = series.data = arr;
                }

                if (keys && hasGroupedData) {
                    // grouped data has already applied keys (#6590)
                    series.options.keys = false;
                }

                for (i = 0; i < processedDataLength; i++) {
                    cursor = cropStart + i;
                    if (!hasGroupedData) {
                        point = data[cursor];
                        if (!point && dataOptions[cursor] !== undefined) { // #970
                            data[cursor] = point = (new PointClass()).init(
                                series,
                                dataOptions[cursor],
                                processedXData[i]
                            );
                        }
                    } else {
                        // splat the y data in case of ohlc data array
                        point = (new PointClass()).init(
                            series, [processedXData[i]].concat(splat(processedYData[i]))
                        );

                        /**
                         * Highstock only. If a point object is created by data
                         * grouping, it doesn't reflect actual points in the raw data.
                         * In this case, the `dataGroup` property holds information
                         * that points back to the raw data.
                         *
                         * - `dataGroup.start` is the index of the first raw data point
                         * in the group.
                         * - `dataGroup.length` is the amount of points in the group.
                         *
                         * @name dataGroup
                         * @memberOf Point
                         * @type {Object}
                         *
                         */
                        point.dataGroup = series.groupMap[i];
                    }
                    if (point) { // #6279
                        point.index = cursor; // For faster access in Point.update
                        points[i] = point;
                    }
                }

                // restore keys options (#6590)
                series.options.keys = keys;

                // Hide cropped-away points - this only runs when the number of points
                // is above cropThreshold, or when swithching view from non-grouped
                // data to grouped data (#637)
                if (
                    data &&
                    (
                        processedDataLength !== (dataLength = data.length) ||
                        hasGroupedData
                    )
                ) {
                    for (i = 0; i < dataLength; i++) {
                        // when has grouped data, clear all points
                        if (i === cropStart && !hasGroupedData) {
                            i += processedDataLength;
                        }
                        if (data[i]) {
                            data[i].destroyElements();
                            data[i].plotX = undefined; // #1003
                        }
                    }
                }

                /**
                 * Read only. An array containing those values converted to points, but
                 * in case the series data length exceeds the `cropThreshold`, or if the
                 * data is grouped, `series.data` doesn't contain all the points. It
                 * only contains the points that have been created on demand. To
                 * modify the data, use {@link Highcharts.Series#setData} or {@link
                 * Highcharts.Point#update}.
                 *
                 * @name data
                 * @memberOf Highcharts.Series
                 * @see  Series.points
                 * @type {Array.<Highcharts.Point>}
                 */
                series.data = data;

                /**
                 * An array containing all currently visible point objects. In case of
                 * cropping, the cropped-away points are not part of this array. The
                 * `series.points` array starts at `series.cropStart` compared to
                 * `series.data` and `series.options.data`. If however the series data
                 * is grouped, these can't be correlated one to one. To
                 * modify the data, use {@link Highcharts.Series#setData} or {@link
                 * Highcharts.Point#update}.
                 * @name points
                 * @memberof Series
                 * @type {Array.<Point>}
                 */
                series.points = points;
            },

            /**
             * Calculate Y extremes for the visible data. The result is set as 
             * `dataMin` and `dataMax` on the Series item.
             *
             * @param  {Array.<Number>} [yData]
             *         The data to inspect. Defaults to the current data within the
             *         visible range.
             * 
             */
            getExtremes: function(yData) {
                var xAxis = this.xAxis,
                    yAxis = this.yAxis,
                    xData = this.processedXData,
                    yDataLength,
                    activeYData = [],
                    activeCounter = 0,
                    // #2117, need to compensate for log X axis
                    xExtremes = xAxis.getExtremes(),
                    xMin = xExtremes.min,
                    xMax = xExtremes.max,
                    validValue,
                    withinRange,
                    x,
                    y,
                    i,
                    j;

                yData = yData || this.stackedYData || this.processedYData || [];
                yDataLength = yData.length;

                for (i = 0; i < yDataLength; i++) {

                    x = xData[i];
                    y = yData[i];

                    // For points within the visible range, including the first point
                    // outside the visible range (#7061), consider y extremes.
                    validValue =
                        (isNumber(y, true) || isArray(y)) &&
                        (!yAxis.positiveValuesOnly || (y.length || y > 0));
                    withinRange =
                        this.getExtremesFromAll ||
                        this.options.getExtremesFromAll ||
                        this.cropped ||
                        ((xData[i + 1] || x) >= xMin && (xData[i - 1] || x) <= xMax);

                    if (validValue && withinRange) {

                        j = y.length;
                        if (j) { // array, like ohlc or range data
                            while (j--) {
                                if (y[j] !== null) {
                                    activeYData[activeCounter++] = y[j];
                                }
                            }
                        } else {
                            activeYData[activeCounter++] = y;
                        }
                    }
                }

                this.dataMin = arrayMin(activeYData);
                this.dataMax = arrayMax(activeYData);
            },

            /**
             * Translate data points from raw data values to chart specific positioning
             * data needed later in the `drawPoints` and `drawGraph` functions. This
             * function can be overridden in plugins and custom series type
             * implementations.
             */
            translate: function() {
                if (!this.processedXData) { // hidden series
                    this.processData();
                }
                this.generatePoints();
                var series = this,
                    options = series.options,
                    stacking = options.stacking,
                    xAxis = series.xAxis,
                    categories = xAxis.categories,
                    yAxis = series.yAxis,
                    points = series.points,
                    dataLength = points.length,
                    hasModifyValue = !!series.modifyValue,
                    i,
                    pointPlacement = options.pointPlacement,
                    dynamicallyPlaced =
                    pointPlacement === 'between' ||
                    isNumber(pointPlacement),
                    threshold = options.threshold,
                    stackThreshold = options.startFromThreshold ? threshold : 0,
                    plotX,
                    plotY,
                    lastPlotX,
                    stackIndicator,
                    closestPointRangePx = Number.MAX_VALUE;

                // Point placement is relative to each series pointRange (#5889)
                if (pointPlacement === 'between') {
                    pointPlacement = 0.5;
                }
                if (isNumber(pointPlacement)) {
                    pointPlacement *= pick(options.pointRange || xAxis.pointRange);
                }

                // Translate each point
                for (i = 0; i < dataLength; i++) {
                    var point = points[i],
                        xValue = point.x,
                        yValue = point.y,
                        yBottom = point.low,
                        stack = stacking && yAxis.stacks[(
                            series.negStacks &&
                            yValue < (stackThreshold ? 0 : threshold) ? '-' : ''
                        ) + series.stackKey],
                        pointStack,
                        stackValues;

                    // Discard disallowed y values for log axes (#3434)
                    if (yAxis.positiveValuesOnly && yValue !== null && yValue <= 0) {
                        point.isNull = true;
                    }

                    // Get the plotX translation
                    point.plotX = plotX = correctFloat( // #5236
                        Math.min(Math.max(-1e5, xAxis.translate(
                            xValue,
                            0,
                            0,
                            0,
                            1,
                            pointPlacement,
                            this.type === 'flags'
                        )), 1e5) // #3923
                    );

                    // Calculate the bottom y value for stacked series
                    if (
                        stacking &&
                        series.visible &&
                        !point.isNull &&
                        stack &&
                        stack[xValue]
                    ) {
                        stackIndicator = series.getStackIndicator(
                            stackIndicator,
                            xValue,
                            series.index
                        );
                        pointStack = stack[xValue];
                        stackValues = pointStack.points[stackIndicator.key];
                        yBottom = stackValues[0];
                        yValue = stackValues[1];

                        if (
                            yBottom === stackThreshold &&
                            stackIndicator.key === stack[xValue].base
                        ) {
                            yBottom = pick(threshold, yAxis.min);
                        }
                        if (yAxis.positiveValuesOnly && yBottom <= 0) { // #1200, #1232
                            yBottom = null;
                        }

                        point.total = point.stackTotal = pointStack.total;
                        point.percentage =
                            pointStack.total &&
                            (point.y / pointStack.total * 100);
                        point.stackY = yValue;

                        // Place the stack label
                        pointStack.setOffset(
                            series.pointXOffset || 0,
                            series.barW || 0
                        );

                    }

                    // Set translated yBottom or remove it
                    point.yBottom = defined(yBottom) ?
                        yAxis.translate(yBottom, 0, 1, 0, 1) :
                        null;

                    // general hook, used for Highstock compare mode
                    if (hasModifyValue) {
                        yValue = series.modifyValue(yValue, point);
                    }

                    // Set the the plotY value, reset it for redraws
                    point.plotY = plotY =
                        (typeof yValue === 'number' && yValue !== Infinity) ?
                        Math.min(Math.max(-1e5,
                            yAxis.translate(yValue, 0, 1, 0, 1)), 1e5) : // #3201
                        undefined;

                    point.isInside =
                        plotY !== undefined &&
                        plotY >= 0 &&
                        plotY <= yAxis.len && // #3519
                        plotX >= 0 &&
                        plotX <= xAxis.len;


                    // Set client related positions for mouse tracking
                    point.clientX = dynamicallyPlaced ?
                        correctFloat(
                            xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)
                        ) :
                        plotX; // #1514, #5383, #5518

                    point.negative = point.y < (threshold || 0);

                    // some API data
                    point.category = categories && categories[point.x] !== undefined ?
                        categories[point.x] : point.x;

                    // Determine auto enabling of markers (#3635, #5099)
                    if (!point.isNull) {
                        if (lastPlotX !== undefined) {
                            closestPointRangePx = Math.min(
                                closestPointRangePx,
                                Math.abs(plotX - lastPlotX)
                            );
                        }
                        lastPlotX = plotX;
                    }

                    // Find point zone
                    point.zone = this.zones.length && point.getZone();
                }
                series.closestPointRangePx = closestPointRangePx;
            },

            /**
             * Return the series points with null points filtered out.
             *
             * @param  {Array.<Point>} [points]
             *         The points to inspect, defaults to {@link Series.points}.
             * @param  {Boolean} [insideOnly=false]
             *         Whether to inspect only the points that are inside the visible
             *         view.
             *
             * @return {Array.<Point>}
             *         The valid points.
             */
            getValidPoints: function(points, insideOnly) {
                var chart = this.chart;
                // #3916, #5029, #5085
                return grep(points || this.points || [], function isValidPoint(point) {
                    if (insideOnly && !chart.isInsidePlot(
                            point.plotX,
                            point.plotY,
                            chart.inverted
                        )) {
                        return false;
                    }
                    return !point.isNull;
                });
            },

            /**
             * Set the clipping for the series. For animated series it is called twice,
             * first to initiate animating the clip then the second time without the
             * animation to set the final clip.
             *
             * @private
             */
            setClip: function(animation) {
                var chart = this.chart,
                    options = this.options,
                    renderer = chart.renderer,
                    inverted = chart.inverted,
                    seriesClipBox = this.clipBox,
                    clipBox = seriesClipBox || chart.clipBox,
                    sharedClipKey =
                    this.sharedClipKey || [
                        '_sharedClip',
                        animation && animation.duration,
                        animation && animation.easing,
                        clipBox.height,
                        options.xAxis,
                        options.yAxis
                    ].join(','), // #4526
                    clipRect = chart[sharedClipKey],
                    markerClipRect = chart[sharedClipKey + 'm'];

                // If a clipping rectangle with the same properties is currently present
                // in the chart, use that.
                if (!clipRect) {

                    // When animation is set, prepare the initial positions
                    if (animation) {
                        clipBox.width = 0;
                        if (inverted) {
                            clipBox.x = chart.plotSizeX;
                        }

                        chart[sharedClipKey + 'm'] = markerClipRect = renderer.clipRect(
                            inverted ? chart.plotSizeX + 99 : -99, // include the width of the first marker
                            inverted ? -chart.plotLeft : -chart.plotTop,
                            99,
                            inverted ? chart.chartWidth : chart.chartHeight
                        );
                    }
                    chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
                    // Create hashmap for series indexes
                    clipRect.count = {
                        length: 0
                    };

                }
                if (animation) {
                    if (!clipRect.count[this.index]) {
                        clipRect.count[this.index] = true;
                        clipRect.count.length += 1;
                    }
                }

                if (options.clip !== false) {
                    this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
                    this.markerGroup.clip(markerClipRect);
                    this.sharedClipKey = sharedClipKey;
                }

                // Remove the shared clipping rectangle when all series are shown
                if (!animation) {
                    if (clipRect.count[this.index]) {
                        delete clipRect.count[this.index];
                        clipRect.count.length -= 1;
                    }

                    if (clipRect.count.length === 0 && sharedClipKey && chart[sharedClipKey]) {
                        if (!seriesClipBox) {
                            chart[sharedClipKey] = chart[sharedClipKey].destroy();
                        }
                        if (chart[sharedClipKey + 'm']) {
                            chart[sharedClipKey + 'm'] = chart[sharedClipKey + 'm'].destroy();
                        }
                    }
                }
            },

            /**
             * Animate in the series. Called internally twice. First with the `init`
             * parameter set to true, which sets up the initial state of the animation.
             * Then when ready, it is called with the `init` parameter undefined, in 
             * order to perform the actual animation. After the second run, the function
             * is removed.
             *
             * @param  {Boolean} init
             *         Initialize the animation.
             */
            animate: function(init) {
                var series = this,
                    chart = series.chart,
                    clipRect,
                    animation = animObject(series.options.animation),
                    sharedClipKey;

                // Initialize the animation. Set up the clipping rectangle.
                if (init) {

                    series.setClip(animation);

                    // Run the animation
                } else {
                    sharedClipKey = this.sharedClipKey;
                    clipRect = chart[sharedClipKey];
                    if (clipRect) {
                        clipRect.animate({
                            width: chart.plotSizeX,
                            x: 0
                        }, animation);
                    }
                    if (chart[sharedClipKey + 'm']) {
                        chart[sharedClipKey + 'm'].animate({
                            width: chart.plotSizeX + 99,
                            x: 0
                        }, animation);
                    }

                    // Delete this function to allow it only once
                    series.animate = null;

                }
            },

            /**
             * This runs after animation to land on the final plot clipping.
             *
             * @private
             */
            afterAnimate: function() {
                this.setClip();
                fireEvent(this, 'afterAnimate');
                this.finishedAnimating = true;
            },

            /**
             * Draw the markers for line-like series types, and columns or other
             * graphical representation for {@link Point} objects for other series
             * types. The resulting element is typically stored as {@link
             * Point.graphic}, and is created on the first call and updated and moved on
             * subsequent calls.
             */
            drawPoints: function() {
                var series = this,
                    points = series.points,
                    chart = series.chart,
                    plotY,
                    i,
                    point,
                    symbol,
                    graphic,
                    options = series.options,
                    seriesMarkerOptions = options.marker,
                    pointMarkerOptions,
                    hasPointMarker,
                    enabled,
                    isInside,
                    markerGroup = series[series.specialGroup] || series.markerGroup,
                    xAxis = series.xAxis,
                    markerAttribs,
                    globallyEnabled = pick(
                        seriesMarkerOptions.enabled,
                        xAxis.isRadial ? true : null,
                        // Use larger or equal as radius is null in bubbles (#6321)
                        series.closestPointRangePx >= 2 * seriesMarkerOptions.radius
                    );

                if (seriesMarkerOptions.enabled !== false || series._hasPointMarkers) {

                    for (i = 0; i < points.length; i++) {
                        point = points[i];
                        plotY = point.plotY;
                        graphic = point.graphic;
                        pointMarkerOptions = point.marker || {};
                        hasPointMarker = !!point.marker;
                        enabled = (globallyEnabled && pointMarkerOptions.enabled === undefined) || pointMarkerOptions.enabled;
                        isInside = point.isInside;

                        // only draw the point if y is defined
                        if (enabled && isNumber(plotY) && point.y !== null) {

                            // Shortcuts
                            symbol = pick(pointMarkerOptions.symbol, series.symbol);
                            point.hasImage = symbol.indexOf('url') === 0;

                            markerAttribs = series.markerAttribs(
                                point,
                                point.selected && 'select'
                            );

                            if (graphic) { // update
                                graphic[isInside ? 'show' : 'hide'](true) // Since the marker group isn't clipped, each individual marker must be toggled
                                    .animate(markerAttribs);
                            } else if (isInside && (markerAttribs.width > 0 || point.hasImage)) {

                                /**
                                 * The graphic representation of the point. Typically
                                 * this is a simple shape, like a `rect` for column
                                 * charts or `path` for line markers, but for some 
                                 * complex series types like boxplot or 3D charts, the
                                 * graphic may be a `g` element containing other shapes.
                                 * The graphic is generated the first time {@link
                                 * Series#drawPoints} runs, and updated and moved on
                                 * subsequent runs.
                                 *
                                 * @memberof Point
                                 * @name graphic
                                 * @type {SVGElement}
                                 */
                                point.graphic = graphic = chart.renderer.symbol(
                                        symbol,
                                        markerAttribs.x,
                                        markerAttribs.y,
                                        markerAttribs.width,
                                        markerAttribs.height,
                                        hasPointMarker ? pointMarkerOptions : seriesMarkerOptions
                                    )
                                    .add(markerGroup);
                            }


                            // Presentational attributes
                            if (graphic) {
                                graphic.attr(series.pointAttribs(point, point.selected && 'select'));
                            }


                            if (graphic) {
                                graphic.addClass(point.getClassName(), true);
                            }

                        } else if (graphic) {
                            point.graphic = graphic.destroy(); // #1269
                        }
                    }
                }

            },

            /**
             * Get non-presentational attributes for a point. Used internally for both
             * styled mode and classic. Can be overridden for different series types.
             *
             * @see    Series#pointAttribs
             *
             * @param  {Point} point
             *         The Point to inspect.
             * @param  {String} [state]
             *         The state, can be either `hover`, `select` or undefined.
             *
             * @return {SVGAttributes}
             *         A hash containing those attributes that are not settable from
             *         CSS.
             */
            markerAttribs: function(point, state) {
                var seriesMarkerOptions = this.options.marker,
                    seriesStateOptions,
                    pointMarkerOptions = point.marker || {},
                    pointStateOptions,
                    radius = pick(
                        pointMarkerOptions.radius,
                        seriesMarkerOptions.radius
                    ),
                    attribs;

                // Handle hover and select states
                if (state) {
                    seriesStateOptions = seriesMarkerOptions.states[state];
                    pointStateOptions = pointMarkerOptions.states &&
                        pointMarkerOptions.states[state];

                    radius = pick(
                        pointStateOptions && pointStateOptions.radius,
                        seriesStateOptions && seriesStateOptions.radius,
                        radius + (seriesStateOptions && seriesStateOptions.radiusPlus || 0)
                    );
                }

                if (point.hasImage) {
                    radius = 0; // and subsequently width and height is not set
                }

                attribs = {
                    x: Math.floor(point.plotX) - radius, // Math.floor for #1843
                    y: point.plotY - radius
                };

                if (radius) {
                    attribs.width = attribs.height = 2 * radius;
                }

                return attribs;

            },


            /**
             * Internal function to get presentational attributes for each point. Unlike
             * {@link Series#markerAttribs}, this function should return those
             * attributes that can also be set in CSS. In styled mode, `pointAttribs`
             * won't be called.
             *
             * @param  {Point} point
             *         The point instance to inspect.
             * @param  {String} [state]
             *         The point state, can be either `hover`, `select` or undefined for
             *         normal state.
             *
             * @return {SVGAttributes}
             *         The presentational attributes to be set on the point.
             */
            pointAttribs: function(point, state) {
                var seriesMarkerOptions = this.options.marker,
                    seriesStateOptions,
                    pointOptions = point && point.options,
                    pointMarkerOptions = (pointOptions && pointOptions.marker) || {},
                    pointStateOptions,
                    color = this.color,
                    pointColorOption = pointOptions && pointOptions.color,
                    pointColor = point && point.color,
                    strokeWidth = pick(
                        pointMarkerOptions.lineWidth,
                        seriesMarkerOptions.lineWidth
                    ),
                    zoneColor = point && point.zone && point.zone.color,
                    fill,
                    stroke;

                color = pointColorOption || zoneColor || pointColor || color;
                fill = pointMarkerOptions.fillColor || seriesMarkerOptions.fillColor || color;
                stroke = pointMarkerOptions.lineColor || seriesMarkerOptions.lineColor || color;

                // Handle hover and select states
                if (state) {
                    seriesStateOptions = seriesMarkerOptions.states[state];
                    pointStateOptions = (pointMarkerOptions.states && pointMarkerOptions.states[state]) || {};
                    strokeWidth = pick(
                        pointStateOptions.lineWidth,
                        seriesStateOptions.lineWidth,
                        strokeWidth + pick(
                            pointStateOptions.lineWidthPlus,
                            seriesStateOptions.lineWidthPlus,
                            0
                        )
                    );
                    fill = pointStateOptions.fillColor || seriesStateOptions.fillColor || fill;
                    stroke = pointStateOptions.lineColor || seriesStateOptions.lineColor || stroke;
                }

                return {
                    'stroke': stroke,
                    'stroke-width': strokeWidth,
                    'fill': fill
                };
            },

            /**
             * Clear DOM objects and free up memory.
             *
             * @private
             */
            destroy: function() {
                var series = this,
                    chart = series.chart,
                    issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
                    destroy,
                    i,
                    data = series.data || [],
                    point,
                    axis;

                // add event hook
                fireEvent(series, 'destroy');

                // remove all events
                removeEvent(series);

                // erase from axes
                each(series.axisTypes || [], function(AXIS) {
                    axis = series[AXIS];
                    if (axis && axis.series) {
                        erase(axis.series, series);
                        axis.isDirty = axis.forceRedraw = true;
                    }
                });

                // remove legend items
                if (series.legendItem) {
                    series.chart.legend.destroyItem(series);
                }

                // destroy all points with their elements
                i = data.length;
                while (i--) {
                    point = data[i];
                    if (point && point.destroy) {
                        point.destroy();
                    }
                }
                series.points = null;

                // Clear the animation timeout if we are destroying the series during initial animation
                clearTimeout(series.animationTimeout);

                // Destroy all SVGElements associated to the series
                objectEach(series, function(val, prop) {
                    if (val instanceof SVGElement && !val.survive) { // Survive provides a hook for not destroying

                        // issue 134 workaround
                        destroy = issue134 && prop === 'group' ?
                            'hide' :
                            'destroy';

                        val[destroy]();
                    }
                });

                // remove from hoverSeries
                if (chart.hoverSeries === series) {
                    chart.hoverSeries = null;
                }
                erase(chart.series, series);
                chart.orderSeries();

                // clear all members
                objectEach(series, function(val, prop) {
                    delete series[prop];
                });
            },

            /**
             * Get the graph path.
             *
             * @private
             */
            getGraphPath: function(points, nullsAsZeroes, connectCliffs) {
                var series = this,
                    options = series.options,
                    step = options.step,
                    reversed,
                    graphPath = [],
                    xMap = [],
                    gap;

                points = points || series.points;

                // Bottom of a stack is reversed
                reversed = points.reversed;
                if (reversed) {
                    points.reverse();
                }
                // Reverse the steps (#5004)
                step = {
                    right: 1,
                    center: 2
                }[step] || (step && 3);
                if (step && reversed) {
                    step = 4 - step;
                }

                // Remove invalid points, especially in spline (#5015)
                if (options.connectNulls && !nullsAsZeroes && !connectCliffs) {
                    points = this.getValidPoints(points);
                }

                // Build the line
                each(points, function(point, i) {

                    var plotX = point.plotX,
                        plotY = point.plotY,
                        lastPoint = points[i - 1],
                        pathToPoint; // the path to this point from the previous

                    if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) && !connectCliffs) {
                        gap = true; // ... and continue
                    }

                    // Line series, nullsAsZeroes is not handled
                    if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
                        gap = !options.connectNulls;

                        // Area series, nullsAsZeroes is set
                    } else if (point.isNull && !nullsAsZeroes) {
                        gap = true;

                    } else {

                        if (i === 0 || gap) {
                            pathToPoint = ['M', point.plotX, point.plotY];

                        } else if (series.getPointSpline) { // generate the spline as defined in the SplineSeries object

                            pathToPoint = series.getPointSpline(points, point, i);

                        } else if (step) {

                            if (step === 1) { // right
                                pathToPoint = [
                                    'L',
                                    lastPoint.plotX,
                                    plotY
                                ];

                            } else if (step === 2) { // center
                                pathToPoint = [
                                    'L',
                                    (lastPoint.plotX + plotX) / 2,
                                    lastPoint.plotY,
                                    'L',
                                    (lastPoint.plotX + plotX) / 2,
                                    plotY
                                ];

                            } else {
                                pathToPoint = [
                                    'L',
                                    plotX,
                                    lastPoint.plotY
                                ];
                            }
                            pathToPoint.push('L', plotX, plotY);

                        } else {
                            // normal line to next point
                            pathToPoint = [
                                'L',
                                plotX,
                                plotY
                            ];
                        }

                        // Prepare for animation. When step is enabled, there are two path nodes for each x value.
                        xMap.push(point.x);
                        if (step) {
                            xMap.push(point.x);
                        }

                        graphPath.push.apply(graphPath, pathToPoint);
                        gap = false;
                    }
                });

                graphPath.xMap = xMap;
                series.graphPath = graphPath;

                return graphPath;

            },

            /**
             * Draw the graph. Called internally when rendering line-like series types.
             * The first time it generates the `series.graph` item and optionally other
             * series-wide items like `series.area` for area charts. On subsequent calls
             * these items are updated with new positions and attributes.
             */
            drawGraph: function() {
                var series = this,
                    options = this.options,
                    graphPath = (this.gappedPath || this.getGraphPath).call(this),
                    props = [
                        [
                            'graph',
                            'highcharts-graph',

                            options.lineColor || this.color,
                            options.dashStyle

                        ]
                    ];

                // Add the zone properties if any
                each(this.zones, function(zone, i) {
                    props.push([
                        'zone-graph-' + i,
                        'highcharts-graph highcharts-zone-graph-' + i + ' ' + (zone.className || ''),

                        zone.color || series.color,
                        zone.dashStyle || options.dashStyle

                    ]);
                });

                // Draw the graph
                each(props, function(prop, i) {
                    var graphKey = prop[0],
                        graph = series[graphKey],
                        attribs;

                    if (graph) {
                        graph.endX = graphPath.xMap;
                        graph.animate({
                            d: graphPath
                        });

                    } else if (graphPath.length) { // #1487

                        series[graphKey] = series.chart.renderer.path(graphPath)
                            .addClass(prop[1])
                            .attr({
                                zIndex: 1
                            }) // #1069
                            .add(series.group);


                        attribs = {
                            'stroke': prop[2],
                            'stroke-width': options.lineWidth,
                            'fill': (series.fillGraph && series.color) || 'none' // Polygon series use filled graph
                        };

                        if (prop[3]) {
                            attribs.dashstyle = prop[3];
                        } else if (options.linecap !== 'square') {
                            attribs['stroke-linecap'] = attribs['stroke-linejoin'] = 'round';
                        }

                        graph = series[graphKey]
                            .attr(attribs)
                            .shadow((i < 2) && options.shadow); // add shadow to normal series (0) or to first zone (1) #3932

                    }

                    // Helpers for animation
                    if (graph) {
                        graph.startX = graphPath.xMap;
                        graph.isArea = graphPath.isArea; // For arearange animation
                    }
                });
            },

            /**
             * Clip the graphs into zones for colors and styling.
             *
             * @private
             */
            applyZones: function() {
                var series = this,
                    chart = this.chart,
                    renderer = chart.renderer,
                    zones = this.zones,
                    translatedFrom,
                    translatedTo,
                    clips = this.clips || [],
                    clipAttr,
                    graph = this.graph,
                    area = this.area,
                    chartSizeMax = Math.max(chart.chartWidth, chart.chartHeight),
                    axis = this[(this.zoneAxis || 'y') + 'Axis'],
                    extremes,
                    reversed,
                    inverted = chart.inverted,
                    horiz,
                    pxRange,
                    pxPosMin,
                    pxPosMax,
                    ignoreZones = false;

                if (zones.length && (graph || area) && axis && axis.min !== undefined) {
                    reversed = axis.reversed;
                    horiz = axis.horiz;
                    // The use of the Color Threshold assumes there are no gaps
                    // so it is safe to hide the original graph and area
                    if (graph) {
                        graph.hide();
                    }
                    if (area) {
                        area.hide();
                    }

                    // Create the clips
                    extremes = axis.getExtremes();
                    each(zones, function(threshold, i) {

                        translatedFrom = reversed ?
                            (horiz ? chart.plotWidth : 0) :
                            (horiz ? 0 : axis.toPixels(extremes.min));
                        translatedFrom = Math.min(Math.max(pick(translatedTo, translatedFrom), 0), chartSizeMax);
                        translatedTo = Math.min(Math.max(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true)), 0), chartSizeMax);

                        if (ignoreZones) {
                            translatedFrom = translatedTo = axis.toPixels(extremes.max);
                        }

                        pxRange = Math.abs(translatedFrom - translatedTo);
                        pxPosMin = Math.min(translatedFrom, translatedTo);
                        pxPosMax = Math.max(translatedFrom, translatedTo);
                        if (axis.isXAxis) {
                            clipAttr = {
                                x: inverted ? pxPosMax : pxPosMin,
                                y: 0,
                                width: pxRange,
                                height: chartSizeMax
                            };
                            if (!horiz) {
                                clipAttr.x = chart.plotHeight - clipAttr.x;
                            }
                        } else {
                            clipAttr = {
                                x: 0,
                                y: inverted ? pxPosMax : pxPosMin,
                                width: chartSizeMax,
                                height: pxRange
                            };
                            if (horiz) {
                                clipAttr.y = chart.plotWidth - clipAttr.y;
                            }
                        }


                        // VML SUPPPORT
                        if (inverted && renderer.isVML) {
                            if (axis.isXAxis) {
                                clipAttr = {
                                    x: 0,
                                    y: reversed ? pxPosMin : pxPosMax,
                                    height: clipAttr.width,
                                    width: chart.chartWidth
                                };
                            } else {
                                clipAttr = {
                                    x: clipAttr.y - chart.plotLeft - chart.spacingBox.x,
                                    y: 0,
                                    width: clipAttr.height,
                                    height: chart.chartHeight
                                };
                            }
                        }
                        // END OF VML SUPPORT


                        if (clips[i]) {
                            clips[i].animate(clipAttr);
                        } else {
                            clips[i] = renderer.clipRect(clipAttr);

                            if (graph) {
                                series['zone-graph-' + i].clip(clips[i]);
                            }

                            if (area) {
                                series['zone-area-' + i].clip(clips[i]);
                            }
                        }
                        // if this zone extends out of the axis, ignore the others
                        ignoreZones = threshold.value > extremes.max;
                    });
                    this.clips = clips;
                }
            },

            /**
             * Initialize and perform group inversion on series.group and
             * series.markerGroup.
             *
             * @private
             */
            invertGroups: function(inverted) {
                var series = this,
                    chart = series.chart,
                    remover;

                function setInvert() {
                    each(['group', 'markerGroup'], function(groupName) {
                        if (series[groupName]) {

                            // VML/HTML needs explicit attributes for flipping
                            if (chart.renderer.isVML) {
                                series[groupName].attr({
                                    width: series.yAxis.len,
                                    height: series.xAxis.len
                                });
                            }

                            series[groupName].width = series.yAxis.len;
                            series[groupName].height = series.xAxis.len;
                            series[groupName].invert(inverted);
                        }
                    });
                }

                // Pie, go away (#1736)
                if (!series.xAxis) {
                    return;
                }

                // A fixed size is needed for inversion to work
                remover = addEvent(chart, 'resize', setInvert);
                addEvent(series, 'destroy', remover);

                // Do it now
                setInvert(inverted); // do it now

                // On subsequent render and redraw, just do setInvert without setting up events again
                series.invertGroups = setInvert;
            },

            /**
             * General abstraction for creating plot groups like series.group,
             * series.dataLabelsGroup and series.markerGroup. On subsequent calls, the
             * group will only be adjusted to the updated plot size.
             *
             * @private
             */
            plotGroup: function(prop, name, visibility, zIndex, parent) {
                var group = this[prop],
                    isNew = !group;

                // Generate it on first call
                if (isNew) {
                    this[prop] = group = this.chart.renderer.g()
                        .attr({
                            zIndex: zIndex || 0.1 // IE8 and pointer logic use this
                        })
                        .add(parent);

                }

                // Add the class names, and replace existing ones as response to
                // Series.update (#6660)
                group.addClass(
                    (
                        'highcharts-' + name +
                        ' highcharts-series-' + this.index +
                        ' highcharts-' + this.type + '-series ' +
                        (
                            defined(this.colorIndex) ?
                            'highcharts-color-' + this.colorIndex + ' ' :
                            ''
                        ) +
                        (this.options.className || '') +
                        (group.hasClass('highcharts-tracker') ? ' highcharts-tracker' : '')
                    ),
                    true
                );

                // Place it on first and subsequent (redraw) calls
                group.attr({
                    visibility: visibility
                })[isNew ? 'attr' : 'animate'](
                    this.getPlotBox()
                );
                return group;
            },

            /**
             * Get the translation and scale for the plot area of this series.
             */
            getPlotBox: function() {
                var chart = this.chart,
                    xAxis = this.xAxis,
                    yAxis = this.yAxis;

                // Swap axes for inverted (#2339)
                if (chart.inverted) {
                    xAxis = yAxis;
                    yAxis = this.xAxis;
                }
                return {
                    translateX: xAxis ? xAxis.left : chart.plotLeft,
                    translateY: yAxis ? yAxis.top : chart.plotTop,
                    scaleX: 1, // #1623
                    scaleY: 1
                };
            },

            /**
             * Render the graph and markers. Called internally when first rendering and
             * later when redrawing the chart. This function can be extended in plugins,
             * but normally shouldn't be called directly.
             */
            render: function() {
                var series = this,
                    chart = series.chart,
                    group,
                    options = series.options,
                    // Animation doesn't work in IE8 quirks when the group div is
                    // hidden, and looks bad in other oldIE
                    animDuration = (!!series.animate &&
                        chart.renderer.isSVG &&
                        animObject(options.animation).duration
                    ),
                    visibility = series.visible ? 'inherit' : 'hidden', // #2597
                    zIndex = options.zIndex,
                    hasRendered = series.hasRendered,
                    chartSeriesGroup = chart.seriesGroup,
                    inverted = chart.inverted;

                // the group
                group = series.plotGroup(
                    'group',
                    'series',
                    visibility,
                    zIndex,
                    chartSeriesGroup
                );

                series.markerGroup = series.plotGroup(
                    'markerGroup',
                    'markers',
                    visibility,
                    zIndex,
                    chartSeriesGroup
                );

                // initiate the animation
                if (animDuration) {
                    series.animate(true);
                }

                // SVGRenderer needs to know this before drawing elements (#1089, #1795)
                group.inverted = series.isCartesian ? inverted : false;

                // draw the graph if any
                if (series.drawGraph) {
                    series.drawGraph();
                    series.applyZones();
                }

                /*		each(series.points, function (point) {
                			if (point.redraw) {
                				point.redraw();
                			}
                		});*/

                // draw the data labels (inn pies they go before the points)
                if (series.drawDataLabels) {
                    series.drawDataLabels();
                }

                // draw the points
                if (series.visible) {
                    series.drawPoints();
                }


                // draw the mouse tracking area
                if (
                    series.drawTracker &&
                    series.options.enableMouseTracking !== false
                ) {
                    series.drawTracker();
                }

                // Handle inverted series and tracker groups
                series.invertGroups(inverted);

                // Initial clipping, must be defined after inverting groups for VML.
                // Applies to columns etc. (#3839).
                if (options.clip !== false && !series.sharedClipKey && !hasRendered) {
                    group.clip(chart.clipRect);
                }

                // Run the animation
                if (animDuration) {
                    series.animate();
                }

                // Call the afterAnimate function on animation complete (but don't
                // overwrite the animation.complete option which should be available to
                // the user).
                if (!hasRendered) {
                    series.animationTimeout = syncTimeout(function() {
                        series.afterAnimate();
                    }, animDuration);
                }

                series.isDirty = false; // means data is in accordance with what you see
                // (See #322) series.isDirty = series.isDirtyData = false; // means
                // data is in accordance with what you see
                series.hasRendered = true;
            },

            /**
             * Redraw the series. This function is called internally from `chart.redraw`
             * and normally shouldn't be called directly.
             *
             * @private
             */
            redraw: function() {
                var series = this,
                    chart = series.chart,
                    // cache it here as it is set to false in render, but used after
                    wasDirty = series.isDirty || series.isDirtyData,
                    group = series.group,
                    xAxis = series.xAxis,
                    yAxis = series.yAxis;

                // reposition on resize
                if (group) {
                    if (chart.inverted) {
                        group.attr({
                            width: chart.plotWidth,
                            height: chart.plotHeight
                        });
                    }

                    group.animate({
                        translateX: pick(xAxis && xAxis.left, chart.plotLeft),
                        translateY: pick(yAxis && yAxis.top, chart.plotTop)
                    });
                }

                series.translate();
                series.render();
                if (wasDirty) { // #3868, #3945
                    delete this.kdTree;
                }
            },

            kdAxisArray: ['clientX', 'plotY'],

            searchPoint: function(e, compareX) {
                var series = this,
                    xAxis = series.xAxis,
                    yAxis = series.yAxis,
                    inverted = series.chart.inverted;

                return this.searchKDTree({
                    clientX: inverted ?
                        xAxis.len - e.chartY + xAxis.pos : e.chartX - xAxis.pos,
                    plotY: inverted ?
                        yAxis.len - e.chartX + yAxis.pos : e.chartY - yAxis.pos
                }, compareX);
            },

            /**
             * Build the k-d-tree that is used by mouse and touch interaction to get the
             * closest point. Line-like series typically have a one-dimensional tree
             * where points are searched along the X axis, while scatter-like series
             * typically search in two dimensions, X and Y.
             *
             * @private
             */
            buildKDTree: function() {

                // Prevent multiple k-d-trees from being built simultaneously (#6235)
                this.buildingKdTree = true;

                var series = this,
                    dimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
                    2 : 1;

                // Internal function
                function _kdtree(points, depth, dimensions) {
                    var axis,
                        median,
                        length = points && points.length;

                    if (length) {

                        // alternate between the axis
                        axis = series.kdAxisArray[depth % dimensions];

                        // sort point array
                        points.sort(function(a, b) {
                            return a[axis] - b[axis];
                        });

                        median = Math.floor(length / 2);

                        // build and return nod
                        return {
                            point: points[median],
                            left: _kdtree(
                                points.slice(0, median), depth + 1, dimensions
                            ),
                            right: _kdtree(
                                points.slice(median + 1), depth + 1, dimensions
                            )
                        };

                    }
                }

                // Start the recursive build process with a clone of the points array
                // and null points filtered out (#3873)
                function startRecursive() {
                    series.kdTree = _kdtree(
                        series.getValidPoints(
                            null,
                            // For line-type series restrict to plot area, but
                            // column-type series not (#3916, #4511)
                            !series.directTouch
                        ),
                        dimensions,
                        dimensions
                    );
                    series.buildingKdTree = false;
                }
                delete series.kdTree;

                // For testing tooltips, don't build async
                syncTimeout(startRecursive, series.options.kdNow ? 0 : 1);
            },

            searchKDTree: function(point, compareX) {
                var series = this,
                    kdX = this.kdAxisArray[0],
                    kdY = this.kdAxisArray[1],
                    kdComparer = compareX ? 'distX' : 'dist',
                    kdDimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
                    2 : 1;

                // Set the one and two dimensional distance on the point object
                function setDistance(p1, p2) {
                    var x = (defined(p1[kdX]) && defined(p2[kdX])) ?
                        Math.pow(p1[kdX] - p2[kdX], 2) :
                        null,
                        y = (defined(p1[kdY]) && defined(p2[kdY])) ?
                        Math.pow(p1[kdY] - p2[kdY], 2) :
                        null,
                        r = (x || 0) + (y || 0);

                    p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
                    p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
                }

                function _search(search, tree, depth, dimensions) {
                    var point = tree.point,
                        axis = series.kdAxisArray[depth % dimensions],
                        tdist,
                        sideA,
                        sideB,
                        ret = point,
                        nPoint1,
                        nPoint2;

                    setDistance(search, point);

                    // Pick side based on distance to splitting point
                    tdist = search[axis] - point[axis];
                    sideA = tdist < 0 ? 'left' : 'right';
                    sideB = tdist < 0 ? 'right' : 'left';

                    // End of tree
                    if (tree[sideA]) {
                        nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);

                        ret = (nPoint1[kdComparer] < ret[kdComparer] ? nPoint1 : point);
                    }
                    if (tree[sideB]) {
                        // compare distance to current best to splitting point to decide
                        // wether to check side B or not
                        if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
                            nPoint2 = _search(
                                search,
                                tree[sideB],
                                depth + 1,
                                dimensions
                            );
                            ret = nPoint2[kdComparer] < ret[kdComparer] ?
                                nPoint2 :
                                ret;
                        }
                    }

                    return ret;
                }

                if (!this.kdTree && !this.buildingKdTree) {
                    this.buildKDTree();
                }

                if (this.kdTree) {
                    return _search(point, this.kdTree, kdDimensions, kdDimensions);
                }
            }

        }); // end Series prototype

        /**
         * A line series displays information as a series of data points connected by
         * straight line segments.
         *
         * @sample {highcharts} highcharts/demo/line-basic/ Line chart
         * @sample {highstock} stock/demo/basic-line/ Line chart
         * 
         * @extends plotOptions.series
         * @product highcharts highstock
         * @apioption plotOptions.line
         */

        /**
         * A `line` series. If the [type](#series.line.type) option is not
         * specified, it is inherited from [chart.type](#chart.type).
         * 
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * line](#plotOptions.line).
         * 
         * @type {Object}
         * @extends series,plotOptions.line
         * @excluding dataParser,dataURL
         * @product highcharts highstock
         * @apioption series.line
         */

        /**
         * An array of data points for the series. For the `line` series type,
         * points can be given in the following ways:
         * 
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. The `x` values will be automatically
         * calculated, either starting at 0 and incremented by 1, or from `pointStart`
         * and `pointInterval` given in the series options. If the axis has
         * categories, these will be used. Example:
         * 
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         * 
         * 2.  An array of arrays with 2 values. In this case, the values correspond
         * to `x,y`. If the first value is a string, it is applied as the name
         * of the point, and the `x` value is inferred.
         * 
         *  ```js
         *     data: [
         *         [0, 1],
         *         [1, 2],
         *         [2, 8]
         *     ]
         *  ```
         * 
         * 3.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.line.turboThreshold),
         * this option is not available.
         * 
         *  ```js
         *     data: [{
         *         x: 1,
         *         y: 9,
         *         name: "Point2",
         *         color: "#00FF00"
         *     }, {
         *         x: 1,
         *         y: 6,
         *         name: "Point1",
         *         color: "#FF00FF"
         *     }]
         *  ```
         * 
         * @type {Array<Object|Array|Number>}
         * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/ Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/ Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/ Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/ Config objects
         * @apioption series.line.data
         */

        /**
         * An additional, individual class name for the data point's graphic
         * representation.
         * 
         * @type {String}
         * @since 5.0.0
         * @product highcharts
         * @apioption series.line.data.className
         */

        /**
         * Individual color for the point. By default the color is pulled from
         * the global `colors` array.
         * 
         * @type {Color}
         * @sample {highcharts} highcharts/point/color/ Mark the highest point
         * @default undefined
         * @product highcharts highstock
         * @apioption series.line.data.color
         */

        /**
         * Styled mode only. A specific color index to use for the point, so its
         * graphic representations are given the class name `highcharts-color-
         * {n}`.
         * 
         * @type {Number}
         * @since 5.0.0
         * @product highcharts
         * @apioption series.line.data.colorIndex
         */

        /**
         * Individual data label for each point. The options are the same as
         * the ones for [plotOptions.series.dataLabels](#plotOptions.series.
         * dataLabels)
         * 
         * @type {Object}
         * @sample {highcharts} highcharts/point/datalabels/ Show a label for the last value
         * @sample {highstock} highcharts/point/datalabels/ Show a label for the last value
         * @product highcharts highstock
         * @apioption series.line.data.dataLabels
         */

        /**
         * A description of the point to add to the screen reader information
         * about the point. Requires the Accessibility module.
         * 
         * @type {String}
         * @default undefined
         * @since 5.0.0
         * @apioption series.line.data.description
         */

        /**
         * An id for the point. This can be used after render time to get a
         * pointer to the point object through `chart.get()`.
         * 
         * @type {String}
         * @sample {highcharts} highcharts/point/id/ Remove an id'd point
         * @default null
         * @since 1.2.0
         * @product highcharts highstock
         * @apioption series.line.data.id
         */

        /**
         * The rank for this point's data label in case of collision. If two
         * data labels are about to overlap, only the one with the highest `labelrank`
         * will be drawn.
         * 
         * @type {Number}
         * @apioption series.line.data.labelrank
         */

        /**
         * The name of the point as shown in the legend, tooltip, dataLabel
         * etc.
         * 
         * @type {String}
         * @sample {highcharts} highcharts/series/data-array-of-objects/ Point names
         * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
         * @apioption series.line.data.name
         */

        /**
         * Whether the data point is selected initially.
         * 
         * @type {Boolean}
         * @default false
         * @product highcharts highstock
         * @apioption series.line.data.selected
         */

        /**
         * The x value of the point. For datetime axes, the X value is the timestamp
         * in milliseconds since 1970.
         * 
         * @type {Number}
         * @product highcharts highstock
         * @apioption series.line.data.x
         */

        /**
         * The y value of the point.
         * 
         * @type {Number}
         * @default null
         * @product highcharts highstock
         * @apioption series.line.data.y
         */

        /**
         * Individual point events
         * 
         * @extends plotOptions.series.point.events
         * @product highcharts highstock
         * @apioption series.line.data.events
         */

        /**
         * @extends plotOptions.series.marker
         * @product highcharts highstock
         * @apioption series.line.data.marker
         */

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var Axis = H.Axis,
            Chart = H.Chart,
            correctFloat = H.correctFloat,
            defined = H.defined,
            destroyObjectProperties = H.destroyObjectProperties,
            each = H.each,
            format = H.format,
            objectEach = H.objectEach,
            pick = H.pick,
            Series = H.Series;

        /**
         * The class for stacks. Each stack, on a specific X value and either negative
         * or positive, has its own stack item.
         *
         * @class
         */
        H.StackItem = function(axis, options, isNegative, x, stackOption) {

            var inverted = axis.chart.inverted;

            this.axis = axis;

            // Tells if the stack is negative
            this.isNegative = isNegative;

            // Save the options to be able to style the label
            this.options = options;

            // Save the x value to be able to position the label later
            this.x = x;

            // Initialize total value
            this.total = null;

            // This will keep each points' extremes stored by series.index and point 
            // index
            this.points = {};

            // Save the stack option on the series configuration object, and whether to 
            // treat it as percent
            this.stack = stackOption;
            this.leftCliff = 0;
            this.rightCliff = 0;

            // The align options and text align varies on whether the stack is negative 
            // and if the chart is inverted or not.
            // First test the user supplied value, then use the dynamic.
            this.alignOptions = {
                align: options.align ||
                    (inverted ? (isNegative ? 'left' : 'right') : 'center'),
                verticalAlign: options.verticalAlign ||
                    (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
                y: pick(options.y, inverted ? 4 : (isNegative ? 14 : -6)),
                x: pick(options.x, inverted ? (isNegative ? -6 : 6) : 0)
            };

            this.textAlign = options.textAlign ||
                (inverted ? (isNegative ? 'right' : 'left') : 'center');
        };

        H.StackItem.prototype = {
            destroy: function() {
                destroyObjectProperties(this, this.axis);
            },

            /**
             * Renders the stack total label and adds it to the stack label group.
             */
            render: function(group) {
                var options = this.options,
                    formatOption = options.format,
                    str = formatOption ?
                    format(formatOption, this) :
                    options.formatter.call(this); // format the text in the label

                // Change the text to reflect the new total and set visibility to hidden
                // in case the serie is hidden
                if (this.label) {
                    this.label.attr({
                        text: str,
                        visibility: 'hidden'
                    });
                    // Create new label
                } else {
                    this.label =
                        this.axis.chart.renderer.text(str, null, null, options.useHTML)
                        .css(options.style)
                        .attr({
                            align: this.textAlign,
                            rotation: options.rotation,
                            visibility: 'hidden' // hidden until setOffset is called
                        })
                        .add(group); // add to the labels-group
                }
            },

            /**
             * Sets the offset that the stack has from the x value and repositions the
             * label.
             */
            setOffset: function(xOffset, xWidth) {
                var stackItem = this,
                    axis = stackItem.axis,
                    chart = axis.chart,
                    // stack value translated mapped to chart coordinates
                    y = axis.translate(
                        axis.usePercentage ? 100 : stackItem.total,
                        0,
                        0,
                        0,
                        1
                    ),
                    yZero = axis.translate(0), // stack origin
                    h = Math.abs(y - yZero), // stack height
                    x = chart.xAxis[0].translate(stackItem.x) + xOffset, // x position
                    stackBox = stackItem.getStackBox(chart, stackItem, x, y, xWidth, h),
                    label = stackItem.label,
                    alignAttr;

                if (label) {
                    // Align the label to the box
                    label.align(stackItem.alignOptions, null, stackBox);

                    // Set visibility (#678)
                    alignAttr = label.alignAttr;
                    label[
                        stackItem.options.crop === false || chart.isInsidePlot(
                            alignAttr.x,
                            alignAttr.y
                        ) ? 'show' : 'hide'](true);
                }
            },
            getStackBox: function(chart, stackItem, x, y, xWidth, h) {
                var reversed = stackItem.axis.reversed,
                    inverted = chart.inverted,
                    plotHeight = chart.plotHeight,
                    neg = (stackItem.isNegative && !reversed) ||
                    (!stackItem.isNegative && reversed); // #4056

                return { // this is the box for the complete stack
                    x: inverted ? (neg ? y : y - h) : x,
                    y: inverted ?
                        plotHeight - x - xWidth :
                        (neg ?
                            (plotHeight - y - h) :
                            plotHeight - y
                        ),
                    width: inverted ? h : xWidth,
                    height: inverted ? xWidth : h
                };
            }
        };

        /**
         * Generate stacks for each series and calculate stacks total values
         */
        Chart.prototype.getStacks = function() {
            var chart = this;

            // reset stacks for each yAxis
            each(chart.yAxis, function(axis) {
                if (axis.stacks && axis.hasVisibleSeries) {
                    axis.oldStacks = axis.stacks;
                }
            });

            each(chart.series, function(series) {
                if (series.options.stacking && (series.visible === true ||
                        chart.options.chart.ignoreHiddenSeries === false)) {
                    series.stackKey = series.type + pick(series.options.stack, '');
                }
            });
        };


        // Stacking methods defined on the Axis prototype

        /**
         * Build the stacks from top down
         */
        Axis.prototype.buildStacks = function() {
            var axisSeries = this.series,
                reversedStacks = pick(this.options.reversedStacks, true),
                len = axisSeries.length,
                i;
            if (!this.isXAxis) {
                this.usePercentage = false;
                i = len;
                while (i--) {
                    axisSeries[reversedStacks ? i : len - i - 1].setStackedPoints();
                }

                // Loop up again to compute percent and stream stack
                for (i = 0; i < len; i++) {
                    axisSeries[i].modifyStacks();
                }
            }
        };

        Axis.prototype.renderStackTotals = function() {
            var axis = this,
                chart = axis.chart,
                renderer = chart.renderer,
                stacks = axis.stacks,
                stackTotalGroup = axis.stackTotalGroup;

            // Create a separate group for the stack total labels
            if (!stackTotalGroup) {
                axis.stackTotalGroup = stackTotalGroup =
                    renderer.g('stack-labels')
                    .attr({
                        visibility: 'visible',
                        zIndex: 6
                    })
                    .add();
            }

            // plotLeft/Top will change when y axis gets wider so we need to translate
            // the stackTotalGroup at every render call. See bug #506 and #516
            stackTotalGroup.translate(chart.plotLeft, chart.plotTop);

            // Render each stack total
            objectEach(stacks, function(type) {
                objectEach(type, function(stack) {
                    stack.render(stackTotalGroup);
                });
            });
        };

        /**
         * Set all the stacks to initial states and destroy unused ones.
         */
        Axis.prototype.resetStacks = function() {
            var axis = this,
                stacks = axis.stacks;
            if (!axis.isXAxis) {
                objectEach(stacks, function(type) {
                    objectEach(type, function(stack, key) {
                        // Clean up memory after point deletion (#1044, #4320)
                        if (stack.touched < axis.stacksTouched) {
                            stack.destroy();
                            delete type[key];

                            // Reset stacks
                        } else {
                            stack.total = null;
                            stack.cum = null;
                        }
                    });
                });
            }
        };

        Axis.prototype.cleanStacks = function() {
            var stacks;

            if (!this.isXAxis) {
                if (this.oldStacks) {
                    stacks = this.stacks = this.oldStacks;
                }

                // reset stacks
                objectEach(stacks, function(type) {
                    objectEach(type, function(stack) {
                        stack.cum = stack.total;
                    });
                });
            }
        };


        // Stacking methods defnied for Series prototype

        /**
         * Adds series' points value to corresponding stack
         */
        Series.prototype.setStackedPoints = function() {
            if (!this.options.stacking || (this.visible !== true &&
                    this.chart.options.chart.ignoreHiddenSeries !== false)) {
                return;
            }

            var series = this,
                xData = series.processedXData,
                yData = series.processedYData,
                stackedYData = [],
                yDataLength = yData.length,
                seriesOptions = series.options,
                threshold = seriesOptions.threshold,
                stackThreshold = seriesOptions.startFromThreshold ? threshold : 0,
                stackOption = seriesOptions.stack,
                stacking = seriesOptions.stacking,
                stackKey = series.stackKey,
                negKey = '-' + stackKey,
                negStacks = series.negStacks,
                yAxis = series.yAxis,
                stacks = yAxis.stacks,
                oldStacks = yAxis.oldStacks,
                stackIndicator,
                isNegative,
                stack,
                other,
                key,
                pointKey,
                i,
                x,
                y;


            yAxis.stacksTouched += 1;

            // loop over the non-null y values and read them into a local array
            for (i = 0; i < yDataLength; i++) {
                x = xData[i];
                y = yData[i];
                stackIndicator = series.getStackIndicator(
                    stackIndicator,
                    x,
                    series.index
                );
                pointKey = stackIndicator.key;
                // Read stacked values into a stack based on the x value,
                // the sign of y and the stack key. Stacking is also handled for null
                // values (#739)
                isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
                key = isNegative ? negKey : stackKey;

                // Create empty object for this stack if it doesn't exist yet
                if (!stacks[key]) {
                    stacks[key] = {};
                }

                // Initialize StackItem for this x
                if (!stacks[key][x]) {
                    if (oldStacks[key] && oldStacks[key][x]) {
                        stacks[key][x] = oldStacks[key][x];
                        stacks[key][x].total = null;
                    } else {
                        stacks[key][x] = new H.StackItem(
                            yAxis,
                            yAxis.options.stackLabels,
                            isNegative,
                            x,
                            stackOption
                        );
                    }
                }

                // If the StackItem doesn't exist, create it first
                stack = stacks[key][x];
                if (y !== null) {
                    stack.points[pointKey] = stack.points[series.index] = [pick(stack.cum, stackThreshold)];

                    // Record the base of the stack
                    if (!defined(stack.cum)) {
                        stack.base = pointKey;
                    }
                    stack.touched = yAxis.stacksTouched;


                    // In area charts, if there are multiple points on the same X value,
                    // let the area fill the full span of those points
                    if (stackIndicator.index > 0 && series.singleStacks === false) {
                        stack.points[pointKey][0] =
                            stack.points[series.index + ',' + x + ',0'][0];
                    }
                }

                // Add value to the stack total
                if (stacking === 'percent') {

                    // Percent stacked column, totals are the same for the positive and
                    // negative stacks
                    other = isNegative ? stackKey : negKey;
                    if (negStacks && stacks[other] && stacks[other][x]) {
                        other = stacks[other][x];
                        stack.total = other.total =
                            Math.max(other.total, stack.total) + Math.abs(y) || 0;

                        // Percent stacked areas
                    } else {
                        stack.total = correctFloat(stack.total + (Math.abs(y) || 0));
                    }
                } else {
                    stack.total = correctFloat(stack.total + (y || 0));
                }

                stack.cum = pick(stack.cum, stackThreshold) + (y || 0);

                if (y !== null) {
                    stack.points[pointKey].push(stack.cum);
                    stackedYData[i] = stack.cum;
                }

            }

            if (stacking === 'percent') {
                yAxis.usePercentage = true;
            }

            this.stackedYData = stackedYData; // To be used in getExtremes

            // Reset old stacks
            yAxis.oldStacks = {};
        };

        /**
         * Iterate over all stacks and compute the absolute values to percent
         */
        Series.prototype.modifyStacks = function() {
            var series = this,
                stackKey = series.stackKey,
                stacks = series.yAxis.stacks,
                processedXData = series.processedXData,
                stackIndicator,
                stacking = series.options.stacking;

            if (series[stacking + 'Stacker']) { // Modifier function exists
                each([stackKey, '-' + stackKey], function(key) {
                    var i = processedXData.length,
                        x,
                        stack,
                        pointExtremes;

                    while (i--) {
                        x = processedXData[i];
                        stackIndicator = series.getStackIndicator(
                            stackIndicator,
                            x,
                            series.index,
                            key
                        );
                        stack = stacks[key] && stacks[key][x];
                        pointExtremes = stack && stack.points[stackIndicator.key];
                        if (pointExtremes) {
                            series[stacking + 'Stacker'](pointExtremes, stack, i);
                        }
                    }
                });
            }
        };

        /**
         * Modifier function for percent stacks. Blows up the stack to 100%.
         */
        Series.prototype.percentStacker = function(pointExtremes, stack, i) {
            var totalFactor = stack.total ? 100 / stack.total : 0;
            // Y bottom value
            pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
            // Y value
            pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
            this.stackedYData[i] = pointExtremes[1];
        };

        /**
         * Get stack indicator, according to it's x-value, to determine points with the
         * same x-value
         */
        Series.prototype.getStackIndicator = function(stackIndicator, x, index, key) {
            // Update stack indicator, when:
            // first point in a stack || x changed || stack type (negative vs positive)
            // changed:
            if (!defined(stackIndicator) || stackIndicator.x !== x ||
                (key && stackIndicator.key !== key)) {
                stackIndicator = {
                    x: x,
                    index: 0,
                    key: key
                };
            } else {
                stackIndicator.index++;
            }

            stackIndicator.key = [index, x, stackIndicator.index].join(',');

            return stackIndicator;
        };

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var addEvent = H.addEvent,
            animate = H.animate,
            Axis = H.Axis,
            Chart = H.Chart,
            createElement = H.createElement,
            css = H.css,
            defined = H.defined,
            each = H.each,
            erase = H.erase,
            extend = H.extend,
            fireEvent = H.fireEvent,
            inArray = H.inArray,
            isNumber = H.isNumber,
            isObject = H.isObject,
            isArray = H.isArray,
            merge = H.merge,
            objectEach = H.objectEach,
            pick = H.pick,
            Point = H.Point,
            Series = H.Series,
            seriesTypes = H.seriesTypes,
            setAnimation = H.setAnimation,
            splat = H.splat;

        // Extend the Chart prototype for dynamic methods
        extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {

            /**
             * Add a series to the chart after render time. Note that this method should
             * never be used when adding data synchronously at chart render time, as it
             * adds expense to the calculations and rendering. When adding data at the
             * same time as the chart is initialized, add the series as a configuration
             * option instead. With multiple axes, the `offset` is dynamically adjusted.
             *
             * @param  {SeriesOptions} options
             *         The config options for the series.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after adding.
             * @param  {AnimationOptions} animation
             *         Whether to apply animation, and optionally animation
             *         configuration.
             *
             * @return {Highcharts.Series}
             *         The newly created series object.
             *
             * @sample highcharts/members/chart-addseries/
             *         Add a series from a button
             * @sample stock/members/chart-addseries/
             *         Add a series in Highstock
             */
            addSeries: function(options, redraw, animation) {
                var series,
                    chart = this;

                if (options) {
                    redraw = pick(redraw, true); // defaults to true

                    fireEvent(chart, 'addSeries', {
                        options: options
                    }, function() {
                        series = chart.initSeries(options);

                        chart.isDirtyLegend = true; // the series array is out of sync with the display
                        chart.linkSeries();
                        if (redraw) {
                            chart.redraw(animation);
                        }
                    });
                }

                return series;
            },

            /**
             * Add an axis to the chart after render time. Note that this method should
             * never be used when adding data synchronously at chart render time, as it
             * adds expense to the calculations and rendering. When adding data at the
             * same time as the chart is initialized, add the axis as a configuration
             * option instead.
             * @param  {AxisOptions} options
             *         The axis options.
             * @param  {Boolean} [isX=false]
             *         Whether it is an X axis or a value axis.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after adding.
             * @param  {AnimationOptions} [animation=true]
             *         Whether and how to apply animation in the redraw.
             *
             * @sample highcharts/members/chart-addaxis/ Add and remove axes
             *
             * @return {Axis}
             *         The newly generated Axis object.
             */
            addAxis: function(options, isX, redraw, animation) {
                var key = isX ? 'xAxis' : 'yAxis',
                    chartOptions = this.options,
                    userOptions = merge(options, {
                        index: this[key].length,
                        isX: isX
                    }),
                    axis;

                axis = new Axis(this, userOptions);

                // Push the new axis options to the chart options
                chartOptions[key] = splat(chartOptions[key] || {});
                chartOptions[key].push(userOptions);

                if (pick(redraw, true)) {
                    this.redraw(animation);
                }

                return axis;
            },

            /**
             * Dim the chart and show a loading text or symbol. Options for the loading
             * screen are defined in {@link
             * https://api.highcharts.com/highcharts/loading|the loading options}.
             * 
             * @param  {String} str
             *         An optional text to show in the loading label instead of the
             *         default one. The default text is set in {@link
             *         http://api.highcharts.com/highcharts/lang.loading|lang.loading}.
             *
             * @sample highcharts/members/chart-hideloading/
             *         Show and hide loading from a button
             * @sample highcharts/members/chart-showloading/
             *         Apply different text labels
             * @sample stock/members/chart-show-hide-loading/
             *         Toggle loading in Highstock
             */
            showLoading: function(str) {
                var chart = this,
                    options = chart.options,
                    loadingDiv = chart.loadingDiv,
                    loadingOptions = options.loading,
                    setLoadingSize = function() {
                        if (loadingDiv) {
                            css(loadingDiv, {
                                left: chart.plotLeft + 'px',
                                top: chart.plotTop + 'px',
                                width: chart.plotWidth + 'px',
                                height: chart.plotHeight + 'px'
                            });
                        }
                    };

                // create the layer at the first call
                if (!loadingDiv) {
                    chart.loadingDiv = loadingDiv = createElement('div', {
                        className: 'highcharts-loading highcharts-loading-hidden'
                    }, null, chart.container);

                    chart.loadingSpan = createElement(
                        'span', {
                            className: 'highcharts-loading-inner'
                        },
                        null,
                        loadingDiv
                    );
                    addEvent(chart, 'redraw', setLoadingSize); // #1080
                }

                loadingDiv.className = 'highcharts-loading';

                // Update text
                chart.loadingSpan.innerHTML = str || options.lang.loading;


                // Update visuals
                css(loadingDiv, extend(loadingOptions.style, {
                    zIndex: 10
                }));
                css(chart.loadingSpan, loadingOptions.labelStyle);

                // Show it
                if (!chart.loadingShown) {
                    css(loadingDiv, {
                        opacity: 0,
                        display: ''
                    });
                    animate(loadingDiv, {
                        opacity: loadingOptions.style.opacity || 0.5
                    }, {
                        duration: loadingOptions.showDuration || 0
                    });
                }


                chart.loadingShown = true;
                setLoadingSize();
            },

            /**
             * Hide the loading layer.
             *
             * @see    Highcharts.Chart#showLoading
             * @sample highcharts/members/chart-hideloading/
             *         Show and hide loading from a button
             * @sample stock/members/chart-show-hide-loading/
             *         Toggle loading in Highstock
             */
            hideLoading: function() {
                var options = this.options,
                    loadingDiv = this.loadingDiv;

                if (loadingDiv) {
                    loadingDiv.className = 'highcharts-loading highcharts-loading-hidden';

                    animate(loadingDiv, {
                        opacity: 0
                    }, {
                        duration: options.loading.hideDuration || 100,
                        complete: function() {
                            css(loadingDiv, {
                                display: 'none'
                            });
                        }
                    });

                }
                this.loadingShown = false;
            },

            /** 
             * These properties cause isDirtyBox to be set to true when updating. Can be extended from plugins.
             */
            propsRequireDirtyBox: ['backgroundColor', 'borderColor', 'borderWidth', 'margin', 'marginTop', 'marginRight',
                'marginBottom', 'marginLeft', 'spacing', 'spacingTop', 'spacingRight', 'spacingBottom', 'spacingLeft',
                'borderRadius', 'plotBackgroundColor', 'plotBackgroundImage', 'plotBorderColor', 'plotBorderWidth',
                'plotShadow', 'shadow'
            ],

            /** 
             * These properties cause all series to be updated when updating. Can be
             * extended from plugins.
             */
            propsRequireUpdateSeries: ['chart.inverted', 'chart.polar',
                'chart.ignoreHiddenSeries', 'chart.type', 'colors', 'plotOptions',
                'tooltip'
            ],

            /**
             * A generic function to update any element of the chart. Elements can be
             * enabled and disabled, moved, re-styled, re-formatted etc.
             *
             * A special case is configuration objects that take arrays, for example
             * {@link https://api.highcharts.com/highcharts/xAxis|xAxis}, 
             * {@link https://api.highcharts.com/highcharts/yAxis|yAxis} or 
             * {@link https://api.highcharts.com/highcharts/series|series}. For these
             * collections, an `id` option is used to map the new option set to an
             * existing object. If an existing object of the same id is not found, the
             * corresponding item is updated. So for example, running `chart.update`
             * with a series item without an id, will cause the existing chart's series
             * with the same index in the series array to be updated. When the
             * `oneToOne` parameter is true, `chart.update` will also take care of
             * adding and removing items from the collection. Read more under the
             * parameter description below.
             *
             * See also the {@link https://api.highcharts.com/highcharts/responsive|
             * responsive option set}. Switching between `responsive.rules` basically
             * runs `chart.update` under the hood.
             *
             * @param  {Options} options
             *         A configuration object for the new chart options.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart.
             * @param  {Boolean} [oneToOne=false]
             *         When `true`, the `series`, `xAxis` and `yAxis` collections will
             *         be updated one to one, and items will be either added or removed
             *         to match the new updated options. For example, if the chart has
             *         two series and we call `chart.update` with a configuration 
             *         containing three series, one will be added. If we call
             *         `chart.update` with one series, one will be removed. Setting an
             *         empty `series` array will remove all series, but leaving out the
             *         `series` property will leave all series untouched. If the series
             *         have id's, the new series options will be matched by id, and the
             *         remaining ones removed.
             *
             * @sample highcharts/members/chart-update/
             *         Update chart geometry 
             */
            update: function(options, redraw, oneToOne) {
                var chart = this,
                    adders = {
                        credits: 'addCredits',
                        title: 'setTitle',
                        subtitle: 'setSubtitle'
                    },
                    optionsChart = options.chart,
                    updateAllAxes,
                    updateAllSeries,
                    newWidth,
                    newHeight,
                    itemsForRemoval = [];

                // If the top-level chart option is present, some special updates are required		
                if (optionsChart) {
                    merge(true, chart.options.chart, optionsChart);

                    // Setter function
                    if ('className' in optionsChart) {
                        chart.setClassName(optionsChart.className);
                    }

                    if ('inverted' in optionsChart || 'polar' in optionsChart) {
                        // Parse options.chart.inverted and options.chart.polar together
                        // with the available series.
                        chart.propFromSeries();
                        updateAllAxes = true;
                    }

                    if ('alignTicks' in optionsChart) { // #6452
                        updateAllAxes = true;
                    }

                    objectEach(optionsChart, function(val, key) {
                        if (inArray('chart.' + key, chart.propsRequireUpdateSeries) !== -1) {
                            updateAllSeries = true;
                        }
                        // Only dirty box
                        if (inArray(key, chart.propsRequireDirtyBox) !== -1) {
                            chart.isDirtyBox = true;
                        }
                    });


                    if ('style' in optionsChart) {
                        chart.renderer.setStyle(optionsChart.style);
                    }

                }

                // Moved up, because tooltip needs updated plotOptions (#6218)

                if (options.colors) {
                    this.options.colors = options.colors;
                }


                if (options.plotOptions) {
                    merge(true, this.options.plotOptions, options.plotOptions);
                }

                // Some option stuctures correspond one-to-one to chart objects that
                // have update methods, for example
                // options.credits => chart.credits
                // options.legend => chart.legend
                // options.title => chart.title
                // options.tooltip => chart.tooltip
                // options.subtitle => chart.subtitle
                // options.mapNavigation => chart.mapNavigation
                // options.navigator => chart.navigator
                // options.scrollbar => chart.scrollbar
                objectEach(options, function(val, key) {
                    if (chart[key] && typeof chart[key].update === 'function') {
                        chart[key].update(val, false);

                        // If a one-to-one object does not exist, look for an adder function
                    } else if (typeof chart[adders[key]] === 'function') {
                        chart[adders[key]](val);
                    }

                    if (
                        key !== 'chart' &&
                        inArray(key, chart.propsRequireUpdateSeries) !== -1
                    ) {
                        updateAllSeries = true;
                    }
                });

                // Setters for collections. For axes and series, each item is referred
                // by an id. If the id is not found, it defaults to the corresponding
                // item in the collection, so setting one series without an id, will
                // update the first series in the chart. Setting two series without
                // an id will update the first and the second respectively (#6019)
                // chart.update and responsive.
                each([
                    'xAxis',
                    'yAxis',
                    'zAxis',
                    'series',
                    'colorAxis',
                    'pane'
                ], function(coll) {
                    if (options[coll]) {
                        each(splat(options[coll]), function(newOptions, i) {
                            var item = (
                                defined(newOptions.id) &&
                                chart.get(newOptions.id)
                            ) || chart[coll][i];
                            if (item && item.coll === coll) {
                                item.update(newOptions, false);

                                if (oneToOne) {
                                    item.touched = true;
                                }
                            }

                            // If oneToOne and no matching item is found, add one
                            if (!item && oneToOne) {
                                if (coll === 'series') {
                                    chart.addSeries(newOptions, false)
                                        .touched = true;
                                } else if (coll === 'xAxis' || coll === 'yAxis') {
                                    chart.addAxis(newOptions, coll === 'xAxis', false)
                                        .touched = true;
                                }
                            }

                        });

                        // Add items for removal
                        if (oneToOne) {
                            each(chart[coll], function(item) {
                                if (!item.touched) {
                                    itemsForRemoval.push(item);
                                } else {
                                    delete item.touched;
                                }
                            });
                        }


                    }
                });

                each(itemsForRemoval, function(item) {
                    item.remove(false);
                });

                if (updateAllAxes) {
                    each(chart.axes, function(axis) {
                        axis.update({}, false);
                    });
                }

                // Certain options require the whole series structure to be thrown away
                // and rebuilt
                if (updateAllSeries) {
                    each(chart.series, function(series) {
                        series.update({}, false);
                    });
                }

                // For loading, just update the options, do not redraw
                if (options.loading) {
                    merge(true, chart.options.loading, options.loading);
                }

                // Update size. Redraw is forced.
                newWidth = optionsChart && optionsChart.width;
                newHeight = optionsChart && optionsChart.height;
                if ((isNumber(newWidth) && newWidth !== chart.chartWidth) ||
                    (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
                    chart.setSize(newWidth, newHeight);
                } else if (pick(redraw, true)) {
                    chart.redraw();
                }
            },

            /**
             * Shortcut to set the subtitle options. This can also be done from {@link
             * Chart#update} or {@link Chart#setTitle}.
             *
             * @param  {SubtitleOptions} options
             *         New subtitle options. The subtitle text itself is set by the
             *         `options.text` property.
             */
            setSubtitle: function(options) {
                this.setTitle(undefined, options);
            }


        });

        // extend the Point prototype for dynamic methods
        extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
            /**
             * Update point with new options (typically x/y data) and optionally redraw
             * the series.
             *
             * @param  {Object} options
             *         The point options. Point options are handled as described under
             *         the `series.type.data` item for each series type. For example
             *         for a line series, if options is a single number, the point will
             *         be given that number as the main y value. If it is an array, it
             *         will be interpreted as x and y values respectively. If it is an
             *         object, advanced options are applied. 
             * @param  {Boolean} [redraw=true]
             *          Whether to redraw the chart after the point is updated. If doing
             *          more operations on the chart, it is best practice to set
             *          `redraw` to false and call `chart.redraw()` after.
             * @param  {AnimationOptions} [animation=true]
             *         Whether to apply animation, and optionally animation
             *         configuration.
             *
             * @sample highcharts/members/point-update-column/
             *         Update column value
             * @sample highcharts/members/point-update-pie/
             *         Update pie slice
             * @sample maps/members/point-update/
             *         Update map area value in Highmaps
             */
            update: function(options, redraw, animation, runEvent) {
                var point = this,
                    series = point.series,
                    graphic = point.graphic,
                    i,
                    chart = series.chart,
                    seriesOptions = series.options;

                redraw = pick(redraw, true);

                function update() {

                    point.applyOptions(options);

                    // Update visuals
                    if (point.y === null && graphic) { // #4146
                        point.graphic = graphic.destroy();
                    }
                    if (isObject(options, true)) {
                        // Destroy so we can get new elements
                        if (graphic && graphic.element) {
                            // "null" is also a valid symbol
                            if (options && options.marker && options.marker.symbol !== undefined) {
                                point.graphic = graphic.destroy();
                            }
                        }
                        if (options && options.dataLabels && point.dataLabel) { // #2468
                            point.dataLabel = point.dataLabel.destroy();
                        }
                    }

                    // record changes in the parallel arrays
                    i = point.index;
                    series.updateParallelArrays(point, i);

                    // Record the options to options.data. If the old or the new config
                    // is an object, use point options, otherwise use raw options
                    // (#4701, #4916).
                    seriesOptions.data[i] = (
                            isObject(seriesOptions.data[i], true) ||
                            isObject(options, true)
                        ) ?
                        point.options :
                        options;

                    // redraw
                    series.isDirty = series.isDirtyData = true;
                    if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
                        chart.isDirtyBox = true;
                    }

                    if (seriesOptions.legendType === 'point') { // #1831, #1885
                        chart.isDirtyLegend = true;
                    }
                    if (redraw) {
                        chart.redraw(animation);
                    }
                }

                // Fire the event with a default handler of doing the update
                if (runEvent === false) { // When called from setData
                    update();
                } else {
                    point.firePointEvent('update', {
                        options: options
                    }, update);
                }
            },

            /**
             * Remove a point and optionally redraw the series and if necessary the axes
             * @param  {Boolean} redraw
             *         Whether to redraw the chart or wait for an explicit call. When
             *         doing more operations on the chart, for example running
             *         `point.remove()` in a loop, it is best practice to set `redraw`
             *         to false and call `chart.redraw()` after.         
             * @param  {AnimationOptions} [animation=false]
             *         Whether to apply animation, and optionally animation
             *         configuration.
             *
             * @sample highcharts/plotoptions/series-point-events-remove/
             *         Remove point and confirm
             * @sample highcharts/members/point-remove/
             *         Remove pie slice
             * @sample maps/members/point-remove/
             *         Remove selected points in Highmaps
             */
            remove: function(redraw, animation) {
                this.series.removePoint(inArray(this, this.series.data), redraw, animation);
            }
        });

        // Extend the series prototype for dynamic methods
        extend(Series.prototype, /** @lends Series.prototype */ {
            /**
             * Add a point to the series after render time. The point can be added at
             * the end, or by giving it an X value, to the start or in the middle of the
             * series.
             * 
             * @param  {Number|Array|Object} options
             *         The point options. If options is a single number, a point with
             *         that y value is appended to the series.If it is an array, it will
             *         be interpreted as x and y values respectively. If it is an
             *         object, advanced options as outlined under `series.data` are
             *         applied.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after the point is added. When adding
             *         more than one point, it is highly recommended that the redraw
             *         option be set to false, and instead {@link Chart#redraw}
             *         is explicitly called after the adding of points is finished.
             *         Otherwise, the chart will redraw after adding each point.
             * @param  {Boolean} [shift=false]
             *         If true, a point is shifted off the start of the series as one is
             *         appended to the end.
             * @param  {AnimationOptions} [animation]
             *         Whether to apply animation, and optionally animation
             *         configuration.
             *
             * @sample highcharts/members/series-addpoint-append/
             *         Append point
             * @sample highcharts/members/series-addpoint-append-and-shift/
             *         Append and shift
             * @sample highcharts/members/series-addpoint-x-and-y/
             *         Both X and Y values given
             * @sample highcharts/members/series-addpoint-pie/
             *         Append pie slice
             * @sample stock/members/series-addpoint/
             *         Append 100 points in Highstock
             * @sample stock/members/series-addpoint-shift/
             *         Append and shift in Highstock
             * @sample maps/members/series-addpoint/
             *         Add a point in Highmaps
             */
            addPoint: function(options, redraw, shift, animation) {
                var series = this,
                    seriesOptions = series.options,
                    data = series.data,
                    chart = series.chart,
                    xAxis = series.xAxis,
                    names = xAxis && xAxis.hasNames && xAxis.names,
                    dataOptions = seriesOptions.data,
                    point,
                    isInTheMiddle,
                    xData = series.xData,
                    i,
                    x;

                // Optional redraw, defaults to true
                redraw = pick(redraw, true);

                // Get options and push the point to xData, yData and series.options. In series.generatePoints
                // the Point instance will be created on demand and pushed to the series.data array.
                point = {
                    series: series
                };
                series.pointClass.prototype.applyOptions.apply(point, [options]);
                x = point.x;

                // Get the insertion point
                i = xData.length;
                if (series.requireSorting && x < xData[i - 1]) {
                    isInTheMiddle = true;
                    while (i && xData[i - 1] > x) {
                        i--;
                    }
                }

                series.updateParallelArrays(point, 'splice', i, 0, 0); // insert undefined item
                series.updateParallelArrays(point, i); // update it

                if (names && point.name) {
                    names[x] = point.name;
                }
                dataOptions.splice(i, 0, options);

                if (isInTheMiddle) {
                    series.data.splice(i, 0, null);
                    series.processData();
                }

                // Generate points to be added to the legend (#1329)
                if (seriesOptions.legendType === 'point') {
                    series.generatePoints();
                }

                // Shift the first point off the parallel arrays
                if (shift) {
                    if (data[0] && data[0].remove) {
                        data[0].remove(false);
                    } else {
                        data.shift();
                        series.updateParallelArrays(point, 'shift');

                        dataOptions.shift();
                    }
                }

                // redraw
                series.isDirty = true;
                series.isDirtyData = true;

                if (redraw) {
                    chart.redraw(animation); // Animation is set anyway on redraw, #5665
                }
            },

            /**
             * Remove a point from the series. Unlike the {@link Highcharts.Point#remove}
             * method, this can also be done on a point that is not instanciated because
             * it is outside the view or subject to Highstock data grouping.
             *
             * @param  {Number} i
             *         The index of the point in the {@link Highcharts.Series.data|data}
             *         array.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after the point is added. When 
             *         removing more than one point, it is highly recommended that the
             *         `redraw` option be set to `false`, and instead {@link
             *         Highcharts.Chart#redraw} is explicitly called after the adding of
             *         points is finished.
             * @param  {AnimationOptions} [animation]
             *         Whether and optionally how the series should be animated.
             *
             * @sample highcharts/members/series-removepoint/
             *         Remove cropped point
             */
            removePoint: function(i, redraw, animation) {

                var series = this,
                    data = series.data,
                    point = data[i],
                    points = series.points,
                    chart = series.chart,
                    remove = function() {

                        if (points && points.length === data.length) { // #4935
                            points.splice(i, 1);
                        }
                        data.splice(i, 1);
                        series.options.data.splice(i, 1);
                        series.updateParallelArrays(point || {
                            series: series
                        }, 'splice', i, 1);

                        if (point) {
                            point.destroy();
                        }

                        // redraw
                        series.isDirty = true;
                        series.isDirtyData = true;
                        if (redraw) {
                            chart.redraw();
                        }
                    };

                setAnimation(animation, chart);
                redraw = pick(redraw, true);

                // Fire the event with a default handler of removing the point
                if (point) {
                    point.firePointEvent('remove', null, remove);
                } else {
                    remove();
                }
            },

            /**
             * Remove a series and optionally redraw the chart.
             *
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart or wait for an explicit call to
             *         {@link Highcharts.Chart#redraw}.
             * @param  {AnimationOptions} [animation]
             *         Whether to apply animation, and optionally animation
             *         configuration
             * @param  {Boolean} [withEvent=true]
             *         Used internally, whether to fire the series `remove` event.
             *
             * @sample highcharts/members/series-remove/
             *         Remove first series from a button
             */
            remove: function(redraw, animation, withEvent) {
                var series = this,
                    chart = series.chart;

                function remove() {

                    // Destroy elements
                    series.destroy();

                    // Redraw
                    chart.isDirtyLegend = chart.isDirtyBox = true;
                    chart.linkSeries();

                    if (pick(redraw, true)) {
                        chart.redraw(animation);
                    }
                }

                // Fire the event with a default handler of removing the point
                if (withEvent !== false) {
                    fireEvent(series, 'remove', null, remove);
                } else {
                    remove();
                }
            },

            /**
             * Update the series with a new set of options. For a clean and precise
             * handling of new options, all methods and elements from the series are
             * removed, and it is initiated from scratch. Therefore, this method is more
             * performance expensive than some other utility methods like {@link
             * Series#setData} or {@link Series#setVisible}.
             *
             * @param  {SeriesOptions} options
             *         New options that will be merged with the series' existing
             *         options.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after the series is altered. If doing
             *         more operations on the chart, it is a good idea to set redraw to
             *         false and call {@link Chart#redraw} after.
             *
             * @sample highcharts/members/series-update/
             *         Updating series options
             * @sample maps/members/series-update/
             *         Update series options in Highmaps
             */
            update: function(newOptions, redraw) {
                var series = this,
                    chart = series.chart,
                    // must use user options when changing type because series.options
                    // is merged in with type specific plotOptions
                    oldOptions = series.userOptions,
                    oldType = series.oldType || series.type,
                    newType = newOptions.type || oldOptions.type || chart.options.chart.type,
                    proto = seriesTypes[oldType].prototype,
                    n,
                    preserveGroups = [
                        'group',
                        'markerGroup',
                        'dataLabelsGroup'
                    ],
                    preserve = [
                        'navigatorSeries',
                        'baseSeries'
                    ],

                    // Animation must be enabled when calling update before the initial
                    // animation has first run. This happens when calling update
                    // directly after chart initialization, or when applying responsive
                    // rules (#6912).
                    animation = series.finishedAnimating && {
                        animation: false
                    };

                // Running Series.update to update the data only is an intuitive usage,
                // so we want to make sure that when used like this, we run the
                // cheaper setData function and allow animation instead of completely
                // recreating the series instance.
                if (Object.keys && Object.keys(newOptions).toString() === 'data') {
                    return this.setData(newOptions.data, redraw);
                }

                // If we're changing type or zIndex, create new groups (#3380, #3404)
                // Also create new groups for navigator series.
                if (
                    (newType && newType !== oldType) ||
                    newOptions.zIndex !== undefined
                ) {
                    preserveGroups.length = 0;
                }
                if (series.options.isInternal) {
                    preserve.length = 0;
                }

                // Make sure preserved properties are not destroyed (#3094)
                preserve = preserveGroups.concat(preserve);
                each(preserve, function(prop) {
                    preserve[prop] = series[prop];
                    delete series[prop];
                });

                // Do the merge, with some forced options
                newOptions = merge(oldOptions, animation, {
                    index: series.index,
                    pointStart: series.xData[0] // when updating after addPoint
                }, {
                    data: series.options.data
                }, newOptions);

                // Destroy the series and delete all properties. Reinsert all methods
                // and properties from the new type prototype (#2270, #3719)
                series.remove(false, null, false);
                for (n in proto) {
                    series[n] = undefined;
                }
                extend(series, seriesTypes[newType || oldType].prototype);

                // Re-register groups (#3094) and other preserved properties
                each(preserve, function(prop) {
                    series[prop] = preserve[prop];
                });

                series.init(chart, newOptions);
                series.oldType = oldType;
                chart.linkSeries(); // Links are lost in series.remove (#3028)
                if (pick(redraw, true)) {
                    chart.redraw(false);
                }
            }
        });

        // Extend the Axis.prototype for dynamic methods
        extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {

            /**
             * Update an axis object with a new set of options. The options are merged
             * with the existing options, so only new or altered options need to be
             * specified.
             *
             * @param  {Object} options
             *         The new options that will be merged in with existing options on
             *         the axis.
             * @sample highcharts/members/axis-update/ Axis update demo
             */
            update: function(options, redraw) {
                var chart = this.chart;

                options = chart.options[this.coll][this.options.index] =
                    merge(this.userOptions, options);

                this.destroy(true);

                this.init(chart, extend(options, {
                    events: undefined
                }));

                chart.isDirtyBox = true;
                if (pick(redraw, true)) {
                    chart.redraw();
                }
            },

            /**
             * Remove the axis from the chart.
             *
             * @param {Boolean} [redraw=true] Whether to redraw the chart following the
             * remove.
             *
             * @sample highcharts/members/chart-addaxis/ Add and remove axes
             */
            remove: function(redraw) {
                var chart = this.chart,
                    key = this.coll, // xAxis or yAxis
                    axisSeries = this.series,
                    i = axisSeries.length;

                // Remove associated series (#2687)
                while (i--) {
                    if (axisSeries[i]) {
                        axisSeries[i].remove(false);
                    }
                }

                // Remove the axis
                erase(chart.axes, this);
                erase(chart[key], this);

                if (isArray(chart.options[key])) {
                    chart.options[key].splice(this.options.index, 1);
                } else { // color axis, #6488
                    delete chart.options[key];
                }

                each(chart[key], function(axis, i) { // Re-index, #1706
                    axis.options.index = i;
                });
                this.destroy();
                chart.isDirtyBox = true;

                if (pick(redraw, true)) {
                    chart.redraw();
                }
            },

            /**
             * Update the axis title by options after render time.
             *
             * @param  {TitleOptions} titleOptions
             *         The additional title options.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after setting the title.
             * @sample highcharts/members/axis-settitle/ Set a new Y axis title
             */
            setTitle: function(titleOptions, redraw) {
                this.update({
                    title: titleOptions
                }, redraw);
            },

            /**
             * Set new axis categories and optionally redraw.
             * @param {Array.<String>} categories - The new categories.
             * @param {Boolean} [redraw=true] - Whether to redraw the chart.
             * @sample highcharts/members/axis-setcategories/ Set categories by click on
             * a button
             */
            setCategories: function(categories, redraw) {
                this.update({
                    categories: categories
                }, redraw);
            }

        });

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var color = H.color,
            each = H.each,
            LegendSymbolMixin = H.LegendSymbolMixin,
            map = H.map,
            pick = H.pick,
            Series = H.Series,
            seriesType = H.seriesType;

        /**
         * Area series type.
         * @constructor seriesTypes.area
         * @extends {Series}
         */
        /**
         * The area series type.
         * @extends {plotOptions.line}
         * @product highcharts highstock
         * @sample {highcharts} highcharts/demo/area-basic/
         *         Area chart
         * @sample {highstock} stock/demo/area/
         *         Area chart
         * @optionparent plotOptions.area
         */
        seriesType('area', 'line', {

            /**
             * Fill color or gradient for the area. When `null`, the series' `color`
             * is used with the series' `fillOpacity`.
             * 
             * @type {Color}
             * @see In styled mode, the fill color can be set with the `.highcharts-area` class name.
             * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/ Null by default
             * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/ Gradient
             * @default null
             * @product highcharts highstock
             * @apioption plotOptions.area.fillColor
             */

            /**
             * Fill opacity for the area. When you set an explicit `fillColor`,
             * the `fillOpacity` is not applied. Instead, you should define the
             * opacity in the `fillColor` with an rgba color definition. The `fillOpacity`
             * setting, also the default setting, overrides the alpha component
             * of the `color` setting.
             * 
             * @type {Number}
             * @see In styled mode, the fill opacity can be set with the `.highcharts-area` class name.
             * @sample {highcharts} highcharts/plotoptions/area-fillopacity/ Automatic fill color and fill opacity of 0.1
             * @default {highcharts} 0.75
             * @default {highstock} .75
             * @product highcharts highstock
             * @apioption plotOptions.area.fillOpacity
             */

            /**
             * A separate color for the graph line. By default the line takes the
             * `color` of the series, but the lineColor setting allows setting a
             * separate color for the line without altering the `fillColor`.
             * 
             * @type {Color}
             * @see In styled mode, the line stroke can be set with the `.highcharts-graph` class name.
             * @sample {highcharts} highcharts/plotoptions/area-linecolor/ Dark gray line
             * @default null
             * @product highcharts highstock
             * @apioption plotOptions.area.lineColor
             */

            /**
             * A separate color for the negative part of the area.
             * 
             * @type {Color}
             * @see [negativeColor](#plotOptions.area.negativeColor). In styled mode, a negative
             * color is set with the `.highcharts-negative` class name ([view live
             * demo](http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-
             * negative-color/)).
             * @since 3.0
             * @product highcharts
             * @apioption plotOptions.area.negativeFillColor
             */

            /**
             * When this is true, the series will not cause the Y axis to cross
             * the zero plane (or [threshold](#plotOptions.series.threshold) option)
             * unless the data actually crosses the plane.
             * 
             * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
             * 3 will make the Y axis show negative values according to the `minPadding`
             * option. If `softThreshold` is `true`, the Y axis starts at 0.
             * 
             * @type {Boolean}
             * @default false
             * @since 4.1.9
             * @product highcharts highstock
             */
            softThreshold: false,

            /**
             * The Y axis value to serve as the base for the area, for distinguishing
             * between values above and below a threshold. If `null`, the area
             * behaves like a line series with fill between the graph and the Y
             * axis minimum.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/area-threshold/ A threshold of 100
             * @default 0
             * @since 2.0
             * @product highcharts highstock
             */
            threshold: 0

            /**
             * Whether the whole area or just the line should respond to mouseover
             * tooltips and other mouse or touch events.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/area-trackbyarea/ Display the tooltip when the     area is hovered
             * @sample {highstock} highcharts/plotoptions/area-trackbyarea/ Display the tooltip when the     area is hovered
             * @default false
             * @since 1.1.6
             * @product highcharts highstock
             * @apioption plotOptions.area.trackByArea
             */


        }, /** @lends seriesTypes.area.prototype */ {
            singleStacks: false,
            /** 
             * Return an array of stacked points, where null and missing points are replaced by 
             * dummy points in order for gaps to be drawn correctly in stacks.
             */
            getStackPoints: function(points) {
                var series = this,
                    segment = [],
                    keys = [],
                    xAxis = this.xAxis,
                    yAxis = this.yAxis,
                    stack = yAxis.stacks[this.stackKey],
                    pointMap = {},
                    seriesIndex = series.index,
                    yAxisSeries = yAxis.series,
                    seriesLength = yAxisSeries.length,
                    visibleSeries,
                    upOrDown = pick(yAxis.options.reversedStacks, true) ? 1 : -1,
                    i;


                points = points || this.points;

                if (this.options.stacking) {
                    // Create a map where we can quickly look up the points by their X value.
                    for (i = 0; i < points.length; i++) {
                        pointMap[points[i].x] = points[i];
                    }

                    // Sort the keys (#1651)
                    H.objectEach(stack, function(stackX, x) {
                        if (stackX.total !== null) { // nulled after switching between grouping and not (#1651, #2336)
                            keys.push(x);
                        }
                    });
                    keys.sort(function(a, b) {
                        return a - b;
                    });

                    visibleSeries = map(yAxisSeries, function() {
                        return this.visible;
                    });

                    each(keys, function(x, idx) {
                        var y = 0,
                            stackPoint,
                            stackedValues;

                        if (pointMap[x] && !pointMap[x].isNull) {
                            segment.push(pointMap[x]);

                            // Find left and right cliff. -1 goes left, 1 goes right.
                            each([-1, 1], function(direction) {
                                var nullName = direction === 1 ? 'rightNull' : 'leftNull',
                                    cliffName = direction === 1 ? 'rightCliff' : 'leftCliff',
                                    cliff = 0,
                                    otherStack = stack[keys[idx + direction]];

                                // If there is a stack next to this one, to the left or to the right...
                                if (otherStack) {
                                    i = seriesIndex;
                                    while (i >= 0 && i < seriesLength) { // Can go either up or down, depending on reversedStacks
                                        stackPoint = otherStack.points[i];
                                        if (!stackPoint) {
                                            // If the next point in this series is missing, mark the point
                                            // with point.leftNull or point.rightNull = true.
                                            if (i === seriesIndex) {
                                                pointMap[x][nullName] = true;

                                                // If there are missing points in the next stack in any of the 
                                                // series below this one, we need to substract the missing values
                                                // and add a hiatus to the left or right.
                                            } else if (visibleSeries[i]) {
                                                stackedValues = stack[x].points[i];
                                                if (stackedValues) {
                                                    cliff -= stackedValues[1] - stackedValues[0];
                                                }
                                            }
                                        }
                                        // When reversedStacks is true, loop up, else loop down
                                        i += upOrDown;
                                    }
                                }
                                pointMap[x][cliffName] = cliff;
                            });


                            // There is no point for this X value in this series, so we 
                            // insert a dummy point in order for the areas to be drawn
                            // correctly.
                        } else {

                            // Loop down the stack to find the series below this one that has
                            // a value (#1991)
                            i = seriesIndex;
                            while (i >= 0 && i < seriesLength) {
                                stackPoint = stack[x].points[i];
                                if (stackPoint) {
                                    y = stackPoint[1];
                                    break;
                                }
                                // When reversedStacks is true, loop up, else loop down
                                i += upOrDown;
                            }
                            y = yAxis.translate(y, 0, 1, 0, 1); // #6272
                            segment.push({
                                isNull: true,
                                plotX: xAxis.translate(x, 0, 0, 0, 1), // #6272
                                x: x,
                                plotY: y,
                                yBottom: y
                            });
                        }
                    });

                }

                return segment;
            },

            getGraphPath: function(points) {
                var getGraphPath = Series.prototype.getGraphPath,
                    graphPath,
                    options = this.options,
                    stacking = options.stacking,
                    yAxis = this.yAxis,
                    topPath,
                    bottomPath,
                    bottomPoints = [],
                    graphPoints = [],
                    seriesIndex = this.index,
                    i,
                    areaPath,
                    plotX,
                    stacks = yAxis.stacks[this.stackKey],
                    threshold = options.threshold,
                    translatedThreshold = yAxis.getThreshold(options.threshold),
                    isNull,
                    yBottom,
                    connectNulls = options.connectNulls || stacking === 'percent',
                    /**
                     * To display null points in underlying stacked series, this series graph must be 
                     * broken, and the area also fall down to fill the gap left by the null point. #2069
                     */
                    addDummyPoints = function(i, otherI, side) {
                        var point = points[i],
                            stackedValues = stacking && stacks[point.x].points[seriesIndex],
                            nullVal = point[side + 'Null'] || 0,
                            cliffVal = point[side + 'Cliff'] || 0,
                            top,
                            bottom,
                            isNull = true;

                        if (cliffVal || nullVal) {

                            top = (nullVal ? stackedValues[0] : stackedValues[1]) + cliffVal;
                            bottom = stackedValues[0] + cliffVal;
                            isNull = !!nullVal;

                        } else if (!stacking && points[otherI] && points[otherI].isNull) {
                            top = bottom = threshold;
                        }

                        // Add to the top and bottom line of the area
                        if (top !== undefined) {
                            graphPoints.push({
                                plotX: plotX,
                                plotY: top === null ? translatedThreshold : yAxis.getThreshold(top),
                                isNull: isNull,
                                isCliff: true
                            });
                            bottomPoints.push({
                                plotX: plotX,
                                plotY: bottom === null ? translatedThreshold : yAxis.getThreshold(bottom),
                                doCurve: false // #1041, gaps in areaspline areas
                            });
                        }
                    };

                // Find what points to use
                points = points || this.points;

                // Fill in missing points
                if (stacking) {
                    points = this.getStackPoints(points);
                }

                for (i = 0; i < points.length; i++) {
                    isNull = points[i].isNull;
                    plotX = pick(points[i].rectPlotX, points[i].plotX);
                    yBottom = pick(points[i].yBottom, translatedThreshold);

                    if (!isNull || connectNulls) {

                        if (!connectNulls) {
                            addDummyPoints(i, i - 1, 'left');
                        }

                        if (!(isNull && !stacking && connectNulls)) { // Skip null point when stacking is false and connectNulls true
                            graphPoints.push(points[i]);
                            bottomPoints.push({
                                x: i,
                                plotX: plotX,
                                plotY: yBottom
                            });
                        }

                        if (!connectNulls) {
                            addDummyPoints(i, i + 1, 'right');
                        }
                    }
                }

                topPath = getGraphPath.call(this, graphPoints, true, true);

                bottomPoints.reversed = true;
                bottomPath = getGraphPath.call(this, bottomPoints, true, true);
                if (bottomPath.length) {
                    bottomPath[0] = 'L';
                }

                areaPath = topPath.concat(bottomPath);
                graphPath = getGraphPath.call(this, graphPoints, false, connectNulls); // TODO: don't set leftCliff and rightCliff when connectNulls?

                areaPath.xMap = topPath.xMap;
                this.areaPath = areaPath;

                return graphPath;
            },

            /**
             * Draw the graph and the underlying area. This method calls the Series base
             * function and adds the area. The areaPath is calculated in the getSegmentPath
             * method called from Series.prototype.drawGraph.
             */
            drawGraph: function() {

                // Define or reset areaPath
                this.areaPath = [];

                // Call the base method
                Series.prototype.drawGraph.apply(this);

                // Define local variables
                var series = this,
                    areaPath = this.areaPath,
                    options = this.options,
                    zones = this.zones,
                    props = [
                        [
                            'area',
                            'highcharts-area',

                            this.color,
                            options.fillColor

                        ]
                    ]; // area name, main color, fill color

                each(zones, function(zone, i) {
                    props.push([
                        'zone-area-' + i,
                        'highcharts-area highcharts-zone-area-' + i + ' ' + zone.className,

                        zone.color || series.color,
                        zone.fillColor || options.fillColor

                    ]);
                });

                each(props, function(prop) {
                    var areaKey = prop[0],
                        area = series[areaKey];

                    // Create or update the area
                    if (area) { // update
                        area.endX = areaPath.xMap;
                        area.animate({
                            d: areaPath
                        });

                    } else { // create
                        area = series[areaKey] = series.chart.renderer.path(areaPath)
                            .addClass(prop[1])
                            .attr({

                                fill: pick(
                                    prop[3],
                                    color(prop[2]).setOpacity(pick(options.fillOpacity, 0.75)).get()
                                ),

                                zIndex: 0 // #1069
                            }).add(series.group);
                        area.isArea = true;
                    }
                    area.startX = areaPath.xMap;
                    area.shiftUnit = options.step ? 2 : 1;
                });
            },

            drawLegendSymbol: LegendSymbolMixin.drawRectangle
        });

        /**
         * A `area` series. If the [type](#series.area.type) option is not
         * specified, it is inherited from [chart.type](#chart.type).
         * 
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * area](#plotOptions.area).
         * 
         * @type {Object}
         * @extends series,plotOptions.area
         * @excluding dataParser,dataURL
         * @product highcharts highstock
         * @apioption series.area
         */

        /**
         * An array of data points for the series. For the `area` series type,
         * points can be given in the following ways:
         * 
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. The `x` values will be automatically
         * calculated, either starting at 0 and incremented by 1, or from `pointStart`
         * and `pointInterval` given in the series options. If the axis has
         * categories, these will be used. Example:
         * 
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         * 
         * 2.  An array of arrays with 2 values. In this case, the values correspond
         * to `x,y`. If the first value is a string, it is applied as the name
         * of the point, and the `x` value is inferred.
         * 
         *  ```js
         *     data: [
         *         [0, 9],
         *         [1, 7],
         *         [2, 6]
         *     ]
         *  ```
         * 
         * 3.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.area.turboThreshold),
         * this option is not available.
         * 
         *  ```js
         *     data: [{
         *         x: 1,
         *         y: 9,
         *         name: "Point2",
         *         color: "#00FF00"
         *     }, {
         *         x: 1,
         *         y: 6,
         *         name: "Point1",
         *         color: "#FF00FF"
         *     }]
         *  ```
         * 
         * @type {Array<Object|Array|Number>}
         * @extends series.line.data
         * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/ Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/ Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/ Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/ Config objects
         * @product highcharts highstock
         * @apioption series.area.data
         */

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var pick = H.pick,
            seriesType = H.seriesType;

        /**
         * A spline series is a special type of line series, where the segments between
         * the data points are smoothed.
         *
         * @sample {highcharts} highcharts/demo/spline-irregular-time/ Spline chart
         * @sample {highstock} stock/demo/spline/ Spline chart
         * 
         * @extends plotOptions.series
         * @excluding step
         * @product highcharts highstock
         * @apioption plotOptions.spline
         */

        /**
         * Spline series type.
         * @constructor seriesTypes.spline
         * @extends {Series}
         */
        seriesType('spline', 'line', {}, /** @lends seriesTypes.spline.prototype */ {
            /**
             * Get the spline segment from a given point's previous neighbour to the
             * given point
             */
            getPointSpline: function(points, point, i) {
                var
                    // 1 means control points midway between points, 2 means 1/3 from
                    // the point, 3 is 1/4 etc
                    smoothing = 1.5,
                    denom = smoothing + 1,
                    plotX = point.plotX,
                    plotY = point.plotY,
                    lastPoint = points[i - 1],
                    nextPoint = points[i + 1],
                    leftContX,
                    leftContY,
                    rightContX,
                    rightContY,
                    ret;

                function doCurve(otherPoint) {
                    return otherPoint &&
                        !otherPoint.isNull &&
                        otherPoint.doCurve !== false &&
                        !point.isCliff; // #6387, area splines next to null
                }

                // Find control points
                if (doCurve(lastPoint) && doCurve(nextPoint)) {
                    var lastX = lastPoint.plotX,
                        lastY = lastPoint.plotY,
                        nextX = nextPoint.plotX,
                        nextY = nextPoint.plotY,
                        correction = 0;

                    leftContX = (smoothing * plotX + lastX) / denom;
                    leftContY = (smoothing * plotY + lastY) / denom;
                    rightContX = (smoothing * plotX + nextX) / denom;
                    rightContY = (smoothing * plotY + nextY) / denom;

                    // Have the two control points make a straight line through main
                    // point
                    if (rightContX !== leftContX) { // #5016, division by zero
                        correction = ((rightContY - leftContY) * (rightContX - plotX)) /
                            (rightContX - leftContX) + plotY - rightContY;
                    }

                    leftContY += correction;
                    rightContY += correction;

                    // to prevent false extremes, check that control points are between
                    // neighbouring points' y values
                    if (leftContY > lastY && leftContY > plotY) {
                        leftContY = Math.max(lastY, plotY);
                        // mirror of left control point
                        rightContY = 2 * plotY - leftContY;
                    } else if (leftContY < lastY && leftContY < plotY) {
                        leftContY = Math.min(lastY, plotY);
                        rightContY = 2 * plotY - leftContY;
                    }
                    if (rightContY > nextY && rightContY > plotY) {
                        rightContY = Math.max(nextY, plotY);
                        leftContY = 2 * plotY - rightContY;
                    } else if (rightContY < nextY && rightContY < plotY) {
                        rightContY = Math.min(nextY, plotY);
                        leftContY = 2 * plotY - rightContY;
                    }

                    // record for drawing in next point
                    point.rightContX = rightContX;
                    point.rightContY = rightContY;


                }

                // Visualize control points for debugging
                /*
                if (leftContX) {
                	this.chart.renderer.circle(
                			leftContX + this.chart.plotLeft,
                			leftContY + this.chart.plotTop,
                			2
                		)
                		.attr({
                			stroke: 'red',
                			'stroke-width': 2,
                			fill: 'none',
                			zIndex: 9
                		})
                		.add();
                	this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
                		leftContY + this.chart.plotTop,
                		'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
                		.attr({
                			stroke: 'red',
                			'stroke-width': 2,
                			zIndex: 9
                		})
                		.add();
                }
                if (rightContX) {
                	this.chart.renderer.circle(
                			rightContX + this.chart.plotLeft,
                			rightContY + this.chart.plotTop,
                			2
                		)
                		.attr({
                			stroke: 'green',
                			'stroke-width': 2,
                			fill: 'none',
                			zIndex: 9
                		})
                		.add();
                	this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
                		rightContY + this.chart.plotTop,
                		'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
                		.attr({
                			stroke: 'green',
                			'stroke-width': 2,
                			zIndex: 9
                		})
                		.add();
                }
                // */
                ret = [
                    'C',
                    pick(lastPoint.rightContX, lastPoint.plotX),
                    pick(lastPoint.rightContY, lastPoint.plotY),
                    pick(leftContX, plotX),
                    pick(leftContY, plotY),
                    plotX,
                    plotY
                ];
                // reset for updating series later
                lastPoint.rightContX = lastPoint.rightContY = null;
                return ret;
            }
        });

        /**
         * A `spline` series. If the [type](#series.spline.type) option is
         * not specified, it is inherited from [chart.type](#chart.type).
         * 
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * spline](#plotOptions.spline).
         * 
         * @type {Object}
         * @extends series,plotOptions.spline
         * @excluding dataParser,dataURL
         * @product highcharts highstock
         * @apioption series.spline
         */

        /**
         * An array of data points for the series. For the `spline` series type,
         * points can be given in the following ways:
         * 
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. The `x` values will be automatically
         * calculated, either starting at 0 and incremented by 1, or from `pointStart`
         * and `pointInterval` given in the series options. If the axis has
         * categories, these will be used. Example:
         * 
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         * 
         * 2.  An array of arrays with 2 values. In this case, the values correspond
         * to `x,y`. If the first value is a string, it is applied as the name
         * of the point, and the `x` value is inferred.
         * 
         *  ```js
         *     data: [
         *         [0, 9],
         *         [1, 2],
         *         [2, 8]
         *     ]
         *  ```
         * 
         * 3.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.spline.turboThreshold),
         * this option is not available.
         * 
         *  ```js
         *     data: [{
         *         x: 1,
         *         y: 9,
         *         name: "Point2",
         *         color: "#00FF00"
         *     }, {
         *         x: 1,
         *         y: 0,
         *         name: "Point1",
         *         color: "#FF00FF"
         *     }]
         *  ```
         * 
         * @type {Array<Object|Array|Number>}
         * @extends series.line.data
         * @sample {highcharts} highcharts/chart/reflow-true/
         *         Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/
         *         Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
         *         Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/
         *         Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/
         *         Config objects
         * @product highcharts highstock
         * @apioption series.spline.data
         */

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var areaProto = H.seriesTypes.area.prototype,
            defaultPlotOptions = H.defaultPlotOptions,
            LegendSymbolMixin = H.LegendSymbolMixin,
            seriesType = H.seriesType;
        /**
         * AreaSplineSeries object
         */
        /**
         * The area spline series is an area series where the graph between the points
         * is smoothed into a spline.
         * 
         * @extends plotOptions.area
         * @excluding step
         * @sample {highcharts} highcharts/demo/areaspline/ Area spline chart
         * @sample {highstock} stock/demo/areaspline/ Area spline chart
         * @product highcharts highstock
         * @apioption plotOptions.areaspline
         */
        seriesType('areaspline', 'spline', defaultPlotOptions.area, {
            getStackPoints: areaProto.getStackPoints,
            getGraphPath: areaProto.getGraphPath,
            drawGraph: areaProto.drawGraph,
            drawLegendSymbol: LegendSymbolMixin.drawRectangle
        });
        /**
         * A `areaspline` series. If the [type](#series.areaspline.type) option
         * is not specified, it is inherited from [chart.type](#chart.type).
         * 
         * 
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * areaspline](#plotOptions.areaspline).
         * 
         * @type {Object}
         * @extends series,plotOptions.areaspline
         * @excluding dataParser,dataURL
         * @product highcharts highstock
         * @apioption series.areaspline
         */


        /**
         * An array of data points for the series. For the `areaspline` series
         * type, points can be given in the following ways:
         * 
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. The `x` values will be automatically
         * calculated, either starting at 0 and incremented by 1, or from `pointStart`
         * and `pointInterval` given in the series options. If the axis has
         * categories, these will be used. Example:
         * 
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         * 
         * 2.  An array of arrays with 2 values. In this case, the values correspond
         * to `x,y`. If the first value is a string, it is applied as the name
         * of the point, and the `x` value is inferred.
         * 
         *  ```js
         *     data: [
         *         [0, 10],
         *         [1, 9],
         *         [2, 3]
         *     ]
         *  ```
         * 
         * 3.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.areaspline.turboThreshold),
         * this option is not available.
         * 
         *  ```js
         *     data: [{
         *         x: 1,
         *         y: 4,
         *         name: "Point2",
         *         color: "#00FF00"
         *     }, {
         *         x: 1,
         *         y: 4,
         *         name: "Point1",
         *         color: "#FF00FF"
         *     }]
         *  ```
         * 
         * @type {Array<Object|Array|Number>}
         * @extends series.line.data
         * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/ Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/ Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/ Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/ Config objects
         * @product highcharts highstock
         * @apioption series.areaspline.data
         */



    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var animObject = H.animObject,
            color = H.color,
            each = H.each,
            extend = H.extend,
            isNumber = H.isNumber,
            LegendSymbolMixin = H.LegendSymbolMixin,
            merge = H.merge,
            noop = H.noop,
            pick = H.pick,
            Series = H.Series,
            seriesType = H.seriesType,
            svg = H.svg;
        /**
         * The column series type.
         *
         * @constructor seriesTypes.column
         * @augments Series
         */

        /**
         * Column series display one column per value along an X axis.
         *
         * @sample {highcharts} highcharts/demo/column-basic/ Column chart
         * @sample {highstock} stock/demo/column/ Column chart
         *
         * @extends {plotOptions.line}
         * @product highcharts highstock
         * @excluding connectNulls,dashStyle,gapSize,gapUnit,linecap,lineWidth,marker,
         *          connectEnds,step
         * @optionparent plotOptions.column
         */
        seriesType('column', 'line', {

            /**
             * The corner radius of the border surrounding each column or bar.
             *
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/column-borderradius/
             *         Rounded columns
             * @default 0
             * @product highcharts highstock
             */
            borderRadius: 0,

            /**
             * The width of the border surrounding each column or bar.
             *
             * In styled mode, the stroke width can be set with the `.highcharts-point`
             * rule.
             *
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
             *         2px black border
             * @default 1
             * @product highcharts highstock
             * @apioption plotOptions.column.borderWidth
             */

            /**
             * When using automatic point colors pulled from the `options.colors`
             * collection, this option determines whether the chart should receive
             * one color per series or one color per point.
             *
             * @type {Boolean}
             * @see [series colors](#plotOptions.column.colors)
             * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
             *         False by default
             * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
             *         True
             * @default false
             * @since 2.0
             * @product highcharts highstock
             * @apioption plotOptions.column.colorByPoint
             */

            /**
             * A series specific or series type specific color set to apply instead
             * of the global [colors](#colors) when [colorByPoint](#plotOptions.
             * column.colorByPoint) is true.
             *
             * @type {Array<Color>}
             * @since 3.0
             * @product highcharts highstock
             * @apioption plotOptions.column.colors
             */

            /**
             * When true, each column edge is rounded to its nearest pixel in order
             * to render sharp on screen. In some cases, when there are a lot of
             * densely packed columns, this leads to visible difference in column
             * widths or distance between columns. In these cases, setting `crisp`
             * to `false` may look better, even though each column is rendered
             * blurry.
             *
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
             *         Crisp is false
             * @default true
             * @since 5.0.10
             * @product highcharts highstock
             */
            crisp: true,

            /**
             * Padding between each value groups, in x axis units.
             *
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
             *         0.2 by default
             * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
             *         No group padding - all columns are evenly spaced
             * @default 0.2
             * @product highcharts highstock
             */
            groupPadding: 0.2,

            /**
             * Whether to group non-stacked columns or to let them render independent
             * of each other. Non-grouped columns will be laid out individually
             * and overlap each other.
             *
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
             *         Grouping disabled
             * @sample {highstock} highcharts/plotoptions/column-grouping-false/
             *         Grouping disabled
             * @default true
             * @since 2.3.0
             * @product highcharts highstock
             * @apioption plotOptions.column.grouping
             */

            marker: null, // point options are specified in the base options

            /**
             * The maximum allowed pixel width for a column, translated to the height
             * of a bar in a bar chart. This prevents the columns from becoming
             * too wide when there is a small number of points in the chart.
             *
             * @type {Number}
             * @see [pointWidth](#plotOptions.column.pointWidth)
             * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
             *         Limited to 50
             * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
             *         Limited to 50
             * @default null
             * @since 4.1.8
             * @product highcharts highstock
             * @apioption plotOptions.column.maxPointWidth
             */

            /**
             * Padding between each column or bar, in x axis units.
             *
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
             *         0.1 by default
             * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
             *         0.25
             * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
             *         0 for tightly packed columns
             * @default 0.1
             * @product highcharts highstock
             */
            pointPadding: 0.1,

            /**
             * A pixel value specifying a fixed width for each column or bar. When
             * `null`, the width is calculated from the `pointPadding` and
             * `groupPadding`.
             *
             * @type {Number}
             * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
             * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
             *         20px wide columns regardless of chart width or the amount of data
             *         points
             * @default null
             * @since 1.2.5
             * @product highcharts highstock
             * @apioption plotOptions.column.pointWidth
             */

            /**
             * The minimal height for a column or width for a bar. By default,
             * 0 values are not shown. To visualize a 0 (or close to zero) point,
             * set the minimal point length to a pixel value like 3\. In stacked
             * column charts, minPointLength might not be respected for tightly
             * packed values.
             *
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
             *         Zero base value
             * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
             *         Positive and negative close to zero values
             * @default 0
             * @product highcharts highstock
             */
            minPointLength: 0,

            /**
             * When the series contains less points than the crop threshold, all
             * points are drawn, event if the points fall outside the visible plot
             * area at the current zoom. The advantage of drawing all points (including
             * markers and columns), is that animation is performed on updates.
             * On the other hand, when the series contains more points than the
             * crop threshold, the series data is cropped to only contain points
             * that fall within the plot area. The advantage of cropping away invisible
             * points is to increase performance on large series. .
             *
             * @type {Number}
             * @default 50
             * @product highcharts highstock
             */
            cropThreshold: 50,

            /**
             * The X axis range that each point is valid for. This determines the
             * width of the column. On a categorized axis, the range will be 1
             * by default (one category unit). On linear and datetime axes, the
             * range will be computed as the distance between the two closest data
             * points.
             *
             * The default `null` means it is computed automatically, but this option
             * can be used to override the automatic value.
             *
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/column-pointrange/
             *         Set the point range to one day on a data set with one week
             *         between the points
             * @default null
             * @since 2.3
             * @product highcharts highstock
             */
            pointRange: null,

            states: {

                /**
                 * @extends plotOptions.series.states.hover
                 * @excluding halo,lineWidth,lineWidthPlus,marker
                 * @product highcharts highstock
                 */
                hover: {

                    /**
                     * @ignore-option
                     */
                    halo: false,
                    /**
                     * A specific border color for the hovered point. Defaults to
                     * inherit the normal state border color.
                     *
                     * @type {Color}
                     * @product highcharts
                     * @apioption plotOptions.column.states.hover.borderColor
                     */

                    /**
                     * A specific color for the hovered point.
                     *
                     * @type {Color}
                     * @default undefined
                     * @product highcharts
                     * @apioption plotOptions.column.states.hover.color
                     */



                    /**
                     * How much to brighten the point on interaction. Requires the main
                     * color to be defined in hex or rgb(a) format.
                     *
                     * In styled mode, the hover brightening is by default replaced
                     * with a fill-opacity set in the `.highcharts-point:hover` rule.
                     *
                     * @type {Number}
                     * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
                     *         Brighten by 0.5
                     * @default 0.1
                     * @product highcharts highstock
                     */
                    brightness: 0.1,

                    shadow: false

                },


                select: {
                    color: '#cccccc',
                    borderColor: '#000000',
                    shadow: false
                }

            },

            dataLabels: {
                align: null, // auto
                verticalAlign: null, // auto
                y: null
            },

            /**
             * When this is true, the series will not cause the Y axis to cross
             * the zero plane (or [threshold](#plotOptions.series.threshold) option)
             * unless the data actually crosses the plane.
             *
             * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
             * 3 will make the Y axis show negative values according to the `minPadding`
             * option. If `softThreshold` is `true`, the Y axis starts at 0.
             *
             * @type {Boolean}
             * @default {highcharts} true
             * @default {highstock} false
             * @since 4.1.9
             * @product highcharts highstock
             */
            softThreshold: false,

            // false doesn't work well: http://jsfiddle.net/highcharts/hz8fopan/14/
            /**	@ignore */
            startFromThreshold: true,

            stickyTracking: false,

            tooltip: {
                distance: 6
            },

            /**
             * The Y axis value to serve as the base for the columns, for distinguishing
             * between values above and below a threshold. If `null`, the columns
             * extend from the padding Y axis minimum.
             *
             * @type {Number}
             * @default 0
             * @since 2.0
             * @product highcharts
             */
            threshold: 0,


            /**
             * The color of the border surrounding each column or bar.
             *
             * In styled mode, the border stroke can be set with the `.highcharts-point`
             * rule.
             *
             * @type {Color}
             * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
             *         Dark gray border
             * @default #ffffff
             * @product highcharts highstock
             */
            borderColor: '#ffffff'
            // borderWidth: 1


        }, /** @lends seriesTypes.column.prototype */ {
            cropShoulder: 0,
            // When tooltip is not shared, this series (and derivatives) requires direct
            // touch/hover. KD-tree does not apply.
            directTouch: true,
            trackerGroups: ['group', 'dataLabelsGroup'],
            // use separate negative stacks, unlike area stacks where a negative point
            // is substracted from previous (#1910)
            negStacks: true,

            /**
             * Initialize the series. Extends the basic Series.init method by
             * marking other series of the same type as dirty.
             *
             * @function #init
             * @memberOf seriesTypes.column
             *
             */
            init: function() {
                Series.prototype.init.apply(this, arguments);

                var series = this,
                    chart = series.chart;

                // if the series is added dynamically, force redraw of other
                // series affected by a new column
                if (chart.hasRendered) {
                    each(chart.series, function(otherSeries) {
                        if (otherSeries.type === series.type) {
                            otherSeries.isDirty = true;
                        }
                    });
                }
            },

            /**
             * Return the width and x offset of the columns adjusted for grouping,
             * groupPadding, pointPadding, pointWidth etc.
             */
            getColumnMetrics: function() {

                var series = this,
                    options = series.options,
                    xAxis = series.xAxis,
                    yAxis = series.yAxis,
                    reversedXAxis = xAxis.reversed,
                    stackKey,
                    stackGroups = {},
                    columnCount = 0;

                // Get the total number of column type series. This is called on every
                // series. Consider moving this logic to a chart.orderStacks() function
                // and call it on init, addSeries and removeSeries
                if (options.grouping === false) {
                    columnCount = 1;
                } else {
                    each(series.chart.series, function(otherSeries) {
                        var otherOptions = otherSeries.options,
                            otherYAxis = otherSeries.yAxis,
                            columnIndex;
                        if (
                            otherSeries.type === series.type &&
                            (
                                otherSeries.visible ||
                                !series.chart.options.chart.ignoreHiddenSeries
                            ) &&
                            yAxis.len === otherYAxis.len &&
                            yAxis.pos === otherYAxis.pos
                        ) { // #642, #2086
                            if (otherOptions.stacking) {
                                stackKey = otherSeries.stackKey;
                                if (stackGroups[stackKey] === undefined) {
                                    stackGroups[stackKey] = columnCount++;
                                }
                                columnIndex = stackGroups[stackKey];
                            } else if (otherOptions.grouping !== false) { // #1162
                                columnIndex = columnCount++;
                            }
                            otherSeries.columnIndex = columnIndex;
                        }
                    });
                }

                var categoryWidth = Math.min(
                        Math.abs(xAxis.transA) * (
                            xAxis.ordinalSlope ||
                            options.pointRange ||
                            xAxis.closestPointRange ||
                            xAxis.tickInterval ||
                            1
                        ), // #2610
                        xAxis.len // #1535
                    ),
                    groupPadding = categoryWidth * options.groupPadding,
                    groupWidth = categoryWidth - 2 * groupPadding,
                    pointOffsetWidth = groupWidth / (columnCount || 1),
                    pointWidth = Math.min(
                        options.maxPointWidth || xAxis.len,
                        pick(
                            options.pointWidth,
                            pointOffsetWidth * (1 - 2 * options.pointPadding)
                        )
                    ),
                    pointPadding = (pointOffsetWidth - pointWidth) / 2,
                    // #1251, #3737
                    colIndex = (series.columnIndex || 0) + (reversedXAxis ? 1 : 0),
                    pointXOffset =
                    pointPadding +
                    (
                        groupPadding +
                        colIndex * pointOffsetWidth -
                        (categoryWidth / 2)
                    ) * (reversedXAxis ? -1 : 1);

                // Save it for reading in linked series (Error bars particularly)
                series.columnMetrics = {
                    width: pointWidth,
                    offset: pointXOffset
                };
                return series.columnMetrics;

            },

            /**
             * Make the columns crisp. The edges are rounded to the nearest full pixel.
             */
            crispCol: function(x, y, w, h) {
                var chart = this.chart,
                    borderWidth = this.borderWidth,
                    xCrisp = -(borderWidth % 2 ? 0.5 : 0),
                    yCrisp = borderWidth % 2 ? 0.5 : 1,
                    right,
                    bottom,
                    fromTop;

                if (chart.inverted && chart.renderer.isVML) {
                    yCrisp += 1;
                }

                // Horizontal. We need to first compute the exact right edge, then round
                // it and compute the width from there.
                if (this.options.crisp) {
                    right = Math.round(x + w) + xCrisp;
                    x = Math.round(x) + xCrisp;
                    w = right - x;
                }

                // Vertical
                bottom = Math.round(y + h) + yCrisp;
                fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
                y = Math.round(y) + yCrisp;
                h = bottom - y;

                // Top edges are exceptions
                if (fromTop && h) { // #5146
                    y -= 1;
                    h += 1;
                }

                return {
                    x: x,
                    y: y,
                    width: w,
                    height: h
                };
            },

            /**
             * Translate each point to the plot area coordinate system and find shape
             * positions
             */
            translate: function() {
                var series = this,
                    chart = series.chart,
                    options = series.options,
                    dense = series.dense =
                    series.closestPointRange * series.xAxis.transA < 2,
                    borderWidth = series.borderWidth = pick(
                        options.borderWidth,
                        dense ? 0 : 1 // #3635
                    ),
                    yAxis = series.yAxis,
                    threshold = options.threshold,
                    translatedThreshold = series.translatedThreshold =
                    yAxis.getThreshold(threshold),
                    minPointLength = pick(options.minPointLength, 5),
                    metrics = series.getColumnMetrics(),
                    pointWidth = metrics.width,
                    // postprocessed for border width
                    seriesBarW = series.barW =
                    Math.max(pointWidth, 1 + 2 * borderWidth),
                    pointXOffset = series.pointXOffset = metrics.offset;

                if (chart.inverted) {
                    translatedThreshold -= 0.5; // #3355
                }

                // When the pointPadding is 0, we want the columns to be packed tightly,
                // so we allow individual columns to have individual sizes. When
                // pointPadding is greater, we strive for equal-width columns (#2694).
                if (options.pointPadding) {
                    seriesBarW = Math.ceil(seriesBarW);
                }

                Series.prototype.translate.apply(series);

                // Record the new values
                each(series.points, function(point) {
                    var yBottom = pick(point.yBottom, translatedThreshold),
                        safeDistance = 999 + Math.abs(yBottom),
                        plotY = Math.min(
                            Math.max(-safeDistance, point.plotY),
                            yAxis.len + safeDistance
                        ), // Don't draw too far outside plot area (#1303, #2241, #4264)
                        barX = point.plotX + pointXOffset,
                        barW = seriesBarW,
                        barY = Math.min(plotY, yBottom),
                        up,
                        barH = Math.max(plotY, yBottom) - barY;

                    // Handle options.minPointLength
                    if (minPointLength && Math.abs(barH) < minPointLength) {
                        barH = minPointLength;
                        up = (!yAxis.reversed && !point.negative) ||
                            (yAxis.reversed && point.negative);

                        // Reverse zeros if there's no positive value in the series
                        // in visible range (#7046)
                        if (point.y === 0 && series.dataMax <= 0) {
                            up = !up;
                        }

                        // If stacked...
                        barY = Math.abs(barY - translatedThreshold) > minPointLength ?
                            // ...keep position
                            yBottom - minPointLength :
                            // #1485, #4051
                            translatedThreshold - (up ? minPointLength : 0);
                    }

                    // Cache for access in polar
                    point.barX = barX;
                    point.pointWidth = pointWidth;

                    // Fix the tooltip on center of grouped columns (#1216, #424, #3648)
                    point.tooltipPos = chart.inverted ? [
                        yAxis.len + yAxis.pos - chart.plotLeft - plotY,
                        series.xAxis.len - barX - barW / 2, barH
                    ] : [barX + barW / 2, plotY + yAxis.pos - chart.plotTop, barH];

                    // Register shape type and arguments to be used in drawPoints
                    point.shapeType = 'rect';
                    point.shapeArgs = series.crispCol.apply(
                        series,
                        point.isNull ?
                        // #3169, drilldown from null must have a position to work
                        // from #6585, dataLabel should be placed on xAxis, not
                        // floating in the middle of the chart
                        [barX, translatedThreshold, barW, 0] : [barX, barY, barW, barH]
                    );
                });

            },

            getSymbol: noop,

            /**
             * Use a solid rectangle like the area series types
             */
            drawLegendSymbol: LegendSymbolMixin.drawRectangle,


            /**
             * Columns have no graph
             */
            drawGraph: function() {
                this.group[
                    this.dense ? 'addClass' : 'removeClass'
                ]('highcharts-dense-data');
            },


            /**
             * Get presentational attributes
             */
            pointAttribs: function(point, state) {
                var options = this.options,
                    stateOptions,
                    ret,
                    p2o = this.pointAttrToOptions || {},
                    strokeOption = p2o.stroke || 'borderColor',
                    strokeWidthOption = p2o['stroke-width'] || 'borderWidth',
                    fill = (point && point.color) || this.color,
                    stroke = (point && point[strokeOption]) || options[strokeOption] ||
                    this.color || fill, // set to fill when borderColor null
                    strokeWidth = (point && point[strokeWidthOption]) ||
                    options[strokeWidthOption] || this[strokeWidthOption] || 0,
                    dashstyle = options.dashStyle,
                    zone,
                    brightness;

                // Handle zone colors
                if (point && this.zones.length) {
                    zone = point.getZone();
                    // When zones are present, don't use point.color (#4267). Changed
                    // order (#6527)
                    fill = point.options.color || (zone && zone.color) || this.color;
                }

                // Select or hover states
                if (state) {
                    stateOptions = merge(
                        options.states[state],
                        // #6401
                        point.options.states && point.options.states[state] || {}
                    );
                    brightness = stateOptions.brightness;
                    fill = stateOptions.color ||
                        (
                            brightness !== undefined &&
                            color(fill).brighten(stateOptions.brightness).get()
                        ) ||
                        fill;
                    stroke = stateOptions[strokeOption] || stroke;
                    strokeWidth = stateOptions[strokeWidthOption] || strokeWidth;
                    dashstyle = stateOptions.dashStyle || dashstyle;
                }

                ret = {
                    'fill': fill,
                    'stroke': stroke,
                    'stroke-width': strokeWidth
                };

                if (dashstyle) {
                    ret.dashstyle = dashstyle;
                }

                return ret;
            },


            /**
             * Draw the columns. For bars, the series.group is rotated, so the same
             * coordinates apply for columns and bars. This method is inherited by
             * scatter series.
             */
            drawPoints: function() {
                var series = this,
                    chart = this.chart,
                    options = series.options,
                    renderer = chart.renderer,
                    animationLimit = options.animationLimit || 250,
                    shapeArgs;

                // draw the columns
                each(series.points, function(point) {
                    var plotY = point.plotY,
                        graphic = point.graphic;

                    if (isNumber(plotY) && point.y !== null) {
                        shapeArgs = point.shapeArgs;

                        if (graphic) { // update
                            graphic[
                                chart.pointCount < animationLimit ? 'animate' : 'attr'
                            ](
                                merge(shapeArgs)
                            );

                        } else {
                            point.graphic = graphic =
                                renderer[point.shapeType](shapeArgs)
                                .add(point.group || series.group);
                        }

                        // Border radius is not stylable (#6900)
                        if (options.borderRadius) {
                            graphic.attr({
                                r: options.borderRadius
                            });
                        }


                        // Presentational
                        graphic
                            .attr(series.pointAttribs(
                                point,
                                point.selected && 'select'
                            ))
                            .shadow(
                                options.shadow,
                                null,
                                options.stacking && !options.borderRadius
                            );


                        graphic.addClass(point.getClassName(), true);


                    } else if (graphic) {
                        point.graphic = graphic.destroy(); // #1269
                    }
                });
            },

            /**
             * Animate the column heights one by one from zero
             * @param {Boolean} init Whether to initialize the animation or run it
             */
            animate: function(init) {
                var series = this,
                    yAxis = this.yAxis,
                    options = series.options,
                    inverted = this.chart.inverted,
                    attr = {},
                    translateProp = inverted ? 'translateX' : 'translateY',
                    translateStart,
                    translatedThreshold;

                if (svg) { // VML is too slow anyway
                    if (init) {
                        attr.scaleY = 0.001;
                        translatedThreshold = Math.min(
                            yAxis.pos + yAxis.len,
                            Math.max(yAxis.pos, yAxis.toPixels(options.threshold))
                        );
                        if (inverted) {
                            attr.translateX = translatedThreshold - yAxis.len;
                        } else {
                            attr.translateY = translatedThreshold;
                        }
                        series.group.attr(attr);

                    } else { // run the animation
                        translateStart = series.group.attr(translateProp);
                        series.group.animate({
                                scaleY: 1
                            },
                            extend(animObject(series.options.animation), {
                                // Do the scale synchronously to ensure smooth updating
                                // (#5030, #7228)
                                step: function(val, fx) {

                                    attr[translateProp] =
                                        translateStart +
                                        fx.pos * (yAxis.pos - translateStart);
                                    series.group.attr(attr);
                                }
                            }));

                        // delete this function to allow it only once
                        series.animate = null;
                    }
                }
            },

            /**
             * Remove this series from the chart
             */
            remove: function() {
                var series = this,
                    chart = series.chart;

                // column and bar series affects other series of the same type
                // as they are either stacked or grouped
                if (chart.hasRendered) {
                    each(chart.series, function(otherSeries) {
                        if (otherSeries.type === series.type) {
                            otherSeries.isDirty = true;
                        }
                    });
                }

                Series.prototype.remove.apply(series, arguments);
            }
        });


        /**
         * A `column` series. If the [type](#series.column.type) option is
         * not specified, it is inherited from [chart.type](#chart.type).
         *
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * column](#plotOptions.column).
         *
         * @type {Object}
         * @extends series,plotOptions.column
         * @excluding dataParser,dataURL
         * @product highcharts highstock
         * @apioption series.column
         */

        /**
         * An array of data points for the series. For the `column` series type,
         * points can be given in the following ways:
         *
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. The `x` values will be automatically
         * calculated, either starting at 0 and incremented by 1, or from `pointStart`
         * and `pointInterval` given in the series options. If the axis has
         * categories, these will be used. Example:
         *
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         *
         * 2.  An array of arrays with 2 values. In this case, the values correspond
         * to `x,y`. If the first value is a string, it is applied as the name
         * of the point, and the `x` value is inferred.
         *
         *  ```js
         *     data: [
         *         [0, 6],
         *         [1, 2],
         *         [2, 6]
         *     ]
         *  ```
         *
         * 3.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.column.turboThreshold),
         * this option is not available.
         *
         *  ```js
         *     data: [{
         *         x: 1,
         *         y: 9,
         *         name: "Point2",
         *         color: "#00FF00"
         *     }, {
         *         x: 1,
         *         y: 6,
         *         name: "Point1",
         *         color: "#FF00FF"
         *     }]
         *  ```
         *
         * @type {Array<Object|Array|Number>}
         * @extends series.line.data
         * @excluding marker
         * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/
         *         Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
         *         Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/
         *         Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/
         *         Config objects
         * @product highcharts highstock
         * @apioption series.column.data
         */


    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */

        var seriesType = H.seriesType;

        /**
         * The Bar series class
         */
        seriesType('bar', 'column', null, {
            inverted: true
        });
        /**
         * A bar series is a special type of column series where the columns are
         * horizontal.
         *
         * @sample highcharts/demo/bar-basic/ Bar chart
         * @extends {plotOptions.column}
         * @product highcharts
         * @optionparent plotOptions.bar
         */


        /**
         * A `bar` series. If the [type](#series.bar.type) option is not specified,
         * it is inherited from [chart.type](#chart.type).
         * 
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * bar](#plotOptions.bar).
         * 
         * @type {Object}
         * @extends series,plotOptions.bar
         * @excluding dataParser,dataURL
         * @product highcharts
         * @apioption series.bar
         */

        /**
         * An array of data points for the series. For the `bar` series type,
         * points can be given in the following ways:
         * 
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. The `x` values will be automatically
         * calculated, either starting at 0 and incremented by 1, or from `pointStart`
         * and `pointInterval` given in the series options. If the axis has
         * categories, these will be used. Example:
         * 
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         * 
         * 2.  An array of arrays with 2 values. In this case, the values correspond
         * to `x,y`. If the first value is a string, it is applied as the name
         * of the point, and the `x` value is inferred.
         * 
         *  ```js
         *     data: [
         *         [0, 5],
         *         [1, 10],
         *         [2, 3]
         *     ]
         *  ```
         * 
         * 3.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.bar.turboThreshold),
         * this option is not available.
         * 
         *  ```js
         *     data: [{
         *         x: 1,
         *         y: 1,
         *         name: "Point2",
         *         color: "#00FF00"
         *     }, {
         *         x: 1,
         *         y: 10,
         *         name: "Point1",
         *         color: "#FF00FF"
         *     }]
         *  ```
         * 
         * @type {Array<Object|Array|Number>}
         * @extends series.column.data
         * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/ Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/ Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/ Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/ Config objects
         * @product highcharts
         * @apioption series.bar.data
         */

        /**
         * Alignment of the data label relative to the data point.
         * 
         * @type {String}
         * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
         *         Data labels inside the bar
         * @default left
         * @product highcharts
         * @apioption plotOptions.bar.dataLabels.align
         */

        /**
         * The x position of the data label relative to the data point.
         * 
         * @type {Number}
         * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
         *         Data labels inside the bar
         * @default 5
         * @product highcharts
         * @apioption plotOptions.bar.dataLabels.x
         */

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var Series = H.Series,
            seriesType = H.seriesType;

        /**
         * A scatter plot uses cartesian coordinates to display values for two variables
         * for a set of data.
         *
         * @sample {highcharts} highcharts/demo/scatter/ Scatter plot
         * 
         * @extends {plotOptions.line}
         * @product highcharts highstock
         * @optionparent plotOptions.scatter
         */
        seriesType('scatter', 'line', {

            /**
             * The width of the line connecting the data points.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
             *         0 by default
             * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
             *         1px
             * @default 0
             * @product highcharts highstock
             */
            lineWidth: 0,

            findNearestPointBy: 'xy',
            marker: {
                enabled: true // Overrides auto-enabling in line series (#3647)
            },

            /**
             * Sticky tracking of mouse events. When true, the `mouseOut` event
             * on a series isn't triggered until the mouse moves over another series,
             * or out of the plot area. When false, the `mouseOut` event on a series
             * is triggered when the mouse leaves the area around the series' graph
             * or markers. This also implies the tooltip. When `stickyTracking`
             * is false and `tooltip.shared` is false, the tooltip will be hidden
             * when moving the mouse between series.
             * 
             * @type {Boolean}
             * @default false
             * @product highcharts highstock
             * @apioption plotOptions.scatter.stickyTracking
             */

            /**
             * A configuration object for the tooltip rendering of each single
             * series. Properties are inherited from <a class="internal">#tooltip</a>.
             * Overridable properties are `headerFormat`, `pointFormat`, `yDecimals`,
             * `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other series, in
             * a scatter plot the series.name by default shows in the headerFormat
             * and point.x and point.y in the pointFormat.
             * 
             * @product highcharts highstock
             */
            tooltip: {

                headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
                    '<span style="font-size: 0.85em"> {series.name}</span><br/>',


                pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
            }

            // Prototype members
        }, {
            sorted: false,
            requireSorting: false,
            noSharedTooltip: true,
            trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
            takeOrdinalPosition: false, // #2342
            drawGraph: function() {
                if (this.options.lineWidth) {
                    Series.prototype.drawGraph.call(this);
                }
            }
        });

        /**
         * A `scatter` series. If the [type](#series.scatter.type) option is
         * not specified, it is inherited from [chart.type](#chart.type).
         * 
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * scatter](#plotOptions.scatter).
         * 
         * @type {Object}
         * @extends series,plotOptions.scatter
         * @excluding dataParser,dataURL,stack
         * @product highcharts highstock
         * @apioption series.scatter
         */

        /**
         * An array of data points for the series. For the `scatter` series
         * type, points can be given in the following ways:
         * 
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. The `x` values will be automatically
         * calculated, either starting at 0 and incremented by 1, or from `pointStart`
         * and `pointInterval` given in the series options. If the axis has
         * categories, these will be used. Example:
         * 
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         * 
         * 2.  An array of arrays with 2 values. In this case, the values correspond
         * to `x,y`. If the first value is a string, it is applied as the name
         * of the point, and the `x` value is inferred.
         * 
         *  ```js
         *     data: [
         *         [0, 0],
         *         [1, 8],
         *         [2, 9]
         *     ]
         *  ```
         * 
         * 3.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.scatter.turboThreshold),
         * this option is not available.
         * 
         *  ```js
         *     data: [{
         *         x: 1,
         *         y: 2,
         *         name: "Point2",
         *         color: "#00FF00"
         *     }, {
         *         x: 1,
         *         y: 4,
         *         name: "Point1",
         *         color: "#FF00FF"
         *     }]
         *  ```
         * 
         * @type {Array<Object|Array|Number>}
         * @extends series.line.data
         * @sample {highcharts} highcharts/chart/reflow-true/
         *         Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/
         *         Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
         *         Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/
         *         Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/
         *         Config objects
         * @product highcharts highstock
         * @apioption series.scatter.data
         */


    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var deg2rad = H.deg2rad,
            isNumber = H.isNumber,
            pick = H.pick,
            relativeLength = H.relativeLength;
        H.CenteredSeriesMixin = {
            /**
             * Get the center of the pie based on the size and center options relative to the
             * plot area. Borrowed by the polar and gauge series types.
             */
            getCenter: function() {

                var options = this.options,
                    chart = this.chart,
                    slicingRoom = 2 * (options.slicedOffset || 0),
                    handleSlicingRoom,
                    plotWidth = chart.plotWidth - 2 * slicingRoom,
                    plotHeight = chart.plotHeight - 2 * slicingRoom,
                    centerOption = options.center,
                    positions = [pick(centerOption[0], '50%'), pick(centerOption[1], '50%'), options.size || '100%', options.innerSize || 0],
                    smallestSize = Math.min(plotWidth, plotHeight),
                    i,
                    value;

                for (i = 0; i < 4; ++i) {
                    value = positions[i];
                    handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));

                    // i == 0: centerX, relative to width
                    // i == 1: centerY, relative to height
                    // i == 2: size, relative to smallestSize
                    // i == 3: innerSize, relative to size
                    positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) +
                        (handleSlicingRoom ? slicingRoom : 0);

                }
                // innerSize cannot be larger than size (#3632)
                if (positions[3] > positions[2]) {
                    positions[3] = positions[2];
                }
                return positions;
            },
            /**
             * getStartAndEndRadians - Calculates start and end angles in radians.
             * Used in series types such as pie and sunburst.
             *
             * @param  {Number} start Start angle in degrees.
             * @param  {Number} end Start angle in degrees.
             * @return {object} Returns an object containing start and end angles as
             * radians.
             */
            getStartAndEndRadians: function getStartAndEndRadians(start, end) {
                var startAngle = isNumber(start) ? start : 0, // must be a number
                    endAngle = (
                        (
                            isNumber(end) && // must be a number
                            end > startAngle && // must be larger than the start angle
                            // difference must be less than 360 degrees
                            (end - startAngle) < 360
                        ) ?
                        end :
                        startAngle + 360
                    ),
                    correction = -90;
                return {
                    start: deg2rad * (startAngle + correction),
                    end: deg2rad * (endAngle + correction)
                };
            }
        };

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var addEvent = H.addEvent,
            CenteredSeriesMixin = H.CenteredSeriesMixin,
            defined = H.defined,
            each = H.each,
            extend = H.extend,
            getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians,
            inArray = H.inArray,
            LegendSymbolMixin = H.LegendSymbolMixin,
            noop = H.noop,
            pick = H.pick,
            Point = H.Point,
            Series = H.Series,
            seriesType = H.seriesType,
            seriesTypes = H.seriesTypes,
            setAnimation = H.setAnimation;

        /**
         * The pie series type.
         *
         * @constructor seriesTypes.pie
         * @augments Series
         */

        /**
         * A pie chart is a circular graphic which is divided into slices to illustrate
         * numerical proportion.
         *
         * @sample highcharts/demo/pie-basic/ Pie chart
         * 
         * @extends {plotOptions.line}
         * @excluding animationLimit,boostThreshold,connectEnds,connectNulls,
         *          cropThreshold,dashStyle,findNearestPointBy,getExtremesFromAll,
         *          lineWidth,marker,negativeColor,pointInterval,pointIntervalUnit,
         *          pointPlacement,pointStart,softThreshold,stacking,step,threshold,
         *          turboThreshold,zoneAxis,zones
         * @product highcharts
         * @optionparent plotOptions.pie
         */
        seriesType('pie', 'line', {

            /**
             * The center of the pie chart relative to the plot area. Can be percentages
             * or pixel values. The default behaviour (as of 3.0) is to center
             * the pie so that all slices and data labels are within the plot area.
             * As a consequence, the pie may actually jump around in a chart with
             * dynamic values, as the data labels move. In that case, the center
             * should be explicitly set, for example to `["50%", "50%"]`.
             * 
             * @type {Array<String|Number>}
             * @sample {highcharts} highcharts/plotoptions/pie-center/ Centered at 100, 100
             * @default [null, null]
             * @product highcharts
             */
            center: [null, null],

            clip: false,

            /** @ignore */
            colorByPoint: true, // always true for pies

            /**
             * A series specific or series type specific color set to use instead
             * of the global [colors](#colors).
             * 
             * @type {Array<Color>}
             * @sample {highcharts} highcharts/demo/pie-monochrome/ Set default colors for all pies
             * @since 3.0
             * @product highcharts
             * @apioption plotOptions.pie.colors
             */

            /**
             * @extends plotOptions.series.dataLabels
             * @excluding align,allowOverlap,staggerLines,step
             * @product highcharts
             */
            dataLabels: {
                /**
                 * The color of the line connecting the data label to the pie slice.
                 * The default color is the same as the point's color.
                 * 
                 * In styled mode, the connector stroke is given in the
                 * `.highcharts-data-label-connector` class.
                 * 
                 * @type {String}
                 * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/ Blue connectors
                 * @sample {highcharts} highcharts/css/pie-point/ Styled connectors
                 * @default {point.color}
                 * @since 2.1
                 * @product highcharts
                 * @apioption plotOptions.pie.dataLabels.connectorColor
                 */

                /**
                 * The distance from the data label to the connector.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/ No padding
                 * @default 5
                 * @since 2.1
                 * @product highcharts
                 * @apioption plotOptions.pie.dataLabels.connectorPadding
                 */

                /**
                 * The width of the line connecting the data label to the pie slice.
                 * 
                 * 
                 * In styled mode, the connector stroke width is given in the
                 * `.highcharts-data-label-connector` class.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/ Disable the connector
                 * @sample {highcharts} highcharts/css/pie-point/ Styled connectors
                 * @default 1
                 * @since 2.1
                 * @product highcharts
                 * @apioption plotOptions.pie.dataLabels.connectorWidth
                 */

                /**
                 * The distance of the data label from the pie's edge. Negative numbers
                 * put the data label on top of the pie slices. Connectors are only
                 * shown for data labels outside the pie.
                 * 
                 * @type {Number}
                 * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/ Data labels on top of the pie
                 * @default 30
                 * @since 2.1
                 * @product highcharts
                 */
                distance: 30,

                /**
                 * Enable or disable the data labels.
                 * 
                 * @type {Boolean}
                 * @since 2.1
                 * @product highcharts
                 */
                enabled: true,

                formatter: function() { // #2945
                    return this.point.isNull ? undefined : this.point.name;
                },

                /**
                 * Whether to render the connector as a soft arc or a line with sharp
                 * break.
                 * 
                 * @type {Boolean}
                 * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/ Soft
                 * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/ Non soft
                 * @since 2.1.7
                 * @product highcharts
                 * @apioption plotOptions.pie.dataLabels.softConnector
                 */

                x: 0
                // y: 0
            },

            /**
             * The end angle of the pie in degrees where 0 is top and 90 is right.
             * Defaults to `startAngle` plus 360.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/demo/pie-semi-circle/ Semi-circle donut
             * @default null
             * @since 1.3.6
             * @product highcharts
             * @apioption plotOptions.pie.endAngle
             */

            /**
             * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
             * this option tells whether the series shall be redrawn as if the
             * hidden point were `null`.
             * 
             * The default value changed from `false` to `true` with Highcharts
             * 3.0.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/ True, the hiddden point is ignored
             * @default true
             * @since 2.3.0
             * @product highcharts
             */
            ignoreHiddenPoint: true,

            /**
             * The size of the inner diameter for the pie. A size greater than 0
             * renders a donut chart. Can be a percentage or pixel value. Percentages
             * are relative to the pie size. Pixel values are given as integers.
             * 
             * 
             * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
             * area, not the pie size.
             * 
             * @type {String|Number}
             * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/ 80px inner size
             * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/ 50% of the plot area
             * @sample {highcharts} highcharts/demo/3d-pie-donut/ 3D donut
             * @default 0
             * @since 2.0
             * @product highcharts
             * @apioption plotOptions.pie.innerSize
             */

            /** @ignore */
            legendType: 'point',

            /**	 @ignore */
            marker: null, // point options are specified in the base options

            /**
             * The minimum size for a pie in response to auto margins. The pie will
             * try to shrink to make room for data labels in side the plot area,
             *  but only to this size.
             * 
             * @type {Number}
             * @default 80
             * @since 3.0
             * @product highcharts
             * @apioption plotOptions.pie.minSize
             */

            /**
             * The diameter of the pie relative to the plot area. Can be a percentage
             * or pixel value. Pixel values are given as integers. The default
             * behaviour (as of 3.0) is to scale to the plot area and give room
             * for data labels within the plot area. As a consequence, the size
             * of the pie may vary when points are updated and data labels more
             * around. In that case it is best to set a fixed value, for example
             * `"75%"`.
             * 
             * @type {String|Number}
             * @sample {highcharts} highcharts/plotoptions/pie-size/ Smaller pie
             * @default  
             * @product highcharts
             */
            size: null,

            /**
             * Whether to display this particular series or series type in the
             * legend. Since 2.1, pies are not shown in the legend by default.
             * 
             * @type {Boolean}
             * @sample {highcharts} highcharts/plotoptions/series-showinlegend/ One series in the legend, one hidden
             * @product highcharts
             */
            showInLegend: false,

            /**
             * If a point is sliced, moved out from the center, how many pixels
             * should it be moved?.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/ 20px offset
             * @default 10
             * @product highcharts
             */
            slicedOffset: 10,

            /**
             * The start angle of the pie slices in degrees where 0 is top and 90
             * right.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/ Start from right
             * @default 0
             * @since 2.3.4
             * @product highcharts
             * @apioption plotOptions.pie.startAngle
             */

            /**
             * Sticky tracking of mouse events. When true, the `mouseOut` event
             * on a series isn't triggered until the mouse moves over another series,
             * or out of the plot area. When false, the `mouseOut` event on a
             * series is triggered when the mouse leaves the area around the series'
             * graph or markers. This also implies the tooltip. When `stickyTracking`
             * is false and `tooltip.shared` is false, the tooltip will be hidden
             * when moving the mouse between series.
             * 
             * @product highcharts
             */
            stickyTracking: false,

            tooltip: {
                followPointer: true
            },


            /**
             * The color of the border surrounding each slice. When `null`, the
             * border takes the same color as the slice fill. This can be used
             * together with a `borderWidth` to fill drawing gaps created by antialiazing
             * artefacts in borderless pies.
             * 
             * In styled mode, the border stroke is given in the `.highcharts-point` class.
             * 
             * @type {Color}
             * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/ Black border
             * @default #ffffff
             * @product highcharts
             */
            borderColor: '#ffffff',

            /**
             * The width of the border surrounding each slice.
             * 
             * When setting the border width to 0, there may be small gaps between
             * the slices due to SVG antialiasing artefacts. To work around this,
             * keep the border width at 0.5 or 1, but set the `borderColor` to
             * `null` instead.
             * 
             * In styled mode, the border stroke width is given in the `.highcharts-point` class.
             * 
             * @type {Number}
             * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/ 3px border
             * @default 1
             * @product highcharts
             */
            borderWidth: 1,

            states: {

                /**
                 * @extends plotOptions.series.states.hover
                 * @product highcharts
                 */
                hover: {

                    /**
                     * How much to brighten the point on interaction. Requires the main
                     * color to be defined in hex or rgb(a) format.
                     * 
                     * In styled mode, the hover brightness is by default replaced
                     * by a fill-opacity given in the `.highcharts-point-hover` class.
                     * 
                     * @type {Number}
                     * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/ Brightened by 0.5
                     * @default 0.1
                     * @product highcharts
                     */
                    brightness: 0.1,

                    shadow: false
                }
            }


        }, /** @lends seriesTypes.pie.prototype */ {
            isCartesian: false,
            requireSorting: false,
            directTouch: true,
            noSharedTooltip: true,
            trackerGroups: ['group', 'dataLabelsGroup'],
            axisTypes: [],
            pointAttribs: seriesTypes.column.prototype.pointAttribs,
            /**
             * Animate the pies in
             */
            animate: function(init) {
                var series = this,
                    points = series.points,
                    startAngleRad = series.startAngleRad;

                if (!init) {
                    each(points, function(point) {
                        var graphic = point.graphic,
                            args = point.shapeArgs;

                        if (graphic) {
                            // start values
                            graphic.attr({
                                r: point.startR || (series.center[3] / 2), // animate from inner radius (#779)
                                start: startAngleRad,
                                end: startAngleRad
                            });

                            // animate
                            graphic.animate({
                                r: args.r,
                                start: args.start,
                                end: args.end
                            }, series.options.animation);
                        }
                    });

                    // delete this function to allow it only once
                    series.animate = null;
                }
            },

            /**
             * Recompute total chart sum and update percentages of points.
             */
            updateTotals: function() {
                var i,
                    total = 0,
                    points = this.points,
                    len = points.length,
                    point,
                    ignoreHiddenPoint = this.options.ignoreHiddenPoint;

                // Get the total sum
                for (i = 0; i < len; i++) {
                    point = points[i];
                    total += (ignoreHiddenPoint && !point.visible) ?
                        0 :
                        point.isNull ? 0 : point.y;
                }
                this.total = total;

                // Set each point's properties
                for (i = 0; i < len; i++) {
                    point = points[i];
                    point.percentage = (total > 0 && (point.visible || !ignoreHiddenPoint)) ? point.y / total * 100 : 0;
                    point.total = total;
                }
            },

            /**
             * Extend the generatePoints method by adding total and percentage properties to each point
             */
            generatePoints: function() {
                Series.prototype.generatePoints.call(this);
                this.updateTotals();
            },

            /**
             * Do translation for pie slices
             */
            translate: function(positions) {
                this.generatePoints();

                var series = this,
                    cumulative = 0,
                    precision = 1000, // issue #172
                    options = series.options,
                    slicedOffset = options.slicedOffset,
                    connectorOffset = slicedOffset + (options.borderWidth || 0),
                    finalConnectorOffset,
                    start,
                    end,
                    angle,
                    radians = getStartAndEndRadians(options.startAngle, options.endAngle),
                    startAngleRad = series.startAngleRad = radians.start,
                    endAngleRad = series.endAngleRad = radians.end,
                    circ = endAngleRad - startAngleRad, // 2 * Math.PI,
                    points = series.points,
                    radiusX, // the x component of the radius vector for a given point
                    radiusY,
                    labelDistance = options.dataLabels.distance,
                    ignoreHiddenPoint = options.ignoreHiddenPoint,
                    i,
                    len = points.length,
                    point;

                // Get positions - either an integer or a percentage string must be given.
                // If positions are passed as a parameter, we're in a recursive loop for adjusting
                // space for data labels.
                if (!positions) {
                    series.center = positions = series.getCenter();
                }

                // Utility for getting the x value from a given y, used for anticollision
                // logic in data labels.
                // Added point for using specific points' label distance.
                series.getX = function(y, left, point) {
                    angle = Math.asin(Math.min((y - positions[1]) / (positions[2] / 2 + point.labelDistance), 1));
                    return positions[0] +
                        (left ? -1 : 1) *
                        (Math.cos(angle) * (positions[2] / 2 + point.labelDistance));
                };

                // Calculate the geometry for each point
                for (i = 0; i < len; i++) {

                    point = points[i];

                    // Used for distance calculation for specific point.
                    point.labelDistance = pick(
                        point.options.dataLabels && point.options.dataLabels.distance,
                        labelDistance
                    );

                    // Saved for later dataLabels distance calculation.
                    series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);

                    // set start and end angle
                    start = startAngleRad + (cumulative * circ);
                    if (!ignoreHiddenPoint || point.visible) {
                        cumulative += point.percentage / 100;
                    }
                    end = startAngleRad + (cumulative * circ);

                    // set the shape
                    point.shapeType = 'arc';
                    point.shapeArgs = {
                        x: positions[0],
                        y: positions[1],
                        r: positions[2] / 2,
                        innerR: positions[3] / 2,
                        start: Math.round(start * precision) / precision,
                        end: Math.round(end * precision) / precision
                    };

                    // The angle must stay within -90 and 270 (#2645)
                    angle = (end + start) / 2;
                    if (angle > 1.5 * Math.PI) {
                        angle -= 2 * Math.PI;
                    } else if (angle < -Math.PI / 2) {
                        angle += 2 * Math.PI;
                    }

                    // Center for the sliced out slice
                    point.slicedTranslation = {
                        translateX: Math.round(Math.cos(angle) * slicedOffset),
                        translateY: Math.round(Math.sin(angle) * slicedOffset)
                    };

                    // set the anchor point for tooltips
                    radiusX = Math.cos(angle) * positions[2] / 2;
                    radiusY = Math.sin(angle) * positions[2] / 2;
                    point.tooltipPos = [
                        positions[0] + radiusX * 0.7,
                        positions[1] + radiusY * 0.7
                    ];

                    point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ? 1 : 0;
                    point.angle = angle;

                    // Set the anchor point for data labels. Use point.labelDistance 
                    // instead of labelDistance // #1174
                    // finalConnectorOffset - not override connectorOffset value.
                    finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
                    point.labelPos = [
                        positions[0] + radiusX + Math.cos(angle) * point.labelDistance, // first break of connector
                        positions[1] + radiusY + Math.sin(angle) * point.labelDistance, // a/a
                        positions[0] + radiusX + Math.cos(angle) * finalConnectorOffset, // second break, right outside pie
                        positions[1] + radiusY + Math.sin(angle) * finalConnectorOffset, // a/a
                        positions[0] + radiusX, // landing point for connector
                        positions[1] + radiusY, // a/a
                        point.labelDistance < 0 ? // alignment
                        'center' :
                        point.half ? 'right' : 'left', // alignment
                        angle // center angle
                    ];

                }
            },

            drawGraph: null,

            /**
             * Draw the data points
             */
            drawPoints: function() {
                var series = this,
                    chart = series.chart,
                    renderer = chart.renderer,
                    groupTranslation,
                    graphic,
                    pointAttr,
                    shapeArgs;


                var shadow = series.options.shadow;
                if (shadow && !series.shadowGroup) {
                    series.shadowGroup = renderer.g('shadow')
                        .add(series.group);
                }


                // draw the slices
                each(series.points, function(point) {
                    graphic = point.graphic;
                    if (!point.isNull) {
                        shapeArgs = point.shapeArgs;


                        // If the point is sliced, use special translation, else use
                        // plot area traslation
                        groupTranslation = point.getTranslate();


                        // Put the shadow behind all points
                        var shadowGroup = point.shadowGroup;
                        if (shadow && !shadowGroup) {
                            shadowGroup = point.shadowGroup = renderer.g('shadow')
                                .add(series.shadowGroup);
                        }

                        if (shadowGroup) {
                            shadowGroup.attr(groupTranslation);
                        }
                        pointAttr = series.pointAttribs(point, point.selected && 'select');


                        // Draw the slice
                        if (graphic) {
                            graphic
                                .setRadialReference(series.center)

                                .attr(pointAttr)

                                .animate(extend(shapeArgs, groupTranslation));
                        } else {

                            point.graphic = graphic = renderer[point.shapeType](shapeArgs)
                                .setRadialReference(series.center)
                                .attr(groupTranslation)
                                .add(series.group);

                            if (!point.visible) {
                                graphic.attr({
                                    visibility: 'hidden'
                                });
                            }


                            graphic
                                .attr(pointAttr)
                                .attr({
                                    'stroke-linejoin': 'round'
                                })
                                .shadow(shadow, shadowGroup);

                        }

                        graphic.addClass(point.getClassName());

                    } else if (graphic) {
                        point.graphic = graphic.destroy();
                    }
                });

            },


            searchPoint: noop,

            /**
             * Utility for sorting data labels
             */
            sortByAngle: function(points, sign) {
                points.sort(function(a, b) {
                    return a.angle !== undefined && (b.angle - a.angle) * sign;
                });
            },

            /**
             * Use a simple symbol from LegendSymbolMixin
             */
            drawLegendSymbol: LegendSymbolMixin.drawRectangle,

            /**
             * Use the getCenter method from drawLegendSymbol
             */
            getCenter: CenteredSeriesMixin.getCenter,

            /**
             * Pies don't have point marker symbols
             */
            getSymbol: noop


            /**
             * @constructor seriesTypes.pie.prototype.pointClass
             * @extends {Point}
             */
        }, /** @lends seriesTypes.pie.prototype.pointClass.prototype */ {
            /**
             * Initiate the pie slice
             */
            init: function() {

                Point.prototype.init.apply(this, arguments);

                var point = this,
                    toggleSlice;

                point.name = pick(point.name, 'Slice');

                // add event listener for select
                toggleSlice = function(e) {
                    point.slice(e.type === 'select');
                };
                addEvent(point, 'select', toggleSlice);
                addEvent(point, 'unselect', toggleSlice);

                return point;
            },

            /**
             * Negative points are not valid (#1530, #3623, #5322)
             */
            isValid: function() {
                return H.isNumber(this.y, true) && this.y >= 0;
            },

            /**
             * Toggle the visibility of the pie slice
             * @param {Boolean} vis Whether to show the slice or not. If undefined, the
             *    visibility is toggled
             */
            setVisible: function(vis, redraw) {
                var point = this,
                    series = point.series,
                    chart = series.chart,
                    ignoreHiddenPoint = series.options.ignoreHiddenPoint;

                redraw = pick(redraw, ignoreHiddenPoint);

                if (vis !== point.visible) {

                    // If called without an argument, toggle visibility
                    point.visible = point.options.visible = vis = vis === undefined ? !point.visible : vis;
                    series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data

                    // Show and hide associated elements. This is performed regardless of redraw or not,
                    // because chart.redraw only handles full series.
                    each(['graphic', 'dataLabel', 'connector', 'shadowGroup'], function(key) {
                        if (point[key]) {
                            point[key][vis ? 'show' : 'hide'](true);
                        }
                    });

                    if (point.legendItem) {
                        chart.legend.colorizeItem(point, vis);
                    }

                    // #4170, hide halo after hiding point
                    if (!vis && point.state === 'hover') {
                        point.setState('');
                    }

                    // Handle ignore hidden slices
                    if (ignoreHiddenPoint) {
                        series.isDirty = true;
                    }

                    if (redraw) {
                        chart.redraw();
                    }
                }
            },

            /**
             * Set or toggle whether the slice is cut out from the pie
             * @param {Boolean} sliced When undefined, the slice state is toggled
             * @param {Boolean} redraw Whether to redraw the chart. True by default.
             */
            slice: function(sliced, redraw, animation) {
                var point = this,
                    series = point.series,
                    chart = series.chart;

                setAnimation(animation, chart);

                // redraw is true by default
                redraw = pick(redraw, true);

                // if called without an argument, toggle
                point.sliced = point.options.sliced = sliced = defined(sliced) ? sliced : !point.sliced;
                series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data

                point.graphic.animate(this.getTranslate());


                if (point.shadowGroup) {
                    point.shadowGroup.animate(this.getTranslate());
                }

            },

            getTranslate: function() {
                return this.sliced ? this.slicedTranslation : {
                    translateX: 0,
                    translateY: 0
                };
            },

            haloPath: function(size) {
                var shapeArgs = this.shapeArgs;

                return this.sliced || !this.visible ? [] :
                    this.series.chart.renderer.symbols.arc(
                        shapeArgs.x,
                        shapeArgs.y,
                        shapeArgs.r + size,
                        shapeArgs.r + size, {
                            innerR: this.shapeArgs.r,
                            start: shapeArgs.start,
                            end: shapeArgs.end
                        }
                    );
            }
        });

        /**
         * A `pie` series. If the [type](#series.pie.type) option is not specified,
         * it is inherited from [chart.type](#chart.type).
         * 
         * For options that apply to multiple series, it is recommended to add
         * them to the [plotOptions.series](#plotOptions.series) options structure.
         * To apply to all series of this specific type, apply it to [plotOptions.
         * pie](#plotOptions.pie).
         * 
         * @type {Object}
         * @extends series,plotOptions.pie
         * @excluding dataParser,dataURL,stack,xAxis,yAxis
         * @product highcharts
         * @apioption series.pie
         */

        /**
         * An array of data points for the series. For the `pie` series type,
         * points can be given in the following ways:
         * 
         * 1.  An array of numerical values. In this case, the numerical values
         * will be interpreted as `y` options. Example:
         * 
         *  ```js
         *  data: [0, 5, 3, 5]
         *  ```
         * 
         * 2.  An array of objects with named values. The objects are point
         * configuration objects as seen below. If the total number of data
         * points exceeds the series' [turboThreshold](#series.pie.turboThreshold),
         * this option is not available.
         * 
         *  ```js
         *     data: [{
         *     y: 1,
         *     name: "Point2",
         *     color: "#00FF00"
         * }, {
         *     y: 7,
         *     name: "Point1",
         *     color: "#FF00FF"
         * }]</pre>
         * 
         * @type {Array<Object|Number>}
         * @extends series.line.data
         * @excluding marker,x
         * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
         * @sample {highcharts} highcharts/series/data-array-of-arrays/ Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/ Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/ Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/ Config objects
         * @product highcharts
         * @apioption series.pie.data
         */

        /**
         * The sequential index of the data point in the legend.
         * 
         * @type {Number}
         * @product highcharts
         * @apioption series.pie.data.legendIndex
         */

        /**
         * Whether to display a slice offset from the center.
         * 
         * @type {Boolean}
         * @sample {highcharts} highcharts/point/sliced/ One sliced point
         * @product highcharts
         * @apioption series.pie.data.sliced
         */

        /**
         * Fires when the checkbox next to the point name in the legend is clicked.
         * One parameter, event, is passed to the function. The state of the
         * checkbox is found by event.checked. The checked item is found by
         * event.item. Return false to prevent the default action which is to
         * toggle the select state of the series.
         * 
         * @type {Function}
         * @context Point
         * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
         *         Alert checkbox status
         * @since 1.2.0
         * @product highcharts
         * @apioption plotOptions.pie.events.checkboxClick
         */

        /**
         * Not applicable to pies, as the legend item is per point. See point.
         * events.
         * 
         * @type {Function}
         * @since 1.2.0
         * @product highcharts
         * @apioption plotOptions.pie.events.legendItemClick
         */

        /**
         * Fires when the legend item belonging to the pie point (slice) is
         * clicked. The `this` keyword refers to the point itself. One parameter,
         * `event`, is passed to the function, containing common event information. The
         * default action is to toggle the visibility of the point. This can be
         * prevented by calling `event.preventDefault()`.
         * 
         * @type {Function}
         * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
         *         Confirm toggle visibility
         * @since 1.2.0
         * @product highcharts
         * @apioption plotOptions.pie.point.events.legendItemClick
         */

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var addEvent = H.addEvent,
            arrayMax = H.arrayMax,
            defined = H.defined,
            each = H.each,
            extend = H.extend,
            format = H.format,
            map = H.map,
            merge = H.merge,
            noop = H.noop,
            pick = H.pick,
            relativeLength = H.relativeLength,
            Series = H.Series,
            seriesTypes = H.seriesTypes,
            stableSort = H.stableSort;

        /* eslint max-len: ["warn", 80, 4] */
        /**
         * Generatl distribution algorithm for distributing labels of differing size
         * along a confined length in two dimensions. The algorithm takes an array of
         * objects containing a size, a target and a rank. It will place the labels as
         * close as possible to their targets, skipping the lowest ranked labels if
         * necessary.
         */
        H.distribute = function(boxes, len) {

            var i,
                overlapping = true,
                origBoxes = boxes, // Original array will be altered with added .pos
                restBoxes = [], // The outranked overshoot
                box,
                target,
                total = 0;

            function sortByTarget(a, b) {
                return a.target - b.target;
            }

            // If the total size exceeds the len, remove those boxes with the lowest
            // rank
            i = boxes.length;
            while (i--) {
                total += boxes[i].size;
            }

            // Sort by rank, then slice away overshoot
            if (total > len) {
                stableSort(boxes, function(a, b) {
                    return (b.rank || 0) - (a.rank || 0);
                });
                i = 0;
                total = 0;
                while (total <= len) {
                    total += boxes[i].size;
                    i++;
                }
                restBoxes = boxes.splice(i - 1, boxes.length);
            }

            // Order by target
            stableSort(boxes, sortByTarget);


            // So far we have been mutating the original array. Now
            // create a copy with target arrays
            boxes = map(boxes, function(box) {
                return {
                    size: box.size,
                    targets: [box.target]
                };
            });

            while (overlapping) {
                // Initial positions: target centered in box
                i = boxes.length;
                while (i--) {
                    box = boxes[i];
                    // Composite box, average of targets
                    target = (Math.min.apply(0, box.targets) +
                        Math.max.apply(0, box.targets)) / 2;
                    box.pos = Math.min(
                        Math.max(0, target - box.size / 2),
                        len - box.size
                    );
                }

                // Detect overlap and join boxes
                i = boxes.length;
                overlapping = false;
                while (i--) {
                    // Overlap
                    if (i > 0 && boxes[i - 1].pos + boxes[i - 1].size > boxes[i].pos) {
                        // Add this size to the previous box
                        boxes[i - 1].size += boxes[i].size;
                        boxes[i - 1].targets = boxes[i - 1]
                            .targets
                            .concat(boxes[i].targets);

                        // Overlapping right, push left
                        if (boxes[i - 1].pos + boxes[i - 1].size > len) {
                            boxes[i - 1].pos = len - boxes[i - 1].size;
                        }
                        boxes.splice(i, 1); // Remove this item
                        overlapping = true;
                    }
                }
            }

            // Now the composite boxes are placed, we need to put the original boxes
            // within them
            i = 0;
            each(boxes, function(box) {
                var posInCompositeBox = 0;
                each(box.targets, function() {
                    origBoxes[i].pos = box.pos + posInCompositeBox;
                    posInCompositeBox += origBoxes[i].size;
                    i++;
                });
            });

            // Add the rest (hidden) boxes and sort by target
            origBoxes.push.apply(origBoxes, restBoxes);
            stableSort(origBoxes, sortByTarget);
        };


        /**
         * Draw the data labels
         */
        Series.prototype.drawDataLabels = function() {
            var series = this,
                seriesOptions = series.options,
                options = seriesOptions.dataLabels,
                points = series.points,
                pointOptions,
                generalOptions,
                hasRendered = series.hasRendered || 0,
                str,
                dataLabelsGroup,
                defer = pick(options.defer, !!seriesOptions.animation),
                renderer = series.chart.renderer;

            if (options.enabled || series._hasPointLabels) {

                // Process default alignment of data labels for columns
                if (series.dlProcessOptions) {
                    series.dlProcessOptions(options);
                }

                // Create a separate group for the data labels to avoid rotation
                dataLabelsGroup = series.plotGroup(
                    'dataLabelsGroup',
                    'data-labels',
                    defer && !hasRendered ? 'hidden' : 'visible', // #5133
                    options.zIndex || 6
                );

                if (defer) {
                    dataLabelsGroup.attr({
                        opacity: +hasRendered
                    }); // #3300
                    if (!hasRendered) {
                        addEvent(series, 'afterAnimate', function() {
                            if (series.visible) { // #2597, #3023, #3024
                                dataLabelsGroup.show(true);
                            }
                            dataLabelsGroup[
                                seriesOptions.animation ? 'animate' : 'attr'
                            ]({
                                opacity: 1
                            }, {
                                duration: 200
                            });
                        });
                    }
                }

                // Make the labels for each point
                generalOptions = options;
                each(points, function(point) {
                    var enabled,
                        dataLabel = point.dataLabel,
                        labelConfig,
                        attr,
                        rotation,
                        connector = point.connector,
                        isNew = !dataLabel,
                        style,
                        formatString;

                    // Determine if each data label is enabled
                    // @note dataLabelAttribs (like pointAttribs) would eradicate
                    // the need for dlOptions, and simplify the section below.
                    pointOptions = point.dlOptions || // dlOptions is used in treemaps
                        (point.options && point.options.dataLabels);
                    enabled = pick(
                        pointOptions && pointOptions.enabled,
                        generalOptions.enabled
                    ) && !point.isNull; // #2282, #4641, #7112

                    if (enabled) {
                        // Create individual options structure that can be extended
                        // without affecting others
                        options = merge(generalOptions, pointOptions);
                        labelConfig = point.getLabelConfig();
                        formatString = (
                            options[point.formatPrefix + 'Format'] ||
                            options.format
                        );
                        str = defined(formatString) ?
                            format(formatString, labelConfig) :
                            options.formatter.call(labelConfig, options);
                        style = options.style;
                        rotation = options.rotation;

                        // Determine the color
                        style.color = pick(
                            options.color,
                            style.color,
                            series.color,
                            '#000000'
                        );
                        // Get automated contrast color
                        if (style.color === 'contrast') {
                            point.contrastColor =
                                renderer.getContrast(point.color || series.color);
                            style.color = options.inside ||
                                pick(point.labelDistance, options.distance) < 0 ||
                                !!seriesOptions.stacking ?
                                point.contrastColor :
                                '#000000';
                        }
                        if (seriesOptions.cursor) {
                            style.cursor = seriesOptions.cursor;
                        }


                        attr = {

                            fill: options.backgroundColor,
                            stroke: options.borderColor,
                            'stroke-width': options.borderWidth,

                            r: options.borderRadius || 0,
                            rotation: rotation,
                            padding: options.padding,
                            zIndex: 1
                        };

                        // Remove unused attributes (#947)
                        H.objectEach(attr, function(val, name) {
                            if (val === undefined) {
                                delete attr[name];
                            }
                        });
                    }
                    // If the point is outside the plot area, destroy it. #678, #820
                    if (dataLabel && (!enabled || !defined(str))) {
                        point.dataLabel = dataLabel = dataLabel.destroy();
                        if (connector) {
                            point.connector = connector.destroy();
                        }
                        // Individual labels are disabled if the are explicitly disabled
                        // in the point options, or if they fall outside the plot area.
                    } else if (enabled && defined(str)) {
                        // create new label
                        if (!dataLabel) {
                            dataLabel = point.dataLabel = renderer[
                                rotation ? 'text' : 'label' // labels don't rotate
                            ](
                                str,
                                0, -9999,
                                options.shape,
                                null,
                                null,
                                options.useHTML,
                                null,
                                'data-label'
                            );
                            dataLabel.addClass(
                                'highcharts-data-label-color-' + point.colorIndex +
                                ' ' + (options.className || '') +
                                (options.useHTML ? 'highcharts-tracker' : '') // #3398
                            );
                        } else {
                            attr.text = str;
                        }
                        dataLabel.attr(attr);

                        // Styles must be applied before add in order to read text
                        // bounding box
                        dataLabel.css(style).shadow(options.shadow);


                        if (!dataLabel.added) {
                            dataLabel.add(dataLabelsGroup);
                        }
                        // Now the data label is created and placed at 0,0, so we need
                        // to align it
                        series.alignDataLabel(point, dataLabel, options, null, isNew);
                    }
                });
            }
        };

        /**
         * Align each individual data label
         */
        Series.prototype.alignDataLabel = function(
            point,
            dataLabel,
            options,
            alignTo,
            isNew
        ) {
            var chart = this.chart,
                inverted = chart.inverted,
                plotX = pick(point.plotX, -9999),
                plotY = pick(point.plotY, -9999),
                bBox = dataLabel.getBBox(),
                fontSize,
                baseline,
                rotation = options.rotation,
                normRotation,
                negRotation,
                align = options.align,
                rotCorr, // rotation correction
                // Math.round for rounding errors (#2683), alignTo to allow column
                // labels (#2700)
                visible =
                this.visible &&
                (
                    point.series.forceDL ||
                    chart.isInsidePlot(plotX, Math.round(plotY), inverted) ||
                    (
                        alignTo && chart.isInsidePlot(
                            plotX,
                            inverted ?
                            alignTo.x + 1 :
                            alignTo.y + alignTo.height - 1,
                            inverted
                        )
                    )
                ),
                alignAttr, // the final position;
                justify = pick(options.overflow, 'justify') === 'justify';

            if (visible) {


                fontSize = options.style.fontSize;


                baseline = chart.renderer.fontMetrics(fontSize, dataLabel).b;

                // The alignment box is a singular point
                alignTo = extend({
                    x: inverted ? this.yAxis.len - plotY : plotX,
                    y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
                    width: 0,
                    height: 0
                }, alignTo);

                // Add the text size for alignment calculation
                extend(options, {
                    width: bBox.width,
                    height: bBox.height
                });

                // Allow a hook for changing alignment in the last moment, then do the
                // alignment
                if (rotation) {
                    justify = false; // Not supported for rotated text
                    rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
                    alignAttr = {
                        x: alignTo.x + options.x + alignTo.width / 2 + rotCorr.x,
                        y: (
                            alignTo.y +
                            options.y + {
                                top: 0,
                                middle: 0.5,
                                bottom: 1
                            }[options.verticalAlign] *
                            alignTo.height
                        )
                    };
                    dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
                        .attr({ // #3003
                            align: align
                        });

                    // Compensate for the rotated label sticking out on the sides
                    normRotation = (rotation + 720) % 360;
                    negRotation = normRotation > 180 && normRotation < 360;

                    if (align === 'left') {
                        alignAttr.y -= negRotation ? bBox.height : 0;
                    } else if (align === 'center') {
                        alignAttr.x -= bBox.width / 2;
                        alignAttr.y -= bBox.height / 2;
                    } else if (align === 'right') {
                        alignAttr.x -= bBox.width;
                        alignAttr.y -= negRotation ? 0 : bBox.height;
                    }


                } else {
                    dataLabel.align(options, null, alignTo);
                    alignAttr = dataLabel.alignAttr;
                }

                // Handle justify or crop
                if (justify) {
                    point.isLabelJustified = this.justifyDataLabel(
                        dataLabel,
                        options,
                        alignAttr,
                        bBox,
                        alignTo,
                        isNew
                    );

                    // Now check that the data label is within the plot area
                } else if (pick(options.crop, true)) {
                    visible =
                        chart.isInsidePlot(
                            alignAttr.x,
                            alignAttr.y
                        ) &&
                        chart.isInsidePlot(
                            alignAttr.x + bBox.width,
                            alignAttr.y + bBox.height
                        );
                }

                // When we're using a shape, make it possible with a connector or an
                // arrow pointing to thie point
                if (options.shape && !rotation) {
                    dataLabel[isNew ? 'attr' : 'animate']({
                        anchorX: inverted ? chart.plotWidth - point.plotY : point.plotX,
                        anchorY: inverted ? chart.plotHeight - point.plotX : point.plotY
                    });
                }
            }

            // Show or hide based on the final aligned position
            if (!visible) {
                dataLabel.attr({
                    y: -9999
                });
                dataLabel.placed = false; // don't animate back in
            }

        };

        /**
         * If data labels fall partly outside the plot area, align them back in, in a
         * way that doesn't hide the point.
         */
        Series.prototype.justifyDataLabel = function(
            dataLabel,
            options,
            alignAttr,
            bBox,
            alignTo,
            isNew
        ) {
            var chart = this.chart,
                align = options.align,
                verticalAlign = options.verticalAlign,
                off,
                justified,
                padding = dataLabel.box ? 0 : (dataLabel.padding || 0);

            // Off left
            off = alignAttr.x + padding;
            if (off < 0) {
                if (align === 'right') {
                    options.align = 'left';
                } else {
                    options.x = -off;
                }
                justified = true;
            }

            // Off right
            off = alignAttr.x + bBox.width - padding;
            if (off > chart.plotWidth) {
                if (align === 'left') {
                    options.align = 'right';
                } else {
                    options.x = chart.plotWidth - off;
                }
                justified = true;
            }

            // Off top
            off = alignAttr.y + padding;
            if (off < 0) {
                if (verticalAlign === 'bottom') {
                    options.verticalAlign = 'top';
                } else {
                    options.y = -off;
                }
                justified = true;
            }

            // Off bottom
            off = alignAttr.y + bBox.height - padding;
            if (off > chart.plotHeight) {
                if (verticalAlign === 'top') {
                    options.verticalAlign = 'bottom';
                } else {
                    options.y = chart.plotHeight - off;
                }
                justified = true;
            }

            if (justified) {
                dataLabel.placed = !isNew;
                dataLabel.align(options, null, alignTo);
            }

            return justified;
        };

        /**
         * Override the base drawDataLabels method by pie specific functionality
         */
        if (seriesTypes.pie) {
            seriesTypes.pie.prototype.drawDataLabels = function() {
                var series = this,
                    data = series.data,
                    point,
                    chart = series.chart,
                    options = series.options.dataLabels,
                    connectorPadding = pick(options.connectorPadding, 10),
                    connectorWidth = pick(options.connectorWidth, 1),
                    plotWidth = chart.plotWidth,
                    plotHeight = chart.plotHeight,
                    connector,
                    seriesCenter = series.center,
                    radius = seriesCenter[2] / 2,
                    centerY = seriesCenter[1],
                    dataLabel,
                    dataLabelWidth,
                    labelPos,
                    labelHeight,
                    // divide the points into right and left halves for anti collision
                    halves = [
                        [], // right
                        [] // left
                    ],
                    x,
                    y,
                    visibility,
                    j,
                    overflow = [0, 0, 0, 0]; // top, right, bottom, left

                // get out if not enabled
                if (!series.visible || (!options.enabled && !series._hasPointLabels)) {
                    return;
                }

                // Reset all labels that have been shortened
                each(data, function(point) {
                    if (point.dataLabel && point.visible && point.dataLabel.shortened) {
                        point.dataLabel
                            .attr({
                                width: 'auto'
                            }).css({
                                width: 'auto',
                                textOverflow: 'clip'
                            });
                        point.dataLabel.shortened = false;
                    }
                });


                // run parent method
                Series.prototype.drawDataLabels.apply(series);

                each(data, function(point) {
                    if (point.dataLabel && point.visible) { // #407, #2510

                        // Arrange points for detection collision
                        halves[point.half].push(point);

                        // Reset positions (#4905)
                        point.dataLabel._pos = null;
                    }
                });

                /* Loop over the points in each half, starting from the top and bottom
                 * of the pie to detect overlapping labels.
                 */
                each(halves, function(points, i) {

                    var top,
                        bottom,
                        length = points.length,
                        positions = [],
                        naturalY,
                        sideOverflow,
                        positionsIndex, // Point index in positions array.
                        size;

                    if (!length) {
                        return;
                    }

                    // Sort by angle
                    series.sortByAngle(points, i - 0.5);
                    // Only do anti-collision when we have dataLabels outside the pie 
                    // and have connectors. (#856)
                    if (series.maxLabelDistance > 0) {
                        top = Math.max(
                            0,
                            centerY - radius - series.maxLabelDistance
                        );
                        bottom = Math.min(
                            centerY + radius + series.maxLabelDistance,
                            chart.plotHeight
                        );
                        each(points, function(point) {
                            // check if specific points' label is outside the pie
                            if (point.labelDistance > 0 && point.dataLabel) {
                                // point.top depends on point.labelDistance value
                                // Used for calculation of y value in getX method 
                                point.top = Math.max(
                                    0,
                                    centerY - radius - point.labelDistance
                                );
                                point.bottom = Math.min(
                                    centerY + radius + point.labelDistance,
                                    chart.plotHeight
                                );
                                size = point.dataLabel.getBBox().height || 21;

                                // point.positionsIndex is needed for getting index of 
                                // parameter related to specific point inside positions 
                                // array - not every point is in positions array.
                                point.positionsIndex = positions.push({
                                    target: point.labelPos[1] - point.top + size / 2,
                                    size: size,
                                    rank: point.y
                                }) - 1;
                            }
                        });
                        H.distribute(positions, bottom + size - top);
                    }

                    // Now the used slots are sorted, fill them up sequentially
                    for (j = 0; j < length; j++) {

                        point = points[j];
                        positionsIndex = point.positionsIndex;
                        labelPos = point.labelPos;
                        dataLabel = point.dataLabel;
                        visibility = point.visible === false ? 'hidden' : 'inherit';
                        naturalY = labelPos[1];
                        y = naturalY;

                        if (positions && defined(positions[positionsIndex])) {
                            if (positions[positionsIndex].pos === undefined) {
                                visibility = 'hidden';
                            } else {
                                labelHeight = positions[positionsIndex].size;
                                y = point.top + positions[positionsIndex].pos;
                            }
                        }

                        // It is needed to delete point.positionIndex for 
                        // dynamically added points etc.

                        delete point.positionIndex;

                        // get the x - use the natural x position for labels near the 
                        // top and bottom, to prevent the top and botton slice
                        // connectors from touching each other on either side
                        if (options.justify) {
                            x = seriesCenter[0] +
                                (i ? -1 : 1) * (radius + point.labelDistance);
                        } else {
                            x = series.getX(
                                y < point.top + 2 || y > point.bottom - 2 ?
                                naturalY :
                                y,
                                i,
                                point
                            );
                        }


                        // Record the placement and visibility
                        dataLabel._attr = {
                            visibility: visibility,
                            align: labelPos[6]
                        };
                        dataLabel._pos = {
                            x: (
                                x +
                                options.x +
                                ({
                                    left: connectorPadding,
                                    right: -connectorPadding
                                }[labelPos[6]] || 0)
                            ),

                            // 10 is for the baseline (label vs text)
                            y: y + options.y - 10
                        };
                        labelPos.x = x;
                        labelPos.y = y;


                        // Detect overflowing data labels
                        if (pick(options.crop, true)) {
                            dataLabelWidth = dataLabel.getBBox().width;

                            sideOverflow = null;
                            // Overflow left
                            if (x - dataLabelWidth < connectorPadding) {
                                sideOverflow = Math.round(
                                    dataLabelWidth - x + connectorPadding
                                );
                                overflow[3] = Math.max(sideOverflow, overflow[3]);

                                // Overflow right
                            } else if (
                                x + dataLabelWidth >
                                plotWidth - connectorPadding
                            ) {
                                sideOverflow = Math.round(
                                    x + dataLabelWidth - plotWidth + connectorPadding
                                );
                                overflow[1] = Math.max(sideOverflow, overflow[1]);
                            }

                            // Overflow top
                            if (y - labelHeight / 2 < 0) {
                                overflow[0] = Math.max(
                                    Math.round(-y + labelHeight / 2),
                                    overflow[0]
                                );

                                // Overflow left
                            } else if (y + labelHeight / 2 > plotHeight) {
                                overflow[2] = Math.max(
                                    Math.round(y + labelHeight / 2 - plotHeight),
                                    overflow[2]
                                );
                            }
                            dataLabel.sideOverflow = sideOverflow;
                        }
                    } // for each point
                }); // for each half

                // Do not apply the final placement and draw the connectors until we
                // have verified that labels are not spilling over.
                if (
                    arrayMax(overflow) === 0 ||
                    this.verifyDataLabelOverflow(overflow)
                ) {

                    // Place the labels in the final position
                    this.placeDataLabels();

                    // Draw the connectors
                    if (connectorWidth) {
                        each(this.points, function(point) {
                            var isNew;

                            connector = point.connector;
                            dataLabel = point.dataLabel;

                            if (
                                dataLabel &&
                                dataLabel._pos &&
                                point.visible &&
                                point.labelDistance > 0
                            ) {
                                visibility = dataLabel._attr.visibility;

                                isNew = !connector;

                                if (isNew) {
                                    point.connector = connector = chart.renderer.path()
                                        .addClass('highcharts-data-label-connector ' +
                                            ' highcharts-color-' + point.colorIndex)
                                        .add(series.dataLabelsGroup);


                                    connector.attr({
                                        'stroke-width': connectorWidth,
                                        'stroke': (
                                            options.connectorColor ||
                                            point.color ||
                                            '#666666'
                                        )
                                    });

                                }
                                connector[isNew ? 'attr' : 'animate']({
                                    d: series.connectorPath(point.labelPos)
                                });
                                connector.attr('visibility', visibility);

                            } else if (connector) {
                                point.connector = connector.destroy();
                            }
                        });
                    }
                }
            };

            /**
             * Extendable method for getting the path of the connector between the data
             * label and the pie slice.
             */
            seriesTypes.pie.prototype.connectorPath = function(labelPos) {
                var x = labelPos.x,
                    y = labelPos.y;
                return pick(this.options.dataLabels.softConnector, true) ? [
                    'M',
                    // end of the string at the label
                    x + (labelPos[6] === 'left' ? 5 : -5), y,
                    'C',
                    x, y, // first break, next to the label
                    2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
                    labelPos[2], labelPos[3], // second break
                    'L',
                    labelPos[4], labelPos[5] // base
                ] : [
                    'M',
                    // end of the string at the label
                    x + (labelPos[6] === 'left' ? 5 : -5), y,
                    'L',
                    labelPos[2], labelPos[3], // second break
                    'L',
                    labelPos[4], labelPos[5] // base
                ];
            };

            /**
             * Perform the final placement of the data labels after we have verified
             * that they fall within the plot area.
             */
            seriesTypes.pie.prototype.placeDataLabels = function() {
                each(this.points, function(point) {
                    var dataLabel = point.dataLabel,
                        _pos;
                    if (dataLabel && point.visible) {
                        _pos = dataLabel._pos;
                        if (_pos) {

                            // Shorten data labels with ellipsis if they still overflow
                            // after the pie has reached minSize (#223).
                            if (dataLabel.sideOverflow) {
                                dataLabel._attr.width =
                                    dataLabel.getBBox().width - dataLabel.sideOverflow;
                                dataLabel.css({
                                    width: dataLabel._attr.width + 'px',
                                    textOverflow: 'ellipsis'
                                });
                                dataLabel.shortened = true;
                            }

                            dataLabel.attr(dataLabel._attr);
                            dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
                            dataLabel.moved = true;
                        } else if (dataLabel) {
                            dataLabel.attr({
                                y: -9999
                            });
                        }
                    }
                }, this);
            };

            seriesTypes.pie.prototype.alignDataLabel = noop;

            /**
             * Verify whether the data labels are allowed to draw, or we should run more
             * translation and data label positioning to keep them inside the plot area.
             * Returns true when data labels are ready to draw.
             */
            seriesTypes.pie.prototype.verifyDataLabelOverflow = function(overflow) {

                var center = this.center,
                    options = this.options,
                    centerOption = options.center,
                    minSize = options.minSize || 80,
                    newSize = minSize,
                    // If a size is set, return true and don't try to shrink the pie
                    // to fit the labels.
                    ret = options.size !== null;

                if (!ret) {
                    // Handle horizontal size and center
                    if (centerOption[0] !== null) { // Fixed center
                        newSize = Math.max(center[2] -
                            Math.max(overflow[1], overflow[3]), minSize);

                    } else { // Auto center
                        newSize = Math.max(
                            // horizontal overflow
                            center[2] - overflow[1] - overflow[3],
                            minSize
                        );
                        // horizontal center
                        center[0] += (overflow[3] - overflow[1]) / 2;
                    }

                    // Handle vertical size and center
                    if (centerOption[1] !== null) { // Fixed center
                        newSize = Math.max(Math.min(newSize, center[2] -
                            Math.max(overflow[0], overflow[2])), minSize);

                    } else { // Auto center
                        newSize = Math.max(
                            Math.min(
                                newSize,
                                // vertical overflow
                                center[2] - overflow[0] - overflow[2]
                            ),
                            minSize
                        );
                        // vertical center
                        center[1] += (overflow[0] - overflow[2]) / 2;
                    }

                    // If the size must be decreased, we need to run translate and
                    // drawDataLabels again
                    if (newSize < center[2]) {
                        center[2] = newSize;
                        center[3] = Math.min( // #3632
                            relativeLength(options.innerSize || 0, newSize),
                            newSize
                        );
                        this.translate(center);

                        if (this.drawDataLabels) {
                            this.drawDataLabels();
                        }
                        // Else, return true to indicate that the pie and its labels is
                        // within the plot area
                    } else {
                        ret = true;
                    }
                }
                return ret;
            };
        }

        if (seriesTypes.column) {

            /**
             * Override the basic data label alignment by adjusting for the position of
             * the column
             */
            seriesTypes.column.prototype.alignDataLabel = function(
                point,
                dataLabel,
                options,
                alignTo,
                isNew
            ) {
                var inverted = this.chart.inverted,
                    series = point.series,
                    // data label box for alignment
                    dlBox = point.dlBox || point.shapeArgs,
                    below = pick(
                        point.below, // range series
                        point.plotY > pick(this.translatedThreshold, series.yAxis.len)
                    ),
                    // draw it inside the box?
                    inside = pick(options.inside, !!this.options.stacking),
                    overshoot;

                // Align to the column itself, or the top of it
                if (dlBox) { // Area range uses this method but not alignTo
                    alignTo = merge(dlBox);

                    if (alignTo.y < 0) {
                        alignTo.height += alignTo.y;
                        alignTo.y = 0;
                    }
                    overshoot = alignTo.y + alignTo.height - series.yAxis.len;
                    if (overshoot > 0) {
                        alignTo.height -= overshoot;
                    }

                    if (inverted) {
                        alignTo = {
                            x: series.yAxis.len - alignTo.y - alignTo.height,
                            y: series.xAxis.len - alignTo.x - alignTo.width,
                            width: alignTo.height,
                            height: alignTo.width
                        };
                    }

                    // Compute the alignment box
                    if (!inside) {
                        if (inverted) {
                            alignTo.x += below ? 0 : alignTo.width;
                            alignTo.width = 0;
                        } else {
                            alignTo.y += below ? alignTo.height : 0;
                            alignTo.height = 0;
                        }
                    }
                }


                // When alignment is undefined (typically columns and bars), display the
                // individual point below or above the point depending on the threshold
                options.align = pick(
                    options.align, !inverted || inside ? 'center' : below ? 'right' : 'left'
                );
                options.verticalAlign = pick(
                    options.verticalAlign,
                    inverted || inside ? 'middle' : below ? 'top' : 'bottom'
                );

                // Call the parent method
                Series.prototype.alignDataLabel.call(
                    this,
                    point,
                    dataLabel,
                    options,
                    alignTo,
                    isNew
                );

                // If label was justified and we have contrast, set it:
                if (point.isLabelJustified && point.contrastColor) {
                    point.dataLabel.css({
                        color: point.contrastColor
                    });
                }
            };
        }

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2009-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        /**
         * Highcharts module to hide overlapping data labels. This module is included in
         * Highcharts.
         */
        var Chart = H.Chart,
            each = H.each,
            objectEach = H.objectEach,
            pick = H.pick,
            addEvent = H.addEvent;

        // Collect potensial overlapping data labels. Stack labels probably don't need
        // to be considered because they are usually accompanied by data labels that lie
        // inside the columns.
        Chart.prototype.callbacks.push(function(chart) {
            function collectAndHide() {
                var labels = [];

                // Consider external label collectors
                each(chart.labelCollectors || [], function(collector) {
                    labels = labels.concat(collector());
                });

                each(chart.yAxis || [], function(yAxis) {
                    if (
                        yAxis.options.stackLabels &&
                        !yAxis.options.stackLabels.allowOverlap
                    ) {
                        objectEach(yAxis.stacks, function(stack) {
                            objectEach(stack, function(stackItem) {
                                labels.push(stackItem.label);
                            });
                        });
                    }
                });

                each(chart.series || [], function(series) {
                    var dlOptions = series.options.dataLabels,
                        // Range series have two collections
                        collections = series.dataLabelCollections || ['dataLabel'];

                    if (
                        (dlOptions.enabled || series._hasPointLabels) &&
                        !dlOptions.allowOverlap &&
                        series.visible
                    ) { // #3866
                        each(collections, function(coll) {
                            each(series.points, function(point) {
                                if (point[coll]) {
                                    point[coll].labelrank = pick(
                                        point.labelrank,
                                        point.shapeArgs && point.shapeArgs.height
                                    ); // #4118
                                    labels.push(point[coll]);
                                }
                            });
                        });
                    }
                });
                chart.hideOverlappingLabels(labels);
            }

            // Do it on render and after each chart redraw
            addEvent(chart, 'render', collectAndHide);

        });

        /**
         * Hide overlapping labels. Labels are moved and faded in and out on zoom to
         * provide a smooth visual imression.
         */
        Chart.prototype.hideOverlappingLabels = function(labels) {

            var len = labels.length,
                label,
                i,
                j,
                label1,
                label2,
                isIntersecting,
                pos1,
                pos2,
                parent1,
                parent2,
                padding,
                bBox,
                intersectRect = function(x1, y1, w1, h1, x2, y2, w2, h2) {
                    return !(
                        x2 > x1 + w1 ||
                        x2 + w2 < x1 ||
                        y2 > y1 + h1 ||
                        y2 + h2 < y1
                    );
                };

            for (i = 0; i < len; i++) {
                label = labels[i];
                if (label) {

                    // Mark with initial opacity
                    label.oldOpacity = label.opacity;
                    label.newOpacity = 1;

                    // Get width and height if pure text nodes (stack labels)
                    if (!label.width) {
                        bBox = label.getBBox();
                        label.width = bBox.width;
                        label.height = bBox.height;
                    }
                }
            }

            // Prevent a situation in a gradually rising slope, that each label will
            // hide the previous one because the previous one always has lower rank.
            labels.sort(function(a, b) {
                return (b.labelrank || 0) - (a.labelrank || 0);
            });

            // Detect overlapping labels
            for (i = 0; i < len; i++) {
                label1 = labels[i];

                for (j = i + 1; j < len; ++j) {
                    label2 = labels[j];
                    if (
                        label1 && label2 &&
                        label1 !== label2 && // #6465, polar chart with connectEnds
                        label1.placed && label2.placed &&
                        label1.newOpacity !== 0 && label2.newOpacity !== 0
                    ) {
                        pos1 = label1.alignAttr;
                        pos2 = label2.alignAttr;
                        // Different panes have different positions
                        parent1 = label1.parentGroup;
                        parent2 = label2.parentGroup;
                        // Substract the padding if no background or border (#4333)
                        padding = 2 * (label1.box ? 0 : (label1.padding || 0));
                        isIntersecting = intersectRect(
                            pos1.x + parent1.translateX,
                            pos1.y + parent1.translateY,
                            label1.width - padding,
                            label1.height - padding,
                            pos2.x + parent2.translateX,
                            pos2.y + parent2.translateY,
                            label2.width - padding,
                            label2.height - padding
                        );

                        if (isIntersecting) {
                            (label1.labelrank < label2.labelrank ? label1 : label2)
                            .newOpacity = 0;
                        }
                    }
                }
            }

            // Hide or show
            each(labels, function(label) {
                var complete,
                    newOpacity;

                if (label) {
                    newOpacity = label.newOpacity;

                    if (label.oldOpacity !== newOpacity && label.placed) {

                        // Make sure the label is completely hidden to avoid catching
                        // clicks (#4362)
                        if (newOpacity) {
                            label.show(true);
                        } else {
                            complete = function() {
                                label.hide();
                            };
                        }

                        // Animate or set the opacity					
                        label.alignAttr.opacity = newOpacity;
                        label[label.isOld ? 'animate' : 'attr'](
                            label.alignAttr,
                            null,
                            complete
                        );

                    }
                    label.isOld = true;
                }
            });
        };

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var addEvent = H.addEvent,
            Chart = H.Chart,
            createElement = H.createElement,
            css = H.css,
            defaultOptions = H.defaultOptions,
            defaultPlotOptions = H.defaultPlotOptions,
            each = H.each,
            extend = H.extend,
            fireEvent = H.fireEvent,
            hasTouch = H.hasTouch,
            inArray = H.inArray,
            isObject = H.isObject,
            Legend = H.Legend,
            merge = H.merge,
            pick = H.pick,
            Point = H.Point,
            Series = H.Series,
            seriesTypes = H.seriesTypes,
            svg = H.svg,
            TrackerMixin;

        /**
         * TrackerMixin for points and graphs.
         */
        TrackerMixin = H.TrackerMixin = {

            /**
             * Draw the tracker for a point.
             */
            drawTrackerPoint: function() {
                var series = this,
                    chart = series.chart,
                    pointer = chart.pointer,
                    onMouseOver = function(e) {
                        var point = pointer.getPointFromEvent(e);
                        // undefined on graph in scatterchart
                        if (point !== undefined) {
                            pointer.isDirectTouch = true;
                            point.onMouseOver(e);
                        }
                    };

                // Add reference to the point
                each(series.points, function(point) {
                    if (point.graphic) {
                        point.graphic.element.point = point;
                    }
                    if (point.dataLabel) {
                        if (point.dataLabel.div) {
                            point.dataLabel.div.point = point;
                        } else {
                            point.dataLabel.element.point = point;
                        }
                    }
                });

                // Add the event listeners, we need to do this only once
                if (!series._hasTracking) {
                    each(series.trackerGroups, function(key) {
                        if (series[key]) { // we don't always have dataLabelsGroup
                            series[key]
                                .addClass('highcharts-tracker')
                                .on('mouseover', onMouseOver)
                                .on('mouseout', function(e) {
                                    pointer.onTrackerMouseOut(e);
                                });
                            if (hasTouch) {
                                series[key].on('touchstart', onMouseOver);
                            }


                            if (series.options.cursor) {
                                series[key]
                                    .css(css)
                                    .css({
                                        cursor: series.options.cursor
                                    });
                            }

                        }
                    });
                    series._hasTracking = true;
                }
            },

            /**
             * Draw the tracker object that sits above all data labels and markers to
             * track mouse events on the graph or points. For the line type charts
             * the tracker uses the same graphPath, but with a greater stroke width
             * for better control.
             */
            drawTrackerGraph: function() {
                var series = this,
                    options = series.options,
                    trackByArea = options.trackByArea,
                    trackerPath = [].concat(trackByArea ? series.areaPath : series.graphPath),
                    trackerPathLength = trackerPath.length,
                    chart = series.chart,
                    pointer = chart.pointer,
                    renderer = chart.renderer,
                    snap = chart.options.tooltip.snap,
                    tracker = series.tracker,
                    i,
                    onMouseOver = function() {
                        if (chart.hoverSeries !== series) {
                            series.onMouseOver();
                        }
                    },
                    /*
                     * Empirical lowest possible opacities for TRACKER_FILL for an element to stay invisible but clickable
                     * IE6: 0.002
                     * IE7: 0.002
                     * IE8: 0.002
                     * IE9: 0.00000000001 (unlimited)
                     * IE10: 0.0001 (exporting only)
                     * FF: 0.00000000001 (unlimited)
                     * Chrome: 0.000001
                     * Safari: 0.000001
                     * Opera: 0.00000000001 (unlimited)
                     */
                    TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';

                // Extend end points. A better way would be to use round linecaps,
                // but those are not clickable in VML.
                if (trackerPathLength && !trackByArea) {
                    i = trackerPathLength + 1;
                    while (i--) {
                        if (trackerPath[i] === 'M') { // extend left side
                            trackerPath.splice(i + 1, 0, trackerPath[i + 1] - snap, trackerPath[i + 2], 'L');
                        }
                        if ((i && trackerPath[i] === 'M') || i === trackerPathLength) { // extend right side
                            trackerPath.splice(i, 0, 'L', trackerPath[i - 2] + snap, trackerPath[i - 1]);
                        }
                    }
                }

                // draw the tracker
                if (tracker) {
                    tracker.attr({
                        d: trackerPath
                    });
                } else if (series.graph) { // create

                    series.tracker = renderer.path(trackerPath)
                        .attr({
                            'stroke-linejoin': 'round', // #1225
                            visibility: series.visible ? 'visible' : 'hidden',
                            stroke: TRACKER_FILL,
                            fill: trackByArea ? TRACKER_FILL : 'none',
                            'stroke-width': series.graph.strokeWidth() + (trackByArea ? 0 : 2 * snap),
                            zIndex: 2
                        })
                        .add(series.group);

                    // The tracker is added to the series group, which is clipped, but is covered
                    // by the marker group. So the marker group also needs to capture events.
                    each([series.tracker, series.markerGroup], function(tracker) {
                        tracker.addClass('highcharts-tracker')
                            .on('mouseover', onMouseOver)
                            .on('mouseout', function(e) {
                                pointer.onTrackerMouseOut(e);
                            });


                        if (options.cursor) {
                            tracker.css({
                                cursor: options.cursor
                            });
                        }


                        if (hasTouch) {
                            tracker.on('touchstart', onMouseOver);
                        }
                    });
                }
            }
        };
        /* End TrackerMixin */


        /**
         * Add tracking event listener to the series group, so the point graphics
         * themselves act as trackers
         */

        if (seriesTypes.column) {
            seriesTypes.column.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
        }

        if (seriesTypes.pie) {
            seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
        }

        if (seriesTypes.scatter) {
            seriesTypes.scatter.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
        }

        /*
         * Extend Legend for item events
         */
        extend(Legend.prototype, {

            setItemEvents: function(item, legendItem, useHTML) {
                var legend = this,
                    boxWrapper = legend.chart.renderer.boxWrapper,
                    activeClass = 'highcharts-legend-' + (item.series ? 'point' : 'series') + '-active';

                // Set the events on the item group, or in case of useHTML, the item itself (#1249)
                (useHTML ? legendItem : item.legendGroup).on('mouseover', function() {
                        item.setState('hover');

                        // A CSS class to dim or hide other than the hovered series
                        boxWrapper.addClass(activeClass);


                        legendItem.css(legend.options.itemHoverStyle);

                    })
                    .on('mouseout', function() {

                        legendItem.css(merge(item.visible ? legend.itemStyle : legend.itemHiddenStyle));


                        // A CSS class to dim or hide other than the hovered series
                        boxWrapper.removeClass(activeClass);

                        item.setState();
                    })
                    .on('click', function(event) {
                        var strLegendItemClick = 'legendItemClick',
                            fnLegendItemClick = function() {
                                if (item.setVisible) {
                                    item.setVisible();
                                }
                            };

                        // Pass over the click/touch event. #4.
                        event = {
                            browserEvent: event
                        };

                        // click the name or symbol
                        if (item.firePointEvent) { // point
                            item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
                        } else {
                            fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
                        }
                    });
            },

            createCheckboxForItem: function(item) {
                var legend = this;

                item.checkbox = createElement('input', {
                    type: 'checkbox',
                    checked: item.selected,
                    defaultChecked: item.selected // required by IE7
                }, legend.options.itemCheckboxStyle, legend.chart.container);

                addEvent(item.checkbox, 'click', function(event) {
                    var target = event.target;
                    fireEvent(
                        item.series || item,
                        'checkboxClick', { // #3712
                            checked: target.checked,
                            item: item
                        },
                        function() {
                            item.select();
                        }
                    );
                });
            }
        });



        // Add pointer cursor to legend itemstyle in defaultOptions
        defaultOptions.legend.itemStyle.cursor = 'pointer';



        /*
         * Extend the Chart object with interaction
         */

        extend(Chart.prototype, /** @lends Chart.prototype */ {
            /**
             * Display the zoom button.
             *
             * @private
             */
            showResetZoom: function() {
                var chart = this,
                    lang = defaultOptions.lang,
                    btnOptions = chart.options.chart.resetZoomButton,
                    theme = btnOptions.theme,
                    states = theme.states,
                    alignTo = btnOptions.relativeTo === 'chart' ? null : 'plotBox';

                function zoomOut() {
                    chart.zoomOut();
                }

                this.resetZoomButton = chart.renderer.button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
                    .attr({
                        align: btnOptions.position.align,
                        title: lang.resetZoomTitle
                    })
                    .addClass('highcharts-reset-zoom')
                    .add()
                    .align(btnOptions.position, false, alignTo);

            },

            /**
             * Zoom out to 1:1.
             *
             * @private
             */
            zoomOut: function() {
                var chart = this;
                fireEvent(chart, 'selection', {
                    resetSelection: true
                }, function() {
                    chart.zoom();
                });
            },

            /**
             * Zoom into a given portion of the chart given by axis coordinates.
             * @param {Object} event
             *
             * @private
             */
            zoom: function(event) {
                var chart = this,
                    hasZoomed,
                    pointer = chart.pointer,
                    displayButton = false,
                    resetZoomButton;

                // If zoom is called with no arguments, reset the axes
                if (!event || event.resetSelection) {
                    each(chart.axes, function(axis) {
                        hasZoomed = axis.zoom();
                    });
                    pointer.initiated = false; // #6804

                } else { // else, zoom in on all axes
                    each(event.xAxis.concat(event.yAxis), function(axisData) {
                        var axis = axisData.axis,
                            isXAxis = axis.isXAxis;

                        // don't zoom more than minRange
                        if (pointer[isXAxis ? 'zoomX' : 'zoomY']) {
                            hasZoomed = axis.zoom(axisData.min, axisData.max);
                            if (axis.displayBtn) {
                                displayButton = true;
                            }
                        }
                    });
                }

                // Show or hide the Reset zoom button
                resetZoomButton = chart.resetZoomButton;
                if (displayButton && !resetZoomButton) {
                    chart.showResetZoom();
                } else if (!displayButton && isObject(resetZoomButton)) {
                    chart.resetZoomButton = resetZoomButton.destroy();
                }


                // Redraw
                if (hasZoomed) {
                    chart.redraw(
                        pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100) // animation
                    );
                }
            },

            /**
             * Pan the chart by dragging the mouse across the pane. This function is
             * called on mouse move, and the distance to pan is computed from chartX
             * compared to the first chartX position in the dragging operation.
             *
             * @private
             */
            pan: function(e, panning) {

                var chart = this,
                    hoverPoints = chart.hoverPoints,
                    doRedraw;

                // remove active points for shared tooltip
                if (hoverPoints) {
                    each(hoverPoints, function(point) {
                        point.setState();
                    });
                }

                each(panning === 'xy' ? [1, 0] : [1], function(isX) { // xy is used in maps
                    var axis = chart[isX ? 'xAxis' : 'yAxis'][0],
                        horiz = axis.horiz,
                        mousePos = e[horiz ? 'chartX' : 'chartY'],
                        mouseDown = horiz ? 'mouseDownX' : 'mouseDownY',
                        startPos = chart[mouseDown],
                        halfPointRange = (axis.pointRange || 0) / 2,
                        extremes = axis.getExtremes(),
                        panMin = axis.toValue(startPos - mousePos, true) +
                        halfPointRange,
                        panMax = axis.toValue(startPos + axis.len - mousePos, true) -
                        halfPointRange,
                        flipped = panMax < panMin,
                        newMin = flipped ? panMax : panMin,
                        newMax = flipped ? panMin : panMax,
                        paddedMin = Math.min(
                            extremes.dataMin,
                            axis.toValue(
                                axis.toPixels(extremes.min) - axis.minPixelPadding
                            )
                        ),
                        paddedMax = Math.max(
                            extremes.dataMax,
                            axis.toValue(
                                axis.toPixels(extremes.max) + axis.minPixelPadding
                            )
                        ),
                        spill;

                    // If the new range spills over, either to the min or max, adjust
                    // the new range.
                    spill = paddedMin - newMin;
                    if (spill > 0) {
                        newMax += spill;
                        newMin = paddedMin;
                    }
                    spill = newMax - paddedMax;
                    if (spill > 0) {
                        newMax = paddedMax;
                        newMin -= spill;
                    }

                    // Set new extremes if they are actually new
                    if (axis.series.length && newMin !== extremes.min && newMax !== extremes.max) {
                        axis.setExtremes(
                            newMin,
                            newMax,
                            false,
                            false, {
                                trigger: 'pan'
                            }
                        );
                        doRedraw = true;
                    }

                    chart[mouseDown] = mousePos; // set new reference for next run
                });

                if (doRedraw) {
                    chart.redraw(false);
                }
                css(chart.container, {
                    cursor: 'move'
                });
            }
        });

        /*
         * Extend the Point object with interaction
         */
        extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
            /**
             * Toggle the selection status of a point.
             * @param  {Boolean} [selected]
             *         When `true`, the point is selected. When `false`, the point is
             *         unselected. When `null` or `undefined`, the selection state is
             *         toggled.
             * @param  {Boolean} [accumulate=false]
             *         When `true`, the selection is added to other selected points.
             *         When `false`, other selected points are deselected. Internally in
             *         Highcharts, when {@link http://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect|allowPointSelect}
             *         is `true`, selected points are accumulated on Control, Shift or
             *         Cmd clicking the point.
             *
             * @see    Highcharts.Chart#getSelectedPoints
             *
             * @sample highcharts/members/point-select/
             *         Select a point from a button
             * @sample highcharts/chart/events-selection-points/
             *         Select a range of points through a drag selection
             * @sample maps/series/data-id/
             *         Select a point in Highmaps
             */
            select: function(selected, accumulate) {
                var point = this,
                    series = point.series,
                    chart = series.chart;

                selected = pick(selected, !point.selected);

                // fire the event with the default handler
                point.firePointEvent(selected ? 'select' : 'unselect', {
                    accumulate: accumulate
                }, function() {

                    /**
                     * Whether the point is selected or not. 
                     * @see Point#select
                     * @see Chart#getSelectedPoints
                     * @memberof Point
                     * @name selected
                     * @type {Boolean}
                     */
                    point.selected = point.options.selected = selected;
                    series.options.data[inArray(point, series.data)] = point.options;

                    point.setState(selected && 'select');

                    // unselect all other points unless Ctrl or Cmd + click
                    if (!accumulate) {
                        each(chart.getSelectedPoints(), function(loopPoint) {
                            if (loopPoint.selected && loopPoint !== point) {
                                loopPoint.selected = loopPoint.options.selected = false;
                                series.options.data[inArray(loopPoint, series.data)] = loopPoint.options;
                                loopPoint.setState('');
                                loopPoint.firePointEvent('unselect');
                            }
                        });
                    }
                });
            },

            /**
             * Runs on mouse over the point. Called internally from mouse and touch
             * events.
             * 
             * @param {Object} e The event arguments
             */
            onMouseOver: function(e) {
                var point = this,
                    series = point.series,
                    chart = series.chart,
                    pointer = chart.pointer;
                e = e ?
                    pointer.normalize(e) :
                    // In cases where onMouseOver is called directly without an event
                    pointer.getChartCoordinatesFromPoint(point, chart.inverted);
                pointer.runPointActions(e, point);
            },

            /**
             * Runs on mouse out from the point. Called internally from mouse and touch
             * events.
             */
            onMouseOut: function() {
                var point = this,
                    chart = point.series.chart;
                point.firePointEvent('mouseOut');
                each(chart.hoverPoints || [], function(p) {
                    p.setState();
                });
                chart.hoverPoints = chart.hoverPoint = null;
            },

            /**
             * Import events from the series' and point's options. Only do it on
             * demand, to save processing time on hovering.
             *
             * @private
             */
            importEvents: function() {
                if (!this.hasImportedEvents) {
                    var point = this,
                        options = merge(point.series.options.point, point.options),
                        events = options.events;

                    point.events = events;

                    H.objectEach(events, function(event, eventType) {
                        addEvent(point, eventType, event);
                    });
                    this.hasImportedEvents = true;

                }
            },

            /**
             * Set the point's state.
             * @param  {String} [state]
             *         The new state, can be one of `''` (an empty string), `hover` or
             *         `select`.
             */
            setState: function(state, move) {
                var point = this,
                    plotX = Math.floor(point.plotX), // #4586
                    plotY = point.plotY,
                    series = point.series,
                    stateOptions = series.options.states[state] || {},
                    markerOptions = defaultPlotOptions[series.type].marker &&
                    series.options.marker,
                    normalDisabled = markerOptions && markerOptions.enabled === false,
                    markerStateOptions = (markerOptions && markerOptions.states &&
                        markerOptions.states[state]) || {},
                    stateDisabled = markerStateOptions.enabled === false,
                    stateMarkerGraphic = series.stateMarkerGraphic,
                    pointMarker = point.marker || {},
                    chart = series.chart,
                    halo = series.halo,
                    haloOptions,
                    markerAttribs,
                    hasMarkers = markerOptions && series.markerAttribs,
                    newSymbol;

                state = state || ''; // empty string

                if (
                    // already has this state
                    (state === point.state && !move) ||

                    // selected points don't respond to hover
                    (point.selected && state !== 'select') ||

                    // series' state options is disabled
                    (stateOptions.enabled === false) ||

                    // general point marker's state options is disabled
                    (state && (
                        stateDisabled ||
                        (normalDisabled && markerStateOptions.enabled === false)
                    )) ||

                    // individual point marker's state options is disabled
                    (
                        state &&
                        pointMarker.states &&
                        pointMarker.states[state] &&
                        pointMarker.states[state].enabled === false
                    ) // #1610

                ) {
                    return;
                }

                if (hasMarkers) {
                    markerAttribs = series.markerAttribs(point, state);
                }

                // Apply hover styles to the existing point
                if (point.graphic) {

                    if (point.state) {
                        point.graphic.removeClass('highcharts-point-' + point.state);
                    }
                    if (state) {
                        point.graphic.addClass('highcharts-point-' + state);
                    }


                    point.graphic.animate(
                        series.pointAttribs(point, state),
                        pick(
                            chart.options.chart.animation,
                            stateOptions.animation
                        )
                    );


                    if (markerAttribs) {
                        point.graphic.animate(
                            markerAttribs,
                            pick(
                                chart.options.chart.animation, // Turn off globally
                                markerStateOptions.animation,
                                markerOptions.animation
                            )
                        );
                    }

                    // Zooming in from a range with no markers to a range with markers
                    if (stateMarkerGraphic) {
                        stateMarkerGraphic.hide();
                    }
                } else {
                    // if a graphic is not applied to each point in the normal state, create a shared
                    // graphic for the hover state
                    if (state && markerStateOptions) {
                        newSymbol = pointMarker.symbol || series.symbol;

                        // If the point has another symbol than the previous one, throw away the
                        // state marker graphic and force a new one (#1459)
                        if (stateMarkerGraphic && stateMarkerGraphic.currentSymbol !== newSymbol) {
                            stateMarkerGraphic = stateMarkerGraphic.destroy();
                        }

                        // Add a new state marker graphic
                        if (!stateMarkerGraphic) {
                            if (newSymbol) {
                                series.stateMarkerGraphic = stateMarkerGraphic = chart.renderer.symbol(
                                        newSymbol,
                                        markerAttribs.x,
                                        markerAttribs.y,
                                        markerAttribs.width,
                                        markerAttribs.height
                                    )
                                    .add(series.markerGroup);
                                stateMarkerGraphic.currentSymbol = newSymbol;
                            }

                            // Move the existing graphic
                        } else {
                            stateMarkerGraphic[move ? 'animate' : 'attr']({ // #1054
                                x: markerAttribs.x,
                                y: markerAttribs.y
                            });
                        }

                        if (stateMarkerGraphic) {
                            stateMarkerGraphic.attr(series.pointAttribs(point, state));
                        }

                    }

                    if (stateMarkerGraphic) {
                        stateMarkerGraphic[state && chart.isInsidePlot(plotX, plotY, chart.inverted) ? 'show' : 'hide'](); // #2450
                        stateMarkerGraphic.element.point = point; // #4310
                    }
                }

                // Show me your halo
                haloOptions = stateOptions.halo;
                if (haloOptions && haloOptions.size) {
                    if (!halo) {
                        series.halo = halo = chart.renderer.path()
                            // #5818, #5903, #6705
                            .add((point.graphic || stateMarkerGraphic).parentGroup);
                    }
                    halo[move ? 'animate' : 'attr']({
                        d: point.haloPath(haloOptions.size)
                    });
                    halo.attr({
                        'class': 'highcharts-halo highcharts-color-' +
                            pick(point.colorIndex, series.colorIndex)
                    });
                    halo.point = point; // #6055


                    halo.attr(extend({
                        'fill': point.color || series.color,
                        'fill-opacity': haloOptions.opacity,
                        'zIndex': -1 // #4929, IE8 added halo above everything
                    }, haloOptions.attributes));


                } else if (halo && halo.point && halo.point.haloPath) {
                    // Animate back to 0 on the current halo point (#6055)
                    halo.animate({
                        d: halo.point.haloPath(0)
                    });
                }

                point.state = state;
            },

            /**
             * Get the path definition for the halo, which is usually a shadow-like
             * circle around the currently hovered point.
             * @param  {Number} size
             *         The radius of the circular halo.
             * @return {Array} The path definition
             */
            haloPath: function(size) {
                var series = this.series,
                    chart = series.chart;

                return chart.renderer.symbols.circle(
                    Math.floor(this.plotX) - size,
                    this.plotY - size,
                    size * 2,
                    size * 2
                );
            }
        });

        /*
         * Extend the Series object with interaction
         */

        extend(Series.prototype, /** @lends Highcharts.Series.prototype */ {
            /**
             * Runs on mouse over the series graphical items.
             */
            onMouseOver: function() {
                var series = this,
                    chart = series.chart,
                    hoverSeries = chart.hoverSeries;

                // set normal state to previous series
                if (hoverSeries && hoverSeries !== series) {
                    hoverSeries.onMouseOut();
                }

                // trigger the event, but to save processing time,
                // only if defined
                if (series.options.events.mouseOver) {
                    fireEvent(series, 'mouseOver');
                }

                // hover this
                series.setState('hover');
                chart.hoverSeries = series;
            },

            /**
             * Runs on mouse out of the series graphical items.
             */
            onMouseOut: function() {
                // trigger the event only if listeners exist
                var series = this,
                    options = series.options,
                    chart = series.chart,
                    tooltip = chart.tooltip,
                    hoverPoint = chart.hoverPoint;

                chart.hoverSeries = null; // #182, set to null before the mouseOut event fires

                // trigger mouse out on the point, which must be in this series
                if (hoverPoint) {
                    hoverPoint.onMouseOut();
                }

                // fire the mouse out event
                if (series && options.events.mouseOut) {
                    fireEvent(series, 'mouseOut');
                }


                // hide the tooltip
                if (tooltip && !series.stickyTracking && (!tooltip.shared || series.noSharedTooltip)) {
                    tooltip.hide();
                }

                // set normal state
                series.setState();
            },

            /**
             * Set the state of the series. Called internally on mouse interaction and
             * select operations, but it can also be called directly to visually
             * highlight a series.
             *
             * @param  {String} [state]
             *         Can be either `hover`, `select` or undefined to set to normal
             *         state.
             */
            setState: function(state) {
                var series = this,
                    options = series.options,
                    graph = series.graph,
                    stateOptions = options.states,
                    lineWidth = options.lineWidth,
                    attribs,
                    i = 0;

                state = state || '';

                if (series.state !== state) {

                    // Toggle class names
                    each([
                        series.group,
                        series.markerGroup,
                        series.dataLabelsGroup
                    ], function(group) {
                        if (group) {
                            // Old state
                            if (series.state) {
                                group.removeClass('highcharts-series-' + series.state);
                            }
                            // New state
                            if (state) {
                                group.addClass('highcharts-series-' + state);
                            }
                        }
                    });

                    series.state = state;



                    if (stateOptions[state] && stateOptions[state].enabled === false) {
                        return;
                    }

                    if (state) {
                        lineWidth = stateOptions[state].lineWidth || lineWidth + (stateOptions[state].lineWidthPlus || 0); // #4035
                    }

                    if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML
                        attribs = {
                            'stroke-width': lineWidth
                        };

                        // Animate the graph stroke-width. By default a quick animation
                        // to hover, slower to un-hover.
                        graph.animate(
                            attribs,
                            pick(
                                series.chart.options.chart.animation,
                                stateOptions[state] && stateOptions[state].animation
                            )
                        );
                        while (series['zone-graph-' + i]) {
                            series['zone-graph-' + i].attr(attribs);
                            i = i + 1;
                        }
                    }

                }
            },

            /**
             * Show or hide the series.
             *
             * @param  {Boolean} [visible]
             *         True to show the series, false to hide. If undefined, the
             *         visibility is toggled.
             * @param  {Boolean} [redraw=true]
             *         Whether to redraw the chart after the series is altered. If doing
             *         more operations on the chart, it is a good idea to set redraw to
             *         false and call {@link Chart#redraw|chart.redraw()} after.
             */
            setVisible: function(vis, redraw) {
                var series = this,
                    chart = series.chart,
                    legendItem = series.legendItem,
                    showOrHide,
                    ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
                    oldVisibility = series.visible;

                // if called without an argument, toggle visibility
                series.visible = vis = series.options.visible = series.userOptions.visible = vis === undefined ? !oldVisibility : vis; // #5618
                showOrHide = vis ? 'show' : 'hide';

                // show or hide elements
                each(['group', 'dataLabelsGroup', 'markerGroup', 'tracker', 'tt'], function(key) {
                    if (series[key]) {
                        series[key][showOrHide]();
                    }
                });


                // hide tooltip (#1361)
                if (chart.hoverSeries === series || (chart.hoverPoint && chart.hoverPoint.series) === series) {
                    series.onMouseOut();
                }


                if (legendItem) {
                    chart.legend.colorizeItem(series, vis);
                }


                // rescale or adapt to resized chart
                series.isDirty = true;
                // in a stack, all other series are affected
                if (series.options.stacking) {
                    each(chart.series, function(otherSeries) {
                        if (otherSeries.options.stacking && otherSeries.visible) {
                            otherSeries.isDirty = true;
                        }
                    });
                }

                // show or hide linked series
                each(series.linkedSeries, function(otherSeries) {
                    otherSeries.setVisible(vis, false);
                });

                if (ignoreHiddenSeries) {
                    chart.isDirtyBox = true;
                }
                if (redraw !== false) {
                    chart.redraw();
                }

                fireEvent(series, showOrHide);
            },

            /**
             * Show the series if hidden.
             *
             * @sample highcharts/members/series-hide/
             *         Toggle visibility from a button
             */
            show: function() {
                this.setVisible(true);
            },

            /**
             * Hide the series if visible. If the {@link
             * https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries|
             * chart.ignoreHiddenSeries} option is true, the chart is redrawn without
             * this series.
             *
             * @sample highcharts/members/series-hide/
             *         Toggle visibility from a button
             */
            hide: function() {
                this.setVisible(false);
            },


            /**
             * Select or unselect the series. This means its {@link
             * Highcharts.Series.selected|selected} property is set, the checkbox in the
             * legend is toggled and when selected, the series is returned by the
             * {@link Highcharts.Chart#getSelectedSeries} function.
             *
             * @param  {Boolean} [selected]
             *         True to select the series, false to unselect. If	undefined, the
             *         selection state is toggled.
             *
             * @sample highcharts/members/series-select/
             *         Select a series from a button
             */
            select: function(selected) {
                var series = this;

                series.selected = selected = (selected === undefined) ?
                    !series.selected :
                    selected;

                if (series.checkbox) {
                    series.checkbox.checked = selected;
                }

                fireEvent(series, selected ? 'select' : 'unselect');
            },

            drawTracker: TrackerMixin.drawTrackerGraph
        });

    }(Highcharts));
    (function(H) {
        /**
         * (c) 2010-2017 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */
        var Chart = H.Chart,
            each = H.each,
            inArray = H.inArray,
            isArray = H.isArray,
            isObject = H.isObject,
            pick = H.pick,
            splat = H.splat;


        /**
         * Allows setting a set of rules to apply for different screen or chart
         * sizes. Each rule specifies additional chart options.
         * 
         * @sample {highstock} stock/demo/responsive/ Stock chart
         * @sample highcharts/responsive/axis/ Axis
         * @sample highcharts/responsive/legend/ Legend
         * @sample highcharts/responsive/classname/ Class name
         * @since 5.0.0
         * @apioption responsive
         */

        /**
         * A set of rules for responsive settings. The rules are executed from
         * the top down.
         * 
         * @type {Array<Object>}
         * @sample {highcharts} highcharts/responsive/axis/ Axis changes
         * @sample {highstock} highcharts/responsive/axis/ Axis changes
         * @sample {highmaps} highcharts/responsive/axis/ Axis changes
         * @since 5.0.0
         * @apioption responsive.rules
         */

        /**
         * A full set of chart options to apply as overrides to the general
         * chart options. The chart options are applied when the given rule
         * is active.
         * 
         * A special case is configuration objects that take arrays, for example
         * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
         * collections, an `id` option is used to map the new option set to
         * an existing object. If an existing object of the same id is not found,
         * the item of the same indexupdated. So for example, setting `chartOptions`
         * with two series items without an `id`, will cause the existing chart's
         * two series to be updated with respective options.
         * 
         * @type {Object}
         * @sample {highstock} stock/demo/responsive/ Stock chart
         * @sample highcharts/responsive/axis/ Axis
         * @sample highcharts/responsive/legend/ Legend
         * @sample highcharts/responsive/classname/ Class name
         * @since 5.0.0
         * @apioption responsive.rules.chartOptions
         */

        /**
         * Under which conditions the rule applies.
         * 
         * @type {Object}
         * @since 5.0.0
         * @apioption responsive.rules.condition
         */

        /**
         * A callback function to gain complete control on when the responsive
         * rule applies. Return `true` if it applies. This opens for checking
         * against other metrics than the chart size, or example the document
         * size or other elements.
         * 
         * @type {Function}
         * @context Chart
         * @since 5.0.0
         * @apioption responsive.rules.condition.callback
         */

        /**
         * The responsive rule applies if the chart height is less than this.
         * 
         * @type {Number}
         * @since 5.0.0
         * @apioption responsive.rules.condition.maxHeight
         */

        /**
         * The responsive rule applies if the chart width is less than this.
         * 
         * @type {Number}
         * @sample highcharts/responsive/axis/ Max width is 500
         * @since 5.0.0
         * @apioption responsive.rules.condition.maxWidth
         */

        /**
         * The responsive rule applies if the chart height is greater than this.
         * 
         * @type {Number}
         * @default 0
         * @since 5.0.0
         * @apioption responsive.rules.condition.minHeight
         */

        /**
         * The responsive rule applies if the chart width is greater than this.
         * 
         * @type {Number}
         * @default 0
         * @since 5.0.0
         * @apioption responsive.rules.condition.minWidth
         */

        /**
         * Update the chart based on the current chart/document size and options for
         * responsiveness.
         */
        Chart.prototype.setResponsive = function(redraw) {
            var options = this.options.responsive,
                ruleIds = [],
                currentResponsive = this.currentResponsive,
                currentRuleIds;

            if (options && options.rules) {
                each(options.rules, function(rule) {
                    if (rule._id === undefined) {
                        rule._id = H.uniqueKey();
                    }

                    this.matchResponsiveRule(rule, ruleIds, redraw);
                }, this);
            }

            // Merge matching rules
            var mergedOptions = H.merge.apply(0, H.map(ruleIds, function(ruleId) {
                return H.find(options.rules, function(rule) {
                    return rule._id === ruleId;
                }).chartOptions;
            }));

            // Stringified key for the rules that currently apply.
            ruleIds = ruleIds.toString() || undefined;
            currentRuleIds = currentResponsive && currentResponsive.ruleIds;


            // Changes in what rules apply
            if (ruleIds !== currentRuleIds) {

                // Undo previous rules. Before we apply a new set of rules, we need to
                // roll back completely to base options (#6291).
                if (currentResponsive) {
                    this.update(currentResponsive.undoOptions, redraw);
                }

                if (ruleIds) {
                    // Get undo-options for matching rules
                    this.currentResponsive = {
                        ruleIds: ruleIds,
                        mergedOptions: mergedOptions,
                        undoOptions: this.currentOptions(mergedOptions)
                    };

                    this.update(mergedOptions, redraw);

                } else {
                    this.currentResponsive = undefined;
                }
            }
        };

        /**
         * Handle a single responsiveness rule
         */
        Chart.prototype.matchResponsiveRule = function(rule, matches) {
            var condition = rule.condition,
                fn = condition.callback || function() {
                    return this.chartWidth <= pick(condition.maxWidth, Number.MAX_VALUE) &&
                        this.chartHeight <= pick(condition.maxHeight, Number.MAX_VALUE) &&
                        this.chartWidth >= pick(condition.minWidth, 0) &&
                        this.chartHeight >= pick(condition.minHeight, 0);
                };

            if (fn.call(this)) {
                matches.push(rule._id);
            }

        };

        /**
         * Get the current values for a given set of options. Used before we update
         * the chart with a new responsiveness rule.
         * TODO: Restore axis options (by id?)
         */
        Chart.prototype.currentOptions = function(options) {

            var ret = {};

            /**
             * Recurse over a set of options and its current values,
             * and store the current values in the ret object.
             */
            function getCurrent(options, curr, ret, depth) {
                var i;
                H.objectEach(options, function(val, key) {
                    if (!depth && inArray(key, ['series', 'xAxis', 'yAxis']) > -1) {
                        options[key] = splat(options[key]);

                        ret[key] = [];

                        // Iterate over collections like series, xAxis or yAxis and map
                        // the items by index.
                        for (i = 0; i < options[key].length; i++) {
                            if (curr[key][i]) { // Item exists in current data (#6347)
                                ret[key][i] = {};
                                getCurrent(
                                    val[i],
                                    curr[key][i],
                                    ret[key][i],
                                    depth + 1
                                );
                            }
                        }
                    } else if (isObject(val)) {
                        ret[key] = isArray(val) ? [] : {};
                        getCurrent(val, curr[key] || {}, ret[key], depth + 1);
                    } else {
                        ret[key] = curr[key] || null;
                    }
                });
            }

            getCurrent(options, this.options, ret, 0);
            return ret;
        };

    }(Highcharts));
    return Highcharts
}));
//! moment.js
//! version : 2.19.1
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com

;(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
    typeof define === 'function' && define.amd ? define(factory) :
    global.moment = factory()
}(this, (function () { 'use strict';

var hookCallback;

function hooks () {
    return hookCallback.apply(null, arguments);
}

// This is done to register the method called with moment()
// without creating circular dependencies.
function setHookCallback (callback) {
    hookCallback = callback;
}

function isArray(input) {
    return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
}

function isObject(input) {
    // IE8 will treat undefined and null as object if it wasn't for
    // input != null
    return input != null && Object.prototype.toString.call(input) === '[object Object]';
}

function isObjectEmpty(obj) {
    if (Object.getOwnPropertyNames) {
        return (Object.getOwnPropertyNames(obj).length === 0);
    } else {
        var k;
        for (k in obj) {
            if (obj.hasOwnProperty(k)) {
                return false;
            }
        }
        return true;
    }
}

function isUndefined(input) {
    return input === void 0;
}

function isNumber(input) {
    return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
}

function isDate(input) {
    return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
}

function map(arr, fn) {
    var res = [], i;
    for (i = 0; i < arr.length; ++i) {
        res.push(fn(arr[i], i));
    }
    return res;
}

function hasOwnProp(a, b) {
    return Object.prototype.hasOwnProperty.call(a, b);
}

function extend(a, b) {
    for (var i in b) {
        if (hasOwnProp(b, i)) {
            a[i] = b[i];
        }
    }

    if (hasOwnProp(b, 'toString')) {
        a.toString = b.toString;
    }

    if (hasOwnProp(b, 'valueOf')) {
        a.valueOf = b.valueOf;
    }

    return a;
}

function createUTC (input, format, locale, strict) {
    return createLocalOrUTC(input, format, locale, strict, true).utc();
}

function defaultParsingFlags() {
    // We need to deep clone this object.
    return {
        empty           : false,
        unusedTokens    : [],
        unusedInput     : [],
        overflow        : -2,
        charsLeftOver   : 0,
        nullInput       : false,
        invalidMonth    : null,
        invalidFormat   : false,
        userInvalidated : false,
        iso             : false,
        parsedDateParts : [],
        meridiem        : null,
        rfc2822         : false,
        weekdayMismatch : false
    };
}

function getParsingFlags(m) {
    if (m._pf == null) {
        m._pf = defaultParsingFlags();
    }
    return m._pf;
}

var some;
if (Array.prototype.some) {
    some = Array.prototype.some;
} else {
    some = function (fun) {
        var t = Object(this);
        var len = t.length >>> 0;

        for (var i = 0; i < len; i++) {
            if (i in t && fun.call(this, t[i], i, t)) {
                return true;
            }
        }

        return false;
    };
}

function isValid(m) {
    if (m._isValid == null) {
        var flags = getParsingFlags(m);
        var parsedParts = some.call(flags.parsedDateParts, function (i) {
            return i != null;
        });
        var isNowValid = !isNaN(m._d.getTime()) &&
            flags.overflow < 0 &&
            !flags.empty &&
            !flags.invalidMonth &&
            !flags.invalidWeekday &&
            !flags.weekdayMismatch &&
            !flags.nullInput &&
            !flags.invalidFormat &&
            !flags.userInvalidated &&
            (!flags.meridiem || (flags.meridiem && parsedParts));

        if (m._strict) {
            isNowValid = isNowValid &&
                flags.charsLeftOver === 0 &&
                flags.unusedTokens.length === 0 &&
                flags.bigHour === undefined;
        }

        if (Object.isFrozen == null || !Object.isFrozen(m)) {
            m._isValid = isNowValid;
        }
        else {
            return isNowValid;
        }
    }
    return m._isValid;
}

function createInvalid (flags) {
    var m = createUTC(NaN);
    if (flags != null) {
        extend(getParsingFlags(m), flags);
    }
    else {
        getParsingFlags(m).userInvalidated = true;
    }

    return m;
}

// Plugins that add properties should also add the key here (null value),
// so we can properly clone ourselves.
var momentProperties = hooks.momentProperties = [];

function copyConfig(to, from) {
    var i, prop, val;

    if (!isUndefined(from._isAMomentObject)) {
        to._isAMomentObject = from._isAMomentObject;
    }
    if (!isUndefined(from._i)) {
        to._i = from._i;
    }
    if (!isUndefined(from._f)) {
        to._f = from._f;
    }
    if (!isUndefined(from._l)) {
        to._l = from._l;
    }
    if (!isUndefined(from._strict)) {
        to._strict = from._strict;
    }
    if (!isUndefined(from._tzm)) {
        to._tzm = from._tzm;
    }
    if (!isUndefined(from._isUTC)) {
        to._isUTC = from._isUTC;
    }
    if (!isUndefined(from._offset)) {
        to._offset = from._offset;
    }
    if (!isUndefined(from._pf)) {
        to._pf = getParsingFlags(from);
    }
    if (!isUndefined(from._locale)) {
        to._locale = from._locale;
    }

    if (momentProperties.length > 0) {
        for (i = 0; i < momentProperties.length; i++) {
            prop = momentProperties[i];
            val = from[prop];
            if (!isUndefined(val)) {
                to[prop] = val;
            }
        }
    }

    return to;
}

var updateInProgress = false;

// Moment prototype object
function Moment(config) {
    copyConfig(this, config);
    this._d = new Date(config._d != null ? config._d.getTime() : NaN);
    if (!this.isValid()) {
        this._d = new Date(NaN);
    }
    // Prevent infinite loop in case updateOffset creates new moment
    // objects.
    if (updateInProgress === false) {
        updateInProgress = true;
        hooks.updateOffset(this);
        updateInProgress = false;
    }
}

function isMoment (obj) {
    return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
}

function absFloor (number) {
    if (number < 0) {
        // -0 -> 0
        return Math.ceil(number) || 0;
    } else {
        return Math.floor(number);
    }
}

function toInt(argumentForCoercion) {
    var coercedNumber = +argumentForCoercion,
        value = 0;

    if (coercedNumber !== 0 && isFinite(coercedNumber)) {
        value = absFloor(coercedNumber);
    }

    return value;
}

// compare two arrays, return the number of differences
function compareArrays(array1, array2, dontConvert) {
    var len = Math.min(array1.length, array2.length),
        lengthDiff = Math.abs(array1.length - array2.length),
        diffs = 0,
        i;
    for (i = 0; i < len; i++) {
        if ((dontConvert && array1[i] !== array2[i]) ||
            (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
            diffs++;
        }
    }
    return diffs + lengthDiff;
}

function warn(msg) {
    if (hooks.suppressDeprecationWarnings === false &&
            (typeof console !==  'undefined') && console.warn) {
        console.warn('Deprecation warning: ' + msg);
    }
}

function deprecate(msg, fn) {
    var firstTime = true;

    return extend(function () {
        if (hooks.deprecationHandler != null) {
            hooks.deprecationHandler(null, msg);
        }
        if (firstTime) {
            var args = [];
            var arg;
            for (var i = 0; i < arguments.length; i++) {
                arg = '';
                if (typeof arguments[i] === 'object') {
                    arg += '\n[' + i + '] ';
                    for (var key in arguments[0]) {
                        arg += key + ': ' + arguments[0][key] + ', ';
                    }
                    arg = arg.slice(0, -2); // Remove trailing comma and space
                } else {
                    arg = arguments[i];
                }
                args.push(arg);
            }
            warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
            firstTime = false;
        }
        return fn.apply(this, arguments);
    }, fn);
}

var deprecations = {};

function deprecateSimple(name, msg) {
    if (hooks.deprecationHandler != null) {
        hooks.deprecationHandler(name, msg);
    }
    if (!deprecations[name]) {
        warn(msg);
        deprecations[name] = true;
    }
}

hooks.suppressDeprecationWarnings = false;
hooks.deprecationHandler = null;

function isFunction(input) {
    return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
}

function set (config) {
    var prop, i;
    for (i in config) {
        prop = config[i];
        if (isFunction(prop)) {
            this[i] = prop;
        } else {
            this['_' + i] = prop;
        }
    }
    this._config = config;
    // Lenient ordinal parsing accepts just a number in addition to
    // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
    // TODO: Remove "ordinalParse" fallback in next major release.
    this._dayOfMonthOrdinalParseLenient = new RegExp(
        (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
            '|' + (/\d{1,2}/).source);
}

function mergeConfigs(parentConfig, childConfig) {
    var res = extend({}, parentConfig), prop;
    for (prop in childConfig) {
        if (hasOwnProp(childConfig, prop)) {
            if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
                res[prop] = {};
                extend(res[prop], parentConfig[prop]);
                extend(res[prop], childConfig[prop]);
            } else if (childConfig[prop] != null) {
                res[prop] = childConfig[prop];
            } else {
                delete res[prop];
            }
        }
    }
    for (prop in parentConfig) {
        if (hasOwnProp(parentConfig, prop) &&
                !hasOwnProp(childConfig, prop) &&
                isObject(parentConfig[prop])) {
            // make sure changes to properties don't modify parent config
            res[prop] = extend({}, res[prop]);
        }
    }
    return res;
}

function Locale(config) {
    if (config != null) {
        this.set(config);
    }
}

var keys;

if (Object.keys) {
    keys = Object.keys;
} else {
    keys = function (obj) {
        var i, res = [];
        for (i in obj) {
            if (hasOwnProp(obj, i)) {
                res.push(i);
            }
        }
        return res;
    };
}

var defaultCalendar = {
    sameDay : '[Today at] LT',
    nextDay : '[Tomorrow at] LT',
    nextWeek : 'dddd [at] LT',
    lastDay : '[Yesterday at] LT',
    lastWeek : '[Last] dddd [at] LT',
    sameElse : 'L'
};

function calendar (key, mom, now) {
    var output = this._calendar[key] || this._calendar['sameElse'];
    return isFunction(output) ? output.call(mom, now) : output;
}

var defaultLongDateFormat = {
    LTS  : 'h:mm:ss A',
    LT   : 'h:mm A',
    L    : 'MM/DD/YYYY',
    LL   : 'MMMM D, YYYY',
    LLL  : 'MMMM D, YYYY h:mm A',
    LLLL : 'dddd, MMMM D, YYYY h:mm A'
};

function longDateFormat (key) {
    var format = this._longDateFormat[key],
        formatUpper = this._longDateFormat[key.toUpperCase()];

    if (format || !formatUpper) {
        return format;
    }

    this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
        return val.slice(1);
    });

    return this._longDateFormat[key];
}

var defaultInvalidDate = 'Invalid date';

function invalidDate () {
    return this._invalidDate;
}

var defaultOrdinal = '%d';
var defaultDayOfMonthOrdinalParse = /\d{1,2}/;

function ordinal (number) {
    return this._ordinal.replace('%d', number);
}

var defaultRelativeTime = {
    future : 'in %s',
    past   : '%s ago',
    s  : 'a few seconds',
    ss : '%d seconds',
    m  : 'a minute',
    mm : '%d minutes',
    h  : 'an hour',
    hh : '%d hours',
    d  : 'a day',
    dd : '%d days',
    M  : 'a month',
    MM : '%d months',
    y  : 'a year',
    yy : '%d years'
};

function relativeTime (number, withoutSuffix, string, isFuture) {
    var output = this._relativeTime[string];
    return (isFunction(output)) ?
        output(number, withoutSuffix, string, isFuture) :
        output.replace(/%d/i, number);
}

function pastFuture (diff, output) {
    var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
    return isFunction(format) ? format(output) : format.replace(/%s/i, output);
}

var aliases = {};

function addUnitAlias (unit, shorthand) {
    var lowerCase = unit.toLowerCase();
    aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
}

function normalizeUnits(units) {
    return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
}

function normalizeObjectUnits(inputObject) {
    var normalizedInput = {},
        normalizedProp,
        prop;

    for (prop in inputObject) {
        if (hasOwnProp(inputObject, prop)) {
            normalizedProp = normalizeUnits(prop);
            if (normalizedProp) {
                normalizedInput[normalizedProp] = inputObject[prop];
            }
        }
    }

    return normalizedInput;
}

var priorities = {};

function addUnitPriority(unit, priority) {
    priorities[unit] = priority;
}

function getPrioritizedUnits(unitsObj) {
    var units = [];
    for (var u in unitsObj) {
        units.push({unit: u, priority: priorities[u]});
    }
    units.sort(function (a, b) {
        return a.priority - b.priority;
    });
    return units;
}

function zeroFill(number, targetLength, forceSign) {
    var absNumber = '' + Math.abs(number),
        zerosToFill = targetLength - absNumber.length,
        sign = number >= 0;
    return (sign ? (forceSign ? '+' : '') : '-') +
        Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
}

var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;

var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;

var formatFunctions = {};

var formatTokenFunctions = {};

// token:    'M'
// padded:   ['MM', 2]
// ordinal:  'Mo'
// callback: function () { this.month() + 1 }
function addFormatToken (token, padded, ordinal, callback) {
    var func = callback;
    if (typeof callback === 'string') {
        func = function () {
            return this[callback]();
        };
    }
    if (token) {
        formatTokenFunctions[token] = func;
    }
    if (padded) {
        formatTokenFunctions[padded[0]] = function () {
            return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
        };
    }
    if (ordinal) {
        formatTokenFunctions[ordinal] = function () {
            return this.localeData().ordinal(func.apply(this, arguments), token);
        };
    }
}

function removeFormattingTokens(input) {
    if (input.match(/\[[\s\S]/)) {
        return input.replace(/^\[|\]$/g, '');
    }
    return input.replace(/\\/g, '');
}

function makeFormatFunction(format) {
    var array = format.match(formattingTokens), i, length;

    for (i = 0, length = array.length; i < length; i++) {
        if (formatTokenFunctions[array[i]]) {
            array[i] = formatTokenFunctions[array[i]];
        } else {
            array[i] = removeFormattingTokens(array[i]);
        }
    }

    return function (mom) {
        var output = '', i;
        for (i = 0; i < length; i++) {
            output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
        }
        return output;
    };
}

// format date using native date object
function formatMoment(m, format) {
    if (!m.isValid()) {
        return m.localeData().invalidDate();
    }

    format = expandFormat(format, m.localeData());
    formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);

    return formatFunctions[format](m);
}

function expandFormat(format, locale) {
    var i = 5;

    function replaceLongDateFormatTokens(input) {
        return locale.longDateFormat(input) || input;
    }

    localFormattingTokens.lastIndex = 0;
    while (i >= 0 && localFormattingTokens.test(format)) {
        format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
        localFormattingTokens.lastIndex = 0;
        i -= 1;
    }

    return format;
}

var match1         = /\d/;            //       0 - 9
var match2         = /\d\d/;          //      00 - 99
var match3         = /\d{3}/;         //     000 - 999
var match4         = /\d{4}/;         //    0000 - 9999
var match6         = /[+-]?\d{6}/;    // -999999 - 999999
var match1to2      = /\d\d?/;         //       0 - 99
var match3to4      = /\d\d\d\d?/;     //     999 - 9999
var match5to6      = /\d\d\d\d\d\d?/; //   99999 - 999999
var match1to3      = /\d{1,3}/;       //       0 - 999
var match1to4      = /\d{1,4}/;       //       0 - 9999
var match1to6      = /[+-]?\d{1,6}/;  // -999999 - 999999

var matchUnsigned  = /\d+/;           //       0 - inf
var matchSigned    = /[+-]?\d+/;      //    -inf - inf

var matchOffset    = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z

var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123

// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;


var regexes = {};

function addRegexToken (token, regex, strictRegex) {
    regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
        return (isStrict && strictRegex) ? strictRegex : regex;
    };
}

function getParseRegexForToken (token, config) {
    if (!hasOwnProp(regexes, token)) {
        return new RegExp(unescapeFormat(token));
    }

    return regexes[token](config._strict, config._locale);
}

// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(s) {
    return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
        return p1 || p2 || p3 || p4;
    }));
}

function regexEscape(s) {
    return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}

var tokens = {};

function addParseToken (token, callback) {
    var i, func = callback;
    if (typeof token === 'string') {
        token = [token];
    }
    if (isNumber(callback)) {
        func = function (input, array) {
            array[callback] = toInt(input);
        };
    }
    for (i = 0; i < token.length; i++) {
        tokens[token[i]] = func;
    }
}

function addWeekParseToken (token, callback) {
    addParseToken(token, function (input, array, config, token) {
        config._w = config._w || {};
        callback(input, config._w, config, token);
    });
}

function addTimeToArrayFromToken(token, input, config) {
    if (input != null && hasOwnProp(tokens, token)) {
        tokens[token](input, config._a, config, token);
    }
}

var YEAR = 0;
var MONTH = 1;
var DATE = 2;
var HOUR = 3;
var MINUTE = 4;
var SECOND = 5;
var MILLISECOND = 6;
var WEEK = 7;
var WEEKDAY = 8;

// FORMATTING

addFormatToken('Y', 0, 0, function () {
    var y = this.year();
    return y <= 9999 ? '' + y : '+' + y;
});

addFormatToken(0, ['YY', 2], 0, function () {
    return this.year() % 100;
});

addFormatToken(0, ['YYYY',   4],       0, 'year');
addFormatToken(0, ['YYYYY',  5],       0, 'year');
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');

// ALIASES

addUnitAlias('year', 'y');

// PRIORITIES

addUnitPriority('year', 1);

// PARSING

addRegexToken('Y',      matchSigned);
addRegexToken('YY',     match1to2, match2);
addRegexToken('YYYY',   match1to4, match4);
addRegexToken('YYYYY',  match1to6, match6);
addRegexToken('YYYYYY', match1to6, match6);

addParseToken(['YYYYY', 'YYYYYY'], YEAR);
addParseToken('YYYY', function (input, array) {
    array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
});
addParseToken('YY', function (input, array) {
    array[YEAR] = hooks.parseTwoDigitYear(input);
});
addParseToken('Y', function (input, array) {
    array[YEAR] = parseInt(input, 10);
});

// HELPERS

function daysInYear(year) {
    return isLeapYear(year) ? 366 : 365;
}

function isLeapYear(year) {
    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}

// HOOKS

hooks.parseTwoDigitYear = function (input) {
    return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};

// MOMENTS

var getSetYear = makeGetSet('FullYear', true);

function getIsLeapYear () {
    return isLeapYear(this.year());
}

function makeGetSet (unit, keepTime) {
    return function (value) {
        if (value != null) {
            set$1(this, unit, value);
            hooks.updateOffset(this, keepTime);
            return this;
        } else {
            return get(this, unit);
        }
    };
}

function get (mom, unit) {
    return mom.isValid() ?
        mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
}

function set$1 (mom, unit, value) {
    if (mom.isValid() && !isNaN(value)) {
        if (unit === 'FullYear' && isLeapYear(mom.year())) {
            mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
        }
        else {
            mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
        }
    }
}

// MOMENTS

function stringGet (units) {
    units = normalizeUnits(units);
    if (isFunction(this[units])) {
        return this[units]();
    }
    return this;
}


function stringSet (units, value) {
    if (typeof units === 'object') {
        units = normalizeObjectUnits(units);
        var prioritized = getPrioritizedUnits(units);
        for (var i = 0; i < prioritized.length; i++) {
            this[prioritized[i].unit](units[prioritized[i].unit]);
        }
    } else {
        units = normalizeUnits(units);
        if (isFunction(this[units])) {
            return this[units](value);
        }
    }
    return this;
}

function mod(n, x) {
    return ((n % x) + x) % x;
}

var indexOf;

if (Array.prototype.indexOf) {
    indexOf = Array.prototype.indexOf;
} else {
    indexOf = function (o) {
        // I know
        var i;
        for (i = 0; i < this.length; ++i) {
            if (this[i] === o) {
                return i;
            }
        }
        return -1;
    };
}

function daysInMonth(year, month) {
    if (isNaN(year) || isNaN(month)) {
        return NaN;
    }
    var modMonth = mod(month, 12);
    year += (month - modMonth) / 12;
    return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
}

// FORMATTING

addFormatToken('M', ['MM', 2], 'Mo', function () {
    return this.month() + 1;
});

addFormatToken('MMM', 0, 0, function (format) {
    return this.localeData().monthsShort(this, format);
});

addFormatToken('MMMM', 0, 0, function (format) {
    return this.localeData().months(this, format);
});

// ALIASES

addUnitAlias('month', 'M');

// PRIORITY

addUnitPriority('month', 8);

// PARSING

addRegexToken('M',    match1to2);
addRegexToken('MM',   match1to2, match2);
addRegexToken('MMM',  function (isStrict, locale) {
    return locale.monthsShortRegex(isStrict);
});
addRegexToken('MMMM', function (isStrict, locale) {
    return locale.monthsRegex(isStrict);
});

addParseToken(['M', 'MM'], function (input, array) {
    array[MONTH] = toInt(input) - 1;
});

addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
    var month = config._locale.monthsParse(input, token, config._strict);
    // if we didn't find a month name, mark the date as invalid.
    if (month != null) {
        array[MONTH] = month;
    } else {
        getParsingFlags(config).invalidMonth = input;
    }
});

// LOCALES

var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
function localeMonths (m, format) {
    if (!m) {
        return isArray(this._months) ? this._months :
            this._months['standalone'];
    }
    return isArray(this._months) ? this._months[m.month()] :
        this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
}

var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
function localeMonthsShort (m, format) {
    if (!m) {
        return isArray(this._monthsShort) ? this._monthsShort :
            this._monthsShort['standalone'];
    }
    return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
        this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}

function handleStrictParse(monthName, format, strict) {
    var i, ii, mom, llc = monthName.toLocaleLowerCase();
    if (!this._monthsParse) {
        // this is not used
        this._monthsParse = [];
        this._longMonthsParse = [];
        this._shortMonthsParse = [];
        for (i = 0; i < 12; ++i) {
            mom = createUTC([2000, i]);
            this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
            this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
        }
    }

    if (strict) {
        if (format === 'MMM') {
            ii = indexOf.call(this._shortMonthsParse, llc);
            return ii !== -1 ? ii : null;
        } else {
            ii = indexOf.call(this._longMonthsParse, llc);
            return ii !== -1 ? ii : null;
        }
    } else {
        if (format === 'MMM') {
            ii = indexOf.call(this._shortMonthsParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._longMonthsParse, llc);
            return ii !== -1 ? ii : null;
        } else {
            ii = indexOf.call(this._longMonthsParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._shortMonthsParse, llc);
            return ii !== -1 ? ii : null;
        }
    }
}

function localeMonthsParse (monthName, format, strict) {
    var i, mom, regex;

    if (this._monthsParseExact) {
        return handleStrictParse.call(this, monthName, format, strict);
    }

    if (!this._monthsParse) {
        this._monthsParse = [];
        this._longMonthsParse = [];
        this._shortMonthsParse = [];
    }

    // TODO: add sorting
    // Sorting makes sure if one month (or abbr) is a prefix of another
    // see sorting in computeMonthsParse
    for (i = 0; i < 12; i++) {
        // make the regex if we don't have it already
        mom = createUTC([2000, i]);
        if (strict && !this._longMonthsParse[i]) {
            this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
            this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
        }
        if (!strict && !this._monthsParse[i]) {
            regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
            this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
        }
        // test the regex
        if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
            return i;
        } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
            return i;
        } else if (!strict && this._monthsParse[i].test(monthName)) {
            return i;
        }
    }
}

// MOMENTS

function setMonth (mom, value) {
    var dayOfMonth;

    if (!mom.isValid()) {
        // No op
        return mom;
    }

    if (typeof value === 'string') {
        if (/^\d+$/.test(value)) {
            value = toInt(value);
        } else {
            value = mom.localeData().monthsParse(value);
            // TODO: Another silent failure?
            if (!isNumber(value)) {
                return mom;
            }
        }
    }

    dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
    mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
    return mom;
}

function getSetMonth (value) {
    if (value != null) {
        setMonth(this, value);
        hooks.updateOffset(this, true);
        return this;
    } else {
        return get(this, 'Month');
    }
}

function getDaysInMonth () {
    return daysInMonth(this.year(), this.month());
}

var defaultMonthsShortRegex = matchWord;
function monthsShortRegex (isStrict) {
    if (this._monthsParseExact) {
        if (!hasOwnProp(this, '_monthsRegex')) {
            computeMonthsParse.call(this);
        }
        if (isStrict) {
            return this._monthsShortStrictRegex;
        } else {
            return this._monthsShortRegex;
        }
    } else {
        if (!hasOwnProp(this, '_monthsShortRegex')) {
            this._monthsShortRegex = defaultMonthsShortRegex;
        }
        return this._monthsShortStrictRegex && isStrict ?
            this._monthsShortStrictRegex : this._monthsShortRegex;
    }
}

var defaultMonthsRegex = matchWord;
function monthsRegex (isStrict) {
    if (this._monthsParseExact) {
        if (!hasOwnProp(this, '_monthsRegex')) {
            computeMonthsParse.call(this);
        }
        if (isStrict) {
            return this._monthsStrictRegex;
        } else {
            return this._monthsRegex;
        }
    } else {
        if (!hasOwnProp(this, '_monthsRegex')) {
            this._monthsRegex = defaultMonthsRegex;
        }
        return this._monthsStrictRegex && isStrict ?
            this._monthsStrictRegex : this._monthsRegex;
    }
}

function computeMonthsParse () {
    function cmpLenRev(a, b) {
        return b.length - a.length;
    }

    var shortPieces = [], longPieces = [], mixedPieces = [],
        i, mom;
    for (i = 0; i < 12; i++) {
        // make the regex if we don't have it already
        mom = createUTC([2000, i]);
        shortPieces.push(this.monthsShort(mom, ''));
        longPieces.push(this.months(mom, ''));
        mixedPieces.push(this.months(mom, ''));
        mixedPieces.push(this.monthsShort(mom, ''));
    }
    // Sorting makes sure if one month (or abbr) is a prefix of another it
    // will match the longer piece.
    shortPieces.sort(cmpLenRev);
    longPieces.sort(cmpLenRev);
    mixedPieces.sort(cmpLenRev);
    for (i = 0; i < 12; i++) {
        shortPieces[i] = regexEscape(shortPieces[i]);
        longPieces[i] = regexEscape(longPieces[i]);
    }
    for (i = 0; i < 24; i++) {
        mixedPieces[i] = regexEscape(mixedPieces[i]);
    }

    this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
    this._monthsShortRegex = this._monthsRegex;
    this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
    this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
}

function createDate (y, m, d, h, M, s, ms) {
    // can't just apply() to create a date:
    // https://stackoverflow.com/q/181348
    var date = new Date(y, m, d, h, M, s, ms);

    // the date constructor remaps years 0-99 to 1900-1999
    if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
        date.setFullYear(y);
    }
    return date;
}

function createUTCDate (y) {
    var date = new Date(Date.UTC.apply(null, arguments));

    // the Date.UTC function remaps years 0-99 to 1900-1999
    if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
        date.setUTCFullYear(y);
    }
    return date;
}

// start-of-first-week - start-of-year
function firstWeekOffset(year, dow, doy) {
    var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
        fwd = 7 + dow - doy,
        // first-week day local weekday -- which local weekday is fwd
        fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;

    return -fwdlw + fwd - 1;
}

// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
    var localWeekday = (7 + weekday - dow) % 7,
        weekOffset = firstWeekOffset(year, dow, doy),
        dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
        resYear, resDayOfYear;

    if (dayOfYear <= 0) {
        resYear = year - 1;
        resDayOfYear = daysInYear(resYear) + dayOfYear;
    } else if (dayOfYear > daysInYear(year)) {
        resYear = year + 1;
        resDayOfYear = dayOfYear - daysInYear(year);
    } else {
        resYear = year;
        resDayOfYear = dayOfYear;
    }

    return {
        year: resYear,
        dayOfYear: resDayOfYear
    };
}

function weekOfYear(mom, dow, doy) {
    var weekOffset = firstWeekOffset(mom.year(), dow, doy),
        week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
        resWeek, resYear;

    if (week < 1) {
        resYear = mom.year() - 1;
        resWeek = week + weeksInYear(resYear, dow, doy);
    } else if (week > weeksInYear(mom.year(), dow, doy)) {
        resWeek = week - weeksInYear(mom.year(), dow, doy);
        resYear = mom.year() + 1;
    } else {
        resYear = mom.year();
        resWeek = week;
    }

    return {
        week: resWeek,
        year: resYear
    };
}

function weeksInYear(year, dow, doy) {
    var weekOffset = firstWeekOffset(year, dow, doy),
        weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
    return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
}

// FORMATTING

addFormatToken('w', ['ww', 2], 'wo', 'week');
addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');

// ALIASES

addUnitAlias('week', 'w');
addUnitAlias('isoWeek', 'W');

// PRIORITIES

addUnitPriority('week', 5);
addUnitPriority('isoWeek', 5);

// PARSING

addRegexToken('w',  match1to2);
addRegexToken('ww', match1to2, match2);
addRegexToken('W',  match1to2);
addRegexToken('WW', match1to2, match2);

addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
    week[token.substr(0, 1)] = toInt(input);
});

// HELPERS

// LOCALES

function localeWeek (mom) {
    return weekOfYear(mom, this._week.dow, this._week.doy).week;
}

var defaultLocaleWeek = {
    dow : 0, // Sunday is the first day of the week.
    doy : 6  // The week that contains Jan 1st is the first week of the year.
};

function localeFirstDayOfWeek () {
    return this._week.dow;
}

function localeFirstDayOfYear () {
    return this._week.doy;
}

// MOMENTS

function getSetWeek (input) {
    var week = this.localeData().week(this);
    return input == null ? week : this.add((input - week) * 7, 'd');
}

function getSetISOWeek (input) {
    var week = weekOfYear(this, 1, 4).week;
    return input == null ? week : this.add((input - week) * 7, 'd');
}

// FORMATTING

addFormatToken('d', 0, 'do', 'day');

addFormatToken('dd', 0, 0, function (format) {
    return this.localeData().weekdaysMin(this, format);
});

addFormatToken('ddd', 0, 0, function (format) {
    return this.localeData().weekdaysShort(this, format);
});

addFormatToken('dddd', 0, 0, function (format) {
    return this.localeData().weekdays(this, format);
});

addFormatToken('e', 0, 0, 'weekday');
addFormatToken('E', 0, 0, 'isoWeekday');

// ALIASES

addUnitAlias('day', 'd');
addUnitAlias('weekday', 'e');
addUnitAlias('isoWeekday', 'E');

// PRIORITY
addUnitPriority('day', 11);
addUnitPriority('weekday', 11);
addUnitPriority('isoWeekday', 11);

// PARSING

addRegexToken('d',    match1to2);
addRegexToken('e',    match1to2);
addRegexToken('E',    match1to2);
addRegexToken('dd',   function (isStrict, locale) {
    return locale.weekdaysMinRegex(isStrict);
});
addRegexToken('ddd',   function (isStrict, locale) {
    return locale.weekdaysShortRegex(isStrict);
});
addRegexToken('dddd',   function (isStrict, locale) {
    return locale.weekdaysRegex(isStrict);
});

addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
    var weekday = config._locale.weekdaysParse(input, token, config._strict);
    // if we didn't get a weekday name, mark the date as invalid
    if (weekday != null) {
        week.d = weekday;
    } else {
        getParsingFlags(config).invalidWeekday = input;
    }
});

addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
    week[token] = toInt(input);
});

// HELPERS

function parseWeekday(input, locale) {
    if (typeof input !== 'string') {
        return input;
    }

    if (!isNaN(input)) {
        return parseInt(input, 10);
    }

    input = locale.weekdaysParse(input);
    if (typeof input === 'number') {
        return input;
    }

    return null;
}

function parseIsoWeekday(input, locale) {
    if (typeof input === 'string') {
        return locale.weekdaysParse(input) % 7 || 7;
    }
    return isNaN(input) ? null : input;
}

// LOCALES

var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
function localeWeekdays (m, format) {
    if (!m) {
        return isArray(this._weekdays) ? this._weekdays :
            this._weekdays['standalone'];
    }
    return isArray(this._weekdays) ? this._weekdays[m.day()] :
        this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
}

var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
function localeWeekdaysShort (m) {
    return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
}

var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
function localeWeekdaysMin (m) {
    return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
}

function handleStrictParse$1(weekdayName, format, strict) {
    var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
    if (!this._weekdaysParse) {
        this._weekdaysParse = [];
        this._shortWeekdaysParse = [];
        this._minWeekdaysParse = [];

        for (i = 0; i < 7; ++i) {
            mom = createUTC([2000, 1]).day(i);
            this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
            this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
            this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
        }
    }

    if (strict) {
        if (format === 'dddd') {
            ii = indexOf.call(this._weekdaysParse, llc);
            return ii !== -1 ? ii : null;
        } else if (format === 'ddd') {
            ii = indexOf.call(this._shortWeekdaysParse, llc);
            return ii !== -1 ? ii : null;
        } else {
            ii = indexOf.call(this._minWeekdaysParse, llc);
            return ii !== -1 ? ii : null;
        }
    } else {
        if (format === 'dddd') {
            ii = indexOf.call(this._weekdaysParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._shortWeekdaysParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._minWeekdaysParse, llc);
            return ii !== -1 ? ii : null;
        } else if (format === 'ddd') {
            ii = indexOf.call(this._shortWeekdaysParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._weekdaysParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._minWeekdaysParse, llc);
            return ii !== -1 ? ii : null;
        } else {
            ii = indexOf.call(this._minWeekdaysParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._weekdaysParse, llc);
            if (ii !== -1) {
                return ii;
            }
            ii = indexOf.call(this._shortWeekdaysParse, llc);
            return ii !== -1 ? ii : null;
        }
    }
}

function localeWeekdaysParse (weekdayName, format, strict) {
    var i, mom, regex;

    if (this._weekdaysParseExact) {
        return handleStrictParse$1.call(this, weekdayName, format, strict);
    }

    if (!this._weekdaysParse) {
        this._weekdaysParse = [];
        this._minWeekdaysParse = [];
        this._shortWeekdaysParse = [];
        this._fullWeekdaysParse = [];
    }

    for (i = 0; i < 7; i++) {
        // make the regex if we don't have it already

        mom = createUTC([2000, 1]).day(i);
        if (strict && !this._fullWeekdaysParse[i]) {
            this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
            this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
            this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
        }
        if (!this._weekdaysParse[i]) {
            regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
            this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
        }
        // test the regex
        if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
            return i;
        } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
            return i;
        } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
            return i;
        } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
            return i;
        }
    }
}

// MOMENTS

function getSetDayOfWeek (input) {
    if (!this.isValid()) {
        return input != null ? this : NaN;
    }
    var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
    if (input != null) {
        input = parseWeekday(input, this.localeData());
        return this.add(input - day, 'd');
    } else {
        return day;
    }
}

function getSetLocaleDayOfWeek (input) {
    if (!this.isValid()) {
        return input != null ? this : NaN;
    }
    var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
    return input == null ? weekday : this.add(input - weekday, 'd');
}

function getSetISODayOfWeek (input) {
    if (!this.isValid()) {
        return input != null ? this : NaN;
    }

    // behaves the same as moment#day except
    // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
    // as a setter, sunday should belong to the previous week.

    if (input != null) {
        var weekday = parseIsoWeekday(input, this.localeData());
        return this.day(this.day() % 7 ? weekday : weekday - 7);
    } else {
        return this.day() || 7;
    }
}

var defaultWeekdaysRegex = matchWord;
function weekdaysRegex (isStrict) {
    if (this._weekdaysParseExact) {
        if (!hasOwnProp(this, '_weekdaysRegex')) {
            computeWeekdaysParse.call(this);
        }
        if (isStrict) {
            return this._weekdaysStrictRegex;
        } else {
            return this._weekdaysRegex;
        }
    } else {
        if (!hasOwnProp(this, '_weekdaysRegex')) {
            this._weekdaysRegex = defaultWeekdaysRegex;
        }
        return this._weekdaysStrictRegex && isStrict ?
            this._weekdaysStrictRegex : this._weekdaysRegex;
    }
}

var defaultWeekdaysShortRegex = matchWord;
function weekdaysShortRegex (isStrict) {
    if (this._weekdaysParseExact) {
        if (!hasOwnProp(this, '_weekdaysRegex')) {
            computeWeekdaysParse.call(this);
        }
        if (isStrict) {
            return this._weekdaysShortStrictRegex;
        } else {
            return this._weekdaysShortRegex;
        }
    } else {
        if (!hasOwnProp(this, '_weekdaysShortRegex')) {
            this._weekdaysShortRegex = defaultWeekdaysShortRegex;
        }
        return this._weekdaysShortStrictRegex && isStrict ?
            this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
    }
}

var defaultWeekdaysMinRegex = matchWord;
function weekdaysMinRegex (isStrict) {
    if (this._weekdaysParseExact) {
        if (!hasOwnProp(this, '_weekdaysRegex')) {
            computeWeekdaysParse.call(this);
        }
        if (isStrict) {
            return this._weekdaysMinStrictRegex;
        } else {
            return this._weekdaysMinRegex;
        }
    } else {
        if (!hasOwnProp(this, '_weekdaysMinRegex')) {
            this._weekdaysMinRegex = defaultWeekdaysMinRegex;
        }
        return this._weekdaysMinStrictRegex && isStrict ?
            this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
    }
}


function computeWeekdaysParse () {
    function cmpLenRev(a, b) {
        return b.length - a.length;
    }

    var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
        i, mom, minp, shortp, longp;
    for (i = 0; i < 7; i++) {
        // make the regex if we don't have it already
        mom = createUTC([2000, 1]).day(i);
        minp = this.weekdaysMin(mom, '');
        shortp = this.weekdaysShort(mom, '');
        longp = this.weekdays(mom, '');
        minPieces.push(minp);
        shortPieces.push(shortp);
        longPieces.push(longp);
        mixedPieces.push(minp);
        mixedPieces.push(shortp);
        mixedPieces.push(longp);
    }
    // Sorting makes sure if one weekday (or abbr) is a prefix of another it
    // will match the longer piece.
    minPieces.sort(cmpLenRev);
    shortPieces.sort(cmpLenRev);
    longPieces.sort(cmpLenRev);
    mixedPieces.sort(cmpLenRev);
    for (i = 0; i < 7; i++) {
        shortPieces[i] = regexEscape(shortPieces[i]);
        longPieces[i] = regexEscape(longPieces[i]);
        mixedPieces[i] = regexEscape(mixedPieces[i]);
    }

    this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
    this._weekdaysShortRegex = this._weekdaysRegex;
    this._weekdaysMinRegex = this._weekdaysRegex;

    this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
    this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
    this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
}

// FORMATTING

function hFormat() {
    return this.hours() % 12 || 12;
}

function kFormat() {
    return this.hours() || 24;
}

addFormatToken('H', ['HH', 2], 0, 'hour');
addFormatToken('h', ['hh', 2], 0, hFormat);
addFormatToken('k', ['kk', 2], 0, kFormat);

addFormatToken('hmm', 0, 0, function () {
    return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
});

addFormatToken('hmmss', 0, 0, function () {
    return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
        zeroFill(this.seconds(), 2);
});

addFormatToken('Hmm', 0, 0, function () {
    return '' + this.hours() + zeroFill(this.minutes(), 2);
});

addFormatToken('Hmmss', 0, 0, function () {
    return '' + this.hours() + zeroFill(this.minutes(), 2) +
        zeroFill(this.seconds(), 2);
});

function meridiem (token, lowercase) {
    addFormatToken(token, 0, 0, function () {
        return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
    });
}

meridiem('a', true);
meridiem('A', false);

// ALIASES

addUnitAlias('hour', 'h');

// PRIORITY
addUnitPriority('hour', 13);

// PARSING

function matchMeridiem (isStrict, locale) {
    return locale._meridiemParse;
}

addRegexToken('a',  matchMeridiem);
addRegexToken('A',  matchMeridiem);
addRegexToken('H',  match1to2);
addRegexToken('h',  match1to2);
addRegexToken('k',  match1to2);
addRegexToken('HH', match1to2, match2);
addRegexToken('hh', match1to2, match2);
addRegexToken('kk', match1to2, match2);

addRegexToken('hmm', match3to4);
addRegexToken('hmmss', match5to6);
addRegexToken('Hmm', match3to4);
addRegexToken('Hmmss', match5to6);

addParseToken(['H', 'HH'], HOUR);
addParseToken(['k', 'kk'], function (input, array, config) {
    var kInput = toInt(input);
    array[HOUR] = kInput === 24 ? 0 : kInput;
});
addParseToken(['a', 'A'], function (input, array, config) {
    config._isPm = config._locale.isPM(input);
    config._meridiem = input;
});
addParseToken(['h', 'hh'], function (input, array, config) {
    array[HOUR] = toInt(input);
    getParsingFlags(config).bigHour = true;
});
addParseToken('hmm', function (input, array, config) {
    var pos = input.length - 2;
    array[HOUR] = toInt(input.substr(0, pos));
    array[MINUTE] = toInt(input.substr(pos));
    getParsingFlags(config).bigHour = true;
});
addParseToken('hmmss', function (input, array, config) {
    var pos1 = input.length - 4;
    var pos2 = input.length - 2;
    array[HOUR] = toInt(input.substr(0, pos1));
    array[MINUTE] = toInt(input.substr(pos1, 2));
    array[SECOND] = toInt(input.substr(pos2));
    getParsingFlags(config).bigHour = true;
});
addParseToken('Hmm', function (input, array, config) {
    var pos = input.length - 2;
    array[HOUR] = toInt(input.substr(0, pos));
    array[MINUTE] = toInt(input.substr(pos));
});
addParseToken('Hmmss', function (input, array, config) {
    var pos1 = input.length - 4;
    var pos2 = input.length - 2;
    array[HOUR] = toInt(input.substr(0, pos1));
    array[MINUTE] = toInt(input.substr(pos1, 2));
    array[SECOND] = toInt(input.substr(pos2));
});

// LOCALES

function localeIsPM (input) {
    // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
    // Using charAt should be more compatible.
    return ((input + '').toLowerCase().charAt(0) === 'p');
}

var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
function localeMeridiem (hours, minutes, isLower) {
    if (hours > 11) {
        return isLower ? 'pm' : 'PM';
    } else {
        return isLower ? 'am' : 'AM';
    }
}


// MOMENTS

// Setting the hour should keep the time, because the user explicitly
// specified which hour he wants. So trying to maintain the same hour (in
// a new timezone) makes sense. Adding/subtracting hours does not follow
// this rule.
var getSetHour = makeGetSet('Hours', true);

// months
// week
// weekdays
// meridiem
var baseConfig = {
    calendar: defaultCalendar,
    longDateFormat: defaultLongDateFormat,
    invalidDate: defaultInvalidDate,
    ordinal: defaultOrdinal,
    dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
    relativeTime: defaultRelativeTime,

    months: defaultLocaleMonths,
    monthsShort: defaultLocaleMonthsShort,

    week: defaultLocaleWeek,

    weekdays: defaultLocaleWeekdays,
    weekdaysMin: defaultLocaleWeekdaysMin,
    weekdaysShort: defaultLocaleWeekdaysShort,

    meridiemParse: defaultLocaleMeridiemParse
};

// internal storage for locale config files
var locales = {};
var localeFamilies = {};
var globalLocale;

function normalizeLocale(key) {
    return key ? key.toLowerCase().replace('_', '-') : key;
}

// pick the locale from the array
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
function chooseLocale(names) {
    var i = 0, j, next, locale, split;

    while (i < names.length) {
        split = normalizeLocale(names[i]).split('-');
        j = split.length;
        next = normalizeLocale(names[i + 1]);
        next = next ? next.split('-') : null;
        while (j > 0) {
            locale = loadLocale(split.slice(0, j).join('-'));
            if (locale) {
                return locale;
            }
            if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
                //the next array item is better than a shallower substring of this one
                break;
            }
            j--;
        }
        i++;
    }
    return null;
}

function loadLocale(name) {
    var oldLocale = null;
    // TODO: Find a better way to register and load all the locales in Node
    if (!locales[name] && (typeof module !== 'undefined') &&
            module && module.exports) {
        try {
            oldLocale = globalLocale._abbr;
            var aliasedRequire = require;
            aliasedRequire('./locale/' + name);
            getSetGlobalLocale(oldLocale);
        } catch (e) {}
    }
    return locales[name];
}

// This function will load locale and then set the global locale.  If
// no arguments are passed in, it will simply return the current global
// locale key.
function getSetGlobalLocale (key, values) {
    var data;
    if (key) {
        if (isUndefined(values)) {
            data = getLocale(key);
        }
        else {
            data = defineLocale(key, values);
        }

        if (data) {
            // moment.duration._locale = moment._locale = data;
            globalLocale = data;
        }
    }

    return globalLocale._abbr;
}

function defineLocale (name, config) {
    if (config !== null) {
        var parentConfig = baseConfig;
        config.abbr = name;
        if (locales[name] != null) {
            deprecateSimple('defineLocaleOverride',
                    'use moment.updateLocale(localeName, config) to change ' +
                    'an existing locale. moment.defineLocale(localeName, ' +
                    'config) should only be used for creating a new locale ' +
                    'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
            parentConfig = locales[name]._config;
        } else if (config.parentLocale != null) {
            if (locales[config.parentLocale] != null) {
                parentConfig = locales[config.parentLocale]._config;
            } else {
                if (!localeFamilies[config.parentLocale]) {
                    localeFamilies[config.parentLocale] = [];
                }
                localeFamilies[config.parentLocale].push({
                    name: name,
                    config: config
                });
                return null;
            }
        }
        locales[name] = new Locale(mergeConfigs(parentConfig, config));

        if (localeFamilies[name]) {
            localeFamilies[name].forEach(function (x) {
                defineLocale(x.name, x.config);
            });
        }

        // backwards compat for now: also set the locale
        // make sure we set the locale AFTER all child locales have been
        // created, so we won't end up with the child locale set.
        getSetGlobalLocale(name);


        return locales[name];
    } else {
        // useful for testing
        delete locales[name];
        return null;
    }
}

function updateLocale(name, config) {
    if (config != null) {
        var locale, parentConfig = baseConfig;
        // MERGE
        if (locales[name] != null) {
            parentConfig = locales[name]._config;
        }
        config = mergeConfigs(parentConfig, config);
        locale = new Locale(config);
        locale.parentLocale = locales[name];
        locales[name] = locale;

        // backwards compat for now: also set the locale
        getSetGlobalLocale(name);
    } else {
        // pass null for config to unupdate, useful for tests
        if (locales[name] != null) {
            if (locales[name].parentLocale != null) {
                locales[name] = locales[name].parentLocale;
            } else if (locales[name] != null) {
                delete locales[name];
            }
        }
    }
    return locales[name];
}

// returns locale data
function getLocale (key) {
    var locale;

    if (key && key._locale && key._locale._abbr) {
        key = key._locale._abbr;
    }

    if (!key) {
        return globalLocale;
    }

    if (!isArray(key)) {
        //short-circuit everything else
        locale = loadLocale(key);
        if (locale) {
            return locale;
        }
        key = [key];
    }

    return chooseLocale(key);
}

function listLocales() {
    return keys(locales);
}

function checkOverflow (m) {
    var overflow;
    var a = m._a;

    if (a && getParsingFlags(m).overflow === -2) {
        overflow =
            a[MONTH]       < 0 || a[MONTH]       > 11  ? MONTH :
            a[DATE]        < 1 || a[DATE]        > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
            a[HOUR]        < 0 || a[HOUR]        > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
            a[MINUTE]      < 0 || a[MINUTE]      > 59  ? MINUTE :
            a[SECOND]      < 0 || a[SECOND]      > 59  ? SECOND :
            a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
            -1;

        if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
            overflow = DATE;
        }
        if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
            overflow = WEEK;
        }
        if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
            overflow = WEEKDAY;
        }

        getParsingFlags(m).overflow = overflow;
    }

    return m;
}

// Pick the first defined of two or three arguments.
function defaults(a, b, c) {
    if (a != null) {
        return a;
    }
    if (b != null) {
        return b;
    }
    return c;
}

function currentDateArray(config) {
    // hooks is actually the exported moment object
    var nowValue = new Date(hooks.now());
    if (config._useUTC) {
        return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
    }
    return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}

// convert an array to a date.
// the array should mirror the parameters below
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
function configFromArray (config) {
    var i, date, input = [], currentDate, yearToUse;

    if (config._d) {
        return;
    }

    currentDate = currentDateArray(config);

    //compute day of the year from weeks and weekdays
    if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
        dayOfYearFromWeekInfo(config);
    }

    //if the day of the year is set, figure out what it is
    if (config._dayOfYear != null) {
        yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);

        if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
            getParsingFlags(config)._overflowDayOfYear = true;
        }

        date = createUTCDate(yearToUse, 0, config._dayOfYear);
        config._a[MONTH] = date.getUTCMonth();
        config._a[DATE] = date.getUTCDate();
    }

    // Default to current date.
    // * if no year, month, day of month are given, default to today
    // * if day of month is given, default month and year
    // * if month is given, default only year
    // * if year is given, don't default anything
    for (i = 0; i < 3 && config._a[i] == null; ++i) {
        config._a[i] = input[i] = currentDate[i];
    }

    // Zero out whatever was not defaulted, including time
    for (; i < 7; i++) {
        config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
    }

    // Check for 24:00:00.000
    if (config._a[HOUR] === 24 &&
            config._a[MINUTE] === 0 &&
            config._a[SECOND] === 0 &&
            config._a[MILLISECOND] === 0) {
        config._nextDay = true;
        config._a[HOUR] = 0;
    }

    config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
    // Apply timezone offset from input. The actual utcOffset can be changed
    // with parseZone.
    if (config._tzm != null) {
        config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
    }

    if (config._nextDay) {
        config._a[HOUR] = 24;
    }

    // check for mismatching day of week
    if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== config._d.getDay()) {
        getParsingFlags(config).weekdayMismatch = true;
    }
}

function dayOfYearFromWeekInfo(config) {
    var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;

    w = config._w;
    if (w.GG != null || w.W != null || w.E != null) {
        dow = 1;
        doy = 4;

        // TODO: We need to take the current isoWeekYear, but that depends on
        // how we interpret now (local, utc, fixed offset). So create
        // a now version of current config (take local/utc/offset flags, and
        // create now).
        weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
        week = defaults(w.W, 1);
        weekday = defaults(w.E, 1);
        if (weekday < 1 || weekday > 7) {
            weekdayOverflow = true;
        }
    } else {
        dow = config._locale._week.dow;
        doy = config._locale._week.doy;

        var curWeek = weekOfYear(createLocal(), dow, doy);

        weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);

        // Default to current week.
        week = defaults(w.w, curWeek.week);

        if (w.d != null) {
            // weekday -- low day numbers are considered next week
            weekday = w.d;
            if (weekday < 0 || weekday > 6) {
                weekdayOverflow = true;
            }
        } else if (w.e != null) {
            // local weekday -- counting starts from begining of week
            weekday = w.e + dow;
            if (w.e < 0 || w.e > 6) {
                weekdayOverflow = true;
            }
        } else {
            // default to begining of week
            weekday = dow;
        }
    }
    if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
        getParsingFlags(config)._overflowWeeks = true;
    } else if (weekdayOverflow != null) {
        getParsingFlags(config)._overflowWeekday = true;
    } else {
        temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
        config._a[YEAR] = temp.year;
        config._dayOfYear = temp.dayOfYear;
    }
}

// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;

var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;

var isoDates = [
    ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
    ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
    ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
    ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
    ['YYYY-DDD', /\d{4}-\d{3}/],
    ['YYYY-MM', /\d{4}-\d\d/, false],
    ['YYYYYYMMDD', /[+-]\d{10}/],
    ['YYYYMMDD', /\d{8}/],
    // YYYYMM is NOT allowed by the standard
    ['GGGG[W]WWE', /\d{4}W\d{3}/],
    ['GGGG[W]WW', /\d{4}W\d{2}/, false],
    ['YYYYDDD', /\d{7}/]
];

// iso time formats and regexes
var isoTimes = [
    ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
    ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
    ['HH:mm:ss', /\d\d:\d\d:\d\d/],
    ['HH:mm', /\d\d:\d\d/],
    ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
    ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
    ['HHmmss', /\d\d\d\d\d\d/],
    ['HHmm', /\d\d\d\d/],
    ['HH', /\d\d/]
];

var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;

// date from iso format
function configFromISO(config) {
    var i, l,
        string = config._i,
        match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
        allowTime, dateFormat, timeFormat, tzFormat;

    if (match) {
        getParsingFlags(config).iso = true;

        for (i = 0, l = isoDates.length; i < l; i++) {
            if (isoDates[i][1].exec(match[1])) {
                dateFormat = isoDates[i][0];
                allowTime = isoDates[i][2] !== false;
                break;
            }
        }
        if (dateFormat == null) {
            config._isValid = false;
            return;
        }
        if (match[3]) {
            for (i = 0, l = isoTimes.length; i < l; i++) {
                if (isoTimes[i][1].exec(match[3])) {
                    // match[2] should be 'T' or space
                    timeFormat = (match[2] || ' ') + isoTimes[i][0];
                    break;
                }
            }
            if (timeFormat == null) {
                config._isValid = false;
                return;
            }
        }
        if (!allowTime && timeFormat != null) {
            config._isValid = false;
            return;
        }
        if (match[4]) {
            if (tzRegex.exec(match[4])) {
                tzFormat = 'Z';
            } else {
                config._isValid = false;
                return;
            }
        }
        config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
        configFromStringAndFormat(config);
    } else {
        config._isValid = false;
    }
}

// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;

function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
    var result = [
        untruncateYear(yearStr),
        defaultLocaleMonthsShort.indexOf(monthStr),
        parseInt(dayStr, 10),
        parseInt(hourStr, 10),
        parseInt(minuteStr, 10)
    ];

    if (secondStr) {
        result.push(parseInt(secondStr, 10));
    }

    return result;
}

function untruncateYear(yearStr) {
    var year = parseInt(yearStr, 10);
    if (year <= 49) {
        return 2000 + year;
    } else if (year <= 999) {
        return 1900 + year;
    }
    return year;
}

function preprocessRFC2822(s) {
    // Remove comments and folding whitespace and replace multiple-spaces with a single space
    return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim();
}

function checkWeekday(weekdayStr, parsedInput, config) {
    if (weekdayStr) {
        // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
        var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
            weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
        if (weekdayProvided !== weekdayActual) {
            getParsingFlags(config).weekdayMismatch = true;
            config._isValid = false;
            return false;
        }
    }
    return true;
}

var obsOffsets = {
    UT: 0,
    GMT: 0,
    EDT: -4 * 60,
    EST: -5 * 60,
    CDT: -5 * 60,
    CST: -6 * 60,
    MDT: -6 * 60,
    MST: -7 * 60,
    PDT: -7 * 60,
    PST: -8 * 60
};

function calculateOffset(obsOffset, militaryOffset, numOffset) {
    if (obsOffset) {
        return obsOffsets[obsOffset];
    } else if (militaryOffset) {
        // the only allowed military tz is Z
        return 0;
    } else {
        var hm = parseInt(numOffset, 10);
        var m = hm % 100, h = (hm - m) / 100;
        return h * 60 + m;
    }
}

// date and time from ref 2822 format
function configFromRFC2822(config) {
    var match = rfc2822.exec(preprocessRFC2822(config._i));
    if (match) {
        var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
        if (!checkWeekday(match[1], parsedArray, config)) {
            return;
        }

        config._a = parsedArray;
        config._tzm = calculateOffset(match[8], match[9], match[10]);

        config._d = createUTCDate.apply(null, config._a);
        config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);

        getParsingFlags(config).rfc2822 = true;
    } else {
        config._isValid = false;
    }
}

// date from iso format or fallback
function configFromString(config) {
    var matched = aspNetJsonRegex.exec(config._i);

    if (matched !== null) {
        config._d = new Date(+matched[1]);
        return;
    }

    configFromISO(config);
    if (config._isValid === false) {
        delete config._isValid;
    } else {
        return;
    }

    configFromRFC2822(config);
    if (config._isValid === false) {
        delete config._isValid;
    } else {
        return;
    }

    // Final attempt, use Input Fallback
    hooks.createFromInputFallback(config);
}

hooks.createFromInputFallback = deprecate(
    'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
    'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
    'discouraged and will be removed in an upcoming major release. Please refer to ' +
    'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
    function (config) {
        config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
    }
);

// constant that refers to the ISO standard
hooks.ISO_8601 = function () {};

// constant that refers to the RFC 2822 form
hooks.RFC_2822 = function () {};

// date from string and format string
function configFromStringAndFormat(config) {
    // TODO: Move this to another part of the creation flow to prevent circular deps
    if (config._f === hooks.ISO_8601) {
        configFromISO(config);
        return;
    }
    if (config._f === hooks.RFC_2822) {
        configFromRFC2822(config);
        return;
    }
    config._a = [];
    getParsingFlags(config).empty = true;

    // This array is used to make a Date, either with `new Date` or `Date.UTC`
    var string = '' + config._i,
        i, parsedInput, tokens, token, skipped,
        stringLength = string.length,
        totalParsedInputLength = 0;

    tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];

    for (i = 0; i < tokens.length; i++) {
        token = tokens[i];
        parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
        // console.log('token', token, 'parsedInput', parsedInput,
        //         'regex', getParseRegexForToken(token, config));
        if (parsedInput) {
            skipped = string.substr(0, string.indexOf(parsedInput));
            if (skipped.length > 0) {
                getParsingFlags(config).unusedInput.push(skipped);
            }
            string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
            totalParsedInputLength += parsedInput.length;
        }
        // don't parse if it's not a known token
        if (formatTokenFunctions[token]) {
            if (parsedInput) {
                getParsingFlags(config).empty = false;
            }
            else {
                getParsingFlags(config).unusedTokens.push(token);
            }
            addTimeToArrayFromToken(token, parsedInput, config);
        }
        else if (config._strict && !parsedInput) {
            getParsingFlags(config).unusedTokens.push(token);
        }
    }

    // add remaining unparsed input length to the string
    getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
    if (string.length > 0) {
        getParsingFlags(config).unusedInput.push(string);
    }

    // clear _12h flag if hour is <= 12
    if (config._a[HOUR] <= 12 &&
        getParsingFlags(config).bigHour === true &&
        config._a[HOUR] > 0) {
        getParsingFlags(config).bigHour = undefined;
    }

    getParsingFlags(config).parsedDateParts = config._a.slice(0);
    getParsingFlags(config).meridiem = config._meridiem;
    // handle meridiem
    config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);

    configFromArray(config);
    checkOverflow(config);
}


function meridiemFixWrap (locale, hour, meridiem) {
    var isPm;

    if (meridiem == null) {
        // nothing to do
        return hour;
    }
    if (locale.meridiemHour != null) {
        return locale.meridiemHour(hour, meridiem);
    } else if (locale.isPM != null) {
        // Fallback
        isPm = locale.isPM(meridiem);
        if (isPm && hour < 12) {
            hour += 12;
        }
        if (!isPm && hour === 12) {
            hour = 0;
        }
        return hour;
    } else {
        // this is not supposed to happen
        return hour;
    }
}

// date from string and array of format strings
function configFromStringAndArray(config) {
    var tempConfig,
        bestMoment,

        scoreToBeat,
        i,
        currentScore;

    if (config._f.length === 0) {
        getParsingFlags(config).invalidFormat = true;
        config._d = new Date(NaN);
        return;
    }

    for (i = 0; i < config._f.length; i++) {
        currentScore = 0;
        tempConfig = copyConfig({}, config);
        if (config._useUTC != null) {
            tempConfig._useUTC = config._useUTC;
        }
        tempConfig._f = config._f[i];
        configFromStringAndFormat(tempConfig);

        if (!isValid(tempConfig)) {
            continue;
        }

        // if there is any input that was not parsed add a penalty for that format
        currentScore += getParsingFlags(tempConfig).charsLeftOver;

        //or tokens
        currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;

        getParsingFlags(tempConfig).score = currentScore;

        if (scoreToBeat == null || currentScore < scoreToBeat) {
            scoreToBeat = currentScore;
            bestMoment = tempConfig;
        }
    }

    extend(config, bestMoment || tempConfig);
}

function configFromObject(config) {
    if (config._d) {
        return;
    }

    var i = normalizeObjectUnits(config._i);
    config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
        return obj && parseInt(obj, 10);
    });

    configFromArray(config);
}

function createFromConfig (config) {
    var res = new Moment(checkOverflow(prepareConfig(config)));
    if (res._nextDay) {
        // Adding is smart enough around DST
        res.add(1, 'd');
        res._nextDay = undefined;
    }

    return res;
}

function prepareConfig (config) {
    var input = config._i,
        format = config._f;

    config._locale = config._locale || getLocale(config._l);

    if (input === null || (format === undefined && input === '')) {
        return createInvalid({nullInput: true});
    }

    if (typeof input === 'string') {
        config._i = input = config._locale.preparse(input);
    }

    if (isMoment(input)) {
        return new Moment(checkOverflow(input));
    } else if (isDate(input)) {
        config._d = input;
    } else if (isArray(format)) {
        configFromStringAndArray(config);
    } else if (format) {
        configFromStringAndFormat(config);
    }  else {
        configFromInput(config);
    }

    if (!isValid(config)) {
        config._d = null;
    }

    return config;
}

function configFromInput(config) {
    var input = config._i;
    if (isUndefined(input)) {
        config._d = new Date(hooks.now());
    } else if (isDate(input)) {
        config._d = new Date(input.valueOf());
    } else if (typeof input === 'string') {
        configFromString(config);
    } else if (isArray(input)) {
        config._a = map(input.slice(0), function (obj) {
            return parseInt(obj, 10);
        });
        configFromArray(config);
    } else if (isObject(input)) {
        configFromObject(config);
    } else if (isNumber(input)) {
        // from milliseconds
        config._d = new Date(input);
    } else {
        hooks.createFromInputFallback(config);
    }
}

function createLocalOrUTC (input, format, locale, strict, isUTC) {
    var c = {};

    if (locale === true || locale === false) {
        strict = locale;
        locale = undefined;
    }

    if ((isObject(input) && isObjectEmpty(input)) ||
            (isArray(input) && input.length === 0)) {
        input = undefined;
    }
    // object construction must be done this way.
    // https://github.com/moment/moment/issues/1423
    c._isAMomentObject = true;
    c._useUTC = c._isUTC = isUTC;
    c._l = locale;
    c._i = input;
    c._f = format;
    c._strict = strict;

    return createFromConfig(c);
}

function createLocal (input, format, locale, strict) {
    return createLocalOrUTC(input, format, locale, strict, false);
}

var prototypeMin = deprecate(
    'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
    function () {
        var other = createLocal.apply(null, arguments);
        if (this.isValid() && other.isValid()) {
            return other < this ? this : other;
        } else {
            return createInvalid();
        }
    }
);

var prototypeMax = deprecate(
    'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
    function () {
        var other = createLocal.apply(null, arguments);
        if (this.isValid() && other.isValid()) {
            return other > this ? this : other;
        } else {
            return createInvalid();
        }
    }
);

// Pick a moment m from moments so that m[fn](other) is true for all
// other. This relies on the function fn to be transitive.
//
// moments should either be an array of moment objects or an array, whose
// first element is an array of moment objects.
function pickBy(fn, moments) {
    var res, i;
    if (moments.length === 1 && isArray(moments[0])) {
        moments = moments[0];
    }
    if (!moments.length) {
        return createLocal();
    }
    res = moments[0];
    for (i = 1; i < moments.length; ++i) {
        if (!moments[i].isValid() || moments[i][fn](res)) {
            res = moments[i];
        }
    }
    return res;
}

// TODO: Use [].sort instead?
function min () {
    var args = [].slice.call(arguments, 0);

    return pickBy('isBefore', args);
}

function max () {
    var args = [].slice.call(arguments, 0);

    return pickBy('isAfter', args);
}

var now = function () {
    return Date.now ? Date.now() : +(new Date());
};

var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];

function isDurationValid(m) {
    for (var key in m) {
        if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
            return false;
        }
    }

    var unitHasDecimal = false;
    for (var i = 0; i < ordering.length; ++i) {
        if (m[ordering[i]]) {
            if (unitHasDecimal) {
                return false; // only allow non-integers for smallest unit
            }
            if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
                unitHasDecimal = true;
            }
        }
    }

    return true;
}

function isValid$1() {
    return this._isValid;
}

function createInvalid$1() {
    return createDuration(NaN);
}

function Duration (duration) {
    var normalizedInput = normalizeObjectUnits(duration),
        years = normalizedInput.year || 0,
        quarters = normalizedInput.quarter || 0,
        months = normalizedInput.month || 0,
        weeks = normalizedInput.week || 0,
        days = normalizedInput.day || 0,
        hours = normalizedInput.hour || 0,
        minutes = normalizedInput.minute || 0,
        seconds = normalizedInput.second || 0,
        milliseconds = normalizedInput.millisecond || 0;

    this._isValid = isDurationValid(normalizedInput);

    // representation for dateAddRemove
    this._milliseconds = +milliseconds +
        seconds * 1e3 + // 1000
        minutes * 6e4 + // 1000 * 60
        hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
    // Because of dateAddRemove treats 24 hours as different from a
    // day when working around DST, we need to store them separately
    this._days = +days +
        weeks * 7;
    // It is impossible to translate months into days without knowing
    // which months you are are talking about, so we have to store
    // it separately.
    this._months = +months +
        quarters * 3 +
        years * 12;

    this._data = {};

    this._locale = getLocale();

    this._bubble();
}

function isDuration (obj) {
    return obj instanceof Duration;
}

function absRound (number) {
    if (number < 0) {
        return Math.round(-1 * number) * -1;
    } else {
        return Math.round(number);
    }
}

// FORMATTING

function offset (token, separator) {
    addFormatToken(token, 0, 0, function () {
        var offset = this.utcOffset();
        var sign = '+';
        if (offset < 0) {
            offset = -offset;
            sign = '-';
        }
        return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
    });
}

offset('Z', ':');
offset('ZZ', '');

// PARSING

addRegexToken('Z',  matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
    config._useUTC = true;
    config._tzm = offsetFromString(matchShortOffset, input);
});

// HELPERS

// timezone chunker
// '+10:00' > ['10',  '00']
// '-1530'  > ['-15', '30']
var chunkOffset = /([\+\-]|\d\d)/gi;

function offsetFromString(matcher, string) {
    var matches = (string || '').match(matcher);

    if (matches === null) {
        return null;
    }

    var chunk   = matches[matches.length - 1] || [];
    var parts   = (chunk + '').match(chunkOffset) || ['-', 0, 0];
    var minutes = +(parts[1] * 60) + toInt(parts[2]);

    return minutes === 0 ?
      0 :
      parts[0] === '+' ? minutes : -minutes;
}

// Return a moment from input, that is local/utc/zone equivalent to model.
function cloneWithOffset(input, model) {
    var res, diff;
    if (model._isUTC) {
        res = model.clone();
        diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
        // Use low-level api, because this fn is low-level api.
        res._d.setTime(res._d.valueOf() + diff);
        hooks.updateOffset(res, false);
        return res;
    } else {
        return createLocal(input).local();
    }
}

function getDateOffset (m) {
    // On Firefox.24 Date#getTimezoneOffset returns a floating point.
    // https://github.com/moment/moment/pull/1871
    return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
}

// HOOKS

// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
hooks.updateOffset = function () {};

// MOMENTS

// keepLocalTime = true means only change the timezone, without
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
//
// Keeping the time actually adds/subtracts (one hour)
// from the actual represented time. That is why we call updateOffset
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
function getSetOffset (input, keepLocalTime, keepMinutes) {
    var offset = this._offset || 0,
        localAdjust;
    if (!this.isValid()) {
        return input != null ? this : NaN;
    }
    if (input != null) {
        if (typeof input === 'string') {
            input = offsetFromString(matchShortOffset, input);
            if (input === null) {
                return this;
            }
        } else if (Math.abs(input) < 16 && !keepMinutes) {
            input = input * 60;
        }
        if (!this._isUTC && keepLocalTime) {
            localAdjust = getDateOffset(this);
        }
        this._offset = input;
        this._isUTC = true;
        if (localAdjust != null) {
            this.add(localAdjust, 'm');
        }
        if (offset !== input) {
            if (!keepLocalTime || this._changeInProgress) {
                addSubtract(this, createDuration(input - offset, 'm'), 1, false);
            } else if (!this._changeInProgress) {
                this._changeInProgress = true;
                hooks.updateOffset(this, true);
                this._changeInProgress = null;
            }
        }
        return this;
    } else {
        return this._isUTC ? offset : getDateOffset(this);
    }
}

function getSetZone (input, keepLocalTime) {
    if (input != null) {
        if (typeof input !== 'string') {
            input = -input;
        }

        this.utcOffset(input, keepLocalTime);

        return this;
    } else {
        return -this.utcOffset();
    }
}

function setOffsetToUTC (keepLocalTime) {
    return this.utcOffset(0, keepLocalTime);
}

function setOffsetToLocal (keepLocalTime) {
    if (this._isUTC) {
        this.utcOffset(0, keepLocalTime);
        this._isUTC = false;

        if (keepLocalTime) {
            this.subtract(getDateOffset(this), 'm');
        }
    }
    return this;
}

function setOffsetToParsedOffset () {
    if (this._tzm != null) {
        this.utcOffset(this._tzm, false, true);
    } else if (typeof this._i === 'string') {
        var tZone = offsetFromString(matchOffset, this._i);
        if (tZone != null) {
            this.utcOffset(tZone);
        }
        else {
            this.utcOffset(0, true);
        }
    }
    return this;
}

function hasAlignedHourOffset (input) {
    if (!this.isValid()) {
        return false;
    }
    input = input ? createLocal(input).utcOffset() : 0;

    return (this.utcOffset() - input) % 60 === 0;
}

function isDaylightSavingTime () {
    return (
        this.utcOffset() > this.clone().month(0).utcOffset() ||
        this.utcOffset() > this.clone().month(5).utcOffset()
    );
}

function isDaylightSavingTimeShifted () {
    if (!isUndefined(this._isDSTShifted)) {
        return this._isDSTShifted;
    }

    var c = {};

    copyConfig(c, this);
    c = prepareConfig(c);

    if (c._a) {
        var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
        this._isDSTShifted = this.isValid() &&
            compareArrays(c._a, other.toArray()) > 0;
    } else {
        this._isDSTShifted = false;
    }

    return this._isDSTShifted;
}

function isLocal () {
    return this.isValid() ? !this._isUTC : false;
}

function isUtcOffset () {
    return this.isValid() ? this._isUTC : false;
}

function isUtc () {
    return this.isValid() ? this._isUTC && this._offset === 0 : false;
}

// ASP.NET json date format regex
var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;

// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
// and further modified to allow for strings containing both week and day
var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;

function createDuration (input, key) {
    var duration = input,
        // matching against regexp is expensive, do it on demand
        match = null,
        sign,
        ret,
        diffRes;

    if (isDuration(input)) {
        duration = {
            ms : input._milliseconds,
            d  : input._days,
            M  : input._months
        };
    } else if (isNumber(input)) {
        duration = {};
        if (key) {
            duration[key] = input;
        } else {
            duration.milliseconds = input;
        }
    } else if (!!(match = aspNetRegex.exec(input))) {
        sign = (match[1] === '-') ? -1 : 1;
        duration = {
            y  : 0,
            d  : toInt(match[DATE])                         * sign,
            h  : toInt(match[HOUR])                         * sign,
            m  : toInt(match[MINUTE])                       * sign,
            s  : toInt(match[SECOND])                       * sign,
            ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
        };
    } else if (!!(match = isoRegex.exec(input))) {
        sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
        duration = {
            y : parseIso(match[2], sign),
            M : parseIso(match[3], sign),
            w : parseIso(match[4], sign),
            d : parseIso(match[5], sign),
            h : parseIso(match[6], sign),
            m : parseIso(match[7], sign),
            s : parseIso(match[8], sign)
        };
    } else if (duration == null) {// checks for null or undefined
        duration = {};
    } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
        diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));

        duration = {};
        duration.ms = diffRes.milliseconds;
        duration.M = diffRes.months;
    }

    ret = new Duration(duration);

    if (isDuration(input) && hasOwnProp(input, '_locale')) {
        ret._locale = input._locale;
    }

    return ret;
}

createDuration.fn = Duration.prototype;
createDuration.invalid = createInvalid$1;

function parseIso (inp, sign) {
    // We'd normally use ~~inp for this, but unfortunately it also
    // converts floats to ints.
    // inp may be undefined, so careful calling replace on it.
    var res = inp && parseFloat(inp.replace(',', '.'));
    // apply sign while we're at it
    return (isNaN(res) ? 0 : res) * sign;
}

function positiveMomentsDifference(base, other) {
    var res = {milliseconds: 0, months: 0};

    res.months = other.month() - base.month() +
        (other.year() - base.year()) * 12;
    if (base.clone().add(res.months, 'M').isAfter(other)) {
        --res.months;
    }

    res.milliseconds = +other - +(base.clone().add(res.months, 'M'));

    return res;
}

function momentsDifference(base, other) {
    var res;
    if (!(base.isValid() && other.isValid())) {
        return {milliseconds: 0, months: 0};
    }

    other = cloneWithOffset(other, base);
    if (base.isBefore(other)) {
        res = positiveMomentsDifference(base, other);
    } else {
        res = positiveMomentsDifference(other, base);
        res.milliseconds = -res.milliseconds;
        res.months = -res.months;
    }

    return res;
}

// TODO: remove 'name' arg after deprecation is removed
function createAdder(direction, name) {
    return function (val, period) {
        var dur, tmp;
        //invert the arguments, but complain about it
        if (period !== null && !isNaN(+period)) {
            deprecateSimple(name, 'moment().' + name  + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
            'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
            tmp = val; val = period; period = tmp;
        }

        val = typeof val === 'string' ? +val : val;
        dur = createDuration(val, period);
        addSubtract(this, dur, direction);
        return this;
    };
}

function addSubtract (mom, duration, isAdding, updateOffset) {
    var milliseconds = duration._milliseconds,
        days = absRound(duration._days),
        months = absRound(duration._months);

    if (!mom.isValid()) {
        // No op
        return;
    }

    updateOffset = updateOffset == null ? true : updateOffset;

    if (months) {
        setMonth(mom, get(mom, 'Month') + months * isAdding);
    }
    if (days) {
        set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
    }
    if (milliseconds) {
        mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
    }
    if (updateOffset) {
        hooks.updateOffset(mom, days || months);
    }
}

var add      = createAdder(1, 'add');
var subtract = createAdder(-1, 'subtract');

function getCalendarFormat(myMoment, now) {
    var diff = myMoment.diff(now, 'days', true);
    return diff < -6 ? 'sameElse' :
            diff < -1 ? 'lastWeek' :
            diff < 0 ? 'lastDay' :
            diff < 1 ? 'sameDay' :
            diff < 2 ? 'nextDay' :
            diff < 7 ? 'nextWeek' : 'sameElse';
}

function calendar$1 (time, formats) {
    // We want to compare the start of today, vs this.
    // Getting start-of-today depends on whether we're local/utc/offset or not.
    var now = time || createLocal(),
        sod = cloneWithOffset(now, this).startOf('day'),
        format = hooks.calendarFormat(this, sod) || 'sameElse';

    var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);

    return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
}

function clone () {
    return new Moment(this);
}

function isAfter (input, units) {
    var localInput = isMoment(input) ? input : createLocal(input);
    if (!(this.isValid() && localInput.isValid())) {
        return false;
    }
    units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
    if (units === 'millisecond') {
        return this.valueOf() > localInput.valueOf();
    } else {
        return localInput.valueOf() < this.clone().startOf(units).valueOf();
    }
}

function isBefore (input, units) {
    var localInput = isMoment(input) ? input : createLocal(input);
    if (!(this.isValid() && localInput.isValid())) {
        return false;
    }
    units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
    if (units === 'millisecond') {
        return this.valueOf() < localInput.valueOf();
    } else {
        return this.clone().endOf(units).valueOf() < localInput.valueOf();
    }
}

function isBetween (from, to, units, inclusivity) {
    inclusivity = inclusivity || '()';
    return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
        (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
}

function isSame (input, units) {
    var localInput = isMoment(input) ? input : createLocal(input),
        inputMs;
    if (!(this.isValid() && localInput.isValid())) {
        return false;
    }
    units = normalizeUnits(units || 'millisecond');
    if (units === 'millisecond') {
        return this.valueOf() === localInput.valueOf();
    } else {
        inputMs = localInput.valueOf();
        return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
    }
}

function isSameOrAfter (input, units) {
    return this.isSame(input, units) || this.isAfter(input,units);
}

function isSameOrBefore (input, units) {
    return this.isSame(input, units) || this.isBefore(input,units);
}

function diff (input, units, asFloat) {
    var that,
        zoneDelta,
        delta, output;

    if (!this.isValid()) {
        return NaN;
    }

    that = cloneWithOffset(input, this);

    if (!that.isValid()) {
        return NaN;
    }

    zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;

    units = normalizeUnits(units);

    switch (units) {
        case 'year': output = monthDiff(this, that) / 12; break;
        case 'month': output = monthDiff(this, that); break;
        case 'quarter': output = monthDiff(this, that) / 3; break;
        case 'second': output = (this - that) / 1e3; break; // 1000
        case 'minute': output = (this - that) / 6e4; break; // 1000 * 60
        case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60
        case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst
        case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst
        default: output = this - that;
    }

    return asFloat ? output : absFloor(output);
}

function monthDiff (a, b) {
    // difference in months
    var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
        // b is in (anchor - 1 month, anchor + 1 month)
        anchor = a.clone().add(wholeMonthDiff, 'months'),
        anchor2, adjust;

    if (b - anchor < 0) {
        anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
        // linear across the month
        adjust = (b - anchor) / (anchor - anchor2);
    } else {
        anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
        // linear across the month
        adjust = (b - anchor) / (anchor2 - anchor);
    }

    //check for negative zero, return zero if negative zero
    return -(wholeMonthDiff + adjust) || 0;
}

hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';

function toString () {
    return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}

function toISOString() {
    if (!this.isValid()) {
        return null;
    }
    var m = this.clone().utc();
    if (m.year() < 0 || m.year() > 9999) {
        return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
    }
    if (isFunction(Date.prototype.toISOString)) {
        // native implementation is ~50x faster, use it when we can
        return this.toDate().toISOString();
    }
    return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
}

/**
 * Return a human readable representation of a moment that can
 * also be evaluated to get a new moment which is the same
 *
 * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
 */
function inspect () {
    if (!this.isValid()) {
        return 'moment.invalid(/* ' + this._i + ' */)';
    }
    var func = 'moment';
    var zone = '';
    if (!this.isLocal()) {
        func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
        zone = 'Z';
    }
    var prefix = '[' + func + '("]';
    var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
    var datetime = '-MM-DD[T]HH:mm:ss.SSS';
    var suffix = zone + '[")]';

    return this.format(prefix + year + datetime + suffix);
}

function format (inputString) {
    if (!inputString) {
        inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
    }
    var output = formatMoment(this, inputString);
    return this.localeData().postformat(output);
}

function from (time, withoutSuffix) {
    if (this.isValid() &&
            ((isMoment(time) && time.isValid()) ||
             createLocal(time).isValid())) {
        return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
    } else {
        return this.localeData().invalidDate();
    }
}

function fromNow (withoutSuffix) {
    return this.from(createLocal(), withoutSuffix);
}

function to (time, withoutSuffix) {
    if (this.isValid() &&
            ((isMoment(time) && time.isValid()) ||
             createLocal(time).isValid())) {
        return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
    } else {
        return this.localeData().invalidDate();
    }
}

function toNow (withoutSuffix) {
    return this.to(createLocal(), withoutSuffix);
}

// If passed a locale key, it will set the locale for this
// instance.  Otherwise, it will return the locale configuration
// variables for this instance.
function locale (key) {
    var newLocaleData;

    if (key === undefined) {
        return this._locale._abbr;
    } else {
        newLocaleData = getLocale(key);
        if (newLocaleData != null) {
            this._locale = newLocaleData;
        }
        return this;
    }
}

var lang = deprecate(
    'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
    function (key) {
        if (key === undefined) {
            return this.localeData();
        } else {
            return this.locale(key);
        }
    }
);

function localeData () {
    return this._locale;
}

function startOf (units) {
    units = normalizeUnits(units);
    // the following switch intentionally omits break keywords
    // to utilize falling through the cases.
    switch (units) {
        case 'year':
            this.month(0);
            /* falls through */
        case 'quarter':
        case 'month':
            this.date(1);
            /* falls through */
        case 'week':
        case 'isoWeek':
        case 'day':
        case 'date':
            this.hours(0);
            /* falls through */
        case 'hour':
            this.minutes(0);
            /* falls through */
        case 'minute':
            this.seconds(0);
            /* falls through */
        case 'second':
            this.milliseconds(0);
    }

    // weeks are a special case
    if (units === 'week') {
        this.weekday(0);
    }
    if (units === 'isoWeek') {
        this.isoWeekday(1);
    }

    // quarters are also special
    if (units === 'quarter') {
        this.month(Math.floor(this.month() / 3) * 3);
    }

    return this;
}

function endOf (units) {
    units = normalizeUnits(units);
    if (units === undefined || units === 'millisecond') {
        return this;
    }

    // 'date' is an alias for 'day', so it should be considered as such.
    if (units === 'date') {
        units = 'day';
    }

    return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
}

function valueOf () {
    return this._d.valueOf() - ((this._offset || 0) * 60000);
}

function unix () {
    return Math.floor(this.valueOf() / 1000);
}

function toDate () {
    return new Date(this.valueOf());
}

function toArray () {
    var m = this;
    return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
}

function toObject () {
    var m = this;
    return {
        years: m.year(),
        months: m.month(),
        date: m.date(),
        hours: m.hours(),
        minutes: m.minutes(),
        seconds: m.seconds(),
        milliseconds: m.milliseconds()
    };
}

function toJSON () {
    // new Date(NaN).toJSON() === null
    return this.isValid() ? this.toISOString() : null;
}

function isValid$2 () {
    return isValid(this);
}

function parsingFlags () {
    return extend({}, getParsingFlags(this));
}

function invalidAt () {
    return getParsingFlags(this).overflow;
}

function creationData() {
    return {
        input: this._i,
        format: this._f,
        locale: this._locale,
        isUTC: this._isUTC,
        strict: this._strict
    };
}

// FORMATTING

addFormatToken(0, ['gg', 2], 0, function () {
    return this.weekYear() % 100;
});

addFormatToken(0, ['GG', 2], 0, function () {
    return this.isoWeekYear() % 100;
});

function addWeekYearFormatToken (token, getter) {
    addFormatToken(0, [token, token.length], 0, getter);
}

addWeekYearFormatToken('gggg',     'weekYear');
addWeekYearFormatToken('ggggg',    'weekYear');
addWeekYearFormatToken('GGGG',  'isoWeekYear');
addWeekYearFormatToken('GGGGG', 'isoWeekYear');

// ALIASES

addUnitAlias('weekYear', 'gg');
addUnitAlias('isoWeekYear', 'GG');

// PRIORITY

addUnitPriority('weekYear', 1);
addUnitPriority('isoWeekYear', 1);


// PARSING

addRegexToken('G',      matchSigned);
addRegexToken('g',      matchSigned);
addRegexToken('GG',     match1to2, match2);
addRegexToken('gg',     match1to2, match2);
addRegexToken('GGGG',   match1to4, match4);
addRegexToken('gggg',   match1to4, match4);
addRegexToken('GGGGG',  match1to6, match6);
addRegexToken('ggggg',  match1to6, match6);

addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
    week[token.substr(0, 2)] = toInt(input);
});

addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
    week[token] = hooks.parseTwoDigitYear(input);
});

// MOMENTS

function getSetWeekYear (input) {
    return getSetWeekYearHelper.call(this,
            input,
            this.week(),
            this.weekday(),
            this.localeData()._week.dow,
            this.localeData()._week.doy);
}

function getSetISOWeekYear (input) {
    return getSetWeekYearHelper.call(this,
            input, this.isoWeek(), this.isoWeekday(), 1, 4);
}

function getISOWeeksInYear () {
    return weeksInYear(this.year(), 1, 4);
}

function getWeeksInYear () {
    var weekInfo = this.localeData()._week;
    return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
}

function getSetWeekYearHelper(input, week, weekday, dow, doy) {
    var weeksTarget;
    if (input == null) {
        return weekOfYear(this, dow, doy).year;
    } else {
        weeksTarget = weeksInYear(input, dow, doy);
        if (week > weeksTarget) {
            week = weeksTarget;
        }
        return setWeekAll.call(this, input, week, weekday, dow, doy);
    }
}

function setWeekAll(weekYear, week, weekday, dow, doy) {
    var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
        date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);

    this.year(date.getUTCFullYear());
    this.month(date.getUTCMonth());
    this.date(date.getUTCDate());
    return this;
}

// FORMATTING

addFormatToken('Q', 0, 'Qo', 'quarter');

// ALIASES

addUnitAlias('quarter', 'Q');

// PRIORITY

addUnitPriority('quarter', 7);

// PARSING

addRegexToken('Q', match1);
addParseToken('Q', function (input, array) {
    array[MONTH] = (toInt(input) - 1) * 3;
});

// MOMENTS

function getSetQuarter (input) {
    return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
}

// FORMATTING

addFormatToken('D', ['DD', 2], 'Do', 'date');

// ALIASES

addUnitAlias('date', 'D');

// PRIOROITY
addUnitPriority('date', 9);

// PARSING

addRegexToken('D',  match1to2);
addRegexToken('DD', match1to2, match2);
addRegexToken('Do', function (isStrict, locale) {
    // TODO: Remove "ordinalParse" fallback in next major release.
    return isStrict ?
      (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
      locale._dayOfMonthOrdinalParseLenient;
});

addParseToken(['D', 'DD'], DATE);
addParseToken('Do', function (input, array) {
    array[DATE] = toInt(input.match(match1to2)[0], 10);
});

// MOMENTS

var getSetDayOfMonth = makeGetSet('Date', true);

// FORMATTING

addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');

// ALIASES

addUnitAlias('dayOfYear', 'DDD');

// PRIORITY
addUnitPriority('dayOfYear', 4);

// PARSING

addRegexToken('DDD',  match1to3);
addRegexToken('DDDD', match3);
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
    config._dayOfYear = toInt(input);
});

// HELPERS

// MOMENTS

function getSetDayOfYear (input) {
    var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
    return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
}

// FORMATTING

addFormatToken('m', ['mm', 2], 0, 'minute');

// ALIASES

addUnitAlias('minute', 'm');

// PRIORITY

addUnitPriority('minute', 14);

// PARSING

addRegexToken('m',  match1to2);
addRegexToken('mm', match1to2, match2);
addParseToken(['m', 'mm'], MINUTE);

// MOMENTS

var getSetMinute = makeGetSet('Minutes', false);

// FORMATTING

addFormatToken('s', ['ss', 2], 0, 'second');

// ALIASES

addUnitAlias('second', 's');

// PRIORITY

addUnitPriority('second', 15);

// PARSING

addRegexToken('s',  match1to2);
addRegexToken('ss', match1to2, match2);
addParseToken(['s', 'ss'], SECOND);

// MOMENTS

var getSetSecond = makeGetSet('Seconds', false);

// FORMATTING

addFormatToken('S', 0, 0, function () {
    return ~~(this.millisecond() / 100);
});

addFormatToken(0, ['SS', 2], 0, function () {
    return ~~(this.millisecond() / 10);
});

addFormatToken(0, ['SSS', 3], 0, 'millisecond');
addFormatToken(0, ['SSSS', 4], 0, function () {
    return this.millisecond() * 10;
});
addFormatToken(0, ['SSSSS', 5], 0, function () {
    return this.millisecond() * 100;
});
addFormatToken(0, ['SSSSSS', 6], 0, function () {
    return this.millisecond() * 1000;
});
addFormatToken(0, ['SSSSSSS', 7], 0, function () {
    return this.millisecond() * 10000;
});
addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
    return this.millisecond() * 100000;
});
addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
    return this.millisecond() * 1000000;
});


// ALIASES

addUnitAlias('millisecond', 'ms');

// PRIORITY

addUnitPriority('millisecond', 16);

// PARSING

addRegexToken('S',    match1to3, match1);
addRegexToken('SS',   match1to3, match2);
addRegexToken('SSS',  match1to3, match3);

var token;
for (token = 'SSSS'; token.length <= 9; token += 'S') {
    addRegexToken(token, matchUnsigned);
}

function parseMs(input, array) {
    array[MILLISECOND] = toInt(('0.' + input) * 1000);
}

for (token = 'S'; token.length <= 9; token += 'S') {
    addParseToken(token, parseMs);
}
// MOMENTS

var getSetMillisecond = makeGetSet('Milliseconds', false);

// FORMATTING

addFormatToken('z',  0, 0, 'zoneAbbr');
addFormatToken('zz', 0, 0, 'zoneName');

// MOMENTS

function getZoneAbbr () {
    return this._isUTC ? 'UTC' : '';
}

function getZoneName () {
    return this._isUTC ? 'Coordinated Universal Time' : '';
}

var proto = Moment.prototype;

proto.add               = add;
proto.calendar          = calendar$1;
proto.clone             = clone;
proto.diff              = diff;
proto.endOf             = endOf;
proto.format            = format;
proto.from              = from;
proto.fromNow           = fromNow;
proto.to                = to;
proto.toNow             = toNow;
proto.get               = stringGet;
proto.invalidAt         = invalidAt;
proto.isAfter           = isAfter;
proto.isBefore          = isBefore;
proto.isBetween         = isBetween;
proto.isSame            = isSame;
proto.isSameOrAfter     = isSameOrAfter;
proto.isSameOrBefore    = isSameOrBefore;
proto.isValid           = isValid$2;
proto.lang              = lang;
proto.locale            = locale;
proto.localeData        = localeData;
proto.max               = prototypeMax;
proto.min               = prototypeMin;
proto.parsingFlags      = parsingFlags;
proto.set               = stringSet;
proto.startOf           = startOf;
proto.subtract          = subtract;
proto.toArray           = toArray;
proto.toObject          = toObject;
proto.toDate            = toDate;
proto.toISOString       = toISOString;
proto.inspect           = inspect;
proto.toJSON            = toJSON;
proto.toString          = toString;
proto.unix              = unix;
proto.valueOf           = valueOf;
proto.creationData      = creationData;

// Year
proto.year       = getSetYear;
proto.isLeapYear = getIsLeapYear;

// Week Year
proto.weekYear    = getSetWeekYear;
proto.isoWeekYear = getSetISOWeekYear;

// Quarter
proto.quarter = proto.quarters = getSetQuarter;

// Month
proto.month       = getSetMonth;
proto.daysInMonth = getDaysInMonth;

// Week
proto.week           = proto.weeks        = getSetWeek;
proto.isoWeek        = proto.isoWeeks     = getSetISOWeek;
proto.weeksInYear    = getWeeksInYear;
proto.isoWeeksInYear = getISOWeeksInYear;

// Day
proto.date       = getSetDayOfMonth;
proto.day        = proto.days             = getSetDayOfWeek;
proto.weekday    = getSetLocaleDayOfWeek;
proto.isoWeekday = getSetISODayOfWeek;
proto.dayOfYear  = getSetDayOfYear;

// Hour
proto.hour = proto.hours = getSetHour;

// Minute
proto.minute = proto.minutes = getSetMinute;

// Second
proto.second = proto.seconds = getSetSecond;

// Millisecond
proto.millisecond = proto.milliseconds = getSetMillisecond;

// Offset
proto.utcOffset            = getSetOffset;
proto.utc                  = setOffsetToUTC;
proto.local                = setOffsetToLocal;
proto.parseZone            = setOffsetToParsedOffset;
proto.hasAlignedHourOffset = hasAlignedHourOffset;
proto.isDST                = isDaylightSavingTime;
proto.isLocal              = isLocal;
proto.isUtcOffset          = isUtcOffset;
proto.isUtc                = isUtc;
proto.isUTC                = isUtc;

// Timezone
proto.zoneAbbr = getZoneAbbr;
proto.zoneName = getZoneName;

// Deprecations
proto.dates  = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
proto.years  = deprecate('years accessor is deprecated. Use year instead', getSetYear);
proto.zone   = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);

function createUnix (input) {
    return createLocal(input * 1000);
}

function createInZone () {
    return createLocal.apply(null, arguments).parseZone();
}

function preParsePostFormat (string) {
    return string;
}

var proto$1 = Locale.prototype;

proto$1.calendar        = calendar;
proto$1.longDateFormat  = longDateFormat;
proto$1.invalidDate     = invalidDate;
proto$1.ordinal         = ordinal;
proto$1.preparse        = preParsePostFormat;
proto$1.postformat      = preParsePostFormat;
proto$1.relativeTime    = relativeTime;
proto$1.pastFuture      = pastFuture;
proto$1.set             = set;

// Month
proto$1.months            =        localeMonths;
proto$1.monthsShort       =        localeMonthsShort;
proto$1.monthsParse       =        localeMonthsParse;
proto$1.monthsRegex       = monthsRegex;
proto$1.monthsShortRegex  = monthsShortRegex;

// Week
proto$1.week = localeWeek;
proto$1.firstDayOfYear = localeFirstDayOfYear;
proto$1.firstDayOfWeek = localeFirstDayOfWeek;

// Day of Week
proto$1.weekdays       =        localeWeekdays;
proto$1.weekdaysMin    =        localeWeekdaysMin;
proto$1.weekdaysShort  =        localeWeekdaysShort;
proto$1.weekdaysParse  =        localeWeekdaysParse;

proto$1.weekdaysRegex       =        weekdaysRegex;
proto$1.weekdaysShortRegex  =        weekdaysShortRegex;
proto$1.weekdaysMinRegex    =        weekdaysMinRegex;

// Hours
proto$1.isPM = localeIsPM;
proto$1.meridiem = localeMeridiem;

function get$1 (format, index, field, setter) {
    var locale = getLocale();
    var utc = createUTC().set(setter, index);
    return locale[field](utc, format);
}

function listMonthsImpl (format, index, field) {
    if (isNumber(format)) {
        index = format;
        format = undefined;
    }

    format = format || '';

    if (index != null) {
        return get$1(format, index, field, 'month');
    }

    var i;
    var out = [];
    for (i = 0; i < 12; i++) {
        out[i] = get$1(format, i, field, 'month');
    }
    return out;
}

// ()
// (5)
// (fmt, 5)
// (fmt)
// (true)
// (true, 5)
// (true, fmt, 5)
// (true, fmt)
function listWeekdaysImpl (localeSorted, format, index, field) {
    if (typeof localeSorted === 'boolean') {
        if (isNumber(format)) {
            index = format;
            format = undefined;
        }

        format = format || '';
    } else {
        format = localeSorted;
        index = format;
        localeSorted = false;

        if (isNumber(format)) {
            index = format;
            format = undefined;
        }

        format = format || '';
    }

    var locale = getLocale(),
        shift = localeSorted ? locale._week.dow : 0;

    if (index != null) {
        return get$1(format, (index + shift) % 7, field, 'day');
    }

    var i;
    var out = [];
    for (i = 0; i < 7; i++) {
        out[i] = get$1(format, (i + shift) % 7, field, 'day');
    }
    return out;
}

function listMonths (format, index) {
    return listMonthsImpl(format, index, 'months');
}

function listMonthsShort (format, index) {
    return listMonthsImpl(format, index, 'monthsShort');
}

function listWeekdays (localeSorted, format, index) {
    return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
}

function listWeekdaysShort (localeSorted, format, index) {
    return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
}

function listWeekdaysMin (localeSorted, format, index) {
    return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
}

getSetGlobalLocale('en', {
    dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
    ordinal : function (number) {
        var b = number % 10,
            output = (toInt(number % 100 / 10) === 1) ? 'th' :
            (b === 1) ? 'st' :
            (b === 2) ? 'nd' :
            (b === 3) ? 'rd' : 'th';
        return number + output;
    }
});

// Side effect imports
hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);

var mathAbs = Math.abs;

function abs () {
    var data           = this._data;

    this._milliseconds = mathAbs(this._milliseconds);
    this._days         = mathAbs(this._days);
    this._months       = mathAbs(this._months);

    data.milliseconds  = mathAbs(data.milliseconds);
    data.seconds       = mathAbs(data.seconds);
    data.minutes       = mathAbs(data.minutes);
    data.hours         = mathAbs(data.hours);
    data.months        = mathAbs(data.months);
    data.years         = mathAbs(data.years);

    return this;
}

function addSubtract$1 (duration, input, value, direction) {
    var other = createDuration(input, value);

    duration._milliseconds += direction * other._milliseconds;
    duration._days         += direction * other._days;
    duration._months       += direction * other._months;

    return duration._bubble();
}

// supports only 2.0-style add(1, 's') or add(duration)
function add$1 (input, value) {
    return addSubtract$1(this, input, value, 1);
}

// supports only 2.0-style subtract(1, 's') or subtract(duration)
function subtract$1 (input, value) {
    return addSubtract$1(this, input, value, -1);
}

function absCeil (number) {
    if (number < 0) {
        return Math.floor(number);
    } else {
        return Math.ceil(number);
    }
}

function bubble () {
    var milliseconds = this._milliseconds;
    var days         = this._days;
    var months       = this._months;
    var data         = this._data;
    var seconds, minutes, hours, years, monthsFromDays;

    // if we have a mix of positive and negative values, bubble down first
    // check: https://github.com/moment/moment/issues/2166
    if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
            (milliseconds <= 0 && days <= 0 && months <= 0))) {
        milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
        days = 0;
        months = 0;
    }

    // The following code bubbles up values, see the tests for
    // examples of what that means.
    data.milliseconds = milliseconds % 1000;

    seconds           = absFloor(milliseconds / 1000);
    data.seconds      = seconds % 60;

    minutes           = absFloor(seconds / 60);
    data.minutes      = minutes % 60;

    hours             = absFloor(minutes / 60);
    data.hours        = hours % 24;

    days += absFloor(hours / 24);

    // convert days to months
    monthsFromDays = absFloor(daysToMonths(days));
    months += monthsFromDays;
    days -= absCeil(monthsToDays(monthsFromDays));

    // 12 months -> 1 year
    years = absFloor(months / 12);
    months %= 12;

    data.days   = days;
    data.months = months;
    data.years  = years;

    return this;
}

function daysToMonths (days) {
    // 400 years have 146097 days (taking into account leap year rules)
    // 400 years have 12 months === 4800
    return days * 4800 / 146097;
}

function monthsToDays (months) {
    // the reverse of daysToMonths
    return months * 146097 / 4800;
}

function as (units) {
    if (!this.isValid()) {
        return NaN;
    }
    var days;
    var months;
    var milliseconds = this._milliseconds;

    units = normalizeUnits(units);

    if (units === 'month' || units === 'year') {
        days   = this._days   + milliseconds / 864e5;
        months = this._months + daysToMonths(days);
        return units === 'month' ? months : months / 12;
    } else {
        // handle milliseconds separately because of floating point math errors (issue #1867)
        days = this._days + Math.round(monthsToDays(this._months));
        switch (units) {
            case 'week'   : return days / 7     + milliseconds / 6048e5;
            case 'day'    : return days         + milliseconds / 864e5;
            case 'hour'   : return days * 24    + milliseconds / 36e5;
            case 'minute' : return days * 1440  + milliseconds / 6e4;
            case 'second' : return days * 86400 + milliseconds / 1000;
            // Math.floor prevents floating point math errors here
            case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
            default: throw new Error('Unknown unit ' + units);
        }
    }
}

// TODO: Use this.as('ms')?
function valueOf$1 () {
    if (!this.isValid()) {
        return NaN;
    }
    return (
        this._milliseconds +
        this._days * 864e5 +
        (this._months % 12) * 2592e6 +
        toInt(this._months / 12) * 31536e6
    );
}

function makeAs (alias) {
    return function () {
        return this.as(alias);
    };
}

var asMilliseconds = makeAs('ms');
var asSeconds      = makeAs('s');
var asMinutes      = makeAs('m');
var asHours        = makeAs('h');
var asDays         = makeAs('d');
var asWeeks        = makeAs('w');
var asMonths       = makeAs('M');
var asYears        = makeAs('y');

function clone$1 () {
    return createDuration(this);
}

function get$2 (units) {
    units = normalizeUnits(units);
    return this.isValid() ? this[units + 's']() : NaN;
}

function makeGetter(name) {
    return function () {
        return this.isValid() ? this._data[name] : NaN;
    };
}

var milliseconds = makeGetter('milliseconds');
var seconds      = makeGetter('seconds');
var minutes      = makeGetter('minutes');
var hours        = makeGetter('hours');
var days         = makeGetter('days');
var months       = makeGetter('months');
var years        = makeGetter('years');

function weeks () {
    return absFloor(this.days() / 7);
}

var round = Math.round;
var thresholds = {
    ss: 44,         // a few seconds to seconds
    s : 45,         // seconds to minute
    m : 45,         // minutes to hour
    h : 22,         // hours to day
    d : 26,         // days to month
    M : 11          // months to year
};

// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
    return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}

function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
    var duration = createDuration(posNegDuration).abs();
    var seconds  = round(duration.as('s'));
    var minutes  = round(duration.as('m'));
    var hours    = round(duration.as('h'));
    var days     = round(duration.as('d'));
    var months   = round(duration.as('M'));
    var years    = round(duration.as('y'));

    var a = seconds <= thresholds.ss && ['s', seconds]  ||
            seconds < thresholds.s   && ['ss', seconds] ||
            minutes <= 1             && ['m']           ||
            minutes < thresholds.m   && ['mm', minutes] ||
            hours   <= 1             && ['h']           ||
            hours   < thresholds.h   && ['hh', hours]   ||
            days    <= 1             && ['d']           ||
            days    < thresholds.d   && ['dd', days]    ||
            months  <= 1             && ['M']           ||
            months  < thresholds.M   && ['MM', months]  ||
            years   <= 1             && ['y']           || ['yy', years];

    a[2] = withoutSuffix;
    a[3] = +posNegDuration > 0;
    a[4] = locale;
    return substituteTimeAgo.apply(null, a);
}

// This function allows you to set the rounding function for relative time strings
function getSetRelativeTimeRounding (roundingFunction) {
    if (roundingFunction === undefined) {
        return round;
    }
    if (typeof(roundingFunction) === 'function') {
        round = roundingFunction;
        return true;
    }
    return false;
}

// This function allows you to set a threshold for relative time strings
function getSetRelativeTimeThreshold (threshold, limit) {
    if (thresholds[threshold] === undefined) {
        return false;
    }
    if (limit === undefined) {
        return thresholds[threshold];
    }
    thresholds[threshold] = limit;
    if (threshold === 's') {
        thresholds.ss = limit - 1;
    }
    return true;
}

function humanize (withSuffix) {
    if (!this.isValid()) {
        return this.localeData().invalidDate();
    }

    var locale = this.localeData();
    var output = relativeTime$1(this, !withSuffix, locale);

    if (withSuffix) {
        output = locale.pastFuture(+this, output);
    }

    return locale.postformat(output);
}

var abs$1 = Math.abs;

function sign(x) {
    return ((x > 0) - (x < 0)) || +x;
}

function toISOString$1() {
    // for ISO strings we do not use the normal bubbling rules:
    //  * milliseconds bubble up until they become hours
    //  * days do not bubble at all
    //  * months bubble up until they become years
    // This is because there is no context-free conversion between hours and days
    // (think of clock changes)
    // and also not between days and months (28-31 days per month)
    if (!this.isValid()) {
        return this.localeData().invalidDate();
    }

    var seconds = abs$1(this._milliseconds) / 1000;
    var days         = abs$1(this._days);
    var months       = abs$1(this._months);
    var minutes, hours, years;

    // 3600 seconds -> 60 minutes -> 1 hour
    minutes           = absFloor(seconds / 60);
    hours             = absFloor(minutes / 60);
    seconds %= 60;
    minutes %= 60;

    // 12 months -> 1 year
    years  = absFloor(months / 12);
    months %= 12;


    // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
    var Y = years;
    var M = months;
    var D = days;
    var h = hours;
    var m = minutes;
    var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
    var total = this.asSeconds();

    if (!total) {
        // this is the same as C#'s (Noda) and python (isodate)...
        // but not other JS (goog.date)
        return 'P0D';
    }

    var totalSign = total < 0 ? '-' : '';
    var ymSign = sign(this._months) !== sign(total) ? '-' : '';
    var daysSign = sign(this._days) !== sign(total) ? '-' : '';
    var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';

    return totalSign + 'P' +
        (Y ? ymSign + Y + 'Y' : '') +
        (M ? ymSign + M + 'M' : '') +
        (D ? daysSign + D + 'D' : '') +
        ((h || m || s) ? 'T' : '') +
        (h ? hmsSign + h + 'H' : '') +
        (m ? hmsSign + m + 'M' : '') +
        (s ? hmsSign + s + 'S' : '');
}

var proto$2 = Duration.prototype;

proto$2.isValid        = isValid$1;
proto$2.abs            = abs;
proto$2.add            = add$1;
proto$2.subtract       = subtract$1;
proto$2.as             = as;
proto$2.asMilliseconds = asMilliseconds;
proto$2.asSeconds      = asSeconds;
proto$2.asMinutes      = asMinutes;
proto$2.asHours        = asHours;
proto$2.asDays         = asDays;
proto$2.asWeeks        = asWeeks;
proto$2.asMonths       = asMonths;
proto$2.asYears        = asYears;
proto$2.valueOf        = valueOf$1;
proto$2._bubble        = bubble;
proto$2.clone          = clone$1;
proto$2.get            = get$2;
proto$2.milliseconds   = milliseconds;
proto$2.seconds        = seconds;
proto$2.minutes        = minutes;
proto$2.hours          = hours;
proto$2.days           = days;
proto$2.weeks          = weeks;
proto$2.months         = months;
proto$2.years          = years;
proto$2.humanize       = humanize;
proto$2.toISOString    = toISOString$1;
proto$2.toString       = toISOString$1;
proto$2.toJSON         = toISOString$1;
proto$2.locale         = locale;
proto$2.localeData     = localeData;

// Deprecations
proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
proto$2.lang = lang;

// Side effect imports

// FORMATTING

addFormatToken('X', 0, 0, 'unix');
addFormatToken('x', 0, 0, 'valueOf');

// PARSING

addRegexToken('x', matchSigned);
addRegexToken('X', matchTimestamp);
addParseToken('X', function (input, array, config) {
    config._d = new Date(parseFloat(input, 10) * 1000);
});
addParseToken('x', function (input, array, config) {
    config._d = new Date(toInt(input));
});

// Side effect imports


hooks.version = '2.19.1';

setHookCallback(createLocal);

hooks.fn                    = proto;
hooks.min                   = min;
hooks.max                   = max;
hooks.now                   = now;
hooks.utc                   = createUTC;
hooks.unix                  = createUnix;
hooks.months                = listMonths;
hooks.isDate                = isDate;
hooks.locale                = getSetGlobalLocale;
hooks.invalid               = createInvalid;
hooks.duration              = createDuration;
hooks.isMoment              = isMoment;
hooks.weekdays              = listWeekdays;
hooks.parseZone             = createInZone;
hooks.localeData            = getLocale;
hooks.isDuration            = isDuration;
hooks.monthsShort           = listMonthsShort;
hooks.weekdaysMin           = listWeekdaysMin;
hooks.defineLocale          = defineLocale;
hooks.updateLocale          = updateLocale;
hooks.locales               = listLocales;
hooks.weekdaysShort         = listWeekdaysShort;
hooks.normalizeUnits        = normalizeUnits;
hooks.relativeTimeRounding  = getSetRelativeTimeRounding;
hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
hooks.calendarFormat        = getCalendarFormat;
hooks.prototype             = proto;

return hooks;

})));
/*!
 * clipboard.js v2.0.4
 * https://zenorocha.github.io/clipboard.js
 *
 * Licensed MIT © Zeno Rocha
 */
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["ClipboardJS"] = factory();
	else
		root["ClipboardJS"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _clipboardAction = __webpack_require__(1);

var _clipboardAction2 = _interopRequireDefault(_clipboardAction);

var _tinyEmitter = __webpack_require__(3);

var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);

var _goodListener = __webpack_require__(4);

var _goodListener2 = _interopRequireDefault(_goodListener);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

/**
 * Base class which takes one or more elements, adds event listeners to them,
 * and instantiates a new `ClipboardAction` on each click.
 */
var Clipboard = function (_Emitter) {
    _inherits(Clipboard, _Emitter);

    /**
     * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
     * @param {Object} options
     */
    function Clipboard(trigger, options) {
        _classCallCheck(this, Clipboard);

        var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));

        _this.resolveOptions(options);
        _this.listenClick(trigger);
        return _this;
    }

    /**
     * Defines if attributes would be resolved using internal setter functions
     * or custom functions that were passed in the constructor.
     * @param {Object} options
     */


    _createClass(Clipboard, [{
        key: 'resolveOptions',
        value: function resolveOptions() {
            var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

            this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
            this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
            this.text = typeof options.text === 'function' ? options.text : this.defaultText;
            this.container = _typeof(options.container) === 'object' ? options.container : document.body;
        }

        /**
         * Adds a click event listener to the passed trigger.
         * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
         */

    }, {
        key: 'listenClick',
        value: function listenClick(trigger) {
            var _this2 = this;

            this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
                return _this2.onClick(e);
            });
        }

        /**
         * Defines a new `ClipboardAction` on each click event.
         * @param {Event} e
         */

    }, {
        key: 'onClick',
        value: function onClick(e) {
            var trigger = e.delegateTarget || e.currentTarget;

            if (this.clipboardAction) {
                this.clipboardAction = null;
            }

            this.clipboardAction = new _clipboardAction2.default({
                action: this.action(trigger),
                target: this.target(trigger),
                text: this.text(trigger),
                container: this.container,
                trigger: trigger,
                emitter: this
            });
        }

        /**
         * Default `action` lookup function.
         * @param {Element} trigger
         */

    }, {
        key: 'defaultAction',
        value: function defaultAction(trigger) {
            return getAttributeValue('action', trigger);
        }

        /**
         * Default `target` lookup function.
         * @param {Element} trigger
         */

    }, {
        key: 'defaultTarget',
        value: function defaultTarget(trigger) {
            var selector = getAttributeValue('target', trigger);

            if (selector) {
                return document.querySelector(selector);
            }
        }

        /**
         * Returns the support of the given action, or all actions if no action is
         * given.
         * @param {String} [action]
         */

    }, {
        key: 'defaultText',


        /**
         * Default `text` lookup function.
         * @param {Element} trigger
         */
        value: function defaultText(trigger) {
            return getAttributeValue('text', trigger);
        }

        /**
         * Destroy lifecycle.
         */

    }, {
        key: 'destroy',
        value: function destroy() {
            this.listener.destroy();

            if (this.clipboardAction) {
                this.clipboardAction.destroy();
                this.clipboardAction = null;
            }
        }
    }], [{
        key: 'isSupported',
        value: function isSupported() {
            var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];

            var actions = typeof action === 'string' ? [action] : action;
            var support = !!document.queryCommandSupported;

            actions.forEach(function (action) {
                support = support && !!document.queryCommandSupported(action);
            });

            return support;
        }
    }]);

    return Clipboard;
}(_tinyEmitter2.default);

/**
 * Helper function to retrieve attribute value.
 * @param {String} suffix
 * @param {Element} element
 */


function getAttributeValue(suffix, element) {
    var attribute = 'data-clipboard-' + suffix;

    if (!element.hasAttribute(attribute)) {
        return;
    }

    return element.getAttribute(attribute);
}

module.exports = Clipboard;

/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _select = __webpack_require__(2);

var _select2 = _interopRequireDefault(_select);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/**
 * Inner class which performs selection from either `text` or `target`
 * properties and then executes copy or cut operations.
 */
var ClipboardAction = function () {
    /**
     * @param {Object} options
     */
    function ClipboardAction(options) {
        _classCallCheck(this, ClipboardAction);

        this.resolveOptions(options);
        this.initSelection();
    }

    /**
     * Defines base properties passed from constructor.
     * @param {Object} options
     */


    _createClass(ClipboardAction, [{
        key: 'resolveOptions',
        value: function resolveOptions() {
            var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

            this.action = options.action;
            this.container = options.container;
            this.emitter = options.emitter;
            this.target = options.target;
            this.text = options.text;
            this.trigger = options.trigger;

            this.selectedText = '';
        }

        /**
         * Decides which selection strategy is going to be applied based
         * on the existence of `text` and `target` properties.
         */

    }, {
        key: 'initSelection',
        value: function initSelection() {
            if (this.text) {
                this.selectFake();
            } else if (this.target) {
                this.selectTarget();
            }
        }

        /**
         * Creates a fake textarea element, sets its value from `text` property,
         * and makes a selection on it.
         */

    }, {
        key: 'selectFake',
        value: function selectFake() {
            var _this = this;

            var isRTL = document.documentElement.getAttribute('dir') == 'rtl';

            this.removeFake();

            this.fakeHandlerCallback = function () {
                return _this.removeFake();
            };
            this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;

            this.fakeElem = document.createElement('textarea');
            // Prevent zooming on iOS
            this.fakeElem.style.fontSize = '12pt';
            // Reset box model
            this.fakeElem.style.border = '0';
            this.fakeElem.style.padding = '0';
            this.fakeElem.style.margin = '0';
            // Move element out of screen horizontally
            this.fakeElem.style.position = 'absolute';
            this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
            // Move element to the same position vertically
            var yPosition = window.pageYOffset || document.documentElement.scrollTop;
            this.fakeElem.style.top = yPosition + 'px';

            this.fakeElem.setAttribute('readonly', '');
            this.fakeElem.value = this.text;

            this.container.appendChild(this.fakeElem);

            this.selectedText = (0, _select2.default)(this.fakeElem);
            this.copyText();
        }

        /**
         * Only removes the fake element after another click event, that way
         * a user can hit `Ctrl+C` to copy because selection still exists.
         */

    }, {
        key: 'removeFake',
        value: function removeFake() {
            if (this.fakeHandler) {
                this.container.removeEventListener('click', this.fakeHandlerCallback);
                this.fakeHandler = null;
                this.fakeHandlerCallback = null;
            }

            if (this.fakeElem) {
                this.container.removeChild(this.fakeElem);
                this.fakeElem = null;
            }
        }

        /**
         * Selects the content from element passed on `target` property.
         */

    }, {
        key: 'selectTarget',
        value: function selectTarget() {
            this.selectedText = (0, _select2.default)(this.target);
            this.copyText();
        }

        /**
         * Executes the copy operation based on the current selection.
         */

    }, {
        key: 'copyText',
        value: function copyText() {
            var succeeded = void 0;

            try {
                succeeded = document.execCommand(this.action);
            } catch (err) {
                succeeded = false;
            }

            this.handleResult(succeeded);
        }

        /**
         * Fires an event based on the copy operation result.
         * @param {Boolean} succeeded
         */

    }, {
        key: 'handleResult',
        value: function handleResult(succeeded) {
            this.emitter.emit(succeeded ? 'success' : 'error', {
                action: this.action,
                text: this.selectedText,
                trigger: this.trigger,
                clearSelection: this.clearSelection.bind(this)
            });
        }

        /**
         * Moves focus away from `target` and back to the trigger, removes current selection.
         */

    }, {
        key: 'clearSelection',
        value: function clearSelection() {
            if (this.trigger) {
                this.trigger.focus();
            }

            window.getSelection().removeAllRanges();
        }

        /**
         * Sets the `action` to be performed which can be either 'copy' or 'cut'.
         * @param {String} action
         */

    }, {
        key: 'destroy',


        /**
         * Destroy lifecycle.
         */
        value: function destroy() {
            this.removeFake();
        }
    }, {
        key: 'action',
        set: function set() {
            var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';

            this._action = action;

            if (this._action !== 'copy' && this._action !== 'cut') {
                throw new Error('Invalid "action" value, use either "copy" or "cut"');
            }
        }

        /**
         * Gets the `action` property.
         * @return {String}
         */
        ,
        get: function get() {
            return this._action;
        }

        /**
         * Sets the `target` property using an element
         * that will be have its content copied.
         * @param {Element} target
         */

    }, {
        key: 'target',
        set: function set(target) {
            if (target !== undefined) {
                if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
                    if (this.action === 'copy' && target.hasAttribute('disabled')) {
                        throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
                    }

                    if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
                        throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
                    }

                    this._target = target;
                } else {
                    throw new Error('Invalid "target" value, use a valid Element');
                }
            }
        }

        /**
         * Gets the `target` property.
         * @return {String|HTMLElement}
         */
        ,
        get: function get() {
            return this._target;
        }
    }]);

    return ClipboardAction;
}();

module.exports = ClipboardAction;

/***/ }),
/* 2 */
/***/ (function(module, exports) {

function select(element) {
    var selectedText;

    if (element.nodeName === 'SELECT') {
        element.focus();

        selectedText = element.value;
    }
    else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
        var isReadOnly = element.hasAttribute('readonly');

        if (!isReadOnly) {
            element.setAttribute('readonly', '');
        }

        element.select();
        element.setSelectionRange(0, element.value.length);

        if (!isReadOnly) {
            element.removeAttribute('readonly');
        }

        selectedText = element.value;
    }
    else {
        if (element.hasAttribute('contenteditable')) {
            element.focus();
        }

        var selection = window.getSelection();
        var range = document.createRange();

        range.selectNodeContents(element);
        selection.removeAllRanges();
        selection.addRange(range);

        selectedText = selection.toString();
    }

    return selectedText;
}

module.exports = select;


/***/ }),
/* 3 */
/***/ (function(module, exports) {

function E () {
  // Keep this empty so it's easier to inherit from
  // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
}

E.prototype = {
  on: function (name, callback, ctx) {
    var e = this.e || (this.e = {});

    (e[name] || (e[name] = [])).push({
      fn: callback,
      ctx: ctx
    });

    return this;
  },

  once: function (name, callback, ctx) {
    var self = this;
    function listener () {
      self.off(name, listener);
      callback.apply(ctx, arguments);
    };

    listener._ = callback
    return this.on(name, listener, ctx);
  },

  emit: function (name) {
    var data = [].slice.call(arguments, 1);
    var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
    var i = 0;
    var len = evtArr.length;

    for (i; i < len; i++) {
      evtArr[i].fn.apply(evtArr[i].ctx, data);
    }

    return this;
  },

  off: function (name, callback) {
    var e = this.e || (this.e = {});
    var evts = e[name];
    var liveEvents = [];

    if (evts && callback) {
      for (var i = 0, len = evts.length; i < len; i++) {
        if (evts[i].fn !== callback && evts[i].fn._ !== callback)
          liveEvents.push(evts[i]);
      }
    }

    // Remove event from queue to prevent memory leak
    // Suggested by https://github.com/lazd
    // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910

    (liveEvents.length)
      ? e[name] = liveEvents
      : delete e[name];

    return this;
  }
};

module.exports = E;


/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

var is = __webpack_require__(5);
var delegate = __webpack_require__(6);

/**
 * Validates all params and calls the right
 * listener function based on its target type.
 *
 * @param {String|HTMLElement|HTMLCollection|NodeList} target
 * @param {String} type
 * @param {Function} callback
 * @return {Object}
 */
function listen(target, type, callback) {
    if (!target && !type && !callback) {
        throw new Error('Missing required arguments');
    }

    if (!is.string(type)) {
        throw new TypeError('Second argument must be a String');
    }

    if (!is.fn(callback)) {
        throw new TypeError('Third argument must be a Function');
    }

    if (is.node(target)) {
        return listenNode(target, type, callback);
    }
    else if (is.nodeList(target)) {
        return listenNodeList(target, type, callback);
    }
    else if (is.string(target)) {
        return listenSelector(target, type, callback);
    }
    else {
        throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
    }
}

/**
 * Adds an event listener to a HTML element
 * and returns a remove listener function.
 *
 * @param {HTMLElement} node
 * @param {String} type
 * @param {Function} callback
 * @return {Object}
 */
function listenNode(node, type, callback) {
    node.addEventListener(type, callback);

    return {
        destroy: function() {
            node.removeEventListener(type, callback);
        }
    }
}

/**
 * Add an event listener to a list of HTML elements
 * and returns a remove listener function.
 *
 * @param {NodeList|HTMLCollection} nodeList
 * @param {String} type
 * @param {Function} callback
 * @return {Object}
 */
function listenNodeList(nodeList, type, callback) {
    Array.prototype.forEach.call(nodeList, function(node) {
        node.addEventListener(type, callback);
    });

    return {
        destroy: function() {
            Array.prototype.forEach.call(nodeList, function(node) {
                node.removeEventListener(type, callback);
            });
        }
    }
}

/**
 * Add an event listener to a selector
 * and returns a remove listener function.
 *
 * @param {String} selector
 * @param {String} type
 * @param {Function} callback
 * @return {Object}
 */
function listenSelector(selector, type, callback) {
    return delegate(document.body, selector, type, callback);
}

module.exports = listen;


/***/ }),
/* 5 */
/***/ (function(module, exports) {

/**
 * Check if argument is a HTML element.
 *
 * @param {Object} value
 * @return {Boolean}
 */
exports.node = function(value) {
    return value !== undefined
        && value instanceof HTMLElement
        && value.nodeType === 1;
};

/**
 * Check if argument is a list of HTML elements.
 *
 * @param {Object} value
 * @return {Boolean}
 */
exports.nodeList = function(value) {
    var type = Object.prototype.toString.call(value);

    return value !== undefined
        && (type === '[object NodeList]' || type === '[object HTMLCollection]')
        && ('length' in value)
        && (value.length === 0 || exports.node(value[0]));
};

/**
 * Check if argument is a string.
 *
 * @param {Object} value
 * @return {Boolean}
 */
exports.string = function(value) {
    return typeof value === 'string'
        || value instanceof String;
};

/**
 * Check if argument is a function.
 *
 * @param {Object} value
 * @return {Boolean}
 */
exports.fn = function(value) {
    var type = Object.prototype.toString.call(value);

    return type === '[object Function]';
};


/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {

var closest = __webpack_require__(7);

/**
 * Delegates event to a selector.
 *
 * @param {Element} element
 * @param {String} selector
 * @param {String} type
 * @param {Function} callback
 * @param {Boolean} useCapture
 * @return {Object}
 */
function _delegate(element, selector, type, callback, useCapture) {
    var listenerFn = listener.apply(this, arguments);

    element.addEventListener(type, listenerFn, useCapture);

    return {
        destroy: function() {
            element.removeEventListener(type, listenerFn, useCapture);
        }
    }
}

/**
 * Delegates event to a selector.
 *
 * @param {Element|String|Array} [elements]
 * @param {String} selector
 * @param {String} type
 * @param {Function} callback
 * @param {Boolean} useCapture
 * @return {Object}
 */
function delegate(elements, selector, type, callback, useCapture) {
    // Handle the regular Element usage
    if (typeof elements.addEventListener === 'function') {
        return _delegate.apply(null, arguments);
    }

    // Handle Element-less usage, it defaults to global delegation
    if (typeof type === 'function') {
        // Use `document` as the first parameter, then apply arguments
        // This is a short way to .unshift `arguments` without running into deoptimizations
        return _delegate.bind(null, document).apply(null, arguments);
    }

    // Handle Selector-based usage
    if (typeof elements === 'string') {
        elements = document.querySelectorAll(elements);
    }

    // Handle Array-like based usage
    return Array.prototype.map.call(elements, function (element) {
        return _delegate(element, selector, type, callback, useCapture);
    });
}

/**
 * Finds closest match and invokes callback.
 *
 * @param {Element} element
 * @param {String} selector
 * @param {String} type
 * @param {Function} callback
 * @return {Function}
 */
function listener(element, selector, type, callback) {
    return function(e) {
        e.delegateTarget = closest(e.target, selector);

        if (e.delegateTarget) {
            callback.call(element, e);
        }
    }
}

module.exports = delegate;


/***/ }),
/* 7 */
/***/ (function(module, exports) {

var DOCUMENT_NODE_TYPE = 9;

/**
 * A polyfill for Element.matches()
 */
if (typeof Element !== 'undefined' && !Element.prototype.matches) {
    var proto = Element.prototype;

    proto.matches = proto.matchesSelector ||
                    proto.mozMatchesSelector ||
                    proto.msMatchesSelector ||
                    proto.oMatchesSelector ||
                    proto.webkitMatchesSelector;
}

/**
 * Finds the closest parent that matches a selector.
 *
 * @param {Element} element
 * @param {String} selector
 * @return {Function}
 */
function closest (element, selector) {
    while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
        if (typeof element.matches === 'function' &&
            element.matches(selector)) {
          return element;
        }
        element = element.parentNode;
    }
}

module.exports = closest;


/***/ })
/******/ ]);
});
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=function(e){if(null===e)return"null";if(void 0===e)return"undefined";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},t=function(e){return{eq:e}},n=t((function(e,t){return e===t})),o=function(e){return t((function(t,n){if(t.length!==n.length)return!1;for(var o=t.length,r=0;r<o;r++)if(!e.eq(t[r],n[r]))return!1;return!0}))},r=function(e){return t((function(r,s){var a=Object.keys(r),i=Object.keys(s);if(!function(e,n){return function(e,n){return t((function(t,o){return e.eq(n(t),n(o))}))}(o(e),(function(e){return function(e,t){return Array.prototype.slice.call(e).sort(t)}(e,n)}))}(n).eq(a,i))return!1;for(var l=a.length,d=0;d<l;d++){var c=a[d];if(!e.eq(r[c],s[c]))return!1}return!0}))},s=t((function(t,n){if(t===n)return!0;var a=e(t);return a===e(n)&&(function(e){return-1!==["undefined","boolean","number","string","function","xml","null"].indexOf(e)}(a)?t===n:"array"===a?o(s).eq(t,n):"object"===a&&r(s).eq(t,n))}));const a=Object.getPrototypeOf,i=(e,t,n)=>{var o;return!!n(e,t.prototype)||(null===(o=e.constructor)||void 0===o?void 0:o.name)===t.name},l=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&i(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":t})(t)===e,d=e=>t=>typeof t===e,c=e=>t=>e===t,u=(e,t)=>f(e)&&i(e,t,((e,t)=>a(e)===t)),m=l("string"),f=l("object"),g=e=>u(e,Object),p=l("array"),h=c(null),b=d("boolean"),v=c(void 0),y=e=>null==e,C=e=>!y(e),w=d("function"),x=d("number"),k=(e,t)=>{if(p(e)){for(let n=0,o=e.length;n<o;++n)if(!t(e[n]))return!1;return!0}return!1},S=()=>{},_=(e,t)=>(...n)=>e(t.apply(null,n)),E=(e,t)=>n=>e(t(n)),N=e=>()=>e,R=e=>e,A=(e,t)=>e===t;function O(e,...t){return(...n)=>{const o=t.concat(n);return e.apply(null,o)}}const T=e=>t=>!e(t),B=e=>e(),D=e=>{e()},P=N(!1),L=N(!0);class M{constructor(e,t){this.tag=e,this.value=t}static some(e){return new M(!0,e)}static none(){return M.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?M.some(e(this.value)):M.none()}bind(e){return this.tag?e(this.value):M.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:M.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return C(e)?M.some(e):M.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}M.singletonNone=new M(!1);const I=Array.prototype.slice,F=Array.prototype.indexOf,U=Array.prototype.push,z=(e,t)=>F.call(e,t),j=(e,t)=>z(e,t)>-1,H=(e,t)=>{for(let n=0,o=e.length;n<o;n++)if(t(e[n],n))return!0;return!1},$=(e,t)=>{const n=e.length,o=new Array(n);for(let r=0;r<n;r++){const n=e[r];o[r]=t(n,r)}return o},V=(e,t)=>{for(let n=0,o=e.length;n<o;n++)t(e[n],n)},q=(e,t)=>{for(let n=e.length-1;n>=0;n--)t(e[n],n)},W=(e,t)=>{const n=[],o=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];(t(s,r)?n:o).push(s)}return{pass:n,fail:o}},K=(e,t)=>{const n=[];for(let o=0,r=e.length;o<r;o++){const r=e[o];t(r,o)&&n.push(r)}return n},G=(e,t,n)=>(q(e,((e,o)=>{n=t(n,e,o)})),n),Y=(e,t,n)=>(V(e,((e,o)=>{n=t(n,e,o)})),n),X=(e,t,n)=>{for(let o=0,r=e.length;o<r;o++){const r=e[o];if(t(r,o))return M.some(r);if(n(r,o))break}return M.none()},Q=(e,t)=>X(e,t,P),J=(e,t)=>{for(let n=0,o=e.length;n<o;n++)if(t(e[n],n))return M.some(n);return M.none()},Z=e=>{const t=[];for(let n=0,o=e.length;n<o;++n){if(!p(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);U.apply(t,e[n])}return t},ee=(e,t)=>Z($(e,t)),te=(e,t)=>{for(let n=0,o=e.length;n<o;++n)if(!0!==t(e[n],n))return!1;return!0},ne=e=>{const t=I.call(e,0);return t.reverse(),t},oe=(e,t)=>K(e,(e=>!j(t,e))),re=(e,t)=>{const n={};for(let o=0,r=e.length;o<r;o++){const r=e[o];n[String(r)]=t(r,o)}return n},se=(e,t)=>{const n=I.call(e,0);return n.sort(t),n},ae=(e,t)=>t>=0&&t<e.length?M.some(e[t]):M.none(),ie=e=>ae(e,0),le=e=>ae(e,e.length-1),de=w(Array.from)?Array.from:e=>I.call(e),ce=(e,t)=>{for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o.isSome())return o}return M.none()},ue=Object.keys,me=Object.hasOwnProperty,fe=(e,t)=>{const n=ue(e);for(let o=0,r=n.length;o<r;o++){const r=n[o];t(e[r],r)}},ge=(e,t)=>pe(e,((e,n)=>({k:n,v:t(e,n)}))),pe=(e,t)=>{const n={};return fe(e,((e,o)=>{const r=t(e,o);n[r.k]=r.v})),n},he=e=>(t,n)=>{e[n]=t},be=(e,t,n,o)=>{fe(e,((e,r)=>{(t(e,r)?n:o)(e,r)}))},ve=(e,t)=>{const n={};return be(e,t,he(n),S),n},ye=(e,t)=>{const n=[];return fe(e,((e,o)=>{n.push(t(e,o))})),n},Ce=e=>ye(e,R),we=(e,t)=>xe(e,t)?M.from(e[t]):M.none(),xe=(e,t)=>me.call(e,t),ke=(e,t)=>xe(e,t)&&void 0!==e[t]&&null!==e[t],Se=e=>{const t={};return V(e,(e=>{t[e]={}})),ue(t)},_e=e=>void 0!==e.length,Ee=Array.isArray,Ne=(e,t,n)=>{if(!e)return!1;if(n=n||e,_e(e)){for(let o=0,r=e.length;o<r;o++)if(!1===t.call(n,e[o],o,e))return!1}else for(const o in e)if(xe(e,o)&&!1===t.call(n,e[o],o,e))return!1;return!0},Re=(e,t)=>{const n=[];return Ne(e,((o,r)=>{n.push(t(o,r,e))})),n},Ae=(e,t)=>{const n=[];return Ne(e,((o,r)=>{t&&!t(o,r,e)||n.push(o)})),n},Oe=(e,t,n,o)=>{let r=v(n)?e[0]:n;for(let n=0;n<e.length;n++)r=t.call(o,r,e[n],n);return r},Te=(e,t,n)=>{for(let o=0,r=e.length;o<r;o++)if(t.call(n,e[o],o,e))return o;return-1},Be=e=>e[e.length-1],De=e=>{let t,n=!1;return(...o)=>(n||(n=!0,t=e.apply(null,o)),t)},Pe=()=>Le(0,0),Le=(e,t)=>({major:e,minor:t}),Me={nu:Le,detect:(e,t)=>{const n=String(t).toLowerCase();return 0===e.length?Pe():((e,t)=>{const n=((e,t)=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.test(t))return o}})(e,t);if(!n)return{major:0,minor:0};const o=e=>Number(t.replace(n,"$"+e));return Le(o(1),o(2))})(e,n)},unknown:Pe},Ie=(e,t)=>{const n=String(t).toLowerCase();return Q(e,(e=>e.search(n)))},Fe=(e,t,n)=>""===t||e.length>=t.length&&e.substr(n,n+t.length)===t,Ue=(e,t,n=0,o)=>{const r=e.indexOf(t,n);return-1!==r&&(!!v(o)||r+t.length<=o)},ze=(e,t)=>Fe(e,t,0),je=(e,t)=>Fe(e,t,e.length-t.length),He=e=>t=>t.replace(e,""),$e=He(/^\s+|\s+$/g),Ve=He(/^\s+/g),qe=He(/\s+$/g),We=e=>e.length>0,Ke=e=>!We(e),Ge=(e,t=10)=>{const n=parseInt(e,t);return isNaN(n)?M.none():M.some(n)},Ye=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Xe=e=>t=>Ue(t,e),Qe=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Ue(e,"edge/")&&Ue(e,"chrome")&&Ue(e,"safari")&&Ue(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Ye],search:e=>Ue(e,"chrome")&&!Ue(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Ue(e,"msie")||Ue(e,"trident")},{name:"Opera",versionRegexes:[Ye,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Xe("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Xe("firefox")},{name:"Safari",versionRegexes:[Ye,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Ue(e,"safari")||Ue(e,"mobile/"))&&Ue(e,"applewebkit")}],Je=[{name:"Windows",search:Xe("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Ue(e,"iphone")||Ue(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Xe("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:Xe("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Xe("linux"),versionRegexes:[]},{name:"Solaris",search:Xe("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Xe("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:Xe("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],Ze={browsers:N(Qe),oses:N(Je)},et="Edge",tt="Chromium",nt="Opera",ot="Firefox",rt="Safari",st=e=>{const t=e.current,n=e.version,o=e=>()=>t===e;return{current:t,version:n,isEdge:o(et),isChromium:o(tt),isIE:o("IE"),isOpera:o(nt),isFirefox:o(ot),isSafari:o(rt)}},at=()=>st({current:void 0,version:Me.unknown()}),it=st,lt=(N(et),N(tt),N("IE"),N(nt),N(ot),N(rt),"Windows"),dt="Android",ct="Linux",ut="macOS",mt="Solaris",ft="FreeBSD",gt="ChromeOS",pt=e=>{const t=e.current,n=e.version,o=e=>()=>t===e;return{current:t,version:n,isWindows:o(lt),isiOS:o("iOS"),isAndroid:o(dt),isMacOS:o(ut),isLinux:o(ct),isSolaris:o(mt),isFreeBSD:o(ft),isChromeOS:o(gt)}},ht=()=>pt({current:void 0,version:Me.unknown()}),bt=pt,vt=(N(lt),N("iOS"),N(dt),N(ct),N(ut),N(mt),N(ft),N(gt),e=>window.matchMedia(e).matches);let yt=De((()=>((e,t,n)=>{const o=Ze.browsers(),r=Ze.oses(),s=t.bind((e=>((e,t)=>ce(t.brands,(t=>{const n=t.brand.toLowerCase();return Q(e,(e=>{var t;return n===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:Me.nu(parseInt(t.version,10),0)})))})))(o,e))).orThunk((()=>((e,t)=>Ie(e,t).map((e=>{const n=Me.detect(e.versionRegexes,t);return{current:e.name,version:n}})))(o,e))).fold(at,it),a=((e,t)=>Ie(e,t).map((e=>{const n=Me.detect(e.versionRegexes,t);return{current:e.name,version:n}})))(r,e).fold(ht,bt),i=((e,t,n,o)=>{const r=e.isiOS()&&!0===/ipad/i.test(n),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||o("(pointer:coarse)"),l=r||!s&&a&&o("(min-device-width:768px)"),d=s||a&&!l,c=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(n),u=!d&&!l&&!c;return{isiPad:N(r),isiPhone:N(s),isTablet:N(l),isPhone:N(d),isTouch:N(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:N(c),isDesktop:N(u)}})(a,s,e,n);return{browser:s,os:a,deviceType:i}})(navigator.userAgent,M.from(navigator.userAgentData),vt)));const Ct=()=>yt(),wt=navigator.userAgent,xt=Ct(),kt=xt.browser,St=xt.os,_t=xt.deviceType,Et=-1!==wt.indexOf("Windows Phone"),Nt={transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",documentMode:kt.isIE()?document.documentMode||7:10,cacheSuffix:null,container:null,canHaveCSP:!kt.isIE(),windowsPhone:Et,browser:{current:kt.current,version:kt.version,isChromium:kt.isChromium,isEdge:kt.isEdge,isFirefox:kt.isFirefox,isIE:kt.isIE,isOpera:kt.isOpera,isSafari:kt.isSafari},os:{current:St.current,version:St.version,isAndroid:St.isAndroid,isChromeOS:St.isChromeOS,isFreeBSD:St.isFreeBSD,isiOS:St.isiOS,isLinux:St.isLinux,isMacOS:St.isMacOS,isSolaris:St.isSolaris,isWindows:St.isWindows},deviceType:{isDesktop:_t.isDesktop,isiPad:_t.isiPad,isiPhone:_t.isiPhone,isPhone:_t.isPhone,isTablet:_t.isTablet,isTouch:_t.isTouch,isWebView:_t.isWebView}},Rt=/^\s*|\s*$/g,At=e=>y(e)?"":(""+e).replace(Rt,""),Ot=function(e,t,n,o){o=o||this,e&&(n&&(e=e[n]),Ne(e,((e,r)=>!1!==t.call(o,e,r,n)&&(Ot(e,t,n,o),!0))))},Tt={trim:At,isArray:Ee,is:(e,t)=>t?!("array"!==t||!Ee(e))||typeof e===t:void 0!==e,toArray:e=>{if(Ee(e))return e;{const t=[];for(let n=0,o=e.length;n<o;n++)t[n]=e[n];return t}},makeMap:(e,t,n={})=>{const o=m(e)?e.split(t||","):e||[];let r=o.length;for(;r--;)n[o[r]]={};return n},each:Ne,map:Re,grep:Ae,inArray:(e,t)=>{if(e)for(let n=0,o=e.length;n<o;n++)if(e[n]===t)return n;return-1},hasOwn:xe,extend:(e,...t)=>{for(let n=0;n<t.length;n++){const o=t[n];for(const t in o)if(xe(o,t)){const n=o[t];void 0!==n&&(e[t]=n)}}return e},walk:Ot,resolve:(e,t=window)=>{const n=e.split(".");for(let e=0,o=n.length;e<o&&(t=t[n[e]]);e++);return t},explode:(e,t)=>p(e)?e:""===e?[]:Re(e.split(t||","),At),_addCacheSuffix:e=>{const t=Nt.cacheSuffix;return t&&(e+=(-1===e.indexOf("?")?"?":"&")+t),e}},Bt=(e,t,n=A)=>e.exists((e=>n(e,t))),Dt=(e,t,n)=>e.isSome()&&t.isSome()?M.some(n(e.getOrDie(),t.getOrDie())):M.none(),Pt=(e,t)=>e?M.some(t):M.none();"undefined"!=typeof window?window:Function("return this;")();const Lt=e=>e.dom.nodeName.toLowerCase(),Mt=e=>e.dom.nodeType,It=e=>t=>Mt(t)===e,Ft=It(1),Ut=It(3),zt=It(9),jt=It(11),Ht=e=>t=>Ft(t)&&Lt(t)===e,$t=(e,t,n)=>{if(!(m(n)||b(n)||x(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")},Vt=(e,t,n)=>{$t(e.dom,t,n)},qt=(e,t)=>{const n=e.dom;fe(t,((e,t)=>{$t(n,t,e)}))},Wt=(e,t)=>{const n=e.dom.getAttribute(t);return null===n?void 0:n},Kt=(e,t)=>M.from(Wt(e,t)),Gt=(e,t)=>{const n=e.dom;return!(!n||!n.hasAttribute)&&n.hasAttribute(t)},Yt=(e,t)=>{e.dom.removeAttribute(t)},Xt=e=>Y(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),Qt=(e,t)=>{const n=Wt(e,t);return void 0===n||""===n?[]:n.split(" ")},Jt=e=>void 0!==e.dom.classList,Zt=e=>Qt(e,"class"),en=(e,t)=>((e,t,n)=>{const o=Qt(e,t).concat([n]);return Vt(e,t,o.join(" ")),!0})(e,"class",t),tn=(e,t)=>((e,t,n)=>{const o=K(Qt(e,t),(e=>e!==n));return o.length>0?Vt(e,t,o.join(" ")):Yt(e,t),!1})(e,"class",t),nn=(e,t)=>{Jt(e)?e.dom.classList.add(t):en(e,t)},on=e=>{0===(Jt(e)?e.dom.classList:Zt(e)).length&&Yt(e,"class")},rn=(e,t)=>{Jt(e)?e.dom.classList.remove(t):tn(e,t),on(e)},sn=(e,t)=>Jt(e)&&e.dom.classList.contains(t),an=e=>void 0!==e.style&&w(e.style.getPropertyValue),ln=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},dn=(e,t)=>{const n=(t||document).createElement("div");if(n.innerHTML=e,!n.hasChildNodes()||n.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return ln(n.childNodes[0])},cn=(e,t)=>{const n=(t||document).createElement(e);return ln(n)},un=(e,t)=>{const n=(t||document).createTextNode(e);return ln(n)},mn=ln,fn=(e,t,n)=>M.from(e.dom.elementFromPoint(t,n)).map(ln),gn=(e,t)=>{const n=[],o=e=>(n.push(e),t(e));let r=t(e);do{r=r.bind(o)}while(r.isSome());return n},pn=(e,t)=>{const n=e.dom;if(1!==n.nodeType)return!1;{const e=n;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},hn=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,bn=(e,t)=>e.dom===t.dom,vn=(e,t)=>{const n=e.dom,o=t.dom;return n!==o&&n.contains(o)},yn=e=>mn(e.dom.ownerDocument),Cn=e=>zt(e)?e:yn(e),wn=e=>mn(Cn(e).dom.defaultView),xn=e=>M.from(e.dom.parentNode).map(mn),kn=e=>M.from(e.dom.parentElement).map(mn),Sn=(e,t)=>{const n=w(t)?t:P;let o=e.dom;const r=[];for(;null!==o.parentNode&&void 0!==o.parentNode;){const e=o.parentNode,t=mn(e);if(r.push(t),!0===n(t))break;o=e}return r},_n=e=>M.from(e.dom.previousSibling).map(mn),En=e=>M.from(e.dom.nextSibling).map(mn),Nn=e=>ne(gn(e,_n)),Rn=e=>gn(e,En),An=e=>$(e.dom.childNodes,mn),On=(e,t)=>{const n=e.dom.childNodes;return M.from(n[t]).map(mn)},Tn=e=>On(e,0),Bn=e=>On(e,e.dom.childNodes.length-1),Dn=e=>e.dom.childNodes.length,Pn=e=>jt(e)&&C(e.dom.host),Ln=w(Element.prototype.attachShadow)&&w(Node.prototype.getRootNode),Mn=N(Ln),In=Ln?e=>mn(e.dom.getRootNode()):Cn,Fn=e=>Pn(e)?e:(e=>{const t=e.dom.head;if(null==t)throw new Error("Head is not available yet");return mn(t)})(Cn(e)),Un=e=>mn(e.dom.host),zn=e=>{if(Mn()&&C(e.target)){const t=mn(e.target);if(Ft(t)&&jn(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return ie(t)}}return M.from(e.target)},jn=e=>C(e.dom.shadowRoot),Hn=e=>{const t=Ut(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const n=t.ownerDocument;return(e=>{const t=In(e);return Pn(t)?M.some(t):M.none()})(mn(t)).fold((()=>n.body.contains(t)),E(Hn,Un))},$n=(e,t,n)=>{if(!m(n))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",n,":: Element ",e),new Error("CSS value must be a string: "+n);an(e)&&e.style.setProperty(t,n)},Vn=(e,t,n)=>{const o=e.dom;$n(o,t,n)},qn=(e,t)=>{const n=e.dom;fe(t,((e,t)=>{$n(n,t,e)}))},Wn=(e,t)=>{const n=e.dom,o=window.getComputedStyle(n).getPropertyValue(t);return""!==o||Hn(e)?o:Kn(n,t)},Kn=(e,t)=>an(e)?e.style.getPropertyValue(t):"",Gn=(e,t)=>{const n=e.dom,o=Kn(n,t);return M.from(o).filter((e=>e.length>0))},Yn=e=>{const t={},n=e.dom;if(an(n))for(let e=0;e<n.style.length;e++){const o=n.style.item(e);t[o]=n.style[o]}return t},Xn=(e,t)=>{((e,t)=>{an(e)&&e.style.removeProperty(t)})(e.dom,t),Bt(Kt(e,"style").map($e),"")&&Yt(e,"style")},Qn=(e,t)=>{xn(e).each((n=>{n.dom.insertBefore(t.dom,e.dom)}))},Jn=(e,t)=>{En(e).fold((()=>{xn(e).each((e=>{eo(e,t)}))}),(e=>{Qn(e,t)}))},Zn=(e,t)=>{Tn(e).fold((()=>{eo(e,t)}),(n=>{e.dom.insertBefore(t.dom,n.dom)}))},eo=(e,t)=>{e.dom.appendChild(t.dom)},to=(e,t)=>{V(t,(t=>{eo(e,t)}))},no=e=>{e.dom.textContent="",V(An(e),(e=>{oo(e)}))},oo=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},ro=e=>{const t=An(e);var n,o;t.length>0&&(n=e,V(o=t,((e,t)=>{const r=0===t?n:o[t-1];Jn(r,e)}))),oo(e)},so=e=>$(e,mn),ao=e=>e.dom.innerHTML,io=(e,t)=>{const n=yn(e).dom,o=mn(n.createDocumentFragment()),r=((e,t)=>{const n=(t||document).createElement("div");return n.innerHTML=e,An(mn(n))})(t,n);to(o,r),no(e),eo(e,o)},lo=(e,t,n,o)=>((e,t,n,o,r)=>{const s=((e,t)=>n=>{e(n)&&t((e=>{const t=mn(zn(e).getOr(e.target)),n=()=>e.stopPropagation(),o=()=>e.preventDefault(),r=_(o,n);return((e,t,n,o,r,s,a)=>({target:e,x:t,y:n,stop:o,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,n,o,r,e)})(n))})(n,o);return e.dom.addEventListener(t,s,false),{unbind:O(co,e,t,s,false)}})(e,t,n,o),co=(e,t,n,o)=>{e.dom.removeEventListener(t,n,o)},uo=(e,t)=>({left:e,top:t,translate:(n,o)=>uo(e+n,t+o)}),mo=uo,fo=(e,t)=>void 0!==e?e:void 0!==t?t:0,go=e=>{const t=e.dom,n=t.ownerDocument.body;return n===t?mo(n.offsetLeft,n.offsetTop):Hn(e)?(e=>{const t=e.getBoundingClientRect();return mo(t.left,t.top)})(t):mo(0,0)},po=e=>{const t=void 0!==e?e.dom:document,n=t.body.scrollLeft||t.documentElement.scrollLeft,o=t.body.scrollTop||t.documentElement.scrollTop;return mo(n,o)},ho=(e,t,n)=>{const o=(void 0!==n?n.dom:document).defaultView;o&&o.scrollTo(e,t)},bo=(e,t)=>{Ct().browser.isSafari()&&w(e.dom.scrollIntoViewIfNeeded)?e.dom.scrollIntoViewIfNeeded(!1):e.dom.scrollIntoView(t)},vo=(e,t,n,o)=>({x:e,y:t,width:n,height:o,right:e+n,bottom:t+o}),yo=e=>{const t=void 0===e?window:e,n=t.document,o=po(mn(n));return(e=>{const t=void 0===e?window:e;return Ct().browser.isFirefox()?M.none():M.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,n=e.clientWidth,r=e.clientHeight;return vo(o.left,o.top,n,r)}),(e=>vo(Math.max(e.pageLeft,o.left),Math.max(e.pageTop,o.top),e.width,e.height)))},Co=(e,t)=>{let n=[];return V(An(e),(e=>{t(e)&&(n=n.concat([e])),n=n.concat(Co(e,t))})),n};var wo=(e,t,n,o,r)=>e(n,o)?M.some(n):w(r)&&r(n)?M.none():t(n,o,r);const xo=(e,t,n)=>{let o=e.dom;const r=w(n)?n:P;for(;o.parentNode;){o=o.parentNode;const e=mn(o);if(t(e))return M.some(e);if(r(e))break}return M.none()},ko=(e,t,n)=>wo(((e,t)=>t(e)),xo,e,t,n),So=(e,t,n)=>xo(e,(e=>pn(e,t)),n),_o=(e,t)=>((e,t)=>{const n=void 0===t?document:t.dom;return hn(n)?M.none():M.from(n.querySelector(e)).map(mn)})(t,e),Eo=(e,t,n)=>wo(((e,t)=>pn(e,t)),So,e,t,n),No=(e,t,n)=>So(e,t,n).isSome();class Ro{constructor(e,t){this.node=e,this.rootNode=t,this.current=this.current.bind(this),this.next=this.next.bind(this),this.prev=this.prev.bind(this),this.prev2=this.prev2.bind(this)}current(){return this.node}next(e){return this.node=this.findSibling(this.node,"firstChild","nextSibling",e),this.node}prev(e){return this.node=this.findSibling(this.node,"lastChild","previousSibling",e),this.node}prev2(e){return this.node=this.findPreviousNode(this.node,e),this.node}findSibling(e,t,n,o){if(e){if(!o&&e[t])return e[t];if(e!==this.rootNode){let t=e[n];if(t)return t;for(let o=e.parentNode;o&&o!==this.rootNode;o=o.parentNode)if(t=o[n],t)return t}}}findPreviousNode(e,t){if(e){const n=e.previousSibling;if(this.rootNode&&n===this.rootNode)return;if(n){if(!t)for(let e=n.lastChild;e;e=e.lastChild)if(!e.lastChild)return e;return n}const o=e.parentNode;if(o&&o!==this.rootNode)return o}}}const Ao=e=>t=>!!t&&t.nodeType===e,Oo=e=>!!e&&!Object.getPrototypeOf(e),To=Ao(1),Bo=e=>{const t=e.toLowerCase();return e=>C(e)&&e.nodeName.toLowerCase()===t},Do=e=>{const t=e.map((e=>e.toLowerCase()));return e=>{if(e&&e.nodeName){const n=e.nodeName.toLowerCase();return j(t,n)}return!1}},Po=(e,t)=>{const n=t.toLowerCase().split(" ");return t=>{if(To(t)){const o=t.ownerDocument.defaultView;if(o)for(let r=0;r<n.length;r++){const s=o.getComputedStyle(t,null);if((s?s.getPropertyValue(e):null)===n[r])return!0}}return!1}},Lo=e=>t=>To(t)&&t.hasAttribute(e),Mo=e=>To(e)&&e.hasAttribute("data-mce-bogus"),Io=e=>To(e)&&"TABLE"===e.tagName,Fo=e=>t=>{if(To(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},Uo=Do(["textarea","input"]),zo=Ao(3),jo=Ao(4),Ho=Ao(7),$o=Ao(8),Vo=Ao(9),qo=Ao(11),Wo=Bo("br"),Ko=Bo("img"),Go=Fo("true"),Yo=Fo("false"),Xo=Do(["td","th"]),Qo=Do(["td","th","caption"]),Jo=Do(["video","audio","object","embed"]),Zo=Bo("li"),er="\ufeff",tr="\xa0",nr=e=>e===er,or=(e,t)=>((e,t)=>{const n=void 0===t?document:t.dom;return hn(n)?[]:$(n.querySelectorAll(e),mn)})(t,e),rr=((e,t)=>{const n=t=>e(t)?M.from(t.dom.nodeValue):M.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return n(t).getOr("")},getOption:n,set:(t,n)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=n}}})(Ut),sr=e=>rr.get(e),ar=e=>rr.getOption(e),ir=["pre"].concat(["h1","h2","h3","h4","h5","h6"]),lr=e=>{let t;return n=>(t=t||re(e,L),xe(t,Lt(n)))},dr=lr(["article","aside","details","div","dt","figcaption","footer","form","fieldset","header","hgroup","html","main","nav","section","summary","body","p","dl","multicol","dd","figure","address","center","blockquote","h1","h2","h3","h4","h5","h6","listing","xmp","pre","plaintext","menu","dir","ul","ol","li","hr","table","tbody","thead","tfoot","th","tr","td","caption"]),cr=e=>Ft(e)&&!dr(e),ur=e=>Ft(e)&&"br"===Lt(e),mr=lr(["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"]),fr=lr(["ul","ol","dl"]),gr=lr(["li","dd","dt"]),pr=lr(["thead","tbody","tfoot"]),hr=lr(["td","th"]),br=lr(["pre","script","textarea","style"]),vr=lr(ir),yr=e=>vr(e)||cr(e),Cr=()=>{const e=cn("br");return Vt(e,"data-mce-bogus","1"),e},wr=e=>{no(e),eo(e,Cr())},xr=e=>{Bn(e).each((t=>{_n(t).each((n=>{dr(e)&&ur(t)&&dr(n)&&oo(t)}))}))},kr=er,Sr=nr,_r=e=>e.replace(/\uFEFF/g,""),Er=To,Nr=zo,Rr=e=>(Nr(e)&&(e=e.parentNode),Er(e)&&e.hasAttribute("data-mce-caret")),Ar=e=>Nr(e)&&Sr(e.data),Or=e=>Rr(e)||Ar(e),Tr=e=>e.firstChild!==e.lastChild||!Wo(e.firstChild),Br=e=>{const t=e.container();return!!zo(t)&&(t.data.charAt(e.offset())===kr||e.isAtStart()&&Ar(t.previousSibling))},Dr=e=>{const t=e.container();return!!zo(t)&&(t.data.charAt(e.offset()-1)===kr||e.isAtEnd()&&Ar(t.nextSibling))},Pr=e=>Nr(e)&&e.data[0]===kr,Lr=e=>Nr(e)&&e.data[e.data.length-1]===kr,Mr=e=>e&&e.hasAttribute("data-mce-caret")?((e=>{var t;const n=e.getElementsByTagName("br"),o=n[n.length-1];Mo(o)&&(null===(t=o.parentNode)||void 0===t||t.removeChild(o))})(e),e.removeAttribute("data-mce-caret"),e.removeAttribute("data-mce-bogus"),e.removeAttribute("style"),e.removeAttribute("data-mce-style"),e.removeAttribute("_moz_abspos"),e):null,Ir=e=>Rr(e.startContainer),Fr=Go,Ur=Yo,zr=Wo,jr=zo,Hr=Do(["script","style","textarea"]),$r=Do(["img","input","textarea","hr","iframe","video","audio","object","embed"]),Vr=Do(["table"]),qr=Or,Wr=e=>!qr(e)&&(jr(e)?!Hr(e.parentNode):$r(e)||zr(e)||Vr(e)||Kr(e)),Kr=e=>!(e=>To(e)&&"true"===e.getAttribute("unselectable"))(e)&&Ur(e),Gr=(e,t)=>Wr(e)&&((e,t)=>{for(let n=e.parentNode;n&&n!==t;n=n.parentNode){if(Kr(n))return!1;if(Fr(n))return!0}return!0})(e,t),Yr=/^[ \t\r\n]*$/,Xr=e=>Yr.test(e),Qr=e=>"\n"===e||"\r"===e,Jr=(e,t=4,n=!0,o=!0)=>{const r=((e,t)=>t<=0?"":new Array(t+1).join(" "))(0,t),s=e.replace(/\t/g,r),a=Y(s,((e,t)=>(e=>-1!==" \f\t\v".indexOf(e))(t)||t===tr?e.pcIsSpace||""===e.str&&n||e.str.length===s.length-1&&o||((e,t)=>t<e.length&&t>=0&&Qr(e[t]))(s,e.str.length+1)?{pcIsSpace:!1,str:e.str+tr}:{pcIsSpace:!0,str:e.str+" "}:{pcIsSpace:Qr(t),str:e.str+t}),{pcIsSpace:!1,str:""});return a.str},Zr=(e,t)=>Wr(e)&&!((e,t)=>zo(e)&&Xr(e.data)&&!((e,t)=>{const n=mn(t),o=mn(e);return No(o,"pre,code",O(bn,n))})(e,t))(e,t)||(e=>To(e)&&"A"===e.nodeName&&!e.hasAttribute("href")&&(e.hasAttribute("name")||e.hasAttribute("id")))(e)||es(e),es=Lo("data-mce-bookmark"),ts=Lo("data-mce-bogus"),ns=("data-mce-bogus","all",e=>To(e)&&"all"===e.getAttribute("data-mce-bogus"));const os=(e,t=!0)=>((e,t)=>{let n=0;if(Zr(e,e))return!1;{let o=e.firstChild;if(!o)return!0;const r=new Ro(o,e);do{if(t){if(ns(o)){o=r.next(!0);continue}if(ts(o)){o=r.next();continue}}if(Wo(o))n++,o=r.next();else{if(Zr(o,e))return!1;o=r.next()}}while(o);return n<=1}})(e.dom,t),rs="data-mce-block",ss=e=>(e=>K(ue(e),(e=>!/[A-Z]/.test(e))))(e).join(","),as=(e,t)=>C(t.querySelector(e))?(t.setAttribute(rs,"true"),"inline-boundary"===t.getAttribute("data-mce-selected")&&t.removeAttribute("data-mce-selected"),!0):(t.removeAttribute(rs),!1),is=(e,t)=>{const n=ss(e.getTransparentElements()),o=ss(e.getBlockElements());return K(t.querySelectorAll(n),(e=>as(o,e)))},ls=(e,t)=>{var n;const o=t?"lastChild":"firstChild";for(let t=e[o];t;t=t[o])if(os(mn(t)))return void(null===(n=t.parentNode)||void 0===n||n.removeChild(t))},ds=(e,t,n)=>{const o=e.getBlockElements(),r=mn(t),s=e=>Lt(e)in o,a=e=>bn(e,r);V(so(n),(t=>{xo(t,s,a).each((n=>{const o=((t,o)=>K(An(t),(t=>s(t)&&!e.isValidChild(Lt(n),Lt(t)))))(t);if(o.length>0){const t=kn(n);V(o,(e=>{xo(e,s,a).each((t=>{((e,t)=>{const n=document.createRange(),o=e.parentNode;if(o){n.setStartBefore(e),n.setEndBefore(t);const r=n.extractContents();ls(r,!0),n.setStartAfter(t),n.setEndAfter(e);const s=n.extractContents();ls(s,!1),os(mn(r))||o.insertBefore(r,e),os(mn(t))||o.insertBefore(t,e),os(mn(s))||o.insertBefore(s,e),o.removeChild(e)}})(t.dom,e.dom)}))})),t.each((t=>is(e,t.dom)))}}))}))},cs=(e,t)=>{const n=is(e,t);ds(e,t,n)},us=(e,t)=>{if(gs(e,t)){const n=ss(e.getBlockElements());as(n,t)}},ms=e=>e.hasAttribute(rs),fs=(e,t)=>xe(e.getTransparentElements(),t),gs=(e,t)=>To(t)&&fs(e,t.nodeName),ps=(e,t)=>gs(e,t)&&ms(t),hs=(e,t)=>1===t.type&&fs(e,t.name)&&v(t.attr(rs)),bs=Ct().browser,vs=e=>Q(e,Ft),ys=(e,t)=>e.children&&j(e.children,t),Cs=(e,t={})=>{let n=0;const o={},r=mn(e),s=Cn(r),a=t.maxLoadTime||5e3,i=i=>new Promise(((l,d)=>{let c;const u=Tt._addCacheSuffix(i),m=(e=>we(o,e).getOrThunk((()=>({id:"mce-u"+n++,passed:[],failed:[],count:0}))))(u);o[u]=m,m.count++;const f=(e,t)=>{V(e,D),m.status=t,m.passed=[],m.failed=[],c&&(c.onload=null,c.onerror=null,c=null)},g=()=>f(m.passed,2),p=()=>f(m.failed,3),h=()=>{var t;t=h,(()=>{const t=e.styleSheets;let n=t.length;for(;n--;){const e=t[n].ownerNode;if(e&&c&&e.id===c.id)return g(),!0}return!1})()||(Date.now()-v<a?setTimeout(t):p())};if(l&&m.passed.push(l),d&&m.failed.push(d),1===m.status)return;if(2===m.status)return void g();if(3===m.status)return void p();m.status=1;const b=cn("link",s.dom);qt(b,{rel:"stylesheet",type:"text/css",id:m.id});const v=Date.now();var y;t.contentCssCors&&Vt(b,"crossOrigin","anonymous"),t.referrerPolicy&&Vt(b,"referrerpolicy",t.referrerPolicy),c=b.dom,c.onload=h,c.onerror=p,y=b,eo(Fn(r),y),Vt(b,"href",u)})),l=e=>{const t=Tt._addCacheSuffix(e);we(o,t).each((e=>{0==--e.count&&(delete o[t],(e=>{const t=Fn(r);_o(t,"#"+e).each(oo)})(e.id))}))};return{load:i,loadAll:e=>Promise.allSettled($(e,(e=>i(e).then(N(e))))).then((e=>{const t=W(e,(e=>"fulfilled"===e.status));return t.fail.length>0?Promise.reject($(t.fail,(e=>e.reason))):$(t.pass,(e=>e.value))})),unload:l,unloadAll:e=>{V(e,(e=>{l(e)}))},_setReferrerPolicy:e=>{t.referrerPolicy=e},_setContentCssCors:e=>{t.contentCssCors=e}}},ws=(()=>{const e=new WeakMap;return{forElement:(t,n)=>{const o=In(t).dom;return M.from(e.get(o)).getOrThunk((()=>{const t=Cs(o,n);return e.set(o,t),t}))}}})(),xs=(e,t)=>C(e)&&(Zr(e,t)||cr(mn(e))),ks=e=>(e=>"span"===e.nodeName.toLowerCase())(e)&&"bookmark"===e.getAttribute("data-mce-type"),Ss=(e,t,n)=>{var o;const r=n||t;if(To(t)&&ks(t))return t;const s=t.childNodes;for(let t=s.length-1;t>=0;t--)Ss(e,s[t],r);if(To(t)){const e=t.childNodes;1===e.length&&ks(e[0])&&(null===(o=t.parentNode)||void 0===o||o.insertBefore(e[0],t))}return(e=>qo(e)||Vo(e))(t)||Zr(t,r)||(e=>!!To(e)&&e.childNodes.length>0)(t)||((e,t)=>zo(e)&&e.data.length>0&&((e,t)=>{const n=new Ro(e,t).prev(!1),o=new Ro(e,t).next(!1),r=v(n)||xs(n,t),s=v(o)||xs(o,t);return r&&s})(e,t))(t,r)||e.remove(t),t},_s=Tt.makeMap,Es=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ns=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Rs=/[<>&\"\']/g,As=/&#([a-z0-9]+);?|&([a-z0-9]+);/gi,Os={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"},Ts={'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;","&":"&amp;","`":"&#96;"},Bs={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&apos;":"'"},Ds=(e,t)=>{const n={};if(e){const o=e.split(",");t=t||10;for(let e=0;e<o.length;e+=2){const r=String.fromCharCode(parseInt(o[e],t));if(!Ts[r]){const t="&"+o[e+1]+";";n[r]=t,n[t]=r}}return n}},Ps=Ds("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),Ls=(e,t)=>e.replace(t?Es:Ns,(e=>Ts[e]||e)),Ms=(e,t)=>e.replace(t?Es:Ns,(e=>e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":Ts[e]||"&#"+e.charCodeAt(0)+";")),Is=(e,t,n)=>{const o=n||Ps;return e.replace(t?Es:Ns,(e=>Ts[e]||o[e]||e))},Fs={encodeRaw:Ls,encodeAllRaw:e=>(""+e).replace(Rs,(e=>Ts[e]||e)),encodeNumeric:Ms,encodeNamed:Is,getEncodeFunc:(e,t)=>{const n=Ds(t)||Ps,o=_s(e.replace(/\+/g,","));return o.named&&o.numeric?(e,t)=>e.replace(t?Es:Ns,(e=>void 0!==Ts[e]?Ts[e]:void 0!==n[e]?n[e]:e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":"&#"+e.charCodeAt(0)+";")):o.named?t?(e,t)=>Is(e,t,n):Is:o.numeric?Ms:Ls},decode:e=>e.replace(As,((e,t)=>t?(t="x"===t.charAt(0).toLowerCase()?parseInt(t.substr(1),16):parseInt(t,10))>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):Os[t]||String.fromCharCode(t):Bs[e]||Ps[e]||(e=>{const t=cn("div").dom;return t.innerHTML=e,t.textContent||t.innerText||e})(e)))},Us={},zs={},js={},Hs=Tt.makeMap,$s=Tt.each,Vs=Tt.extend,qs=Tt.explode,Ws=Tt.inArray,Ks=(e,t)=>(e=Tt.trim(e))?e.split(t||" "):[],Gs=(e,t={})=>{const n=Hs(e," ",Hs(e.toUpperCase()," "));return Vs(n,t)},Ys=e=>Gs("td th li dt dd figcaption caption details summary",e.getTextBlockElements()),Xs=(e,t)=>{if(e){const n={};return m(e)&&(e={"*":e}),$s(e,((e,o)=>{n[o]=n[o.toUpperCase()]="map"===t?Hs(e,/[, ]/):qs(e,/[, ]/)})),n}},Qs=(e={})=>{var t;const n={},o={};let r=[];const s={},a={},i=(t,n,o)=>{const r=e[t];if(r)return Hs(r,/[, ]/,Hs(r.toUpperCase(),/[, ]/));{let e=zs[t];return e||(e=Gs(n,o),zs[t]=e),e}},l=null!==(t=e.schema)&&void 0!==t?t:"html5",d=(e=>{const t={};let n,o,r,s;const a=(e,o="",r="")=>{const s=Ks(r),a=Ks(e);let i=a.length;for(;i--;){const e=Ks([n,o].join(" "));t[a[i]]={attributes:re(e,(()=>({}))),attributesOrder:e,children:re(s,N(js))}}},i=(e,n)=>{const o=Ks(e),r=Ks(n);let s=o.length;for(;s--;){const e=t[o[s]];for(let t=0,n=r.length;t<n;t++)e.attributes[r[t]]={},e.attributesOrder.push(r[t])}};if(Us[e])return Us[e];if(n="id accesskey class dir lang style tabindex title role",o="address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul",r="a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment","html4"!==e&&(n+=" contenteditable contextmenu draggable dropzone hidden spellcheck translate",o+=" article aside details dialog figure main header footer hgroup section nav a ins del canvas map",r+=" audio canvas command datalist mark meter output picture progress time wbr video ruby bdi keygen"),"html5-strict"!==e){n+=" xml:lang";const e="acronym applet basefont big font strike tt";r=[r,e].join(" "),$s(Ks(e),(e=>{a(e,"",r)}));const t="center dir isindex noframes";o=[o,t].join(" "),s=[o,r].join(" "),$s(Ks(t),(e=>{a(e,"",s)}))}return s=s||[o,r].join(" "),a("html","manifest","head body"),a("head","","base command link meta noscript script style title"),a("title hr noscript br"),a("base","href target"),a("link","href rel media hreflang type sizes hreflang"),a("meta","name http-equiv content charset"),a("style","media type scoped"),a("script","src async defer type charset"),a("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",s),a("address dt dd div caption","",s),a("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",r),a("blockquote","cite",s),a("ol","reversed start type","li"),a("ul","","li"),a("li","value",s),a("dl","","dt dd"),a("a","href target rel media hreflang type",s),a("q","cite",r),a("ins del","cite datetime",s),a("img","src sizes srcset alt usemap ismap width height"),a("iframe","src name width height",s),a("embed","src type width height"),a("object","data type typemustmatch name usemap form width height",[s,"param"].join(" ")),a("param","name value"),a("map","name",[s,"area"].join(" ")),a("area","alt coords shape href target rel media hreflang type"),a("table","border","caption colgroup thead tfoot tbody tr"+("html4"===e?" col":"")),a("colgroup","span","col"),a("col","span"),a("tbody thead tfoot","","tr"),a("tr","","td th"),a("td","colspan rowspan headers",s),a("th","colspan rowspan headers scope abbr",s),a("form","accept-charset action autocomplete enctype method name novalidate target",s),a("fieldset","disabled form name",[s,"legend"].join(" ")),a("label","form for",r),a("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),a("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"===e?s:r),a("select","disabled form multiple name required size","option optgroup"),a("optgroup","disabled label","option"),a("option","disabled label selected value"),a("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),a("menu","type label",[s,"li"].join(" ")),a("noscript","",s),"html4"!==e&&(a("wbr"),a("ruby","",[r,"rt rp"].join(" ")),a("figcaption","",s),a("mark rt rp summary bdi","",r),a("canvas","width height",s),a("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",[s,"track source"].join(" ")),a("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",[s,"track source"].join(" ")),a("picture","","img source"),a("source","src srcset type media sizes"),a("track","kind src srclang label default"),a("datalist","",[r,"option"].join(" ")),a("article section nav aside main header footer","",s),a("hgroup","","h1 h2 h3 h4 h5 h6"),a("figure","",[s,"figcaption"].join(" ")),a("time","datetime",r),a("dialog","open",s),a("command","type label icon disabled checked radiogroup command"),a("output","for form name",r),a("progress","value max",r),a("meter","value min max low high optimum",r),a("details","open",[s,"summary"].join(" ")),a("keygen","autofocus challenge disabled form keytype name")),"html5-strict"!==e&&(i("script","language xml:space"),i("style","xml:space"),i("object","declare classid code codebase codetype archive standby align border hspace vspace"),i("embed","align name hspace vspace"),i("param","valuetype type"),i("a","charset name rev shape coords"),i("br","clear"),i("applet","codebase archive code object alt name width height align hspace vspace"),i("img","name longdesc align border hspace vspace"),i("iframe","longdesc frameborder marginwidth marginheight scrolling align"),i("font basefont","size color face"),i("input","usemap align"),i("select"),i("textarea"),i("h1 h2 h3 h4 h5 h6 div p legend caption","align"),i("ul","type compact"),i("li","type"),i("ol dl menu dir","compact"),i("pre","width xml:space"),i("hr","align noshade size width"),i("isindex","prompt"),i("table","summary width frame rules cellspacing cellpadding align bgcolor"),i("col","width align char charoff valign"),i("colgroup","width align char charoff valign"),i("thead","align char charoff valign"),i("tr","align char charoff valign bgcolor"),i("th","axis align char charoff valign nowrap bgcolor width height"),i("form","accept"),i("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),i("tfoot","align char charoff valign"),i("tbody","align char charoff valign"),i("area","nohref"),i("body","background bgcolor text link vlink alink")),"html4"!==e&&(i("input button select textarea","autofocus"),i("input textarea","placeholder"),i("a","download"),i("link script img","crossorigin"),i("img","loading"),i("iframe","sandbox seamless allow allowfullscreen loading")),"html4"!==e&&V([t.video,t.audio],(e=>{delete e.children.audio,delete e.children.video})),$s(Ks("a form meter progress dfn"),(e=>{t[e]&&delete t[e].children[e]})),delete t.caption.children.table,delete t.script,Us[e]=t,t})(l);!1===e.verify_html&&(e.valid_elements="*[*]");const c=Xs(e.valid_styles),u=Xs(e.invalid_styles,"map"),m=Xs(e.valid_classes,"map"),f=i("whitespace_elements","pre script noscript style textarea video audio iframe object code"),g=i("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),p=i("void_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),h=i("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls allowfullscreen"),b="td th iframe video audio object script code",v=i("non_empty_elements",b+" pre",p),y=i("move_caret_before_on_enter_elements",b+" table",p),C=i("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside main nav figure"),w=i("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup figcaption details summary",C),x=i("text_inline_elements","span strong b em i font s strike u var cite dfn code mark q sup sub samp"),k=i("transparent_elements","a ins del canvas map");$s("script noscript iframe noframes noembed title style textarea xmp plaintext".split(" "),(e=>{a[e]=new RegExp("</"+e+"[^>]*>","gi")}));const S=e=>new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$"),_=e=>{const t=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)])?$/,o=/^([!\-])?(\w+[\\:]:\w+|[^=~<]+)?(?:([=~<])(.*))?$/,s=/[*?+]/;if(e){const a=Ks(e,",");let i,l;n["@"]&&(i=n["@"].attributes,l=n["@"].attributesOrder);for(let e=0,d=a.length;e<d;e++){let d=t.exec(a[e]);if(d){const e=d[1],t=d[2],a=d[3],c=d[5],u={},m=[],f={attributes:u,attributesOrder:m};if("#"===e&&(f.paddEmpty=!0),"-"===e&&(f.removeEmpty=!0),"!"===d[4]&&(f.removeEmptyAttrs=!0),i&&(fe(i,((e,t)=>{u[t]=e})),l&&m.push(...l)),c){const e=Ks(c,"|");for(let t=0,n=e.length;t<n;t++)if(d=o.exec(e[t]),d){const e={},t=d[1],n=d[2].replace(/[\\:]:/g,":"),o=d[3],r=d[4];if("!"===t&&(f.attributesRequired=f.attributesRequired||[],f.attributesRequired.push(n),e.required=!0),"-"===t){delete u[n],m.splice(Ws(m,n),1);continue}if(o&&("="===o&&(f.attributesDefault=f.attributesDefault||[],f.attributesDefault.push({name:n,value:r}),e.defaultValue=r),"~"===o&&(f.attributesForced=f.attributesForced||[],f.attributesForced.push({name:n,value:r}),e.forcedValue=r),"<"===o&&(e.validValues=Hs(r,"?"))),s.test(n)){const t=e;f.attributePatterns=f.attributePatterns||[],t.pattern=S(n),f.attributePatterns.push(t)}else u[n]||m.push(n),u[n]=e}}if(i||"@"!==t||(i=u,l=m),a&&(f.outputName=t,n[a]=f),s.test(t)){const e=f;e.pattern=S(t),r.push(e)}else n[t]=f}}}},E=e=>{r=[],V(ue(n),(e=>{delete n[e]})),_(e),$s(d,((e,t)=>{o[t]=e.children}))},R=e=>{const t=/^(~)?(.+)$/;e&&(delete zs.text_block_elements,delete zs.block_elements,$s(Ks(e,","),(e=>{const r=t.exec(e);if(r){const e="~"===r[1],t=e?"span":"div",a=r[2];if(o[a]=o[t],s[a]=t,v[a.toUpperCase()]={},v[a]={},e||(w[a.toUpperCase()]={},w[a]={}),!n[a]){let e=n[t];e=Vs({},e),delete e.removeEmptyAttrs,delete e.removeEmpty,n[a]=e}$s(o,((e,n)=>{e[t]&&(o[n]=e=Vs({},o[n]),e[a]=e[t])}))}})))},A=e=>{const t=/^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;delete Us[l],e&&$s(Ks(e,","),(e=>{const n=t.exec(e);if(n){const e=n[1];let t;t=e?o[n[2]]:o[n[2]]={"#comment":{}},t=o[n[2]],$s(Ks(n[3],"|"),(n=>{"-"===e?delete t[n]:t[n]={}}))}}))},O=e=>{const t=n[e];if(t)return t;let o=r.length;for(;o--;){const t=r[o];if(t.pattern.test(e))return t}};e.valid_elements?E(e.valid_elements):($s(d,((e,t)=>{n[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},o[t]=e.children})),$s(Ks("strong/b em/i"),(e=>{const t=Ks(e,"/");n[t[1]].outputName=t[0]})),$s(x,((t,o)=>{n[o]&&(e.padd_empty_block_inline_children&&(n[o].paddInEmptyBlock=!0),n[o].removeEmpty=!0)})),$s(Ks("ol ul blockquote a table tbody"),(e=>{n[e]&&(n[e].removeEmpty=!0)})),$s(Ks("p h1 h2 h3 h4 h5 h6 th td pre div address caption li"),(e=>{n[e].paddEmpty=!0})),$s(Ks("span"),(e=>{n[e].removeEmptyAttrs=!0}))),R(e.custom_elements),A(e.valid_children),_(e.extended_valid_elements),A("+ol[ul|ol],+ul[ul|ol]"),$s({dd:"dl",dt:"dl",li:"ul ol",td:"tr",th:"tr",tr:"tbody thead tfoot",tbody:"table",thead:"table",tfoot:"table",legend:"fieldset",area:"map",param:"video audio object"},((e,t)=>{n[t]&&(n[t].parentsRequired=Ks(e))})),e.invalid_elements&&$s(qs(e.invalid_elements),(e=>{n[e]&&delete n[e]})),O("span")||_("span[!data-mce-type|*]");const T=N(c),B=N(u),D=N(m),P=N(h),L=N(w),M=N(C),I=N(x),F=N(Object.seal(p)),U=N(g),z=N(v),j=N(y),H=N(f),$=N(k),q=N(Object.seal(a)),W=N(s);return{type:l,children:o,elements:n,getValidStyles:T,getValidClasses:D,getBlockElements:L,getInvalidStyles:B,getVoidElements:F,getTextBlockElements:M,getTextInlineElements:I,getBoolAttrs:P,getElementRule:O,getSelfClosingElements:U,getNonEmptyElements:z,getMoveCaretBeforeOnEnterElements:j,getWhitespaceElements:H,getTransparentElements:$,getSpecialElements:q,isValidChild:(e,t)=>{const n=o[e.toLowerCase()];return!(!n||!n[t.toLowerCase()])},isValid:(e,t)=>{const n=O(e);if(n){if(!t)return!0;{if(n.attributes[t])return!0;const e=n.attributePatterns;if(e){let n=e.length;for(;n--;)if(e[n].pattern.test(t))return!0}}}return!1},getCustomElements:W,addValidElements:_,setValidElements:E,addCustomElements:R,addValidChildren:A}},Js=(e={},t)=>{const n=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,o=/\s*([^:]+):\s*([^;]+);?/g,r=/\s+$/,s={};let a,i;t&&(a=t.getValidStyles(),i=t.getInvalidStyles());const l="\\\" \\' \\; \\: ; : \ufeff".split(" ");for(let e=0;e<l.length;e++)s[l[e]]="\ufeff"+e,s["\ufeff"+e]=l[e];const d={parse:t=>{const a={};let i=!1;const l=e.url_converter,c=e.url_converter_scope||d,u=(e,t,n)=>{const o=a[e+"-top"+t];if(!o)return;const r=a[e+"-right"+t];if(!r)return;const s=a[e+"-bottom"+t];if(!s)return;const i=a[e+"-left"+t];if(!i)return;const l=[o,r,s,i];let d=l.length-1;for(;d--&&l[d]===l[d+1];);d>-1&&n||(a[e+t]=-1===d?l[0]:l.join(" "),delete a[e+"-top"+t],delete a[e+"-right"+t],delete a[e+"-bottom"+t],delete a[e+"-left"+t])},m=e=>{const t=a[e];if(!t)return;const n=t.split(" ");let o=n.length;for(;o--;)if(n[o]!==n[0])return!1;return a[e]=n[0],!0},f=e=>(i=!0,s[e]),g=(e,t)=>(i&&(e=e.replace(/\uFEFF[0-9]/g,(e=>s[e]))),t||(e=e.replace(/\\([\'\";:])/g,"$1")),e),p=e=>String.fromCharCode(parseInt(e.slice(1),16)),h=e=>e.replace(/\\[0-9a-f]+/gi,p),b=(t,n,o,r,s,a)=>{if(s=s||a)return"'"+(s=g(s)).replace(/\'/g,"\\'")+"'";if(n=g(n||o||r||""),!e.allow_script_urls){const t=n.replace(/[\s\r\n]+/g,"");if(/(java|vb)script:/i.test(t))return"";if(!e.allow_svg_data_urls&&/^data:image\/svg/i.test(t))return""}return l&&(n=l.call(c,n,"style")),"url('"+n.replace(/\'/g,"\\'")+"')"};if(t){let s;for(t=(t=t.replace(/[\u0000-\u001F]/g,"")).replace(/\\[\"\';:\uFEFF]/g,f).replace(/\"[^\"]+\"|\'[^\']+\'/g,(e=>e.replace(/[;:]/g,f)));s=o.exec(t);){o.lastIndex=s.index+s[0].length;let t=s[1].replace(r,"").toLowerCase(),l=s[2].replace(r,"");if(t&&l){if(t=h(t),l=h(l),-1!==t.indexOf("\ufeff")||-1!==t.indexOf('"'))continue;if(!e.allow_script_urls&&("behavior"===t||/expression\s*\(|\/\*|\*\//.test(l)))continue;"font-weight"===t&&"700"===l?l="bold":"color"!==t&&"background-color"!==t||(l=l.toLowerCase()),l=l.replace(n,b),a[t]=i?g(l,!0):l}}u("border","",!0),u("border","-width"),u("border","-color"),u("border","-style"),u("padding",""),u("margin",""),"border",y="border-style",C="border-color",m(v="border-width")&&m(y)&&m(C)&&(a.border=a[v]+" "+a[y]+" "+a[C],delete a[v],delete a[y],delete a[C]),"medium none"===a.border&&delete a.border,"none"===a["border-image"]&&delete a["border-image"]}var v,y,C;return a},serialize:(e,t)=>{let n="";const o=(t,o)=>{const r=o[t];if(r)for(let t=0,o=r.length;t<o;t++){const o=r[t],s=e[o];s&&(n+=(n.length>0?" ":"")+o+": "+s+";")}};return t&&a?(o("*",a),o(t,a)):fe(e,((e,o)=>{e&&((e,t)=>{if(!i||!t)return!0;let n=i["*"];return!(n&&n[e]||(n=i[t],n&&n[e]))})(o,t)&&(n+=(n.length>0?" ":"")+o+": "+e+";")})),n}};return d},Zs={keyLocation:!0,layerX:!0,layerY:!0,returnValue:!0,webkitMovementX:!0,webkitMovementY:!0,keyIdentifier:!0,mozPressure:!0},ea=(e,t)=>{const n=null!=t?t:{};for(const t in e)xe(Zs,t)||(n[t]=e[t]);return C(e.composedPath)&&(n.composedPath=()=>e.composedPath()),n},ta=(e,t,n,o)=>{var r;const s=ea(t,o);return s.type=e,y(s.target)&&(s.target=null!==(r=s.srcElement)&&void 0!==r?r:n),(e=>y(e.preventDefault)||(e=>e instanceof Event||w(e.initEvent))(e))(t)&&(s.preventDefault=()=>{s.defaultPrevented=!0,s.isDefaultPrevented=L,w(t.preventDefault)&&t.preventDefault()},s.stopPropagation=()=>{s.cancelBubble=!0,s.isPropagationStopped=L,w(t.stopPropagation)&&t.stopPropagation()},s.stopImmediatePropagation=()=>{s.isImmediatePropagationStopped=L,s.stopPropagation()},(e=>e.isDefaultPrevented===L||e.isDefaultPrevented===P)(s)||(s.isDefaultPrevented=!0===s.defaultPrevented?L:P,s.isPropagationStopped=!0===s.cancelBubble?L:P,s.isImmediatePropagationStopped=P)),s},na=/^(?:mouse|contextmenu)|click/,oa=(e,t,n,o)=>{e.addEventListener(t,n,o||!1)},ra=(e,t,n,o)=>{e.removeEventListener(t,n,o||!1)},sa=(e,t)=>{const n=ta(e.type,e,document,t);if((e=>C(e)&&na.test(e.type))(e)&&v(e.pageX)&&!v(e.clientX)){const t=n.target.ownerDocument||document,o=t.documentElement,r=t.body,s=n;s.pageX=e.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),s.pageY=e.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)}return n},aa=(e,t,n)=>{const o=e.document,r={type:"ready"};if(n.domLoaded)return void t(r);const s=()=>{ra(e,"DOMContentLoaded",s),ra(e,"load",s),n.domLoaded||(n.domLoaded=!0,t(r)),e=null};"complete"===o.readyState||"interactive"===o.readyState&&o.body?s():oa(e,"DOMContentLoaded",s),n.domLoaded||oa(e,"load",s)};class ia{constructor(){this.domLoaded=!1,this.events={},this.count=1,this.expando="mce-data-"+(+new Date).toString(32),this.hasFocusIn="onfocusin"in document.documentElement,this.count=1}bind(e,t,n,o){const r=this;let s;const a=window,i=e=>{r.executeHandlers(sa(e||a.event),l)};if(!e||zo(e)||$o(e))return n;let l;e[r.expando]?l=e[r.expando]:(l=r.count++,e[r.expando]=l,r.events[l]={}),o=o||e;const d=t.split(" ");let c=d.length;for(;c--;){let t=d[c],u=i,m=!1,f=!1;"DOMContentLoaded"===t&&(t="ready"),r.domLoaded&&"ready"===t&&"complete"===e.readyState?n.call(o,sa({type:t})):(r.hasFocusIn||"focusin"!==t&&"focusout"!==t||(m=!0,f="focusin"===t?"focus":"blur",u=e=>{const t=sa(e||a.event);t.type="focus"===t.type?"focusin":"focusout",r.executeHandlers(t,l)}),s=r.events[l][t],s?"ready"===t&&r.domLoaded?n(sa({type:t})):s.push({func:n,scope:o}):(r.events[l][t]=s=[{func:n,scope:o}],s.fakeName=f,s.capture=m,s.nativeHandler=u,"ready"===t?aa(e,u,r):oa(e,f||t,u,m)))}return e=s=null,n}unbind(e,t,n){if(!e||zo(e)||$o(e))return this;const o=e[this.expando];if(o){let r=this.events[o];if(t){const o=t.split(" ");let s=o.length;for(;s--;){const t=o[s],a=r[t];if(a){if(n){let e=a.length;for(;e--;)if(a[e].func===n){const n=a.nativeHandler,o=a.fakeName,s=a.capture,i=a.slice(0,e).concat(a.slice(e+1));i.nativeHandler=n,i.fakeName=o,i.capture=s,r[t]=i}}n&&0!==a.length||(delete r[t],ra(e,a.fakeName||t,a.nativeHandler,a.capture))}}}else fe(r,((t,n)=>{ra(e,t.fakeName||n,t.nativeHandler,t.capture)})),r={};for(const e in r)if(xe(r,e))return this;delete this.events[o];try{delete e[this.expando]}catch(t){e[this.expando]=null}}return this}fire(e,t,n){return this.dispatch(e,t,n)}dispatch(e,t,n){if(!e||zo(e)||$o(e))return this;const o=sa({type:t,target:e},n);do{const t=e[this.expando];t&&this.executeHandlers(o,t),e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow}while(e&&!o.isPropagationStopped());return this}clean(e){if(!e||zo(e)||$o(e))return this;if(e[this.expando]&&this.unbind(e),e.getElementsByTagName||(e=e.document),e&&e.getElementsByTagName){this.unbind(e);const t=e.getElementsByTagName("*");let n=t.length;for(;n--;)(e=t[n])[this.expando]&&this.unbind(e)}return this}destroy(){this.events={}}cancel(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1}executeHandlers(e,t){const n=this.events[t],o=n&&n[e.type];if(o)for(let t=0,n=o.length;t<n;t++){const n=o[t];if(n&&!1===n.func.call(n.scope,e)&&e.preventDefault(),e.isImmediatePropagationStopped())return}}}ia.Event=new ia;const la=Tt.each,da=Tt.grep,ca="data-mce-style",ua=Tt.makeMap("fill-opacity font-weight line-height opacity orphans widows z-index zoom"," "),ma=(e,t,n)=>{y(n)||""===n?Yt(e,t):Vt(e,t,n)},fa=e=>e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase())),ga=(e,t)=>{let n=0;if(e)for(let o=e.nodeType,r=e.previousSibling;r;r=r.previousSibling){const e=r.nodeType;(!t||!zo(r)||e!==o&&r.data.length)&&(n++,o=e)}return n},pa=(e,t)=>{const n=Wt(t,"style"),o=e.serialize(e.parse(n),Lt(t));ma(t,ca,o)},ha=(e,t,n)=>{const o=fa(t);y(n)||""===n?Xn(e,o):Vn(e,o,((e,t)=>x(e)?xe(ua,t)?e+"":e+"px":e)(n,o))},ba=(e,t={})=>{const n={},o=window,r={};let s=0;const a=ws.forElement(mn(e),{contentCssCors:t.contentCssCors,referrerPolicy:t.referrerPolicy}),i=[],l=t.schema?t.schema:Qs({}),d=Js({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope},t.schema),c=t.ownEvents?new ia:ia.Event,u=l.getBlockElements(),f=t=>t&&e&&m(t)?e.getElementById(t):t,g=e=>{const t=f(e);return C(t)?mn(t):null},h=(e,t,n="")=>{let o;const r=g(e);if(C(r)&&Ft(r)){const e=Y[t];o=e&&e.get?e.get(r.dom,t):Wt(r,t)}return C(o)?o:n},b=e=>{const t=f(e);return y(t)?[]:t.attributes},v=(e,n,o)=>{T(e,(e=>{if(To(e)){const r=mn(e),s=""===o?null:o,a=Wt(r,n),i=Y[n];i&&i.set?i.set(r.dom,s,n):ma(r,n,s),a!==s&&t.onSetAttrib&&t.onSetAttrib({attrElm:r.dom,attrName:n,attrValue:s})}}))},x=()=>t.root_element||e.body,k=(t,n)=>((e,t,n)=>{let o=0,r=0;const s=e.ownerDocument;if(n=n||e,t){if(n===e&&t.getBoundingClientRect&&"static"===Wn(mn(e),"position")){const n=t.getBoundingClientRect();return o=n.left+(s.documentElement.scrollLeft||e.scrollLeft)-s.documentElement.clientLeft,r=n.top+(s.documentElement.scrollTop||e.scrollTop)-s.documentElement.clientTop,{x:o,y:r}}let a=t;for(;a&&a!==n&&a.nodeType&&!ys(a,n);){const e=a;o+=e.offsetLeft||0,r+=e.offsetTop||0,a=e.offsetParent}for(a=t.parentNode;a&&a!==n&&a.nodeType&&!ys(a,n);)o-=a.scrollLeft||0,r-=a.scrollTop||0,a=a.parentNode;r+=(e=>bs.isFirefox()&&"table"===Lt(e)?vs(An(e)).filter((e=>"caption"===Lt(e))).bind((e=>vs(Rn(e)).map((t=>{const n=t.dom.offsetTop,o=e.dom.offsetTop,r=e.dom.offsetHeight;return n<=o?-r:0})))).getOr(0):0)(mn(t))}return{x:o,y:r}})(e.body,f(t),n),_=(e,t,n)=>{const o=f(e);if(!y(o)&&To(o))return n?Wn(mn(o),fa(t)):("float"===(t=t.replace(/-(\D)/g,((e,t)=>t.toUpperCase())))&&(t="cssFloat"),o.style?o.style[t]:void 0)},E=e=>{const t=f(e);if(!t)return{w:0,h:0};let n=_(t,"width"),o=_(t,"height");return n&&-1!==n.indexOf("px")||(n="0"),o&&-1!==o.indexOf("px")||(o="0"),{w:parseInt(n,10)||t.offsetWidth||t.clientWidth,h:parseInt(o,10)||t.offsetHeight||t.clientHeight}},R=(e,t)=>{if(!e)return!1;const n=p(e)?e:[e];return H(n,(e=>pn(mn(e),t)))},A=(e,t,n,o)=>{const r=[];let s=f(e);o=void 0===o;const a=n||("BODY"!==x().nodeName?x().parentNode:null);if(m(t))if("*"===t)t=To;else{const e=t;t=t=>R(t,e)}for(;s&&!(s===a||y(s.nodeType)||Vo(s)||qo(s));){if(!t||t(s)){if(!o)return[s];r.push(s)}s=s.parentNode}return o?r:null},O=(e,t,n)=>{let o=t;if(e){m(t)&&(o=e=>R(e,t));for(let t=e[n];t;t=t[n])if(w(o)&&o(t))return t}return null},T=function(e,t,n){const o=null!=n?n:this;if(p(e)){const n=[];return la(e,((e,r)=>{const s=f(e);s&&n.push(t.call(o,s,r))})),n}{const n=f(e);return!!n&&t.call(o,n)}},B=(e,t)=>{T(e,(e=>{fe(t,((t,n)=>{v(e,n,t)}))}))},D=(e,t)=>{T(e,(e=>{const n=mn(e);io(n,t)}))},P=(t,n,o,r,s)=>T(t,(t=>{const a=m(n)?e.createElement(n):n;return C(o)&&B(a,o),r&&(!m(r)&&r.nodeType?a.appendChild(r):m(r)&&D(a,r)),s?a:t.appendChild(a)})),L=(t,n,o)=>P(e.createElement(t),t,n,o,!0),M=Fs.encodeAllRaw,I=(e,t)=>T(e,(e=>{const n=mn(e);return t&&V(An(n),(e=>{Ut(e)&&0===e.dom.length?oo(e):Qn(n,e)})),oo(n),n.dom})),F=(e,t,n)=>{T(e,(e=>{if(To(e)){const o=mn(e),r=t.split(" ");V(r,(e=>{C(n)?(n?nn:rn)(o,e):((e,t)=>{const n=Jt(e)?e.dom.classList.toggle(t):((e,t)=>j(Zt(e),t)?tn(e,t):en(e,t))(e,t);on(e)})(o,e)}))}}))},U=(e,t,n)=>T(t,(o=>{var r;const s=p(t)?e.cloneNode(!0):e;return n&&la(da(o.childNodes),(e=>{s.appendChild(e)})),null===(r=o.parentNode)||void 0===r||r.replaceChild(s,o),o})),z=e=>{if(To(e)){const t="a"===e.nodeName.toLowerCase()&&!h(e,"href")&&h(e,"id");if(h(e,"name")||h(e,"data-mce-bookmark")||t)return!0}return!1},$=()=>e.createRange(),q=(n,r,s,a)=>{if(p(n)){let e=n.length;const t=[];for(;e--;)t[e]=q(n[e],r,s,a);return t}return!t.collect||n!==e&&n!==o||i.push([n,r,s,a]),c.bind(n,r,s,a||G)},W=(t,n,r)=>{if(p(t)){let e=t.length;const o=[];for(;e--;)o[e]=W(t[e],n,r);return o}if(i.length>0&&(t===e||t===o)){let e=i.length;for(;e--;){const[o,s,a]=i[e];t!==o||n&&n!==s||r&&r!==a||c.unbind(o,s,a)}}return c.unbind(t,n,r)},K=e=>{if(e&&To(e)){const t=e.getAttribute("data-mce-contenteditable");return t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null}return null},G={doc:e,settings:t,win:o,files:r,stdMode:!0,boxModel:!0,styleSheetLoader:a,boundEvents:i,styles:d,schema:l,events:c,isBlock:e=>m(e)?xe(u,e):To(e)&&(xe(u,e.nodeName)||ps(l,e)),root:null,clone:(e,t)=>e.cloneNode(t),getRoot:x,getViewPort:e=>{const t=yo(e);return{x:t.x,y:t.y,w:t.width,h:t.height}},getRect:e=>{const t=f(e),n=k(t),o=E(t);return{x:n.x,y:n.y,w:o.w,h:o.h}},getSize:E,getParent:(e,t,n)=>{const o=A(e,t,n,!1);return o&&o.length>0?o[0]:null},getParents:A,get:f,getNext:(e,t)=>O(e,t,"nextSibling"),getPrev:(e,t)=>O(e,t,"previousSibling"),select:(n,o)=>{var r,s;const a=null!==(s=null!==(r=f(o))&&void 0!==r?r:t.root_element)&&void 0!==s?s:e;return w(a.querySelectorAll)?de(a.querySelectorAll(n)):[]},is:R,add:P,create:L,createHTML:(e,t,n="")=>{let o="<"+e;for(const e in t)ke(t,e)&&(o+=" "+e+'="'+M(t[e])+'"');return Ke(n)&&xe(l.getVoidElements(),e)?o+" />":o+">"+n+"</"+e+">"},createFragment:t=>{const n=e.createElement("div"),o=e.createDocumentFragment();let r;for(o.appendChild(n),t&&(n.innerHTML=t);r=n.firstChild;)o.appendChild(r);return o.removeChild(n),o},remove:I,setStyle:(e,n,o)=>{T(e,(e=>{const r=mn(e);ha(r,n,o),t.update_styles&&pa(d,r)}))},getStyle:_,setStyles:(e,n)=>{T(e,(e=>{const o=mn(e);fe(n,((e,t)=>{ha(o,t,e)})),t.update_styles&&pa(d,o)}))},removeAllAttribs:e=>T(e,(e=>{const t=e.attributes;for(let n=t.length-1;n>=0;n--)e.removeAttributeNode(t.item(n))})),setAttrib:v,setAttribs:B,getAttrib:h,getPos:k,parseStyle:e=>d.parse(e),serializeStyle:(e,t)=>d.serialize(e,t),addStyle:t=>{if(G!==ba.DOM&&e===document){if(n[t])return;n[t]=!0}let o=e.getElementById("mceDefaultStyles");if(!o){o=e.createElement("style"),o.id="mceDefaultStyles",o.type="text/css";const t=e.head;t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o)}o.styleSheet?o.styleSheet.cssText+=t:o.appendChild(e.createTextNode(t))},loadCSS:e=>{e||(e=""),V(e.split(","),(e=>{r[e]=!0,a.load(e).catch(S)}))},addClass:(e,t)=>{F(e,t,!0)},removeClass:(e,t)=>{F(e,t,!1)},hasClass:(e,t)=>{const n=g(e),o=t.split(" ");return C(n)&&te(o,(e=>sn(n,e)))},toggleClass:F,show:e=>{T(e,(e=>Xn(mn(e),"display")))},hide:e=>{T(e,(e=>Vn(mn(e),"display","none")))},isHidden:e=>{const t=g(e);return C(t)&&Bt(Gn(t,"display"),"none")},uniqueId:e=>(e||"mce_")+s++,setHTML:D,getOuterHTML:e=>{const t=g(e);return C(t)?To(t.dom)?t.dom.outerHTML:(e=>{const t=cn("div"),n=mn(e.dom.cloneNode(!0));return eo(t,n),ao(t)})(t):""},setOuterHTML:(e,t)=>{T(e,(e=>{To(e)&&(e.outerHTML=t)}))},decode:Fs.decode,encode:M,insertAfter:(e,t)=>{const n=f(t);return T(e,(e=>{const t=null==n?void 0:n.parentNode,o=null==n?void 0:n.nextSibling;return t&&(o?t.insertBefore(e,o):t.appendChild(e)),e}))},replace:U,rename:(e,t)=>{if(e.nodeName!==t.toUpperCase()){const n=L(t);return la(b(e),(t=>{v(n,t.nodeName,h(e,t.nodeName))})),U(n,e,!0),n}return e},findCommonAncestor:(e,t)=>{let n=e;for(;n;){let e=t;for(;e&&n!==e;)e=e.parentNode;if(n===e)break;n=n.parentNode}return!n&&e.ownerDocument?e.ownerDocument.documentElement:n},run:T,getAttribs:b,isEmpty:(e,t)=>{let n=0;if(z(e))return!1;const o=e.firstChild;if(o){const r=new Ro(o,e),s=l?l.getWhitespaceElements():{},a=t||(l?l.getNonEmptyElements():null);let i=o;do{if(To(i)){const e=i.getAttribute("data-mce-bogus");if(e){i=r.next("all"===e);continue}const t=i.nodeName.toLowerCase();if(a&&a[t]){if("br"===t){n++,i=r.next();continue}return!1}if(z(i))return!1}if($o(i))return!1;if(zo(i)&&!Xr(i.data))return!1;if(zo(i)&&i.parentNode&&s[i.parentNode.nodeName]&&Xr(i.data))return!1;i=r.next()}while(i)}return n<=1},createRng:$,nodeIndex:ga,split:(e,t,n)=>{let o,r,s=$();if(e&&t&&e.parentNode&&t.parentNode){const a=e.parentNode;return s.setStart(a,ga(e)),s.setEnd(t.parentNode,ga(t)),o=s.extractContents(),s=$(),s.setStart(t.parentNode,ga(t)+1),s.setEnd(a,ga(e)+1),r=s.extractContents(),a.insertBefore(Ss(G,o),e),n?a.insertBefore(n,e):a.insertBefore(t,e),a.insertBefore(Ss(G,r),e),I(e),n||t}},bind:q,unbind:W,fire:(e,t,n)=>c.dispatch(e,t,n),dispatch:(e,t,n)=>c.dispatch(e,t,n),getContentEditable:K,getContentEditableParent:e=>{const t=x();let n=null;for(let o=e;o&&o!==t&&(n=K(o),null===n);o=o.parentNode);return n},destroy:()=>{if(i.length>0){let e=i.length;for(;e--;){const[t,n,o]=i[e];c.unbind(t,n,o)}}fe(r,((e,t)=>{a.unload(t),delete r[t]}))},isChildOf:(e,t)=>e===t||t.contains(e),dumpRng:e=>"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset},Y=((e,t,n)=>{const o=t.keep_values,r={set:(e,o,r)=>{const s=mn(e);w(t.url_converter)&&C(o)&&(o=t.url_converter.call(t.url_converter_scope||n(),String(o),r,e)),ma(s,"data-mce-"+r,o),ma(s,r,o)},get:(e,t)=>{const n=mn(e);return Wt(n,"data-mce-"+t)||Wt(n,t)}},s={style:{set:(t,n)=>{const r=mn(t);o&&ma(r,ca,n),Yt(r,"style"),m(n)&&qn(r,e.parse(n))},get:t=>{const n=mn(t),o=Wt(n,ca)||Wt(n,"style");return e.serialize(e.parse(o),Lt(n))}}};return o&&(s.href=s.src=r),s})(d,t,N(G));return G};ba.DOM=ba(document),ba.nodeIndex=ga;const va=ba.DOM;class ya{constructor(e={}){this.states={},this.queue=[],this.scriptLoadedCallbacks={},this.queueLoadedCallbacks=[],this.loading=!1,this.settings=e}_setReferrerPolicy(e){this.settings.referrerPolicy=e}loadScript(e){return new Promise(((t,n)=>{const o=va;let r;const s=()=>{o.remove(a),r&&(r.onerror=r.onload=r=null)},a=o.uniqueId();r=document.createElement("script"),r.id=a,r.type="text/javascript",r.src=Tt._addCacheSuffix(e),this.settings.referrerPolicy&&o.setAttrib(r,"referrerpolicy",this.settings.referrerPolicy),r.onload=()=>{s(),t()},r.onerror=()=>{s(),n("Failed to load script: "+e)},(document.getElementsByTagName("head")[0]||document.body).appendChild(r)}))}isDone(e){return 2===this.states[e]}markDone(e){this.states[e]=2}add(e){const t=this;return t.queue.push(e),void 0===t.states[e]&&(t.states[e]=0),new Promise(((n,o)=>{t.scriptLoadedCallbacks[e]||(t.scriptLoadedCallbacks[e]=[]),t.scriptLoadedCallbacks[e].push({resolve:n,reject:o})}))}load(e){return this.add(e)}remove(e){delete this.states[e],delete this.scriptLoadedCallbacks[e]}loadQueue(){const e=this.queue;return this.queue=[],this.loadScripts(e)}loadScripts(e){const t=this,n=(e,n)=>{we(t.scriptLoadedCallbacks,n).each((t=>{V(t,(t=>t[e](n)))})),delete t.scriptLoadedCallbacks[n]},o=e=>{const t=K(e,(e=>"rejected"===e.status));return t.length>0?Promise.reject(ee(t,(({reason:e})=>p(e)?e:[e]))):Promise.resolve()},r=e=>Promise.allSettled($(e,(e=>2===t.states[e]?(n("resolve",e),Promise.resolve()):3===t.states[e]?(n("reject",e),Promise.reject(e)):(t.states[e]=1,t.loadScript(e).then((()=>{t.states[e]=2,n("resolve",e);const s=t.queue;return s.length>0?(t.queue=[],r(s).then(o)):Promise.resolve()}),(()=>(t.states[e]=3,n("reject",e),Promise.reject(e)))))))),s=e=>(t.loading=!0,r(e).then((e=>{t.loading=!1;const n=t.queueLoadedCallbacks.shift();return M.from(n).each(D),o(e)}))),a=Se(e);return t.loading?new Promise(((e,n)=>{t.queueLoadedCallbacks.push((()=>s(a).then(e,n)))})):s(a)}}ya.ScriptLoader=new ya;const Ca=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},wa={},xa=Ca("en"),ka=()=>we(wa,xa.get()),Sa={getData:()=>ge(wa,(e=>({...e}))),setCode:e=>{e&&xa.set(e)},getCode:()=>xa.get(),add:(e,t)=>{let n=wa[e];n||(wa[e]=n={}),fe(t,((e,t)=>{n[t.toLowerCase()]=e}))},translate:e=>{const t=ka().getOr({}),n=e=>w(e)?Object.prototype.toString.call(e):o(e)?"":""+e,o=e=>""===e||null==e,r=e=>{const o=n(e);return we(t,o.toLowerCase()).map(n).getOr(o)},s=e=>e.replace(/{context:\w+}$/,"");if(o(e))return"";if(f(a=e)&&xe(a,"raw"))return n(e.raw);var a;if((e=>p(e)&&e.length>1)(e)){const t=e.slice(1);return s(r(e[0]).replace(/\{([0-9]+)\}/g,((e,o)=>xe(t,o)?n(t[o]):e)))}return s(r(e))},isRtl:()=>ka().bind((e=>we(e,"_dir"))).exists((e=>"rtl"===e)),hasCode:e=>xe(wa,e)},_a=()=>{const e=[],t={},n={},o=[],r=(e,t)=>{const n=K(o,(n=>n.name===e&&n.state===t));V(n,(e=>e.resolve()))},s=e=>xe(t,e),a=(e,n)=>{const o=Sa.getCode();!o||n&&-1===(","+(n||"")+",").indexOf(","+o+",")||ya.ScriptLoader.add(t[e]+"/langs/"+o+".js")},i=(e,t="added")=>"added"===t&&(e=>xe(n,e))(e)||"loaded"===t&&s(e)?Promise.resolve():new Promise((n=>{o.push({name:e,state:t,resolve:n})}));return{items:e,urls:t,lookup:n,get:e=>{if(n[e])return n[e].instance},requireLangPack:(e,t)=>{!1!==_a.languageLoad&&(s(e)?a(e,t):i(e,"loaded").then((()=>a(e,t))))},add:(t,o)=>(e.push(o),n[t]={instance:o},r(t,"added"),o),remove:e=>{delete t[e],delete n[e]},createUrl:(e,t)=>m(t)?m(e)?{prefix:"",resource:t,suffix:""}:{prefix:e.prefix,resource:t,suffix:e.suffix}:t,load:(e,o)=>{if(t[e])return Promise.resolve();let s=m(o)?o:o.prefix+o.resource+o.suffix;0!==s.indexOf("/")&&-1===s.indexOf("://")&&(s=_a.baseURL+"/"+s),t[e]=s.substring(0,s.lastIndexOf("/"));const a=()=>(r(e,"loaded"),Promise.resolve());return n[e]?a():ya.ScriptLoader.add(s).then(a)},waitFor:i}};_a.languageLoad=!0,_a.baseURL="",_a.PluginManager=_a(),_a.ThemeManager=_a(),_a.ModelManager=_a();const Ea=e=>{const t=Ca(M.none()),n=()=>t.get().each((e=>clearInterval(e)));return{clear:()=>{n(),t.set(M.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:o=>{n(),t.set(M.some(setInterval(o,e)))}}},Na=()=>{const e=(e=>{const t=Ca(M.none()),n=()=>t.get().each(e);return{clear:()=>{n(),t.set(M.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{n(),t.set(M.some(e))}}})(S);return{...e,on:t=>e.get().each(t)}},Ra=(e,t)=>{let n=null;return{cancel:()=>{h(n)||(clearTimeout(n),n=null)},throttle:(...o)=>{h(n)&&(n=setTimeout((()=>{n=null,e.apply(null,o)}),t))}}},Aa=(e,t)=>{let n=null;const o=()=>{h(n)||(clearTimeout(n),n=null)};return{cancel:o,throttle:(...r)=>{o(),n=setTimeout((()=>{n=null,e.apply(null,r)}),t)}}},Oa=N("mce-annotation"),Ta=N("data-mce-annotation"),Ba=N("data-mce-annotation-uid"),Da=N("data-mce-annotation-active"),Pa=N("data-mce-annotation-classes"),La=N("data-mce-annotation-attrs"),Ma=e=>t=>bn(t,e),Ia=(e,t)=>{const n=e.selection.getRng(),o=mn(n.startContainer),r=mn(e.getBody()),s=t.fold((()=>"."+Oa()),(e=>`[${Ta()}="${e}"]`)),a=On(o,n.startOffset).getOr(o);return Eo(a,s,Ma(r)).bind((t=>Kt(t,`${Ba()}`).bind((n=>Kt(t,`${Ta()}`).map((t=>{const o=Ua(e,n);return{uid:n,name:t,elements:o}}))))))},Fa=(e,t)=>Gt(e,"data-mce-bogus")||No(e,'[data-mce-bogus="all"]',Ma(t)),Ua=(e,t)=>{const n=mn(e.getBody()),o=or(n,`[${Ba()}="${t}"]`);return K(o,(e=>!Fa(e,n)))},za=(e,t)=>{const n=mn(e.getBody()),o=or(n,`[${Ta()}="${t}"]`),r={};return V(o,(e=>{if(!Fa(e,n)){const t=Wt(e,Ba()),n=we(r,t).getOr([]);r[t]=n.concat([e])}})),r};let ja=0;const Ha=e=>{const t=(new Date).getTime(),n=Math.floor(1e9*Math.random());return ja++,e+"_"+n+ja+String(t)},$a=(e,t)=>mn(e.dom.cloneNode(t)),Va=e=>$a(e,!1),qa=e=>$a(e,!0),Wa=(e,t,n=P)=>{const o=new Ro(e,t),r=e=>{let t;do{t=o[e]()}while(t&&!zo(t)&&!n(t));return M.from(t).filter(zo)};return{current:()=>M.from(o.current()).filter(zo),next:()=>r("next"),prev:()=>r("prev"),prev2:()=>r("prev2")}},Ka=(e,t)=>{const n=t||(t=>e.isBlock(t)||Wo(t)||Yo(t)),o=(e,t,n,r)=>{if(zo(e)){const n=r(e,t,e.data);if(-1!==n)return M.some({container:e,offset:n})}return n().bind((e=>o(e.container,e.offset,n,r)))};return{backwards:(t,r,s,a)=>{const i=Wa(t,null!=a?a:e.getRoot(),n);return o(t,r,(()=>i.prev().map((e=>({container:e,offset:e.length})))),s).getOrNull()},forwards:(t,r,s,a)=>{const i=Wa(t,null!=a?a:e.getRoot(),n);return o(t,r,(()=>i.next().map((e=>({container:e,offset:0})))),s).getOrNull()}}},Ga=Math.round,Ya=e=>e?{left:Ga(e.left),top:Ga(e.top),bottom:Ga(e.bottom),right:Ga(e.right),width:Ga(e.width),height:Ga(e.height)}:{left:0,top:0,bottom:0,right:0,width:0,height:0},Xa=(e,t)=>(e=Ya(e),t||(e.left=e.left+e.width),e.right=e.left,e.width=0,e),Qa=(e,t,n)=>e>=0&&e<=Math.min(t.height,n.height)/2,Ja=(e,t)=>{const n=Math.min(t.height/2,e.height/2);return e.bottom-n<t.top||!(e.top>t.bottom)&&Qa(t.top-e.bottom,e,t)},Za=(e,t)=>e.top>t.bottom||!(e.bottom<t.top)&&Qa(t.bottom-e.top,e,t),ei=(e,t,n)=>{const o=Math.max(Math.min(t,e.left+e.width),e.left),r=Math.max(Math.min(n,e.top+e.height),e.top);return Math.sqrt((t-o)*(t-o)+(n-r)*(n-r))},ti=e=>{const t=e.startContainer,n=e.startOffset;return t===e.endContainer&&t.hasChildNodes()&&e.endOffset===n+1?t.childNodes[n]:null},ni=(e,t)=>{if(To(e)&&e.hasChildNodes()){const n=e.childNodes,o=((e,t,n)=>Math.min(Math.max(e,0),n))(t,0,n.length-1);return n[o]}return e},oi=new RegExp("[\u0300-\u036f\u0483-\u0487\u0488-\u0489\u0591-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e3-\u0902\u093a\u093c\u0941-\u0948\u094d\u0951-\u0957\u0962-\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a02\u0a3c\u0a41-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a51\u0a70-\u0a71\u0a75\u0a81-\u0a82\u0abc\u0ac1-\u0ac5\u0ac7-\u0ac8\u0acd\u0ae2-\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62-\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c00\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c62-\u0c63\u0c81\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc-\u0ccd\u0cd5-\u0cd6\u0ce2-\u0ce3\u0d01\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62-\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039-\u103a\u103d-\u103e\u1058-\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108d\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b4-\u17b5\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193b\u1a17-\u1a18\u1a1b\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1ab0-\u1abd\u1abe\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80-\u1b81\u1ba2-\u1ba5\u1ba8-\u1ba9\u1bab-\u1bad\u1be6\u1be8-\u1be9\u1bed\u1bef-\u1bf1\u1c2c-\u1c33\u1c36-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1cf4\u1cf8-\u1cf9\u1dc0-\u1df5\u1dfc-\u1dff\u200c-\u200d\u20d0-\u20dc\u20dd-\u20e0\u20e1\u20e2-\u20e4\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302d\u302e-\u302f\u3099-\u309a\ua66f\ua670-\ua672\ua674-\ua67d\ua69e-\ua69f\ua6f0-\ua6f1\ua802\ua806\ua80b\ua825-\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\ua9e5\uaa29-\uaa2e\uaa31-\uaa32\uaa35-\uaa36\uaa43\uaa4c\uaa7c\uaab0\uaab2-\uaab4\uaab7-\uaab8\uaabe-\uaabf\uaac1\uaaec-\uaaed\uaaf6\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\uff9e-\uff9f]"),ri=e=>m(e)&&e.charCodeAt(0)>=768&&oi.test(e),si=To,ai=Wr,ii=Po("display","block table"),li=Po("float","left right"),di=((...e)=>t=>{for(let n=0;n<e.length;n++)if(!e[n](t))return!1;return!0})(si,ai,T(li)),ci=T(Po("white-space","pre pre-line pre-wrap")),ui=zo,mi=Wo,fi=ba.nodeIndex,gi=(e,t)=>t<0&&To(e)&&e.hasChildNodes()?void 0:ni(e,t),pi=e=>e?e.createRange():ba.DOM.createRng(),hi=e=>m(e)&&/[\r\n\t ]/.test(e),bi=e=>!!e.setStart&&!!e.setEnd,vi=e=>{const t=e.startContainer,n=e.startOffset;if(hi(e.toString())&&ci(t.parentNode)&&zo(t)){const e=t.data;if(hi(e[n-1])||hi(e[n+1]))return!0}return!1},yi=e=>0===e.left&&0===e.right&&0===e.top&&0===e.bottom,Ci=e=>{var t;let n;const o=e.getClientRects();return n=o.length>0?Ya(o[0]):Ya(e.getBoundingClientRect()),!bi(e)&&mi(e)&&yi(n)?(e=>{const t=e.ownerDocument,n=pi(t),o=t.createTextNode(tr),r=e.parentNode;r.insertBefore(o,e),n.setStart(o,0),n.setEnd(o,1);const s=Ya(n.getBoundingClientRect());return r.removeChild(o),s})(e):yi(n)&&bi(e)&&null!==(t=(e=>{const t=e.startContainer,n=e.endContainer,o=e.startOffset,r=e.endOffset;if(t===n&&zo(n)&&0===o&&1===r){const t=e.cloneRange();return t.setEndAfter(n),Ci(t)}return null})(e))&&void 0!==t?t:n},wi=(e,t)=>{const n=Xa(e,t);return n.width=1,n.right=n.left+1,n},xi=(e,t,n)=>{const o=()=>(n||(n=(e=>{const t=[],n=e=>{var n,o;0!==e.height&&(t.length>0&&(n=e,o=t[t.length-1],n.left===o.left&&n.top===o.top&&n.bottom===o.bottom&&n.right===o.right)||t.push(e))},o=(e,t)=>{const o=pi(e.ownerDocument);if(t<e.data.length){if(ri(e.data[t]))return;if(ri(e.data[t-1])&&(o.setStart(e,t),o.setEnd(e,t+1),!vi(o)))return void n(wi(Ci(o),!1))}t>0&&(o.setStart(e,t-1),o.setEnd(e,t),vi(o)||n(wi(Ci(o),!1))),t<e.data.length&&(o.setStart(e,t),o.setEnd(e,t+1),vi(o)||n(wi(Ci(o),!0)))},r=e.container(),s=e.offset();if(ui(r))return o(r,s),t;if(si(r))if(e.isAtEnd()){const e=gi(r,s);ui(e)&&o(e,e.data.length),di(e)&&!mi(e)&&n(wi(Ci(e),!1))}else{const a=gi(r,s);if(ui(a)&&o(a,0),di(a)&&e.isAtEnd())return n(wi(Ci(a),!1)),t;const i=gi(e.container(),e.offset()-1);di(i)&&!mi(i)&&(ii(i)||ii(a)||!di(a))&&n(wi(Ci(i),!1)),di(a)&&n(wi(Ci(a),!0))}return t})(xi(e,t))),n);return{container:N(e),offset:N(t),toRange:()=>{const n=pi(e.ownerDocument);return n.setStart(e,t),n.setEnd(e,t),n},getClientRects:o,isVisible:()=>o().length>0,isAtStart:()=>(ui(e),0===t),isAtEnd:()=>ui(e)?t>=e.data.length:t>=e.childNodes.length,isEqual:n=>n&&e===n.container()&&t===n.offset(),getNode:n=>gi(e,n?t-1:t)}};xi.fromRangeStart=e=>xi(e.startContainer,e.startOffset),xi.fromRangeEnd=e=>xi(e.endContainer,e.endOffset),xi.after=e=>xi(e.parentNode,fi(e)+1),xi.before=e=>xi(e.parentNode,fi(e)),xi.isAbove=(e,t)=>Dt(ie(t.getClientRects()),le(e.getClientRects()),Ja).getOr(!1),xi.isBelow=(e,t)=>Dt(le(t.getClientRects()),ie(e.getClientRects()),Za).getOr(!1),xi.isAtStart=e=>!!e&&e.isAtStart(),xi.isAtEnd=e=>!!e&&e.isAtEnd(),xi.isTextPosition=e=>!!e&&zo(e.container()),xi.isElementPosition=e=>!xi.isTextPosition(e);const ki=(e,t)=>{zo(t)&&0===t.data.length&&e.remove(t)},Si=(e,t,n)=>{qo(n)?((e,t,n)=>{const o=M.from(n.firstChild),r=M.from(n.lastChild);t.insertNode(n),o.each((t=>ki(e,t.previousSibling))),r.each((t=>ki(e,t.nextSibling)))})(e,t,n):((e,t,n)=>{t.insertNode(n),ki(e,n.previousSibling),ki(e,n.nextSibling)})(e,t,n)},_i=zo,Ei=Mo,Ni=ba.nodeIndex,Ri=e=>{const t=e.parentNode;return Ei(t)?Ri(t):t},Ai=e=>e?Oe(e.childNodes,((e,t)=>(Ei(t)&&"BR"!==t.nodeName?e=e.concat(Ai(t)):e.push(t),e)),[]):[],Oi=e=>t=>e===t,Ti=e=>(_i(e)?"text()":e.nodeName.toLowerCase())+"["+(e=>{let t,n;t=Ai(Ri(e)),n=Te(t,Oi(e),e),t=t.slice(0,n+1);const o=Oe(t,((e,n,o)=>(_i(n)&&_i(t[o-1])&&e++,e)),0);return t=Ae(t,Do([e.nodeName])),n=Te(t,Oi(e),e),n-o})(e)+"]",Bi=(e,t)=>{let n,o=[],r=t.container(),s=t.offset();if(_i(r))n=((e,t)=>{let n=e;for(;(n=n.previousSibling)&&_i(n);)t+=n.data.length;return t})(r,s);else{const e=r.childNodes;s>=e.length?(n="after",s=e.length-1):n="before",r=e[s]}o.push(Ti(r));let a=((e,t,n)=>{const o=[];for(let n=t.parentNode;n&&n!==e;n=n.parentNode)o.push(n);return o})(e,r);return a=Ae(a,T(Mo)),o=o.concat(Re(a,(e=>Ti(e)))),o.reverse().join("/")+","+n},Di=(e,t)=>{if(!t)return null;const n=t.split(","),o=n[0].split("/"),r=n.length>1?n[1]:"before",s=Oe(o,((e,t)=>{const n=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(t);return n?("text()"===n[1]&&(n[1]="#text"),((e,t,n)=>{let o=Ai(e);return o=Ae(o,((e,t)=>!_i(e)||!_i(o[t-1]))),o=Ae(o,Do([t])),o[n]})(e,n[1],parseInt(n[2],10))):null}),e);if(!s)return null;if(!_i(s)&&s.parentNode){let e;return e="after"===r?Ni(s)+1:Ni(s),xi(s.parentNode,e)}return((e,t)=>{let n=e,o=0;for(;_i(n);){const r=n.data.length;if(t>=o&&t<=o+r){e=n,t-=o;break}if(!_i(n.nextSibling)){e=n,t=r;break}o+=r,n=n.nextSibling}return _i(e)&&t>e.data.length&&(t=e.data.length),xi(e,t)})(s,parseInt(r,10))},Pi=Yo,Li=(e,t,n,o,r)=>{const s=r?o.startContainer:o.endContainer;let a=r?o.startOffset:o.endOffset;const i=[],l=e.getRoot();if(zo(s))i.push(n?((e,t,n)=>{let o=e(t.data.slice(0,n)).length;for(let n=t.previousSibling;n&&zo(n);n=n.previousSibling)o+=e(n.data).length;return o})(t,s,a):a);else{let t=0;const o=s.childNodes;a>=o.length&&o.length&&(t=1,a=Math.max(0,o.length-1)),i.push(e.nodeIndex(o[a],n)+t)}for(let t=s;t&&t!==l;t=t.parentNode)i.push(e.nodeIndex(t,n));return i},Mi=(e,t,n)=>{let o=0;return Tt.each(e.select(t),(e=>"all"===e.getAttribute("data-mce-bogus")?void 0:e!==n&&void o++)),o},Ii=(e,t)=>{let n=t?e.startContainer:e.endContainer,o=t?e.startOffset:e.endOffset;if(To(n)&&"TR"===n.nodeName){const r=n.childNodes;n=r[Math.min(t?o:o-1,r.length-1)],n&&(o=t?0:n.childNodes.length,t?e.setStart(n,o):e.setEnd(n,o))}},Fi=e=>(Ii(e,!0),Ii(e,!1),e),Ui=(e,t)=>{if(To(e)&&(e=ni(e,t),Pi(e)))return e;if(Or(e)){zo(e)&&Rr(e)&&(e=e.parentNode);let t=e.previousSibling;if(Pi(t))return t;if(t=e.nextSibling,Pi(t))return t}},zi=(e,t,n)=>{const o=n.getNode(),r=n.getRng();if("IMG"===o.nodeName||Pi(o)){const e=o.nodeName;return{name:e,index:Mi(n.dom,e,o)}}const s=(e=>Ui(e.startContainer,e.startOffset)||Ui(e.endContainer,e.endOffset))(r);if(s){const e=s.tagName;return{name:e,index:Mi(n.dom,e,s)}}return((e,t,n,o)=>{const r=t.dom,s=Li(r,e,n,o,!0),a=t.isForward(),i=Ir(o)?{isFakeCaret:!0}:{};return t.isCollapsed()?{start:s,forward:a,...i}:{start:s,end:Li(r,e,n,o,!1),forward:a,...i}})(e,n,t,r)},ji=(e,t,n)=>{const o={"data-mce-type":"bookmark",id:t,style:"overflow:hidden;line-height:0px"};return n?e.create("span",o,"&#xFEFF;"):e.create("span",o)},Hi=(e,t)=>{const n=e.dom;let o=e.getRng();const r=n.uniqueId(),s=e.isCollapsed(),a=e.getNode(),i=a.nodeName,l=e.isForward();if("IMG"===i)return{name:i,index:Mi(n,i,a)};const d=Fi(o.cloneRange());if(!s){d.collapse(!1);const e=ji(n,r+"_end",t);Si(n,d,e)}o=Fi(o),o.collapse(!0);const c=ji(n,r+"_start",t);return Si(n,o,c),e.moveToBookmark({id:r,keep:!0,forward:l}),{id:r,forward:l}},$i=O(zi,R,!0),Vi=e=>{const t=t=>t(e),n=N(e),o=()=>r,r={tag:!0,inner:e,fold:(t,n)=>n(e),isValue:L,isError:P,map:t=>Wi.value(t(e)),mapError:o,bind:t,exists:t,forall:t,getOr:n,or:o,getOrThunk:n,orThunk:o,getOrDie:n,each:t=>{t(e)},toOptional:()=>M.some(e)};return r},qi=e=>{const t=()=>n,n={tag:!1,inner:e,fold:(t,n)=>t(e),isValue:P,isError:L,map:t,mapError:t=>Wi.error(t(e)),bind:t,exists:P,forall:L,getOr:R,or:R,getOrThunk:B,orThunk:B,getOrDie:(o=String(e),()=>{throw new Error(o)}),each:S,toOptional:M.none};var o;return n},Wi={value:Vi,error:qi,fromOption:(e,t)=>e.fold((()=>qi(t)),Vi)},Ki=e=>{if(!p(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],n={};return V(e,((o,r)=>{const s=ue(o);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=o[a];if(void 0!==n[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!p(i))throw new Error("case arguments must be an array");t.push(a),n[a]=(...n)=>{const o=n.length;if(o!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+o);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,n)},match:e=>{const o=ue(e);if(t.length!==o.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+o.join(","));if(!te(t,(e=>j(o,e))))throw new Error("Not all branches were specified when using match. Specified: "+o.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,n)},log:e=>{console.log(e,{constructors:t,constructor:a,params:n})}}}})),n};Ki([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Gi=e=>"inline-command"===e.type||"inline-format"===e.type,Yi=e=>"block-command"===e.type||"block-format"===e.type,Xi=e=>{const t=t=>Wi.error({message:t,pattern:e}),n=(n,o,r)=>{if(void 0!==e.format){let r;if(p(e.format)){if(!te(e.format,m))return t(n+" pattern has non-string items in the `format` array");r=e.format}else{if(!m(e.format))return t(n+" pattern has non-string `format` parameter");r=[e.format]}return Wi.value(o(r))}return void 0!==e.cmd?m(e.cmd)?Wi.value(r(e.cmd,e.value)):t(n+" pattern has non-string `cmd` parameter"):t(n+" pattern is missing both `format` and `cmd` parameters")};if(!f(e))return t("Raw pattern is not an object");if(!m(e.start))return t("Raw pattern is missing `start` parameter");if(void 0!==e.end){if(!m(e.end))return t("Inline pattern has non-string `end` parameter");if(0===e.start.length&&0===e.end.length)return t("Inline pattern has empty `start` and `end` parameters");let o=e.start,r=e.end;return 0===r.length&&(r=o,o=""),n("Inline",(e=>({type:"inline-format",start:o,end:r,format:e})),((e,t)=>({type:"inline-command",start:o,end:r,cmd:e,value:t})))}return void 0!==e.replacement?m(e.replacement)?0===e.start.length?t("Replacement pattern has empty `start` parameter"):Wi.value({type:"inline-command",start:"",end:e.start,cmd:"mceInsertContent",value:e.replacement}):t("Replacement pattern has non-string `replacement` parameter"):0===e.start.length?t("Block pattern has empty `start` parameter"):n("Block",(t=>({type:"block-format",start:e.start,format:t[0]})),((t,n)=>({type:"block-command",start:e.start,cmd:t,value:n})))},Qi=e=>K(e,Yi),Ji=e=>K(e,Gi),Zi=e=>{const t=(e=>{const t=[],n=[];return V(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{n.push(e)}))})),{errors:t,values:n}})($(e,Xi));return V(t.errors,(e=>console.error(e.message,e.pattern))),t.values},el=Ct().deviceType,tl=el.isTouch(),nl=ba.DOM,ol=e=>u(e,RegExp),rl=e=>t=>t.options.get(e),sl=e=>m(e)||f(e),al=(e,t="")=>n=>{const o=m(n);if(o){if(-1!==n.indexOf("=")){const r=(e=>{const t=e.indexOf("=")>0?e.split(/[;,](?![^=;,]*(?:[;,]|$))/):e.split(",");return Y(t,((e,t)=>{const n=t.split("="),o=n[0],r=n.length>1?n[1]:o;return e[$e(o)]=$e(r),e}),{})})(n);return{value:we(r,e.id).getOr(t),valid:o}}return{value:n,valid:o}}return{valid:!1,message:"Must be a string."}},il=rl("iframe_attrs"),ll=rl("doctype"),dl=rl("document_base_url"),cl=rl("body_id"),ul=rl("body_class"),ml=rl("content_security_policy"),fl=rl("br_in_pre"),gl=rl("forced_root_block"),pl=rl("forced_root_block_attrs"),hl=rl("newline_behavior"),bl=rl("br_newline_selector"),vl=rl("no_newline_selector"),yl=rl("keep_styles"),Cl=rl("end_container_on_empty_block"),wl=rl("automatic_uploads"),xl=rl("images_reuse_filename"),kl=rl("images_replace_blob_uris"),Sl=rl("icons"),_l=rl("icons_url"),El=rl("images_upload_url"),Nl=rl("images_upload_base_path"),Rl=rl("images_upload_credentials"),Al=rl("images_upload_handler"),Ol=rl("content_css_cors"),Tl=rl("referrer_policy"),Bl=rl("language"),Dl=rl("language_url"),Pl=rl("indent_use_margin"),Ll=rl("indentation"),Ml=rl("content_css"),Il=rl("content_style"),Fl=rl("font_css"),Ul=rl("directionality"),zl=rl("inline_boundaries_selector"),jl=rl("object_resizing"),Hl=rl("resize_img_proportional"),$l=rl("placeholder"),Vl=rl("event_root"),ql=rl("service_message"),Wl=rl("theme"),Kl=rl("theme_url"),Gl=rl("model"),Yl=rl("model_url"),Xl=rl("inline_boundaries"),Ql=rl("formats"),Jl=rl("preview_styles"),Zl=rl("format_empty_lines"),ed=rl("format_noneditable_selector"),td=rl("custom_ui_selector"),nd=rl("inline"),od=rl("hidden_input"),rd=rl("submit_patch"),sd=rl("add_form_submit_trigger"),ad=rl("add_unload_trigger"),id=rl("custom_undo_redo_levels"),ld=rl("disable_nodechange"),dd=rl("readonly"),cd=rl("content_css_cors"),ud=rl("plugins"),md=rl("external_plugins"),fd=rl("block_unsupported_drop"),gd=rl("visual"),pd=rl("visual_table_class"),hd=rl("visual_anchor_class"),bd=rl("iframe_aria_text"),vd=rl("setup"),yd=rl("init_instance_callback"),Cd=rl("urlconverter_callback"),wd=rl("auto_focus"),xd=rl("browser_spellcheck"),kd=rl("protect"),Sd=rl("paste_block_drop"),_d=rl("paste_data_images"),Ed=rl("paste_preprocess"),Nd=rl("paste_postprocess"),Rd=rl("paste_webkit_styles"),Ad=rl("paste_remove_styles_if_webkit"),Od=rl("paste_merge_formats"),Td=rl("smart_paste"),Bd=rl("paste_as_text"),Dd=rl("paste_tab_spaces"),Pd=rl("allow_html_data_urls"),Ld=rl("text_patterns"),Md=rl("text_patterns_lookup"),Id=rl("noneditable_class"),Fd=rl("editable_class"),Ud=rl("noneditable_regexp"),zd=rl("preserve_cdata"),jd=e=>Tt.explode(e.options.get("images_file_types")),Hd=rl("table_tab_navigation"),$d=To,Vd=zo,qd=e=>{const t=e.parentNode;t&&t.removeChild(e)},Wd=e=>{const t=_r(e);return{count:e.length-t.length,text:t}},Kd=e=>{let t;for(;-1!==(t=e.data.lastIndexOf(kr));)e.deleteData(t,1)},Gd=(e,t)=>(Xd(e),t),Yd=(e,t)=>xi.isTextPosition(t)?((e,t)=>Vd(e)&&t.container()===e?((e,t)=>{const n=Wd(e.data.substr(0,t.offset())),o=Wd(e.data.substr(t.offset()));return(n.text+o.text).length>0?(Kd(e),xi(e,t.offset()-n.count)):t})(e,t):Gd(e,t))(e,t):((e,t)=>t.container()===e.parentNode?((e,t)=>{const n=t.container(),o=((e,t)=>{const n=z(e,t);return-1===n?M.none():M.some(n)})(de(n.childNodes),e).map((e=>e<t.offset()?xi(n,t.offset()-1):t)).getOr(t);return Xd(e),o})(e,t):Gd(e,t))(e,t),Xd=e=>{$d(e)&&Or(e)&&(Tr(e)?e.removeAttribute("data-mce-caret"):qd(e)),Vd(e)&&(Kd(e),0===e.data.length&&qd(e))},Qd=Yo,Jd=Jo,Zd=Xo,ec=(e,t,n)=>{const o=Xa(t.getBoundingClientRect(),n);let r,s;if("BODY"===e.tagName){const t=e.ownerDocument.documentElement;r=e.scrollLeft||t.scrollLeft,s=e.scrollTop||t.scrollTop}else{const t=e.getBoundingClientRect();r=e.scrollLeft-t.left,s=e.scrollTop-t.top}o.left+=r,o.right+=r,o.top+=s,o.bottom+=s,o.width=1;let a=t.offsetWidth-t.clientWidth;return a>0&&(n&&(a*=-1),o.left+=a,o.right+=a),o},tc=(e,t,n,o)=>{const r=Na();let s,a;const i=gl(e),l=e.dom,d=()=>{(e=>{var t,n;const o=or(mn(e),"*[contentEditable=false],video,audio,embed,object");for(let e=0;e<o.length;e++){const r=o[e].dom;let s=r.previousSibling;if(Lr(s)){const e=s.data;1===e.length?null===(t=s.parentNode)||void 0===t||t.removeChild(s):s.deleteData(e.length-1,1)}s=r.nextSibling,Pr(s)&&(1===s.data.length?null===(n=s.parentNode)||void 0===n||n.removeChild(s):s.deleteData(0,1))}})(t),a&&(Xd(a),a=null),r.on((e=>{l.remove(e.caret),r.clear()})),s&&(clearInterval(s),s=void 0)};return{show:(e,c)=>{let u;if(d(),Zd(c))return null;if(!n(c))return a=((e,t)=>{var n;const o=(null!==(n=e.ownerDocument)&&void 0!==n?n:document).createTextNode(kr),r=e.parentNode;if(t){const t=e.previousSibling;if(Nr(t)){if(Or(t))return t;if(Lr(t))return t.splitText(t.data.length-1)}null==r||r.insertBefore(o,e)}else{const t=e.nextSibling;if(Nr(t)){if(Or(t))return t;if(Pr(t))return t.splitText(1),t}e.nextSibling?null==r||r.insertBefore(o,e.nextSibling):null==r||r.appendChild(o)}return o})(c,e),u=c.ownerDocument.createRange(),oc(a.nextSibling)?(u.setStart(a,0),u.setEnd(a,0)):(u.setStart(a,1),u.setEnd(a,1)),u;{const n=((e,t,n)=>{var o;const r=(null!==(o=t.ownerDocument)&&void 0!==o?o:document).createElement(e);r.setAttribute("data-mce-caret",n?"before":"after"),r.setAttribute("data-mce-bogus","all"),r.appendChild(Cr().dom);const s=t.parentNode;return n?null==s||s.insertBefore(r,t):t.nextSibling?null==s||s.insertBefore(r,t.nextSibling):null==s||s.appendChild(r),r})(i,c,e),d=ec(t,c,e);l.setStyle(n,"top",d.top),a=n;const m=l.create("div",{class:"mce-visual-caret","data-mce-bogus":"all"});l.setStyles(m,{...d}),l.add(t,m),r.set({caret:m,element:c,before:e}),e&&l.addClass(m,"mce-visual-caret-before"),s=setInterval((()=>{r.on((e=>{o()?l.toggleClass(e.caret,"mce-visual-caret-hidden"):l.addClass(e.caret,"mce-visual-caret-hidden")}))}),500),u=c.ownerDocument.createRange(),u.setStart(n,0),u.setEnd(n,0)}return u},hide:d,getCss:()=>".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}",reposition:()=>{r.on((e=>{const n=ec(t,e.element,e.before);l.setStyles(e.caret,{...n})}))},destroy:()=>clearInterval(s)}},nc=()=>Nt.browser.isFirefox(),oc=e=>Qd(e)||Jd(e),rc=e=>oc(e)||Io(e)&&nc(),sc=Go,ac=Yo,ic=Jo,lc=Po("display","block table table-cell table-caption list-item"),dc=Or,cc=Rr,uc=To,mc=zo,fc=Wr,gc=e=>e>0,pc=e=>e<0,hc=(e,t)=>{let n;for(;n=e(t);)if(!cc(n))return n;return null},bc=(e,t,n,o,r)=>{const s=new Ro(e,o),a=ac(e)||cc(e);let i;if(pc(t)){if(a&&(i=hc(s.prev.bind(s),!0),n(i)))return i;for(;i=hc(s.prev.bind(s),r);)if(n(i))return i}if(gc(t)){if(a&&(i=hc(s.next.bind(s),!0),n(i)))return i;for(;i=hc(s.next.bind(s),r);)if(n(i))return i}return null},vc=(e,t)=>{for(;e&&e!==t;){if(lc(e))return e;e=e.parentNode}return null},yc=(e,t,n)=>vc(e.container(),n)===vc(t.container(),n),Cc=(e,t)=>{if(!t)return M.none();const n=t.container(),o=t.offset();return uc(n)?M.from(n.childNodes[o+e]):M.none()},wc=(e,t)=>{var n;const o=(null!==(n=t.ownerDocument)&&void 0!==n?n:document).createRange();return e?(o.setStartBefore(t),o.setEndBefore(t)):(o.setStartAfter(t),o.setEndAfter(t)),o},xc=(e,t,n)=>vc(t,e)===vc(n,e),kc=(e,t,n)=>{const o=e?"previousSibling":"nextSibling";let r=n;for(;r&&r!==t;){let e=r[o];if(e&&dc(e)&&(e=e[o]),ac(e)||ic(e)){if(xc(t,e,r))return e;break}if(fc(e))break;r=r.parentNode}return null},Sc=O(wc,!0),_c=O(wc,!1),Ec=(e,t,n)=>{let o;const r=O(kc,!0,t),s=O(kc,!1,t),a=n.startContainer,i=n.startOffset;if(Rr(a)){const e=mc(a)?a.parentNode:a,t=e.getAttribute("data-mce-caret");if("before"===t&&(o=e.nextSibling,rc(o)))return Sc(o);if("after"===t&&(o=e.previousSibling,rc(o)))return _c(o)}if(!n.collapsed)return n;if(zo(a)){if(dc(a)){if(1===e){if(o=s(a),o)return Sc(o);if(o=r(a),o)return _c(o)}if(-1===e){if(o=r(a),o)return _c(o);if(o=s(a),o)return Sc(o)}return n}if(Lr(a)&&i>=a.data.length-1)return 1===e&&(o=s(a),o)?Sc(o):n;if(Pr(a)&&i<=1)return-1===e&&(o=r(a),o)?_c(o):n;if(i===a.data.length)return o=s(a),o?Sc(o):n;if(0===i)return o=r(a),o?_c(o):n}return n},Nc=(e,t)=>Cc(e?0:-1,t).filter(ac),Rc=(e,t,n)=>{const o=Ec(e,t,n);return-1===e?xi.fromRangeStart(o):xi.fromRangeEnd(o)},Ac=e=>M.from(e.getNode()).map(mn),Oc=(e,t)=>{let n=t;for(;n=e(n);)if(n.isVisible())return n;return n},Tc=(e,t)=>{const n=yc(e,t);return!(n||!Wo(e.getNode()))||n};var Bc;!function(e){e[e.Backwards=-1]="Backwards",e[e.Forwards=1]="Forwards"}(Bc||(Bc={}));const Dc=Yo,Pc=zo,Lc=To,Mc=Wo,Ic=Wr,Fc=e=>$r(e)||(e=>!!Kr(e)&&!Y(de(e.getElementsByTagName("*")),((e,t)=>e||Fr(t)),!1))(e),Uc=Gr,zc=(e,t)=>e.hasChildNodes()&&t<e.childNodes.length?e.childNodes[t]:null,jc=(e,t)=>{if(gc(e)){if(Ic(t.previousSibling)&&!Pc(t.previousSibling))return xi.before(t);if(Pc(t))return xi(t,0)}if(pc(e)){if(Ic(t.nextSibling)&&!Pc(t.nextSibling))return xi.after(t);if(Pc(t))return xi(t,t.data.length)}return pc(e)?Mc(t)?xi.before(t):xi.after(t):xi.before(t)},Hc=(e,t,n)=>{let o,r,s,a;if(!Lc(n)||!t)return null;if(t.isEqual(xi.after(n))&&n.lastChild){if(a=xi.after(n.lastChild),pc(e)&&Ic(n.lastChild)&&Lc(n.lastChild))return Mc(n.lastChild)?xi.before(n.lastChild):a}else a=t;const i=a.container();let l=a.offset();if(Pc(i)){if(pc(e)&&l>0)return xi(i,--l);if(gc(e)&&l<i.length)return xi(i,++l);o=i}else{if(pc(e)&&l>0&&(r=zc(i,l-1),Ic(r)))return!Fc(r)&&(s=bc(r,e,Uc,r),s)?Pc(s)?xi(s,s.data.length):xi.after(s):Pc(r)?xi(r,r.data.length):xi.before(r);if(gc(e)&&l<i.childNodes.length&&(r=zc(i,l),Ic(r)))return Mc(r)?((e,t)=>{const n=t.nextSibling;return n&&Ic(n)?Pc(n)?xi(n,0):xi.before(n):Hc(Bc.Forwards,xi.after(t),e)})(n,r):!Fc(r)&&(s=bc(r,e,Uc,r),s)?Pc(s)?xi(s,0):xi.before(s):Pc(r)?xi(r,0):xi.after(r);o=r||a.getNode()}if(o&&(gc(e)&&a.isAtEnd()||pc(e)&&a.isAtStart())&&(o=bc(o,e,L,n,!0),Uc(o,n)))return jc(e,o);r=o?bc(o,e,Uc,n):o;const d=Be(K(((e,t)=>{const n=[];let o=e;for(;o&&o!==t;)n.push(o),o=o.parentNode;return n})(i,n),Dc));return!d||r&&d.contains(r)?r?jc(e,r):null:(a=gc(e)?xi.after(d):xi.before(d),a)},$c=e=>({next:t=>Hc(Bc.Forwards,t,e),prev:t=>Hc(Bc.Backwards,t,e)}),Vc=e=>xi.isTextPosition(e)?0===e.offset():Wr(e.getNode()),qc=e=>{if(xi.isTextPosition(e)){const t=e.container();return e.offset()===t.data.length}return Wr(e.getNode(!0))},Wc=(e,t)=>!xi.isTextPosition(e)&&!xi.isTextPosition(t)&&e.getNode()===t.getNode(!0),Kc=(e,t,n)=>{const o=$c(t);return M.from(e?o.next(n):o.prev(n))},Gc=(e,t,n)=>Kc(e,t,n).bind((o=>yc(n,o,t)&&((e,t,n)=>{return e?!Wc(t,n)&&(o=t,!(!xi.isTextPosition(o)&&Wo(o.getNode())))&&qc(t)&&Vc(n):!Wc(n,t)&&Vc(t)&&qc(n);var o})(e,n,o)?Kc(e,t,o):M.some(o))),Yc=(e,t,n,o)=>Gc(e,t,n).bind((n=>o(n)?Yc(e,t,n,o):M.some(n))),Xc=(e,t)=>{const n=e?t.firstChild:t.lastChild;return zo(n)?M.some(xi(n,e?0:n.data.length)):n?Wr(n)?M.some(e?xi.before(n):Wo(o=n)?xi.before(o):xi.after(o)):((e,t,n)=>{const o=e?xi.before(n):xi.after(n);return Kc(e,t,o)})(e,t,n):M.none();var o},Qc=O(Kc,!0),Jc=O(Kc,!1),Zc=O(Xc,!0),eu=O(Xc,!1),tu="_mce_caret",nu=e=>To(e)&&e.id===tu,ou=(e,t)=>{let n=t;for(;n&&n!==e;){if(nu(n))return n;n=n.parentNode}return null},ru=e=>xe(e,"name"),su=e=>Tt.isArray(e.start),au=e=>!(!ru(e)&&b(e.forward))||e.forward,iu=(e,t)=>(To(t)&&e.isBlock(t)&&!t.innerHTML&&(t.innerHTML='<br data-mce-bogus="1" />'),t),lu=(e,t)=>eu(e).fold(P,(e=>(t.setStart(e.container(),e.offset()),t.setEnd(e.container(),e.offset()),!0))),du=(e,t,n)=>!(!(e=>!e.hasChildNodes())(t)||!ou(e,t)||(((e,t)=>{var n;const o=(null!==(n=e.ownerDocument)&&void 0!==n?n:document).createTextNode(kr);e.appendChild(o),t.setStart(o,0),t.setEnd(o,0)})(t,n),0)),cu=(e,t,n,o)=>{const r=n[t?"start":"end"],s=e.getRoot();if(r){let e=s,n=r[0];for(let t=r.length-1;e&&t>=1;t--){const n=e.childNodes;if(du(s,e,o))return!0;if(r[t]>n.length-1)return!!du(s,e,o)||lu(e,o);e=n[r[t]]}zo(e)&&(n=Math.min(r[0],e.data.length)),To(e)&&(n=Math.min(r[0],e.childNodes.length)),t?o.setStart(e,n):o.setEnd(e,n)}return!0},uu=e=>zo(e)&&e.data.length>0,mu=(e,t,n)=>{const o=e.get(n.id+"_"+t),r=null==o?void 0:o.parentNode,s=n.keep;if(o&&r){let a,i;if("start"===t?s?o.hasChildNodes()?(a=o.firstChild,i=1):uu(o.nextSibling)?(a=o.nextSibling,i=0):uu(o.previousSibling)?(a=o.previousSibling,i=o.previousSibling.data.length):(a=r,i=e.nodeIndex(o)+1):(a=r,i=e.nodeIndex(o)):s?o.hasChildNodes()?(a=o.firstChild,i=1):uu(o.previousSibling)?(a=o.previousSibling,i=o.previousSibling.data.length):(a=r,i=e.nodeIndex(o)):(a=r,i=e.nodeIndex(o)),!s){const r=o.previousSibling,s=o.nextSibling;let l;for(Tt.each(Tt.grep(o.childNodes),(e=>{zo(e)&&(e.data=e.data.replace(/\uFEFF/g,""))}));l=e.get(n.id+"_"+t);)e.remove(l,!0);if(zo(s)&&zo(r)&&!Nt.browser.isOpera()){const t=r.data.length;r.appendData(s.data),e.remove(s),a=r,i=t}}return M.some(xi(a,i))}return M.none()},fu=(e,t,n)=>((e,t,n=!1)=>2===t?zi(_r,n,e):3===t?(e=>{const t=e.getRng();return{start:Bi(e.dom.getRoot(),xi.fromRangeStart(t)),end:Bi(e.dom.getRoot(),xi.fromRangeEnd(t)),forward:e.isForward()}})(e):t?(e=>({rng:e.getRng(),forward:e.isForward()}))(e):Hi(e,!1))(e,t,n),gu=(e,t)=>{((e,t)=>{const n=e.dom;if(t){if(su(t))return((e,t)=>{const n=e.createRng();return cu(e,!0,t,n)&&cu(e,!1,t,n)?M.some({range:n,forward:au(t)}):M.none()})(n,t);if((e=>m(e.start))(t))return((e,t)=>{const n=M.from(Di(e.getRoot(),t.start)),o=M.from(Di(e.getRoot(),t.end));return Dt(n,o,((n,o)=>{const r=e.createRng();return r.setStart(n.container(),n.offset()),r.setEnd(o.container(),o.offset()),{range:r,forward:au(t)}}))})(n,t);if((e=>xe(e,"id"))(t))return((e,t)=>{const n=mu(e,"start",t),o=mu(e,"end",t);return Dt(n,o.or(n),((n,o)=>{const r=e.createRng();return r.setStart(iu(e,n.container()),n.offset()),r.setEnd(iu(e,o.container()),o.offset()),{range:r,forward:au(t)}}))})(n,t);if(ru(t))return((e,t)=>M.from(e.select(t.name)[t.index]).map((t=>{const n=e.createRng();return n.selectNode(t),{range:n,forward:!0}})))(n,t);if((e=>xe(e,"rng"))(t))return M.some({range:t.rng,forward:au(t)})}return M.none()})(e,t).each((({range:t,forward:n})=>{e.setRng(t,n)}))},pu=e=>To(e)&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type"),hu=(tr,e=>"\xa0"===e);const bu=e=>""!==e&&-1!==" \f\n\r\t\v".indexOf(e),vu=e=>!bu(e)&&!hu(e)&&!nr(e),yu=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Cu=e=>(e=>({value:e}))(yu(e.red)+yu(e.green)+yu(e.blue)),wu=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,xu=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,ku=(e,t,n,o)=>({red:e,green:t,blue:n,alpha:o}),Su=(e,t,n,o)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(n,10),i=parseFloat(o);return ku(r,s,a,i)},_u=e=>(e=>{if("transparent"===e)return M.some(ku(0,0,0,0));const t=wu.exec(e);if(null!==t)return M.some(Su(t[1],t[2],t[3],"1"));const n=xu.exec(e);return null!==n?M.some(Su(n[1],n[2],n[3],n[4])):M.none()})(e).map(Cu).map((e=>"#"+e.value)).getOr(e),Eu=e=>{const t=[];if(e)for(let n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t},Nu=(e,t)=>{const n=or(t,"td[data-mce-selected],th[data-mce-selected]");return n.length>0?n:(e=>K((e=>ee(e,(e=>{const t=ti(e);return t?[mn(t)]:[]})))(e),hr))(e)},Ru=e=>Nu(Eu(e.selection.getSel()),mn(e.getBody())),Au=(e,t)=>So(e,"table",t),Ou=e=>Tn(e).fold(N([e]),(t=>[e].concat(Ou(t)))),Tu=e=>Bn(e).fold(N([e]),(t=>"br"===Lt(t)?_n(t).map((t=>[e].concat(Tu(t)))).getOr([]):[e].concat(Tu(t)))),Bu=(e,t)=>Dt((e=>{const t=e.startContainer,n=e.startOffset;return zo(t)?0===n?M.some(mn(t)):M.none():M.from(t.childNodes[n]).map(mn)})(t),(e=>{const t=e.endContainer,n=e.endOffset;return zo(t)?n===t.data.length?M.some(mn(t)):M.none():M.from(t.childNodes[n-1]).map(mn)})(t),((t,n)=>{const o=Q(Ou(e),O(bn,t)),r=Q(Tu(e),O(bn,n));return o.isSome()&&r.isSome()})).getOr(!1),Du=(e,t,n,o)=>{const r=n,s=new Ro(n,r),a=ve(e.schema.getMoveCaretBeforeOnEnterElements(),((e,t)=>!j(["td","th","table"],t.toLowerCase())));let i=n;do{if(zo(i)&&0!==Tt.trim(i.data).length)return void(o?t.setStart(i,0):t.setEnd(i,i.data.length));if(a[i.nodeName])return void(o?t.setStartBefore(i):"BR"===i.nodeName?t.setEndBefore(i):t.setEndAfter(i))}while(i=o?s.next():s.prev());"BODY"===r.nodeName&&(o?t.setStart(r,0):t.setEnd(r,r.childNodes.length))},Pu=e=>{const t=e.selection.getSel();return C(t)&&t.rangeCount>0},Lu=(e,t)=>{const n=Ru(e);n.length>0?V(n,(n=>{const o=n.dom,r=e.dom.createRng();r.setStartBefore(o),r.setEndAfter(o),t(r,!0)})):t(e.selection.getRng(),!1)},Mu=(e,t,n)=>{const o=Hi(e,t);n(o),e.moveToBookmark(o)},Iu=e=>x(null==e?void 0:e.nodeType),Fu=e=>To(e)&&!pu(e)&&!nu(e)&&!Mo(e),Uu=e=>!0===e.isContentEditable,zu=(e,t,n)=>{const{selection:o,dom:r}=e,s=o.getNode(),a=Yo(s);Mu(o,!0,(()=>{t()})),a&&Yo(s)&&r.isChildOf(s,e.getBody())?e.selection.select(s):n(o.getStart())&&ju(r,o)},ju=(e,t)=>{var n,o;const r=t.getRng(),{startContainer:s,startOffset:a}=r;if(!((e,t)=>{if(Fu(t)&&!/^(TD|TH)$/.test(t.nodeName)){const n=e.getAttrib(t,"data-mce-selected"),o=parseInt(n,10);return!isNaN(o)&&o>0}return!1})(e,t.getNode())&&To(s)){const i=s.childNodes,l=e.getRoot();let d;if(a<i.length){const t=i[a];d=new Ro(t,null!==(n=e.getParent(t,e.isBlock))&&void 0!==n?n:l)}else{const t=i[i.length-1];d=new Ro(t,null!==(o=e.getParent(t,e.isBlock))&&void 0!==o?o:l),d.next(!0)}for(let n=d.current();n;n=d.next()){if("false"===e.getContentEditable(n))return;if(zo(n)&&!qu(n))return r.setStart(n,0),void t.setRng(r)}}},Hu=(e,t,n)=>{if(e){const o=t?"nextSibling":"previousSibling";for(e=n?e:e[o];e;e=e[o])if(To(e)||!qu(e))return e}},$u=(e,t)=>!!e.getTextBlockElements()[t.nodeName.toLowerCase()]||ps(e,t),Vu=(e,t,n)=>e.schema.isValidChild(t,n),qu=(e,t=!1)=>{if(C(e)&&zo(e)){const n=t?e.data.replace(/ /g,"\xa0"):e.data;return Xr(n)}return!1},Wu=(e,t)=>{const n=e.dom;return Fu(t)&&"false"===n.getContentEditable(t)&&((e,t)=>{const n="[data-mce-cef-wrappable]",o=ed(e),r=Ke(o)?n:`${n},${o}`;return pn(mn(t),r)})(e,t)&&0===n.select('[contenteditable="true"]',t).length},Ku=(e,t)=>w(e)?e(t):(C(t)&&(e=e.replace(/%(\w+)/g,((e,n)=>t[n]||e))),e),Gu=(e,t)=>(t=t||"",e=""+((e=e||"").nodeName||e),t=""+(t.nodeName||t),e.toLowerCase()===t.toLowerCase()),Yu=(e,t)=>{if(y(e))return null;{let n=String(e);return"color"!==t&&"backgroundColor"!==t||(n=_u(n)),"fontWeight"===t&&700===e&&(n="bold"),"fontFamily"===t&&(n=n.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),n}},Xu=(e,t,n)=>{const o=e.getStyle(t,n);return Yu(o,n)},Qu=(e,t)=>{let n;return e.getParent(t,(t=>!!To(t)&&(n=e.getStyle(t,"text-decoration"),!!n&&"none"!==n))),n},Ju=(e,t,n)=>e.getParents(t,n,e.getRoot()),Zu=(e,t,n)=>{const o=e.formatter.get(t);return C(o)&&H(o,n)},em=e=>ke(e,"block"),tm=e=>ke(e,"selector"),nm=e=>ke(e,"inline"),om=e=>tm(e)&&!1!==e.expand&&!nm(e),rm=pu,sm=Ju,am=qu,im=$u,lm=(e,t)=>{let n=t;for(;n;){if(To(n)&&e.getContentEditable(n))return"false"===e.getContentEditable(n)?n:t;n=n.parentNode}return t},dm=(e,t,n,o)=>{const r=t.data;if(e){for(let e=n;e>0;e--)if(o(r.charAt(e-1)))return e}else for(let e=n;e<r.length;e++)if(o(r.charAt(e)))return e;return-1},cm=(e,t,n)=>dm(e,t,n,(e=>hu(e)||bu(e))),um=(e,t,n)=>dm(e,t,n,vu),mm=(e,t,n,o,r,s)=>{let a;const i=e.getParent(n,e.isBlock)||t,l=(t,n,o)=>{const s=Ka(e),l=r?s.backwards:s.forwards;return M.from(l(t,n,((e,t)=>rm(e.parentNode)?-1:(a=e,o(r,e,t))),i))};return l(n,o,cm).bind((e=>s?l(e.container,e.offset+(r?-1:0),um):M.some(e))).orThunk((()=>a?M.some({container:a,offset:r?0:a.length}):M.none()))},fm=(e,t,n,o,r)=>{const s=o[r];zo(o)&&Ke(o.data)&&s&&(o=s);const a=sm(e,o);for(let o=0;o<a.length;o++)for(let r=0;r<t.length;r++){const s=t[r];if((!C(s.collapsed)||s.collapsed===n.collapsed)&&tm(s)&&e.is(a[o],s.selector))return a[o]}return o},gm=(e,t,n,o)=>{var r;let s=n;const a=e.getRoot(),i=t[0];if(em(i)&&(s=i.wrapper?null:e.getParent(n,i.block,a)),!s){const t=null!==(r=e.getParent(n,"LI,TD,TH"))&&void 0!==r?r:a;s=e.getParent(zo(n)?n.parentNode:n,(t=>t!==a&&im(e.schema,t)),t)}if(s&&em(i)&&i.wrapper&&(s=sm(e,s,"ul,ol").reverse()[0]||s),!s)for(s=n;s&&s[o]&&!e.isBlock(s[o])&&(s=s[o],!Gu(s,"br")););return s||n},pm=(e,t,n,o)=>{const r=n.parentNode;return!C(n[o])&&(!(r!==t&&!y(r)&&!e.isBlock(r))||pm(e,t,r,o))},hm=(e,t,n,o,r)=>{let s=n;const a=r?"previousSibling":"nextSibling",i=e.getRoot();if(zo(n)&&!am(n)&&(r?o>0:o<n.data.length))return n;for(;s;){if(!t[0].block_expand&&e.isBlock(s))return s;for(let t=s[a];t;t=t[a]){const n=zo(t)&&!pm(e,i,t,a);if(!rm(t)&&(!Wo(l=t)||!l.getAttribute("data-mce-bogus")||l.nextSibling)&&!am(t,n))return s}if(s===i||s.parentNode===i){n=s;break}s=s.parentNode}var l;return n},bm=e=>rm(e.parentNode)||rm(e),vm=(e,t,n,o=!1)=>{let{startContainer:r,startOffset:s,endContainer:a,endOffset:i}=t;const l=n[0];return To(r)&&r.hasChildNodes()&&(r=ni(r,s),zo(r)&&(s=0)),To(a)&&a.hasChildNodes()&&(a=ni(a,t.collapsed?i:i-1),zo(a)&&(i=a.data.length)),r=lm(e,r),a=lm(e,a),bm(r)&&(r=rm(r)?r:r.parentNode,r=t.collapsed?r.previousSibling||r:r.nextSibling||r,zo(r)&&(s=t.collapsed?r.length:0)),bm(a)&&(a=rm(a)?a:a.parentNode,a=t.collapsed?a.nextSibling||a:a.previousSibling||a,zo(a)&&(i=t.collapsed?0:a.length)),t.collapsed&&(mm(e,e.getRoot(),r,s,!0,o).each((({container:e,offset:t})=>{r=e,s=t})),mm(e,e.getRoot(),a,i,!1,o).each((({container:e,offset:t})=>{a=e,i=t}))),(nm(l)||l.block_expand)&&(nm(l)&&zo(r)&&0!==s||(r=hm(e,n,r,s,!0)),nm(l)&&zo(a)&&i!==a.data.length||(a=hm(e,n,a,i,!1))),om(l)&&(r=fm(e,n,t,r,"previousSibling"),a=fm(e,n,t,a,"nextSibling")),(em(l)||tm(l))&&(r=gm(e,n,r,"previousSibling"),a=gm(e,n,a,"nextSibling"),em(l)&&(e.isBlock(r)||(r=hm(e,n,r,s,!0)),e.isBlock(a)||(a=hm(e,n,a,i,!1)))),To(r)&&r.parentNode&&(s=e.nodeIndex(r),r=r.parentNode),To(a)&&a.parentNode&&(i=e.nodeIndex(a)+1,a=a.parentNode),{startContainer:r,startOffset:s,endContainer:a,endOffset:i}},ym=(e,t,n)=>{var o;const r=t.startOffset,s=ni(t.startContainer,r),a=t.endOffset,i=ni(t.endContainer,a-1),l=e=>{const t=e[0];zo(t)&&t===s&&r>=t.data.length&&e.splice(0,1);const n=e[e.length-1];return 0===a&&e.length>0&&n===i&&zo(n)&&e.splice(e.length-1,1),e},d=(e,t,n)=>{const o=[];for(;e&&e!==n;e=e[t])o.push(e);return o},c=(t,n)=>e.getParent(t,(e=>e.parentNode===n),n),u=(e,t,o)=>{const r=o?"nextSibling":"previousSibling";for(let s=e,a=s.parentNode;s&&s!==t;s=a){a=s.parentNode;const t=d(s===e?s:s[r],r);t.length&&(o||t.reverse(),n(l(t)))}};if(s===i)return n(l([s]));const m=null!==(o=e.findCommonAncestor(s,i))&&void 0!==o?o:e.getRoot();if(e.isChildOf(s,i))return u(s,m,!0);if(e.isChildOf(i,s))return u(i,m);const f=c(s,m)||s,g=c(i,m)||i;u(s,f,!0);const p=d(f===s?f:f.nextSibling,"nextSibling",g===i?g.nextSibling:g);p.length&&n(l(p)),u(i,g)},Cm=['pre[class*=language-][contenteditable="false"]',"figure.image","div[data-ephox-embed-iri]","div.tiny-pageembed","div.mce-toc","div[data-mce-toc]"],wm=(e,t,n,o,r,s)=>{const{uid:a=t,...i}=n;nn(e,Oa()),Vt(e,`${Ba()}`,a),Vt(e,`${Ta()}`,o);const{attributes:l={},classes:d=[]}=r(a,i);if(qt(e,l),((e,t)=>{V(t,(t=>{nn(e,t)}))})(e,d),s){d.length>0&&Vt(e,`${Pa()}`,d.join(","));const t=ue(l);t.length>0&&Vt(e,`${La()}`,t.join(","))}},xm=(e,t,n,o,r)=>{const s=cn("span",e);return wm(s,t,n,o,r,!1),s},km=(e,t,n,o,r,s)=>{const a=[],i=xm(e.getDoc(),n,s,o,r),l=Na(),d=()=>{l.clear()},c=e=>{V(e,u)},u=t=>{switch(((e,t,n,o)=>xn(t).fold((()=>"skipping"),(r=>"br"===o||(e=>Ut(e)&&sr(e)===kr)(t)?"valid":(e=>Ft(e)&&sn(e,Oa()))(t)?"existing":nu(t.dom)?"caret":H(Cm,(e=>pn(t,e)))?"valid-block":Vu(e,n,o)&&Vu(e,Lt(r),n)?"valid":"invalid-child")))(e,t,"span",Lt(t))){case"invalid-child":{d();const e=An(t);c(e),d();break}case"valid-block":d(),wm(t,n,s,o,r,!0);break;case"valid":{const e=l.get().getOrThunk((()=>{const e=Va(i);return a.push(e),l.set(e),e}));((e,t)=>{Qn(e,t),eo(t,e)})(t,e);break}}};return ym(e.dom,t,(e=>{d(),(e=>{const t=$(e,mn);c(t)})(e)})),a},Sm=e=>{const t=(()=>{const e={};return{register:(t,n)=>{e[t]={name:t,settings:n}},lookup:t=>we(e,t).map((e=>e.settings)),getNames:()=>ue(e)}})();((e,t)=>{const n=Ta(),o=e=>M.from(e.attr(n)).bind(t.lookup),r=e=>{var t,n;e.attr(Ba(),null),e.attr(Ta(),null),e.attr(Da(),null);const o=M.from(e.attr(La())).map((e=>e.split(","))).getOr([]),r=M.from(e.attr(Pa())).map((e=>e.split(","))).getOr([]);V(o,(t=>e.attr(t,null)));const s=null!==(n=null===(t=e.attr("class"))||void 0===t?void 0:t.split(" "))&&void 0!==n?n:[],a=oe(s,[Oa()].concat(r));e.attr("class",a.length>0?a.join(" "):null),e.attr(Pa(),null),e.attr(La(),null)};e.serializer.addTempAttr(Da()),e.serializer.addAttributeFilter(n,(e=>{for(const t of e)o(t).each((e=>{!1===e.persistent&&("span"===t.name?t.unwrap():r(t))}))}))})(e,t);const n=((e,t)=>{const n=Ca({}),o=()=>({listeners:[],previous:Na()}),r=(e,t)=>{s(e,(e=>(t(e),e)))},s=(e,t)=>{const r=n.get(),s=t(we(r,e).getOrThunk(o));r[e]=s,n.set(r)},a=(t,n)=>{V(Ua(e,t),(e=>{n?Vt(e,Da(),"true"):Yt(e,Da())}))},i=Aa((()=>{const n=se(t.getNames());V(n,(t=>{s(t,(n=>{const o=n.previous.get();return Ia(e,M.some(t)).fold((()=>{o.each((e=>{(e=>{r(e,(t=>{V(t.listeners,(t=>t(!1,e)))}))})(t),n.previous.clear(),a(e,!1)}))}),(({uid:e,name:t,elements:s})=>{Bt(o,e)||(o.each((e=>a(e,!1))),((e,t,n)=>{r(e,(o=>{V(o.listeners,(o=>o(!0,e,{uid:t,nodes:$(n,(e=>e.dom))})))}))})(t,e,s),n.previous.set(e),a(e,!0))})),{previous:n.previous,listeners:n.listeners}}))}))}),30);return e.on("remove",(()=>{i.cancel()})),e.on("NodeChange",(()=>{i.throttle()})),{addListener:(e,t)=>{s(e,(e=>({previous:e.previous,listeners:e.listeners.concat([t])})))}}})(e,t),o=Ht("span"),r=e=>{V(e,(e=>{o(e)?ro(e):(e=>{rn(e,Oa()),Yt(e,`${Ba()}`),Yt(e,`${Ta()}`),Yt(e,`${Da()}`);const t=Kt(e,`${La()}`).map((e=>e.split(","))).getOr([]),n=Kt(e,`${Pa()}`).map((e=>e.split(","))).getOr([]);var o;V(t,(t=>Yt(e,t))),o=e,V(n,(e=>{rn(o,e)})),Yt(e,`${Pa()}`),Yt(e,`${La()}`)})(e)}))};return{register:(e,n)=>{t.register(e,n)},annotate:(n,o)=>{t.lookup(n).each((t=>{((e,t,n,o)=>{e.undoManager.transact((()=>{const r=e.selection,s=r.getRng(),a=Ru(e).length>0,i=Ha("mce-annotation");if(s.collapsed&&!a&&((e,t)=>{const n=vm(e.dom,t,[{inline:"span"}]);t.setStart(n.startContainer,n.startOffset),t.setEnd(n.endContainer,n.endOffset),e.selection.setRng(t)})(e,s),r.getRng().collapsed&&!a){const s=xm(e.getDoc(),i,o,t,n.decorate);io(s,tr),r.getRng().insertNode(s.dom),r.select(s.dom)}else Mu(r,!1,(()=>{Lu(e,(r=>{km(e,r,i,t,n.decorate,o)}))}))}))})(e,n,t,o)}))},annotationChanged:(e,t)=>{n.addListener(e,t)},remove:t=>{const n=e.selection.getBookmark();Ia(e,M.some(t)).each((({elements:e})=>{r(e)})),e.selection.moveToBookmark(n)},removeAll:t=>{const n=e.selection.getBookmark();fe(za(e,t),((e,t)=>{r(e)})),e.selection.moveToBookmark(n)},getAll:t=>{const n=za(e,t);return ge(n,(e=>$(e,(e=>e.dom))))}}},_m=e=>({getBookmark:O(fu,e),moveToBookmark:O(gu,e)});_m.isBookmarkNode=pu;const Em=(e,t,n)=>!n.collapsed&&H(n.getClientRects(),(n=>((e,t,n)=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom)(n,e,t))),Nm=(e,t,n)=>{e.dispatch(t,n)},Rm=(e,t,n,o)=>{e.dispatch("FormatApply",{format:t,node:n,vars:o})},Am=(e,t,n,o)=>{e.dispatch("FormatRemove",{format:t,node:n,vars:o})},Om=(e,t)=>e.dispatch("SetContent",t),Tm=(e,t)=>e.dispatch("GetContent",t),Bm=(e,t)=>e.dispatch("PastePlainTextToggle",{state:t}),Dm={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,modifierPressed:e=>e.shiftKey||e.ctrlKey||e.altKey||Dm.metaKeyPressed(e),metaKeyPressed:e=>Nt.os.isMacOS()||Nt.os.isiOS()?e.metaKey:e.ctrlKey&&!e.altKey},Pm="data-mce-selected",Lm=Math.abs,Mm=Math.round,Im={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]},Fm=(e,t)=>{const n=t.dom,o=t.getDoc(),r=document,s=t.getBody();let a,i,l,d,c,u,m,f,g,p,h,b,v,y,w;const x=e=>C(e)&&(Ko(e)||n.is(e,"figure.image")),k=e=>Jo(e)||n.hasClass(e,"mce-preview-object"),S=e=>{const n=e.target;((e,t)=>{if((e=>"longpress"===e.type||0===e.type.indexOf("touch"))(e)){const n=e.touches[0];return x(e.target)&&!Em(n.clientX,n.clientY,t)}return x(e.target)&&!Em(e.clientX,e.clientY,t)})(e,t.selection.getRng())&&!e.isDefaultPrevented()&&t.selection.select(n)},_=e=>n.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?[e,e.firstElementChild]:n.is(e,"figure.image")?[e.querySelector("img")]:[e],E=e=>{const o=jl(t);return!!o&&"false"!==e.getAttribute("data-mce-resize")&&e!==t.getBody()&&(n.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?pn(mn(e.firstElementChild),o):pn(mn(e),o))},N=(e,o,r)=>{if(C(r)){const s=_(e);V(s,(e=>{e.style[o]||!t.schema.isValid(e.nodeName.toLowerCase(),o)?n.setStyle(e,o,r):n.setAttrib(e,o,""+r)}))}},R=(e,t,n)=>{N(e,"width",t),N(e,"height",n)},A=e=>{let o,r,c,C,S;o=e.screenX-u,r=e.screenY-m,b=o*d[2]+f,v=r*d[3]+g,b=b<5?5:b,v=v<5?5:v,c=(x(a)||k(a))&&!1!==Hl(t)?!Dm.modifierPressed(e):Dm.modifierPressed(e),c&&(Lm(o)>Lm(r)?(v=Mm(b*p),b=Mm(v/p)):(b=Mm(v/p),v=Mm(b*p))),R(i,b,v),C=d.startPos.x+o,S=d.startPos.y+r,C=C>0?C:0,S=S>0?S:0,n.setStyles(l,{left:C,top:S,display:"block"}),l.innerHTML=b+" &times; "+v,d[2]<0&&i.clientWidth<=b&&n.setStyle(i,"left",void 0+(f-b)),d[3]<0&&i.clientHeight<=v&&n.setStyle(i,"top",void 0+(g-v)),o=s.scrollWidth-y,r=s.scrollHeight-w,o+r!==0&&n.setStyles(l,{left:C-o,top:S-r}),h||(((e,t,n,o,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:n,height:o,origin:r})})(t,a,f,g,"corner-"+d.name),h=!0)},O=()=>{const e=h;h=!1,e&&(N(a,"width",b),N(a,"height",v)),n.unbind(o,"mousemove",A),n.unbind(o,"mouseup",O),r!==o&&(n.unbind(r,"mousemove",A),n.unbind(r,"mouseup",O)),n.remove(i),n.remove(l),n.remove(c),T(a),e&&(((e,t,n,o,r)=>{e.dispatch("ObjectResized",{target:t,width:n,height:o,origin:r})})(t,a,b,v,"corner-"+d.name),n.setAttrib(a,"style",n.getAttrib(a,"style"))),t.nodeChanged()},T=e=>{M();const h=n.getPos(e,s),C=h.x,x=h.y,S=e.getBoundingClientRect(),N=S.width||S.right-S.left,T=S.height||S.bottom-S.top;a!==e&&(D(),a=e,b=v=0);const B=t.dispatch("ObjectSelected",{target:e});E(e)&&!B.isDefaultPrevented()?fe(Im,((e,t)=>{let h=n.get("mceResizeHandle"+t);h&&n.remove(h),h=n.add(s,"div",{id:"mceResizeHandle"+t,"data-mce-bogus":"all",class:"mce-resizehandle",unselectable:!0,style:"cursor:"+t+"-resize; margin:0; padding:0"}),n.bind(h,"mousedown",(h=>{h.stopImmediatePropagation(),h.preventDefault(),(h=>{const b=_(a)[0];var v;u=h.screenX,m=h.screenY,f=b.clientWidth,g=b.clientHeight,p=g/f,d=e,d.name=t,d.startPos={x:N*e[0]+C,y:T*e[1]+x},y=s.scrollWidth,w=s.scrollHeight,c=n.add(s,"div",{class:"mce-resize-backdrop","data-mce-bogus":"all"}),n.setStyles(c,{position:"fixed",left:"0",top:"0",width:"100%",height:"100%"}),i=k(v=a)?n.create("img",{src:Nt.transparentSrc}):v.cloneNode(!0),n.addClass(i,"mce-clonedresizable"),n.setAttrib(i,"data-mce-bogus","all"),i.contentEditable="false",n.setStyles(i,{left:C,top:x,margin:0}),R(i,N,T),i.removeAttribute(Pm),s.appendChild(i),n.bind(o,"mousemove",A),n.bind(o,"mouseup",O),r!==o&&(n.bind(r,"mousemove",A),n.bind(r,"mouseup",O)),l=n.add(s,"div",{class:"mce-resize-helper","data-mce-bogus":"all"},f+" &times; "+g)})(h)})),e.elm=h,n.setStyles(h,{left:N*e[0]+C-h.offsetWidth/2,top:T*e[1]+x-h.offsetHeight/2})})):D(!1)},B=Ra(T,0),D=(e=!0)=>{B.cancel(),M(),a&&e&&a.removeAttribute(Pm),fe(Im,((e,t)=>{const o=n.get("mceResizeHandle"+t);o&&(n.unbind(o),n.remove(o))}))},P=(e,t)=>n.isChildOf(e,t),L=o=>{if(h||t.removed||t.composing)return;const r="mousedown"===o.type?o.target:e.getNode(),a=Eo(mn(r),"table,img,figure.image,hr,video,span.mce-preview-object").map((e=>e.dom)).getOrUndefined(),i=C(a)?n.getAttrib(a,Pm,"1"):"1";if(V(n.select("img[data-mce-selected],hr[data-mce-selected]"),(e=>{e.removeAttribute(Pm)})),C(a)&&P(a,s)){I();const t=e.getStart(!0);if(P(t,a)&&P(e.getEnd(!0),a))return n.setAttrib(a,Pm,i),void B.throttle(a)}D()},M=()=>{fe(Im,(e=>{e.elm&&(n.unbind(e.elm),delete e.elm)}))},I=()=>{try{t.getDoc().execCommand("enableObjectResizing",!1,"false")}catch(e){}};return t.on("init",(()=>{I(),t.on("NodeChange ResizeEditor ResizeWindow ResizeContent drop",L),t.on("keyup compositionend",(e=>{a&&"TABLE"===a.nodeName&&L(e)})),t.on("hide blur",D),t.on("contextmenu longpress",S,!0)})),t.on("remove",M),{isResizable:E,showResizeRect:T,hideResizeRect:D,updateResizeRect:L,destroy:()=>{B.cancel(),a=i=c=null}}},Um=(e,t,n)=>{const o=e.document.createRange();var r;return r=o,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,n)=>{e.setEnd(t.dom,n)}),(t=>{e.setEndAfter(t.dom)}))})(o,n),o},zm=(e,t,n,o,r)=>{const s=e.document.createRange();return s.setStart(t.dom,n),s.setEnd(o.dom,r),s},jm=Ki([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Hm=(e,t,n)=>t(mn(n.startContainer),n.startOffset,mn(n.endContainer),n.endOffset);jm.ltr,jm.rtl;const $m=(e,t,n,o)=>({start:e,soffset:t,finish:n,foffset:o}),Vm=document.caretPositionFromPoint?(e,t,n)=>{var o,r;return M.from(null===(r=(o=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(o,t,n)).bind((t=>{if(null===t.offsetNode)return M.none();const n=e.dom.createRange();return n.setStart(t.offsetNode,t.offset),n.collapse(),M.some(n)}))}:document.caretRangeFromPoint?(e,t,n)=>{var o,r;return M.from(null===(r=(o=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(o,t,n))}:M.none,qm=Ki([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Wm={before:qm.before,on:qm.on,after:qm.after,cata:(e,t,n,o)=>e.fold(t,n,o),getStart:e=>e.fold(R,R,R)},Km=Ki([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Gm={domRange:Km.domRange,relative:Km.relative,exact:Km.exact,exactFromRange:e=>Km.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>mn(e.startContainer),relative:(e,t)=>Wm.getStart(e),exact:(e,t,n,o)=>e}))(e);return wn(t)},range:$m},Ym=(e,t)=>{const n=Lt(e);return"input"===n?Wm.after(e):j(["br","img"],n)?0===t?Wm.before(e):Wm.after(e):Wm.on(e,t)},Xm=(e,t)=>{const n=e.fold(Wm.before,Ym,Wm.after),o=t.fold(Wm.before,Ym,Wm.after);return Gm.relative(n,o)},Qm=(e,t,n,o)=>{const r=Ym(e,t),s=Ym(n,o);return Gm.relative(r,s)},Jm=(e,t)=>{const n=(t||document).createDocumentFragment();return V(e,(e=>{n.appendChild(e.dom)})),mn(n)},Zm=e=>{const t=Gm.getWin(e).dom,n=(e,n,o,r)=>zm(t,e,n,o,r),o=(e=>e.match({domRange:e=>{const t=mn(e.startContainer),n=mn(e.endContainer);return Qm(t,e.startOffset,n,e.endOffset)},relative:Xm,exact:Qm}))(e);return((e,t)=>{const n=((e,t)=>t.match({domRange:e=>({ltr:N(e),rtl:M.none}),relative:(t,n)=>({ltr:De((()=>Um(e,t,n))),rtl:De((()=>M.some(Um(e,n,t))))}),exact:(t,n,o,r)=>({ltr:De((()=>zm(e,t,n,o,r))),rtl:De((()=>M.some(zm(e,o,r,t,n))))})}))(e,t);return((e,t)=>{const n=t.ltr();return n.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>jm.rtl(mn(e.endContainer),e.endOffset,mn(e.startContainer),e.startOffset))).getOrThunk((()=>Hm(0,jm.ltr,n))):Hm(0,jm.ltr,n)})(0,n)})(t,o).match({ltr:n,rtl:n})},ef=(e,t,n)=>((e,t,n)=>((e,t,n)=>{const o=mn(e.document);return Vm(o,t,n).map((e=>$m(mn(e.startContainer),e.startOffset,mn(e.endContainer),e.endOffset)))})(e,t,n))(wn(mn(n)).dom,e,t).map((e=>{const t=n.createRange();return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),t})).getOrUndefined(),tf=(e,t)=>C(e)&&C(t)&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset,nf=(e,t,n)=>null!==((e,t,n)=>{let o=e;for(;o&&o!==t;){if(n(o))return o;o=o.parentNode}return null})(e,t,n),of=(e,t,n)=>nf(e,t,(e=>e.nodeName===n)),rf=(e,t)=>Or(e)&&!nf(e,t,nu),sf=(e,t,n)=>{const o=t.parentNode;if(o){const r=new Ro(t,e.getParent(o,e.isBlock)||e.getRoot());let s;for(;s=r[n?"prev":"next"]();)if(Wo(s))return!0}return!1},af=(e,t,n,o,r)=>{const s=e.getRoot(),a=e.schema.getNonEmptyElements(),i=r.parentNode;let l,d;if(!i)return M.none();const c=e.getParent(i,e.isBlock)||s;if(o&&Wo(r)&&t&&e.isEmpty(c))return M.some(xi(i,e.nodeIndex(r)));const u=new Ro(r,c);for(;d=u[o?"prev":"next"]();){if("false"===e.getContentEditableParent(d)||rf(d,s))return M.none();if(zo(d)&&d.data.length>0)return of(d,s,"A")?M.none():M.some(xi(d,o?d.data.length:0));if(e.isBlock(d)||a[d.nodeName.toLowerCase()])return M.none();l=d}return $o(l)?M.none():n&&l?M.some(xi(l,0)):M.none()},lf=(e,t,n,o)=>{const r=e.getRoot();let s,a=!1,i=n?o.startContainer:o.endContainer,l=n?o.startOffset:o.endOffset;const d=To(i)&&l===i.childNodes.length,c=e.schema.getNonEmptyElements();let u=n;if(Or(i))return M.none();if(To(i)&&l>i.childNodes.length-1&&(u=!1),Vo(i)&&(i=r,l=0),i===r){if(u&&(s=i.childNodes[l>0?l-1:0],s)){if(Or(s))return M.none();if(c[s.nodeName]||Io(s))return M.none()}if(i.hasChildNodes()){if(l=Math.min(!u&&l>0?l-1:l,i.childNodes.length-1),i=i.childNodes[l],l=zo(i)&&d?i.data.length:0,!t&&i===r.lastChild&&Io(i))return M.none();if(((e,t)=>{let n=t;for(;n&&n!==e;){if(Yo(n))return!0;n=n.parentNode}return!1})(r,i)||Or(i))return M.none();if(i.hasChildNodes()&&!Io(i)){s=i;const t=new Ro(i,r);do{if(Yo(s)||Or(s)){a=!1;break}if(zo(s)&&s.data.length>0){l=u?0:s.data.length,i=s,a=!0;break}if(c[s.nodeName.toLowerCase()]&&!Qo(s)){l=e.nodeIndex(s),i=s.parentNode,u||l++,a=!0;break}}while(s=u?t.next():t.prev())}}}return t&&(zo(i)&&0===l&&af(e,d,t,!0,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),To(i)&&(s=i.childNodes[l],s||(s=i.childNodes[l-1]),!s||!Wo(s)||((e,t)=>{var n;return"A"===(null===(n=e.previousSibling)||void 0===n?void 0:n.nodeName)})(s)||sf(e,s,!1)||sf(e,s,!0)||af(e,d,t,!0,s).each((e=>{i=e.container(),l=e.offset(),a=!0})))),u&&!t&&zo(i)&&l===i.data.length&&af(e,d,t,!1,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),a&&i?M.some(xi(i,l)):M.none()},df=(e,t)=>{const n=t.collapsed,o=t.cloneRange(),r=xi.fromRangeStart(t);return lf(e,n,!0,o).each((e=>{n&&xi.isAbove(r,e)||o.setStart(e.container(),e.offset())})),n||lf(e,n,!1,o).each((e=>{o.setEnd(e.container(),e.offset())})),n&&o.collapse(!0),tf(t,o)?M.none():M.some(o)},cf=(e,t)=>e.splitText(t),uf=e=>{let t=e.startContainer,n=e.startOffset,o=e.endContainer,r=e.endOffset;if(t===o&&zo(t)){if(n>0&&n<t.data.length)if(o=cf(t,n),t=o.previousSibling,r>n){r-=n;const e=cf(o,r).previousSibling;t=o=e,r=e.data.length,n=0}else r=0}else if(zo(t)&&n>0&&n<t.data.length&&(t=cf(t,n),n=0),zo(o)&&r>0&&r<o.data.length){const e=cf(o,r).previousSibling;o=e,r=e.data.length}return{startContainer:t,startOffset:n,endContainer:o,endOffset:r}},mf=e=>({walk:(t,n)=>ym(e,t,n),split:uf,expand:(t,n={type:"word"})=>{if("word"===n.type){const n=vm(e,t,[{inline:"span"}]),o=e.createRng();return o.setStart(n.startContainer,n.startOffset),o.setEnd(n.endContainer,n.endOffset),o}return t},normalize:t=>df(e,t).fold(P,(e=>(t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),!0)))});mf.compareRanges=tf,mf.getCaretRangeFromPoint=ef,mf.getSelectedNode=ti,mf.getNode=ni;const ff=((e,t)=>{const n=t=>{const n=(e=>{const t=e.dom;return Hn(e)?t.getBoundingClientRect().height:t.offsetHeight})(t);if(n<=0||null===n){const n=Wn(t,e);return parseFloat(n)||0}return n},o=(e,t)=>Y(t,((t,n)=>{const o=Wn(e,n),r=void 0===o?0:parseInt(o,10);return isNaN(r)?t:t+r}),0);return{set:(t,n)=>{if(!x(n)&&!n.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+n);const o=t.dom;an(o)&&(o.style[e]=n+"px")},get:n,getOuter:n,aggregate:o,max:(e,t,n)=>{const r=o(e,n);return t>r?t-r:0}}})("height"),gf=()=>mn(document),pf=(e,t)=>e.view(t).fold(N([]),(t=>{const n=e.owner(t),o=pf(e,n);return[t].concat(o)}));var hf=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?M.none():M.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(mn)},owner:e=>Cn(e)});const bf=e=>"textarea"===Lt(e),vf=(e,t)=>{const n=(e=>{const t=e.dom.ownerDocument,n=t.body,o=t.defaultView,r=t.documentElement;if(n===e.dom)return mo(n.offsetLeft,n.offsetTop);const s=fo(null==o?void 0:o.pageYOffset,r.scrollTop),a=fo(null==o?void 0:o.pageXOffset,r.scrollLeft),i=fo(r.clientTop,n.clientTop),l=fo(r.clientLeft,n.clientLeft);return go(e).translate(a-l,s-i)})(e),o=(e=>ff.get(e))(e);return{element:e,bottom:n.top+o,height:o,pos:n,cleanup:t}},yf=(e,t,n,o)=>{kf(e,((r,s)=>wf(e,t,n,o)),n)},Cf=(e,t,n,o,r)=>{const s={elm:o.element.dom,alignToTop:r};((e,t)=>e.dispatch("ScrollIntoView",t).isDefaultPrevented())(e,s)||(n(t,po(t).top,o,r),((e,t)=>{e.dispatch("AfterScrollIntoView",t)})(e,s))},wf=(e,t,n,o)=>{const r=mn(e.getBody()),s=mn(e.getDoc());r.dom.offsetWidth;const a=((e,t)=>{const n=((e,t)=>{const n=An(e);if(0===n.length||bf(e))return{element:e,offset:t};if(t<n.length&&!bf(n[t]))return{element:n[t],offset:0};{const o=n[n.length-1];return bf(o)?{element:e,offset:t}:"img"===Lt(o)?{element:o,offset:1}:Ut(o)?{element:o,offset:sr(o).length}:{element:o,offset:An(o).length}}})(e,t),o=dn('<span data-mce-bogus="all" style="display: inline-block;">\ufeff</span>');return Qn(n.element,o),vf(o,(()=>oo(o)))})(mn(n.startContainer),n.startOffset);Cf(e,s,t,a,o),a.cleanup()},xf=(e,t,n,o)=>{const r=mn(e.getDoc());Cf(e,r,n,(e=>vf(mn(e),S))(t),o)},kf=(e,t,n)=>{const o=n.startContainer,r=n.startOffset,s=n.endContainer,a=n.endOffset;t(mn(o),mn(s));const i=e.dom.createRng();i.setStart(o,r),i.setEnd(s,a),e.selection.setRng(n)},Sf=(e,t,n,o)=>{const r=e.pos;if(n)ho(r.left,r.top,o);else{const n=r.top-t+e.height;ho(r.left,n,o)}},_f=(e,t,n,o,r)=>{const s=n+t,a=o.pos.top,i=o.bottom,l=i-a>=n;a<t?Sf(o,n,!1!==r,e):a>s?Sf(o,n,l?!1!==r:!0===r,e):i>s&&!l&&Sf(o,n,!0===r,e)},Ef=(e,t,n,o)=>{const r=wn(e).dom.innerHeight;_f(e,t,r,n,o)},Nf=(e,t,n,o)=>{const r=wn(e).dom.innerHeight;_f(e,t,r,n,o);const s=(e=>{const t=gf(),n=po(t),o=((e,t)=>{const n=t.owner(e);return pf(t,n)})(e,hf),r=go(e),s=G(o,((e,t)=>{const n=go(t);return{left:e.left+n.left,top:e.top+n.top}}),{left:0,top:0});return mo(s.left+r.left+n.left,s.top+r.top+n.top)})(n.element),a=yo(window);s.top<a.y?bo(n.element,!1!==o):s.top>a.bottom&&bo(n.element,!0===o)},Rf=(e,t,n)=>yf(e,Ef,t,n),Af=(e,t,n)=>xf(e,t,Ef,n),Of=(e,t,n)=>yf(e,Nf,t,n),Tf=(e,t,n)=>xf(e,t,Nf,n),Bf=(e,t,n)=>{(e.inline?Rf:Of)(e,t,n)},Df=e=>e.dom.focus(),Pf=e=>{const t=In(e).dom;return e.dom===t.activeElement},Lf=(e=gf())=>M.from(e.dom.activeElement).map(mn),Mf=(e,t)=>{const n=Ut(t)?sr(t).length:An(t).length+1;return e>n?n:e<0?0:e},If=e=>Gm.range(e.start,Mf(e.soffset,e.start),e.finish,Mf(e.foffset,e.finish)),Ff=(e,t)=>!Oo(t.dom)&&(vn(e,t)||bn(e,t)),Uf=e=>t=>Ff(e,t.start)&&Ff(e,t.finish),zf=e=>Gm.range(mn(e.startContainer),e.startOffset,mn(e.endContainer),e.endOffset),jf=e=>{const t=document.createRange();try{return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),M.some(t)}catch(e){return M.none()}},Hf=e=>{const t=(e=>e.inline||Nt.browser.isFirefox())(e)?(n=mn(e.getBody()),(e=>{const t=e.getSelection();return(t&&0!==t.rangeCount?M.from(t.getRangeAt(0)):M.none()).map(zf)})(wn(n).dom).filter(Uf(n))):M.none();var n;e.bookmark=t.isSome()?t:e.bookmark},$f=e=>(e.bookmark?e.bookmark:M.none()).bind((t=>{return n=mn(e.getBody()),o=t,M.from(o).filter(Uf(n)).map(If);var n,o})).bind(jf),Vf={isEditorUIElement:e=>{const t=e.className.toString();return-1!==t.indexOf("tox-")||-1!==t.indexOf("mce-")}},qf={setEditorTimeout:(e,t,n)=>((e,t)=>(x(t)||(t=0),setTimeout(e,t)))((()=>{e.removed||t()}),n),setEditorInterval:(e,t,n)=>{const o=((e,t)=>(x(t)||(t=0),setInterval(e,t)))((()=>{e.removed?clearInterval(o):t()}),n);return o}};let Wf;const Kf=ba.DOM,Gf=(e,t)=>{const n=td(e),o=Kf.getParent(t,(t=>(e=>To(e)&&Vf.isEditorUIElement(e))(t)||!!n&&e.dom.is(t,n)));return null!==o},Yf=(e,t)=>{const n=t.editor;(e=>{const t=Ra((()=>{Hf(e)}),0);e.on("init",(()=>{e.inline&&((e,t)=>{const n=()=>{t.throttle()};ba.DOM.bind(document,"mouseup",n),e.on("remove",(()=>{ba.DOM.unbind(document,"mouseup",n)}))})(e,t),((e,t)=>{((e,t)=>{e.on("mouseup touchend",(e=>{t.throttle()}))})(e,t),e.on("keyup NodeChange AfterSetSelectionRange",(t=>{(e=>"nodechange"===e.type&&e.selectionChange)(t)||Hf(e)}))})(e,t)})),e.on("remove",(()=>{t.cancel()}))})(n),n.on("focusin",(()=>{const t=e.focusedEditor;t!==n&&(t&&t.dispatch("blur",{focusedEditor:n}),e.setActive(n),e.focusedEditor=n,n.dispatch("focus",{blurredEditor:t}),n.focus(!0))})),n.on("focusout",(()=>{qf.setEditorTimeout(n,(()=>{const t=e.focusedEditor;Gf(n,(e=>{try{const t=In(mn(e.getElement()));return Lf(t).fold((()=>document.body),(e=>e.dom))}catch(e){return document.body}})(n))||t!==n||(n.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null)}))})),Wf||(Wf=t=>{const n=e.activeEditor;n&&zn(t).each((t=>{const o=t;o.ownerDocument===document&&(o===document.body||Gf(n,o)||e.focusedEditor!==n||(n.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null))}))},Kf.bind(document,"focusin",Wf))},Xf=(e,t)=>{e.focusedEditor===t.editor&&(e.focusedEditor=null),!e.activeEditor&&Wf&&(Kf.unbind(document,"focusin",Wf),Wf=null)},Qf=(e,t)=>{((e,t)=>(e=>e.collapsed?M.from(ni(e.startContainer,e.startOffset)).map(mn):M.none())(t).bind((t=>pr(t)?M.some(t):vn(e,t)?M.none():M.some(e))))(mn(e.getBody()),t).bind((e=>Zc(e.dom))).fold((()=>{e.selection.normalize()}),(t=>e.selection.setRng(t.toRange())))},Jf=e=>{if(e.setActive)try{e.setActive()}catch(t){e.focus()}else e.focus()},Zf=e=>e.inline?(e=>{const t=e.getBody();return t&&(n=mn(t),Pf(n)||(o=n,Lf(In(o)).filter((e=>o.dom.contains(e.dom)))).isSome());var n,o})(e):(e=>C(e.iframeElement)&&Pf(mn(e.iframeElement)))(e),eg=e=>e.editorManager.setActive(e),tg=(e,t,n,o,r)=>{const s=n?t.startContainer:t.endContainer,a=n?t.startOffset:t.endOffset;return M.from(s).map(mn).map((e=>o&&t.collapsed?e:On(e,r(e,a)).getOr(e))).bind((e=>Ft(e)?M.some(e):xn(e).filter(Ft))).map((e=>e.dom)).getOr(e)},ng=(e,t,n=!1)=>tg(e,t,!0,n,((e,t)=>Math.min(Dn(e),t))),og=(e,t,n=!1)=>tg(e,t,!1,n,((e,t)=>t>0?t-1:t)),rg=(e,t)=>{const n=e;for(;e&&zo(e)&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||n},sg=(e,t)=>$(t,(t=>{const n=e.dispatch("GetSelectionRange",{range:t});return n.range!==t?n.range:t})),ag=["img","br"],ig=e=>{const t=ar(e).filter((e=>0!==e.trim().length||e.indexOf(tr)>-1)).isSome();return t||j(ag,Lt(e))},lg="[data-mce-autocompleter]",dg=(e,t)=>{if(cg(mn(e.getBody())).isNone()){const o=dn('<span data-mce-autocompleter="1" data-mce-bogus="1"></span>',e.getDoc());eo(o,mn(t.extractContents())),t.insertNode(o.dom),xn(o).each((e=>e.dom.normalize())),(n=o,((e,t)=>{const n=e=>{const o=An(e);for(let e=o.length-1;e>=0;e--){const r=o[e];if(t(r))return M.some(r);const s=n(r);if(s.isSome())return s}return M.none()};return n(e)})(n,ig)).map((t=>{e.selection.setCursorLocation(t.dom,(e=>"img"===Lt(e)?1:ar(e).fold((()=>An(e).length),(e=>e.length)))(t))}))}var n},cg=e=>_o(e,lg),ug={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11},mg=(e,t,n)=>{const o=n?"lastChild":"firstChild",r=n?"prev":"next";if(e[o])return e[o];if(e!==t){let n=e[r];if(n)return n;for(let o=e.parent;o&&o!==t;o=o.parent)if(n=o[r],n)return n}},fg=e=>{var t;const n=null!==(t=e.value)&&void 0!==t?t:"";if(!Xr(n))return!1;const o=e.parent;return!o||"span"===o.name&&!o.attr("style")||!/^[ ]+$/.test(n)},gg=e=>{const t="a"===e.name&&!e.attr("href")&&e.attr("id");return e.attr("name")||e.attr("id")&&!e.firstChild||e.attr("data-mce-bookmark")||t};class pg{constructor(e,t){this.name=e,this.type=t,1===t&&(this.attributes=[],this.attributes.map={})}static create(e,t){const n=new pg(e,ug[e]||1);return t&&fe(t,((e,t)=>{n.attr(t,e)})),n}replace(e){const t=this;return e.parent&&e.remove(),t.insert(e,t),t.remove(),t}attr(e,t){const n=this;if(!m(e))return C(e)&&fe(e,((e,t)=>{n.attr(t,e)})),n;const o=n.attributes;if(o){if(void 0!==t){if(null===t){if(e in o.map){delete o.map[e];let t=o.length;for(;t--;)if(o[t].name===e)return o.splice(t,1),n}return n}if(e in o.map){let n=o.length;for(;n--;)if(o[n].name===e){o[n].value=t;break}}else o.push({name:e,value:t});return o.map[e]=t,n}return o.map[e]}}clone(){const e=this,t=new pg(e.name,e.type),n=e.attributes;if(n){const e=[];e.map={};for(let t=0,o=n.length;t<o;t++){const o=n[t];"id"!==o.name&&(e[e.length]={name:o.name,value:o.value},e.map[o.name]=o.value)}t.attributes=e}return t.value=e.value,t}wrap(e){const t=this;return t.parent&&(t.parent.insert(e,t),e.append(t)),t}unwrap(){const e=this;for(let t=e.firstChild;t;){const n=t.next;e.insert(t,e,!0),t=n}e.remove()}remove(){const e=this,t=e.parent,n=e.next,o=e.prev;return t&&(t.firstChild===e?(t.firstChild=n,n&&(n.prev=null)):o&&(o.next=n),t.lastChild===e?(t.lastChild=o,o&&(o.next=null)):n&&(n.prev=o),e.parent=e.next=e.prev=null),e}append(e){const t=this;e.parent&&e.remove();const n=t.lastChild;return n?(n.next=e,e.prev=n,t.lastChild=e):t.lastChild=t.firstChild=e,e.parent=t,e}insert(e,t,n){e.parent&&e.remove();const o=t.parent||this;return n?(t===o.firstChild?o.firstChild=e:t.prev&&(t.prev.next=e),e.prev=t.prev,e.next=t,t.prev=e):(t===o.lastChild?o.lastChild=e:t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e),e.parent=o,e}getAll(e){const t=this,n=[];for(let o=t.firstChild;o;o=mg(o,t))o.name===e&&n.push(o);return n}children(){const e=[];for(let t=this.firstChild;t;t=t.next)e.push(t);return e}empty(){const e=this;if(e.firstChild){const t=[];for(let n=e.firstChild;n;n=mg(n,e))t.push(n);let n=t.length;for(;n--;){const e=t[n];e.parent=e.firstChild=e.lastChild=e.next=e.prev=null}}return e.firstChild=e.lastChild=null,e}isEmpty(e,t={},n){var o;const r=this;let s=r.firstChild;if(gg(r))return!1;if(s)do{if(1===s.type){if(s.attr("data-mce-bogus"))continue;if(e[s.name])return!1;if(gg(s))return!1}if(8===s.type)return!1;if(3===s.type&&!fg(s))return!1;if(3===s.type&&s.parent&&t[s.parent.name]&&Xr(null!==(o=s.value)&&void 0!==o?o:""))return!1;if(n&&n(s))return!1}while(s=mg(s,r));return!0}walk(e){return mg(this,null,e)}}const hg=(e,t,n=0)=>{const o=e.toLowerCase();if(-1!==o.indexOf("[if ",n)&&((e,t)=>/^\s*\[if [\w\W]+\]>.*<!\[endif\](--!?)?>/.test(e.substr(t)))(o,n)){const e=o.indexOf("[endif]",n);return o.indexOf(">",e)}if(t){const e=o.indexOf(">",n);return-1!==e?e:o.length}{const t=/--!?>/g;t.lastIndex=n;const r=t.exec(e);return r?r.index+r[0].length:o.length}},bg=(e,t,n)=>{const o=/<([!?\/])?([A-Za-z0-9\-_:.]+)/g,r=/(?:\s(?:[^'">]+(?:"[^"]*"|'[^']*'))*[^"'>]*(?:"[^">]*|'[^'>]*)?|\s*|\/)>/g,s=e.getVoidElements();let a=1,i=n;for(;0!==a;)for(o.lastIndex=i;;){const e=o.exec(t);if(null===e)return i;if("!"===e[1]){i=ze(e[2],"--")?hg(t,!1,e.index+"!--".length):hg(t,!0,e.index+1);break}{r.lastIndex=o.lastIndex;const n=r.exec(t);if(h(n)||n.index!==o.lastIndex)continue;"/"===e[1]?a-=1:xe(s,e[2])||(a+=1),i=o.lastIndex+n[0].length;break}}return i},vg=(e,t)=>{const n=/<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g,o=e.schema;let r=((e,t)=>{const n=new RegExp(["\\s?("+e.join("|")+')="[^"]+"'].join("|"),"gi");return t.replace(n,"")})(e.getTempAttrs(),t);const s=o.getVoidElements();let a;for(;a=n.exec(r);){const e=n.lastIndex,t=a[0].length;let i;i=s[a[1]]?e:bg(o,r,e),r=r.substring(0,e-t)+r.substring(i),n.lastIndex=e-t}return _r(r)},yg=vg,Cg=e=>{const t=or(e,"[data-mce-bogus]");V(t,(e=>{"all"===Wt(e,"data-mce-bogus")?oo(e):ur(e)?(Qn(e,un(er)),oo(e)):ro(e)}))},wg=e=>{const t=or(e,"input");V(t,(e=>{Yt(e,"name")}))},xg=(e,t,n)=>{let o;return o="raw"===t.format?Tt.trim(yg(e.serializer,n.innerHTML)):"text"===t.format?((e,t)=>{const n=e.getDoc(),o=In(mn(e.getBody())),r=cn("div",n);Vt(r,"data-mce-bogus","all"),qn(r,{position:"fixed",left:"-9999999px",top:"0"}),io(r,t.innerHTML),Cg(r),wg(r);const s=(e=>Pn(e)?e:mn(Cn(e).dom.body))(o);eo(s,r);const a=_r(r.dom.innerText);return oo(r),a})(e,n):"tree"===t.format?e.serializer.serialize(n,t):((e,t)=>{const n=gl(e),o=new RegExp(`^(<${n}[^>]*>(&nbsp;|&#160;|\\s|\xa0|<br \\/>|)<\\/${n}>[\r\n]*|<br \\/>[\r\n]*)$`);return t.replace(o,"")})(e,e.serializer.serialize(n,t)),"text"!==t.format&&!br(mn(n))&&m(o)?Tt.trim(o):o},kg=Tt.makeMap,Sg=e=>{const t=[],n=(e=e||{}).indent,o=kg(e.indent_before||""),r=kg(e.indent_after||""),s=Fs.getEncodeFunc(e.entity_encoding||"raw",e.entities),a="xhtml"!==e.element_format;return{start:(e,i,l)=>{if(n&&o[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}if(t.push("<",e),i)for(let e=0,n=i.length;e<n;e++){const n=i[e];t.push(" ",n.name,'="',s(n.value,!0),'"')}if(t[t.length]=!l||a?">":" />",l&&n&&r[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}},end:e=>{let o;t.push("</",e,">"),n&&r[e]&&t.length>0&&(o=t[t.length-1],o.length>0&&"\n"!==o&&t.push("\n"))},text:(e,n)=>{e.length>0&&(t[t.length]=n?e:s(e))},cdata:e=>{t.push("<![CDATA[",e,"]]>")},comment:e=>{t.push("\x3c!--",e,"--\x3e")},pi:(e,o)=>{o?t.push("<?",e," ",s(o),"?>"):t.push("<?",e,"?>"),n&&t.push("\n")},doctype:e=>{t.push("<!DOCTYPE",e,">",n?"\n":"")},reset:()=>{t.length=0},getContent:()=>t.join("").replace(/\n$/,"")}},_g=(e={},t=Qs())=>{const n=Sg(e);return e.validate=!("validate"in e)||e.validate,{serialize:o=>{const r=e.validate,s={3:e=>{var t;n.text(null!==(t=e.value)&&void 0!==t?t:"",e.raw)},8:e=>{var t;n.comment(null!==(t=e.value)&&void 0!==t?t:"")},7:e=>{n.pi(e.name,e.value)},10:e=>{var t;n.doctype(null!==(t=e.value)&&void 0!==t?t:"")},4:e=>{var t;n.cdata(null!==(t=e.value)&&void 0!==t?t:"")},11:e=>{let t=e;if(t=t.firstChild)do{a(t)}while(t=t.next)}};n.reset();const a=e=>{var o;const i=s[e.type];if(i)i(e);else{const s=e.name,i=s in t.getVoidElements();let l=e.attributes;if(r&&l&&l.length>1){const n=[];n.map={};const o=t.getElementRule(e.name);if(o){for(let e=0,t=o.attributesOrder.length;e<t;e++){const t=o.attributesOrder[e];if(t in l.map){const e=l.map[t];n.map[t]=e,n.push({name:t,value:e})}}for(let e=0,t=l.length;e<t;e++){const t=l[e].name;if(!(t in n.map)){const e=l.map[t];n.map[t]=e,n.push({name:t,value:e})}}l=n}}if(n.start(s,l,i),!i){let t=e.firstChild;if(t){"pre"!==s&&"textarea"!==s||3!==t.type||"\n"!==(null===(o=t.value)||void 0===o?void 0:o[0])||n.text("\n",!0);do{a(t)}while(t=t.next)}n.end(s)}}};return 1!==o.type||e.inner?3===o.type?s[3](o):s[11](o):a(o),n.getContent()}}},Eg=new Set;V(["margin","margin-left","margin-right","margin-top","margin-bottom","padding","padding-left","padding-right","padding-top","padding-bottom","border","border-width","border-style","border-color","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","float","position","left","right","top","bottom","z-index","display","transform","width","max-width","min-width","height","max-height","min-height","overflow","overflow-x","overflow-y","text-overflow","vertical-align","transition","transition-delay","transition-duration","transition-property","transition-timing-function"],(e=>{Eg.add(e)}));const Ng=["font","text-decoration","text-emphasis"],Rg=(e,t)=>ue(e.parseStyle(e.getAttrib(t,"style"))),Ag=(e,t,n)=>{const o=Rg(e,t),r=Rg(e,n),s=o=>{var r,s;const a=null!==(r=e.getStyle(t,o))&&void 0!==r?r:"",i=null!==(s=e.getStyle(n,o))&&void 0!==s?s:"";return We(a)&&We(i)&&a!==i};return H(o,(e=>{const t=t=>H(t,(t=>t===e));if(!t(r)&&t(Ng)){const e=K(r,(e=>H(Ng,(t=>ze(e,t)))));return H(e,s)}return s(e)}))},Og=(e,t,n)=>M.from(n.container()).filter(zo).exists((o=>{const r=e?0:-1;return t(o.data.charAt(n.offset()+r))})),Tg=O(Og,!0,bu),Bg=O(Og,!1,bu),Dg=e=>{const t=e.container();return zo(t)&&(0===t.data.length||Sr(t.data)&&_m.isBookmarkNode(t.parentNode))},Pg=(e,t)=>n=>Cc(e?0:-1,n).filter(t).isSome(),Lg=e=>Ko(e)&&"block"===Wn(mn(e),"display"),Mg=e=>Yo(e)&&!(e=>To(e)&&"all"===e.getAttribute("data-mce-bogus"))(e),Ig=Pg(!0,Lg),Fg=Pg(!1,Lg),Ug=Pg(!0,Jo),zg=Pg(!1,Jo),jg=Pg(!0,Io),Hg=Pg(!1,Io),$g=Pg(!0,Mg),Vg=Pg(!1,Mg),qg=(e,t)=>((e,t,n)=>vn(t,e)?Sn(e,(e=>n(e)||bn(e,t))).slice(0,-1):[])(e,t,P),Wg=(e,t)=>[e].concat(qg(e,t)),Kg=(e,t,n)=>Yc(e,t,n,Dg),Gg=(e,t)=>Q(Wg(mn(t.container()),e),dr),Yg=(e,t,n)=>Kg(e,t.dom,n).forall((e=>Gg(t,n).fold((()=>!yc(e,n,t.dom)),(o=>!yc(e,n,t.dom)&&vn(o,mn(e.container())))))),Xg=(e,t,n)=>Gg(t,n).fold((()=>Kg(e,t.dom,n).forall((e=>!yc(e,n,t.dom)))),(t=>Kg(e,t.dom,n).isNone())),Qg=O(Xg,!1),Jg=O(Xg,!0),Zg=O(Yg,!1),ep=O(Yg,!0),tp=e=>Ac(e).exists(ur),np=(e,t,n)=>{const o=K(Wg(mn(n.container()),t),dr),r=ie(o).getOr(t);return Kc(e,r.dom,n).filter(tp)},op=(e,t)=>Ac(t).exists(ur)||np(!0,e,t).isSome(),rp=(e,t)=>(e=>M.from(e.getNode(!0)).map(mn))(t).exists(ur)||np(!1,e,t).isSome(),sp=O(np,!1),ap=O(np,!0),ip=e=>xi.isTextPosition(e)&&!e.isAtStart()&&!e.isAtEnd(),lp=(e,t)=>{const n=K(Wg(mn(t.container()),e),dr);return ie(n).getOr(e)},dp=(e,t)=>ip(t)?Bg(t):Bg(t)||Jc(lp(e,t).dom,t).exists(Bg),cp=(e,t)=>ip(t)?Tg(t):Tg(t)||Qc(lp(e,t).dom,t).exists(Tg),up=e=>Ac(e).bind((e=>ko(e,Ft))).exists((e=>(e=>j(["pre","pre-wrap"],e))(Wn(e,"white-space")))),mp=(e,t)=>n=>{return o=new Ro(n,e)[t](),C(o)&&Yo(o)&&lc(o);var o},fp=(e,t)=>!up(t)&&(Qg(e,t)||Zg(e,t)||rp(e,t)||dp(e,t)||((e,t)=>{const n=Jc(e.dom,t).getOr(t),o=mp(e.dom,"prev");return t.isAtStart()&&(o(t.container())||o(n.container()))})(e,t)),gp=(e,t)=>!up(t)&&(Jg(e,t)||ep(e,t)||op(e,t)||cp(e,t)||((e,t)=>{const n=Qc(e.dom,t).getOr(t),o=mp(e.dom,"next");return t.isAtEnd()&&(o(t.container())||o(n.container()))})(e,t)),pp=(e,t)=>fp(e,t)||gp(e,(e=>{const t=e.container(),n=e.offset();return zo(t)&&n<t.data.length?xi(t,n+1):e})(t)),hp=(e,t)=>hu(e.charAt(t)),bp=(e,t)=>bu(e.charAt(t)),vp=(e,t,n)=>{const o=t.data,r=xi(t,0);return n||!hp(o,0)||pp(e,r)?!!(n&&bp(o,0)&&fp(e,r))&&(t.data=tr+o.slice(1),!0):(t.data=" "+o.slice(1),!0)},yp=(e,t,n)=>{const o=t.data,r=xi(t,o.length-1);return n||!hp(o,o.length-1)||pp(e,r)?!!(n&&bp(o,o.length-1)&&gp(e,r))&&(t.data=o.slice(0,-1)+tr,!0):(t.data=o.slice(0,-1)+" ",!0)},Cp=(e,t)=>{const n=t.container();if(!zo(n))return M.none();if((e=>{const t=e.container();return zo(t)&&Ue(t.data,tr)})(t)){const o=vp(e,n,!1)||(e=>{const t=e.data,n=(e=>{const t=e.split("");return $(t,((e,n)=>hu(e)&&n>0&&n<t.length-1&&vu(t[n-1])&&vu(t[n+1])?" ":e)).join("")})(t);return n!==t&&(e.data=n,!0)})(n)||yp(e,n,!1);return Pt(o,t)}if(pp(e,t)){const o=vp(e,n,!0)||yp(e,n,!0);return Pt(o,t)}return M.none()},wp=(e,t,n)=>{if(0===n)return;const o=mn(e),r=xo(o,dr).getOr(o),s=e.data.slice(t,t+n),a=t+n>=e.data.length&&gp(r,xi(e,e.data.length)),i=0===t&&fp(r,xi(e,0));e.replaceData(t,n,Jr(s,4,i,a))},xp=(e,t)=>{const n=e.data.slice(t),o=n.length-Ve(n).length;wp(e,t,o)},kp=(e,t)=>{const n=e.data.slice(0,t),o=n.length-qe(n).length;wp(e,t-o,o)},Sp=(e,t,n,o=!0)=>{const r=qe(e.data).length,s=o?e:t,a=o?t:e;return o?s.appendData(a.data):s.insertData(0,a.data),oo(mn(a)),n&&xp(s,r),s},_p=(e,t)=>((e,t)=>{const n=e.container(),o=e.offset();return!xi.isTextPosition(e)&&n===t.parentNode&&o>xi.before(t).offset()})(t,e)?xi(t.container(),t.offset()-1):t,Ep=e=>{return Wr(e.previousSibling)?M.some((t=e.previousSibling,zo(t)?xi(t,t.data.length):xi.after(t))):e.previousSibling?eu(e.previousSibling):M.none();var t},Np=e=>{return Wr(e.nextSibling)?M.some((t=e.nextSibling,zo(t)?xi(t,0):xi.before(t))):e.nextSibling?Zc(e.nextSibling):M.none();var t},Rp=(e,t,n)=>((e,t,n)=>e?((e,t)=>Np(t).orThunk((()=>Ep(t))).orThunk((()=>((e,t)=>Qc(e,xi.after(t)).orThunk((()=>Jc(e,xi.before(t)))))(e,t))))(t,n):((e,t)=>Ep(t).orThunk((()=>Np(t))).orThunk((()=>((e,t)=>M.from(t.previousSibling?t.previousSibling:t.parentNode).bind((t=>Jc(e,xi.before(t)))).orThunk((()=>Qc(e,xi.after(t)))))(e,t))))(t,n))(e,t,n).map(O(_p,n)),Ap=(e,t,n)=>{n.fold((()=>{e.focus()}),(n=>{e.selection.setRng(n.toRange(),t)}))},Op=(e,t)=>t&&xe(e.schema.getBlockElements(),Lt(t)),Tp=e=>{if(os(e)){const t=dn('<br data-mce-bogus="1">');return no(e),eo(e,t),M.some(xi.before(t.dom))}return M.none()},Bp=(e,t,n,o=!0)=>{const r=Rp(t,e.getBody(),n.dom),s=xo(n,O(Op,e),(a=e.getBody(),e=>e.dom===a));var a;const i=((e,t,n)=>{const o=_n(e).filter(Ut),r=En(e).filter(Ut);return oo(e),(s=o,a=r,i=t,l=(e,t,o)=>{const r=e.dom,s=t.dom,a=r.data.length;return Sp(r,s,n),o.container()===s?xi(r,a):o},s.isSome()&&a.isSome()&&i.isSome()?M.some(l(s.getOrDie(),a.getOrDie(),i.getOrDie())):M.none()).orThunk((()=>(n&&(o.each((e=>kp(e.dom,e.dom.length))),r.each((e=>xp(e.dom,0)))),t)));var s,a,i,l})(n,r,((e,t)=>xe(e.schema.getTextInlineElements(),Lt(t)))(e,n));e.dom.isEmpty(e.getBody())?(e.setContent(""),e.selection.setCursorLocation()):s.bind(Tp).fold((()=>{o&&Ap(e,t,i)}),(n=>{o&&Ap(e,t,M.some(n))}))},Dp=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,Pp=(e,t)=>pn(mn(t),zl(e))&&!ps(e.schema,t),Lp=(e,t,n)=>{const o=((e,t,n)=>K(ba.DOM.getParents(n.container(),"*",t),e))(e,t,n);return M.from(o[o.length-1])},Mp=(e,t)=>{const n=t.container(),o=t.offset();return e?Ar(n)?zo(n.nextSibling)?xi(n.nextSibling,0):xi.after(n):Br(t)?xi(n,o+1):t:Ar(n)?zo(n.previousSibling)?xi(n.previousSibling,n.previousSibling.data.length):xi.before(n):Dr(t)?xi(n,o-1):t},Ip=O(Mp,!0),Fp=O(Mp,!1),Up=(e,t)=>{const n=e=>e.stopImmediatePropagation();e.on("beforeinput input",n,!0),e.getDoc().execCommand(t),e.off("beforeinput input",n)},zp=e=>Up(e,"Delete"),jp=e=>mr(e)||gr(e),Hp=(e,t)=>vn(e,t)?ko(t,jp,(e=>t=>Bt(xn(t),e,bn))(e)):M.none(),$p=(e,t=!0)=>{e.dom.isEmpty(e.getBody())&&e.setContent("",{no_selection:!t})},Vp=e=>{var t;return(8===Mt(t=e)||"#comment"===Lt(t)?_n(e):Bn(e)).bind(Vp).orThunk((()=>M.some(e)))},qp=(e,t,n,o=!0)=>{var r;t.deleteContents();const s=Vp(n).getOr(n),a=mn(null!==(r=e.dom.getParent(s.dom,e.dom.isBlock))&&void 0!==r?r:n.dom);if(a.dom===e.getBody()?$p(e,o):os(a)&&(wr(a),o&&e.selection.setCursorLocation(a.dom,0)),!bn(n,a)){const e=Bt(xn(a),n)?[]:xn(i=a).map(An).map((e=>K(e,(e=>!bn(i,e))))).getOr([]);V(e.concat(An(n)),(e=>{bn(e,a)||vn(e,a)||!os(e)||oo(e)}))}var i},Wp=e=>or(e,"td,th"),Kp=(e,t)=>({start:e,end:t}),Gp=Ki([{singleCellTable:["rng","cell"]},{fullTable:["table"]},{partialTable:["cells","outsideDetails"]},{multiTable:["startTableCells","endTableCells","betweenRng"]}]),Yp=(e,t)=>Eo(mn(e),"td,th",t),Xp=e=>!bn(e.start,e.end),Qp=(e,t)=>Au(e.start,t).bind((n=>Au(e.end,t).bind((e=>Pt(bn(n,e),n))))),Jp=e=>t=>Qp(t,e).map((e=>((e,t,n)=>({rng:e,table:t,cells:n}))(t,e,Wp(e)))),Zp=(e,t,n,o)=>{if(n.collapsed||!e.forall(Xp))return M.none();if(t.isSameTable){const t=e.bind(Jp(o));return M.some({start:t,end:t})}{const e=Yp(n.startContainer,o),t=Yp(n.endContainer,o),r=e.bind((e=>t=>Au(t,e).bind((e=>le(Wp(e)).map((e=>Kp(t,e))))))(o)).bind(Jp(o)),s=t.bind((e=>t=>Au(t,e).bind((e=>ie(Wp(e)).map((e=>Kp(e,t))))))(o)).bind(Jp(o));return M.some({start:r,end:s})}},eh=(e,t)=>J(e,(e=>bn(e,t))),th=e=>Dt(eh(e.cells,e.rng.start),eh(e.cells,e.rng.end),((t,n)=>e.cells.slice(t,n+1))),nh=(e,t)=>{const{startTable:n,endTable:o}=t,r=e.cloneRange();return n.each((e=>r.setStartAfter(e.dom))),o.each((e=>r.setEndBefore(e.dom))),r},oh=(e,t)=>{const n=(e=>t=>bn(e,t))(e),o=((e,t)=>{const n=Yp(e.startContainer,t),o=Yp(e.endContainer,t);return Dt(n,o,Kp)})(t,n),r=((e,t)=>{const n=e=>Au(mn(e),t),o=n(e.startContainer),r=n(e.endContainer),s=o.isSome(),a=r.isSome(),i=Dt(o,r,bn).getOr(!1);return{startTable:o,endTable:r,isStartInTable:s,isEndInTable:a,isSameTable:i,isMultiTable:!i&&s&&a}})(t,n);return((e,t,n)=>e.exists((e=>((e,t)=>!Xp(e)&&Qp(e,t).exists((e=>{const t=e.dom.rows;return 1===t.length&&1===t[0].cells.length})))(e,n)&&Bu(e.start,t))))(o,t,n)?o.map((e=>Gp.singleCellTable(t,e.start))):r.isMultiTable?((e,t,n,o)=>Zp(e,t,n,o).bind((({start:e,end:o})=>{const r=e.bind(th).getOr([]),s=o.bind(th).getOr([]);if(r.length>0&&s.length>0){const e=nh(n,t);return M.some(Gp.multiTable(r,s,e))}return M.none()})))(o,r,t,n):((e,t,n,o)=>Zp(e,t,n,o).bind((({start:e,end:t})=>e.or(t))).bind((e=>{const{isSameTable:o}=t,r=th(e).getOr([]);if(o&&e.cells.length===r.length)return M.some(Gp.fullTable(e.table));if(r.length>0){if(o)return M.some(Gp.partialTable(r,M.none()));{const e=nh(n,t);return M.some(Gp.partialTable(r,M.some({...t,rng:e})))}}return M.none()})))(o,r,t,n)},rh=e=>V(e,(e=>{Yt(e,"contenteditable"),wr(e)})),sh=(e,t,n,o)=>{const r=n.cloneRange();o?(r.setStart(n.startContainer,n.startOffset),r.setEndAfter(t.dom.lastChild)):(r.setStartBefore(t.dom.firstChild),r.setEnd(n.endContainer,n.endOffset)),dh(e,r,t,!1).each((e=>e()))},ah=e=>{const t=Ru(e),n=mn(e.selection.getNode());Xo(n.dom)&&os(n)?e.selection.setCursorLocation(n.dom,0):e.selection.collapse(!0),t.length>1&&H(t,(e=>bn(e,n)))&&Vt(n,"data-mce-selected","1")},ih=(e,t,n)=>M.some((()=>{const o=e.selection.getRng(),r=n.bind((({rng:n,isStartInTable:r})=>{const s=((e,t)=>M.from(e.dom.getParent(t,e.dom.isBlock)).map(mn))(e,r?n.endContainer:n.startContainer);n.deleteContents(),((e,t,n)=>{n.each((n=>{t?oo(n):(wr(n),e.selection.setCursorLocation(n.dom,0))}))})(e,r,s.filter(os));const a=r?t[0]:t[t.length-1];return sh(e,a,o,r),os(a)?M.none():M.some(r?t.slice(1):t.slice(0,-1))})).getOr(t);rh(r),ah(e)})),lh=(e,t,n,o)=>M.some((()=>{const r=e.selection.getRng(),s=t[0],a=n[n.length-1];sh(e,s,r,!0),sh(e,a,r,!1);const i=os(s)?t:t.slice(1),l=os(a)?n:n.slice(0,-1);rh(i.concat(l)),o.deleteContents(),ah(e)})),dh=(e,t,n,o=!0)=>M.some((()=>{qp(e,t,n,o)})),ch=(e,t)=>M.some((()=>Bp(e,!1,t))),uh=(e,t)=>Q(Wg(t,e),hr),mh=(e,t)=>Q(Wg(t,e),Ht("caption")),fh=(e,t)=>M.some((()=>{wr(t),e.selection.setCursorLocation(t.dom,0)})),gh=(e,t)=>e?jg(t):Hg(t),ph=(e,t,n)=>{const o=mn(e.getBody());return mh(o,n).fold((()=>((e,t,n,o)=>{const r=xi.fromRangeStart(e.selection.getRng());return uh(n,o).bind((o=>os(o)?fh(e,o):((e,t,n,o,r)=>Gc(n,e.getBody(),r).bind((e=>uh(t,mn(e.getNode())).bind((e=>bn(e,o)?M.none():M.some(S))))))(e,n,t,o,r)))})(e,t,o,n).orThunk((()=>Pt(((e,t)=>{const n=xi.fromRangeStart(e.selection.getRng());return gh(t,n)||Kc(t,e.getBody(),n).exists((e=>gh(t,e)))})(e,t),S)))),(n=>((e,t,n,o)=>{const r=xi.fromRangeStart(e.selection.getRng());return os(o)?fh(e,o):((e,t,n,o,r)=>Gc(n,e.getBody(),r).fold((()=>M.some(S)),(s=>((e,t,n,o)=>Zc(e.dom).bind((r=>eu(e.dom).map((e=>t?n.isEqual(r)&&o.isEqual(e):n.isEqual(e)&&o.isEqual(r))))).getOr(!0))(o,n,r,s)?((e,t)=>fh(e,t))(e,o):((e,t,n)=>mh(e,mn(n.getNode())).fold((()=>M.some(S)),(e=>Pt(!bn(e,t),S))))(t,o,s))))(e,n,t,o,r)})(e,t,o,n)))},hh=(e,t)=>{const n=mn(e.selection.getStart(!0)),o=Ru(e);return e.selection.isCollapsed()&&0===o.length?ph(e,t,n):((e,t,n)=>{const o=mn(e.getBody()),r=e.selection.getRng();return 0!==n.length?ih(e,n,M.none()):((e,t,n,o)=>mh(t,o).fold((()=>((e,t,n)=>oh(t,n).bind((t=>t.fold(O(dh,e),O(ch,e),O(ih,e),O(lh,e)))))(e,t,n)),(t=>((e,t)=>fh(e,t))(e,t))))(e,o,r,t)})(e,n,o)},bh=(e,t)=>{let n=t;for(;n&&n!==e;){if(Go(n)||Yo(n))return n;n=n.parentNode}return null},vh=["data-ephox-","data-mce-","data-alloy-","data-snooker-","_"],yh=Tt.each,Ch=e=>{const t=e.dom,n=new Set(e.serializer.getTempAttrs()),o=e=>H(vh,(t=>ze(e,t)))||n.has(e);return{compare:(e,n)=>{if(e.nodeName!==n.nodeName||e.nodeType!==n.nodeType)return!1;const r=e=>{const n={};return yh(t.getAttribs(e),(r=>{const s=r.nodeName.toLowerCase();"style"===s||o(s)||(n[s]=t.getAttrib(e,s))})),n},s=(e,t)=>{for(const n in e)if(xe(e,n)){const o=t[n];if(v(o))return!1;if(e[n]!==o)return!1;delete t[n]}for(const e in t)if(xe(t,e))return!1;return!0};if(To(e)&&To(n)){if(!s(r(e),r(n)))return!1;if(!s(t.parseStyle(t.getAttrib(e,"style")),t.parseStyle(t.getAttrib(n,"style"))))return!1}return!pu(e)&&!pu(n)},isAttributeInternal:o}},wh=(e,t,n,o)=>{const r=n.name;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s.name===r){const e=o.nodes[r];e?e.nodes.push(n):o.nodes[r]={filter:s,nodes:[n]}}}if(n.attributes)for(let e=0,r=t.length;e<r;e++){const r=t[e],s=r.name;if(s in n.attributes.map){const e=o.attributes[s];e?e.nodes.push(n):o.attributes[s]={filter:r,nodes:[n]}}}},xh=(e,t)=>{const n=(e,n)=>{fe(e,(e=>{const o=de(e.nodes);V(e.filter.callbacks,(r=>{for(let t=o.length-1;t>=0;t--){const r=o[t];(n?void 0!==r.attr(e.filter.name):r.name===e.filter.name)&&!y(r.parent)||o.splice(t,1)}o.length>0&&r(o,e.filter.name,t)}))}))};n(e.nodes,!1),n(e.attributes,!0)},kh=(e,t,n,o={})=>{const r=((e,t,n)=>{const o={nodes:{},attributes:{}};return n.firstChild&&((n,r)=>{let s=n;for(;s=s.walk();)wh(e,t,s,o)})(n),o})(e,t,n);xh(r,o)},Sh=(e,t,n)=>{if(e.insert&&t(n)){const e=new pg("br",1);e.attr("data-mce-bogus","1"),n.empty().append(e)}else n.empty().append(new pg("#text",3)).value=tr},_h=(e,t)=>{const n=null==e?void 0:e.firstChild;return C(n)&&n===e.lastChild&&n.name===t},Eh=(e,t,n,o)=>o.isEmpty(t,n,(t=>((e,t)=>{const n=e.getElementRule(t.name);return!0===(null==n?void 0:n.paddEmpty)})(e,t))),Nh=(e,t,n=e.parent)=>{if(t.getSpecialElements()[e.name])e.empty().remove();else{const o=e.children();for(const e of o)n&&!t.isValidChild(n.name,e.name)&&Nh(e,t,n);e.unwrap()}},Rh=(e,t,n=S)=>{const o=t.getTextBlockElements(),r=t.getNonEmptyElements(),s=t.getWhitespaceElements(),a=Tt.makeMap("tr,td,th,tbody,thead,tfoot,table"),i=new Set;for(let l=0;l<e.length;l++){const d=e[l];let c,u,m;if(!d.parent||i.has(d))continue;if(o[d.name]&&"li"===d.parent.name){let e=d.next;for(;e&&o[e.name];)e.name="li",i.add(e),d.parent.insert(e,d.parent),e=e.next;d.unwrap();continue}const f=[d];for(c=d.parent;c&&!t.isValidChild(c.name,d.name)&&!a[c.name];c=c.parent)f.push(c);if(c&&f.length>1)if(t.isValidChild(c.name,d.name)){f.reverse(),u=f[0].clone(),n(u);let e=u;for(let o=0;o<f.length-1;o++){t.isValidChild(e.name,f[o].name)?(m=f[o].clone(),n(m),e.append(m)):m=e;for(let e=f[o].firstChild;e&&e!==f[o+1];){const t=e.next;m.append(e),e=t}e=m}Eh(t,r,s,u)?c.insert(d,f[0],!0):(c.insert(u,f[0],!0),c.insert(d,u)),c=f[0],(Eh(t,r,s,c)||_h(c,"br"))&&c.empty().remove()}else Nh(d,t);else if(d.parent){if("li"===d.name){let e=d.prev;if(e&&("ul"===e.name||"ol"===e.name)){e.append(d);continue}if(e=d.next,e&&("ul"===e.name||"ol"===e.name)&&e.firstChild){e.insert(d,e.firstChild,!0);continue}const t=new pg("ul",1);n(t),d.wrap(t);continue}if(t.isValidChild(d.parent.name,"div")&&t.isValidChild("div",d.name)){const e=new pg("div",1);n(e),d.wrap(e)}else Nh(d,t)}}},Ah=(e,t,n=t.parent)=>!(!n||!e.children[t.name]||e.isValidChild(n.name,t.name))||!(!n||"a"!==t.name||!((e,t)=>{let n=e;for(;n;){if("a"===n.name)return!0;n=n.parent}return!1})(n)),Oh=e=>e.collapsed?e:(e=>{const t=xi.fromRangeStart(e),n=xi.fromRangeEnd(e),o=e.commonAncestorContainer;return Kc(!1,o,n).map((r=>!yc(t,n,o)&&yc(t,r,o)?((e,t,n,o)=>{const r=document.createRange();return r.setStart(e,t),r.setEnd(n,o),r})(t.container(),t.offset(),r.container(),r.offset()):e)).getOr(e)})(e),Th=(e,t)=>{let n=t.firstChild,o=t.lastChild;return n&&"meta"===n.name&&(n=n.next),o&&"mce_marker"===o.attr("id")&&(o=o.prev),((e,t)=>{const n=e.getNonEmptyElements();return C(t)&&(t.isEmpty(n)||((e,t)=>e.getBlockElements()[t.name]&&(e=>C(e.firstChild)&&e.firstChild===e.lastChild)(t)&&(e=>"br"===e.name||e.value===tr)(t.firstChild))(e,t))})(e,o)&&(o=null==o?void 0:o.prev),!(!n||n!==o||"ul"!==n.name&&"ol"!==n.name)},Bh=e=>{return e.length>0&&(!(n=e[e.length-1]).firstChild||C(null==(t=n)?void 0:t.firstChild)&&t.firstChild===t.lastChild&&(e=>e.data===tr||Wo(e))(t.firstChild))?e.slice(0,-1):e;var t,n},Dh=(e,t)=>{const n=e.getParent(t,e.isBlock);return n&&"LI"===n.nodeName?n:null},Ph=(e,t)=>{const n=xi.after(e),o=$c(t).prev(n);return o?o.toRange():null},Lh=(e,t,n,o)=>{const r=((e,t,n)=>{const o=t.serialize(n);return(e=>{var t,n;const o=e.firstChild,r=e.lastChild;return o&&"META"===o.nodeName&&(null===(t=o.parentNode)||void 0===t||t.removeChild(o)),r&&"mce_marker"===r.id&&(null===(n=r.parentNode)||void 0===n||n.removeChild(r)),e})(e.createFragment(o))})(t,e,o),s=Dh(t,n.startContainer),a=Bh((i=r.firstChild,K(null!==(l=null==i?void 0:i.childNodes)&&void 0!==l?l:[],(e=>"LI"===e.nodeName))));var i,l;const d=t.getRoot(),c=e=>{const o=xi.fromRangeStart(n),r=$c(t.getRoot()),a=1===e?r.prev(o):r.next(o),i=null==a?void 0:a.getNode();return!i||Dh(t,i)!==s};return s?c(1)?((e,t,n)=>{const o=e.parentNode;return o&&Tt.each(t,(t=>{o.insertBefore(t,e)})),((e,t)=>{const n=xi.before(e),o=$c(t).next(n);return o?o.toRange():null})(e,n)})(s,a,d):c(2)?((e,t,n,o)=>(o.insertAfter(t.reverse(),e),Ph(t[0],n)))(s,a,d,t):((e,t,n,o)=>{const r=((e,t)=>{const n=t.cloneRange(),o=t.cloneRange();return n.setStartBefore(e),o.setEndAfter(e),[n.cloneContents(),o.cloneContents()]})(e,o),s=e.parentNode;return s&&(s.insertBefore(r[0],e),Tt.each(t,(t=>{s.insertBefore(t,e)})),s.insertBefore(r[1],e),s.removeChild(e)),Ph(t[t.length-1],n)})(s,a,d,n):null},Mh=["pre"],Ih=Xo,Fh=(e,t,n)=>{var o,r;const s=e.selection,a=e.dom,i=e.parser,l=n.merge,d=_g({validate:!0},e.schema),c='<span id="mce_marker" data-mce-type="bookmark">&#xFEFF;</span>';-1===t.indexOf("{$caret}")&&(t+="{$caret}"),t=t.replace(/\{\$caret\}/,c);let u=s.getRng();const m=u.startContainer,f=e.getBody();m===f&&s.isCollapsed()&&a.isBlock(f.firstChild)&&((e,t)=>C(t)&&!e.schema.getVoidElements()[t.nodeName])(e,f.firstChild)&&a.isEmpty(f.firstChild)&&(u=a.createRng(),u.setStart(f.firstChild,0),u.setEnd(f.firstChild,0),s.setRng(u)),s.isCollapsed()||(e=>{const t=e.dom,n=Oh(e.selection.getRng());e.selection.setRng(n);const o=t.getParent(n.startContainer,Ih);((e,t,n)=>!!C(n)&&n===e.getParent(t.endContainer,Ih)&&Bu(mn(n),t))(t,n,o)?dh(e,n,mn(o)):n.startContainer===n.endContainer&&n.endOffset-n.startOffset==1&&zo(n.startContainer.childNodes[n.startOffset])?n.deleteContents():e.getDoc().execCommand("Delete",!1)})(e);const g=s.getNode(),p={context:g.nodeName.toLowerCase(),data:n.data,insert:!0},h=i.parse(t,p);if(!0===n.paste&&Th(e.schema,h)&&((e,t)=>!!Dh(e,t))(a,g))return u=Lh(d,a,s.getRng(),h),u&&s.setRng(u),t;!0===n.paste&&((e,t,n,o)=>{var r;const s=t.firstChild,a=t.lastChild,i=s===("bookmark"===a.attr("data-mce-type")?a.prev:a),l=j(Mh,s.name);if(i&&l){const t="false"!==s.attr("contenteditable"),a=(null===(r=e.getParent(n,e.isBlock))||void 0===r?void 0:r.nodeName.toLowerCase())===s.name,i=M.from(bh(o,n)).forall(Go);return t&&a&&i}return!1})(a,h,g,e.getBody())&&(null===(o=h.firstChild)||void 0===o||o.unwrap()),(e=>{let t=e;for(;t=t.walk();)1===t.type&&t.attr("data-mce-fragment","1")})(h);let b=h.lastChild;if(b&&"mce_marker"===b.attr("id")){const t=b;for(b=b.prev;b;b=b.walk(!0))if(3===b.type||!a.isBlock(b.name)){b.parent&&e.schema.isValidChild(b.parent.name,"span")&&b.parent.insert(t,b,"br"===b.name);break}}if(e._selectionOverrides.showBlockCaretContainer(g),p.invalid){e.selection.setContent(c);let n,o=s.getNode();const l=e.getBody();for(Vo(o)?o=n=l:n=o;n&&n!==l;)o=n,n=n.parentNode;t=o===l?l.innerHTML:a.getOuterHTML(o);const u=i.parse(t);for(let e=u;e;e=e.walk())if("mce_marker"===e.attr("id")){e.replace(h);break}const m=h.children(),f=null!==(r=h.parent)&&void 0!==r?r:u;h.unwrap();const g=K(m,(t=>Ah(e.schema,t,f)));Rh(g,e.schema),kh(i.getNodeFilters(),i.getAttributeFilters(),u),t=d.serialize(u),o===l?a.setHTML(l,t):a.setOuterHTML(o,t)}else t=d.serialize(h),((e,t,n)=>{var o;if("all"===n.getAttribute("data-mce-bogus"))null===(o=n.parentNode)||void 0===o||o.insertBefore(e.dom.createFragment(t),n);else{const o=n.firstChild,r=n.lastChild;!o||o===r&&"BR"===o.nodeName?e.dom.setHTML(n,t):e.selection.setContent(t,{no_events:!0})}})(e,t,g);var v;return((e,t)=>{const n=e.schema.getTextInlineElements(),o=e.dom;if(t){const t=e.getBody(),r=Ch(e);Tt.each(o.select("*[data-mce-fragment]"),(e=>{if(C(n[e.nodeName.toLowerCase()])&&((e,t)=>te(Rg(e,t),(e=>!(e=>Eg.has(e))(e))))(o,e))for(let n=e.parentElement;C(n)&&n!==t&&!Ag(o,e,n);n=n.parentElement)if(r.compare(n,e)){o.remove(e,!0);break}}))}})(e,l),((e,t)=>{var n,o,r;let s;const a=e.dom,i=e.selection;if(!t)return;i.scrollIntoView(t);const l=bh(e.getBody(),t);if(l&&"false"===a.getContentEditable(l))return a.remove(t),void i.select(l);let d=a.createRng();const c=t.previousSibling;if(zo(c)){d.setStart(c,null!==(o=null===(n=c.nodeValue)||void 0===n?void 0:n.length)&&void 0!==o?o:0);const e=t.nextSibling;zo(e)&&(c.appendData(e.data),null===(r=e.parentNode)||void 0===r||r.removeChild(e))}else d.setStartBefore(t),d.setEndBefore(t);const u=a.getParent(t,a.isBlock);a.remove(t),u&&a.isEmpty(u)&&(no(mn(u)),d.setStart(u,0),d.setEnd(u,0),Ih(u)||(e=>!!e.getAttribute("data-mce-fragment"))(u)||!(s=(t=>{let n=xi.fromRangeStart(t);return n=$c(e.getBody()).next(n),null==n?void 0:n.toRange()})(d))?a.add(u,a.create("br",{"data-mce-bogus":"1"})):(d=s,a.remove(u))),i.setRng(d)})(e,a.get("mce_marker")),v=e.getBody(),Tt.each(v.getElementsByTagName("*"),(e=>{e.removeAttribute("data-mce-fragment")})),((e,t)=>{M.from(e.getParent(t,"td,th")).map(mn).each(xr)})(a,s.getStart()),((e,t,n)=>{const o=Sn(mn(n),(e=>bn(e,mn(t))));ae(o,o.length-2).filter(Ft).fold((()=>cs(e,t)),(t=>cs(e,t.dom)))})(e.schema,e.getBody(),s.getStart()),t},Uh=e=>e instanceof pg,zh=(e,t,n)=>{e.dom.setHTML(e.getBody(),t),!0!==n&&(e=>{Zf(e)&&Zc(e.getBody()).each((t=>{const n=t.getNode(),o=Io(n)?Zc(n).getOr(t):t;e.selection.setRng(o.toRange())}))})(e)},jh=(e,t)=>((e,t)=>{const n=e.dom;return n.parentNode?((e,t)=>Q(e.dom.childNodes,(e=>t(mn(e)))).map(mn))(mn(n.parentNode),(n=>!bn(e,n)&&t(n))):M.none()})(e,t).isSome(),Hh=e=>w(e)?e:P,$h=(e,t,n)=>{const o=t(e),r=Hh(n);return o.orThunk((()=>r(e)?M.none():((e,t,n)=>{let o=e.dom;const r=Hh(n);for(;o.parentNode;){o=o.parentNode;const e=mn(o),n=t(e);if(n.isSome())return n;if(r(e))break}return M.none()})(e,t,r)))},Vh=Gu,qh=(e,t,n)=>{const o=e.formatter.get(n);if(o)for(let n=0;n<o.length;n++){const r=o[n];if(tm(r)&&!1===r.inherit&&e.dom.is(t,r.selector))return!0}return!1},Wh=(e,t,n,o,r)=>{const s=e.dom.getRoot();if(t===s)return!1;const a=e.dom.getParent(t,(t=>!!qh(e,t,n)||t.parentNode===s||!!Yh(e,t,n,o,!0)));return!!Yh(e,a,n,o,r)},Kh=(e,t,n)=>!(!nm(n)||!Vh(t,n.inline))||!(!em(n)||!Vh(t,n.block))||!!tm(n)&&To(t)&&e.is(t,n.selector),Gh=(e,t,n,o,r,s)=>{const a=n[o],i="attributes"===o;if(w(n.onmatch))return n.onmatch(t,n,o);if(a)if(_e(a)){for(let n=0;n<a.length;n++)if(i?e.getAttrib(t,a[n]):Xu(e,t,a[n]))return!0}else for(const o in a)if(xe(a,o)){const l=i?e.getAttrib(t,o):Xu(e,t,o),d=Ku(a[o],s),c=y(l)||Ke(l);if(c&&y(d))continue;if(r&&c&&!n.exact)return!1;if((!r||n.exact)&&!Vh(l,Yu(d,o)))return!1}return!0},Yh=(e,t,n,o,r)=>{const s=e.formatter.get(n),a=e.dom;if(s&&To(t))for(let n=0;n<s.length;n++){const i=s[n];if(Kh(e.dom,t,i)&&Gh(a,t,i,"attributes",r,o)&&Gh(a,t,i,"styles",r,o)){const n=i.classes;if(n)for(let r=0;r<n.length;r++)if(!e.dom.hasClass(t,Ku(n[r],o)))return;return i}}},Xh=(e,t,n,o,r)=>{if(o)return Wh(e,o,t,n,r);if(o=e.selection.getNode(),Wh(e,o,t,n,r))return!0;const s=e.selection.getStart();return!(s===o||!Wh(e,s,t,n,r))},Qh=kr,Jh=e=>(e=>{const t=[];let n=e;for(;n;){if(zo(n)&&n.data!==Qh||n.childNodes.length>1)return[];To(n)&&t.push(n),n=n.firstChild}return t})(e).length>0,Zh=e=>{if(e){const t=new Ro(e,e);for(let e=t.current();e;e=t.next())if(zo(e))return e}return null},eb=e=>{const t=cn("span");return qt(t,{id:tu,"data-mce-bogus":"1","data-mce-type":"format-caret"}),e&&eo(t,un(Qh)),t},tb=(e,t,n=!0)=>{const o=e.dom,r=e.selection;if(Jh(t))Bp(e,!1,mn(t),n);else{const e=r.getRng(),n=o.getParent(t,o.isBlock),s=e.startContainer,a=e.startOffset,i=e.endContainer,l=e.endOffset,d=(e=>{const t=Zh(e);return t&&t.data.charAt(0)===Qh&&t.deleteData(0,1),t})(t);o.remove(t,!0),s===d&&a>0&&e.setStart(d,a-1),i===d&&l>0&&e.setEnd(d,l-1),n&&o.isEmpty(n)&&wr(mn(n)),r.setRng(e)}},nb=(e,t,n=!0)=>{const o=e.dom,r=e.selection;if(t)tb(e,t,n);else if(!(t=ou(e.getBody(),r.getStart())))for(;t=o.get(tu);)tb(e,t,!1)},ob=(e,t)=>(e.appendChild(t),t),rb=(e,t)=>{var n;const o=G(e,((e,t)=>ob(e,t.cloneNode(!1))),t),r=null!==(n=o.ownerDocument)&&void 0!==n?n:document;return ob(o,r.createTextNode(Qh))},sb=(e,t,n,o)=>{const a=e.dom,i=e.selection;let l=!1;const d=e.formatter.get(t);if(!d)return;const c=i.getRng(),u=c.startContainer,m=c.startOffset;let f=u;zo(u)&&(m!==u.data.length&&(l=!0),f=f.parentNode);const g=[];let h;for(;f;){if(Yh(e,f,t,n,o)){h=f;break}f.nextSibling&&(l=!0),g.push(f),f=f.parentNode}if(h)if(l){const r=i.getBookmark();c.collapse(!0);let s=vm(a,c,d,!0);s=uf(s),e.formatter.remove(t,n,s,o),i.moveToBookmark(r)}else{const l=ou(e.getBody(),h),d=eb(!1).dom;((e,t,n)=>{var o,r;const s=e.dom,a=s.getParent(n,O($u,e.schema));a&&s.isEmpty(a)?null===(o=n.parentNode)||void 0===o||o.replaceChild(t,n):((e=>{const t=or(e,"br"),n=K((e=>{const t=[];let n=e.dom;for(;n;)t.push(mn(n)),n=n.lastChild;return t})(e).slice(-1),ur);t.length===n.length&&V(n,oo)})(mn(n)),s.isEmpty(n)?null===(r=n.parentNode)||void 0===r||r.replaceChild(t,n):s.insertAfter(t,n))})(e,d,null!=l?l:h);const c=((e,t,n,o,a,i)=>{const l=e.formatter,d=e.dom,c=K(ue(l.get()),(e=>e!==o&&!Ue(e,"removeformat"))),u=((e,t,n)=>Y(n,((n,o)=>{const r=((e,t)=>Zu(e,t,(e=>{const t=e=>w(e)||e.length>1&&"%"===e.charAt(0);return H(["styles","attributes"],(n=>we(e,n).exists((e=>{const n=p(e)?e:Ce(e);return H(n,t)}))))})))(e,o);return e.formatter.matchNode(t,o,{},r)?n.concat([o]):n}),[]))(e,n,c);if(K(u,(t=>!((e,t,n)=>{const o=["inline","block","selector","attributes","styles","classes"],a=e=>ve(e,((e,t)=>H(o,(e=>e===t))));return Zu(e,t,(t=>{const o=a(t);return Zu(e,n,(e=>{const t=a(e);return((e,t,n=s)=>r(n).eq(e,t))(o,t)}))}))})(e,t,o))).length>0){const e=n.cloneNode(!1);return d.add(t,e),l.remove(o,a,e,i),d.remove(e),M.some(e)}return M.none()})(e,d,h,t,n,o),u=rb(g.concat(c.toArray()),d);l&&tb(e,l,!1),i.setCursorLocation(u,1),a.isEmpty(h)&&a.remove(h)}},ab=(e,t)=>{const n=e.schema.getTextInlineElements();return xe(n,Lt(t))&&!nu(t.dom)&&!Mo(t.dom)},ib={},lb=Do(["pre"]);ib.pre||(ib.pre=[]),ib.pre.push((e=>{if(!e.selection.getRng().collapsed){const t=e.selection.getSelectedBlocks(),n=K(K(t,lb),(e=>t=>{const n=t.previousSibling;return lb(n)&&j(e,n)})(t));V(n,(e=>{((e,t)=>{const n=mn(t),o=Cn(n).dom;oo(n),to(mn(e),[cn("br",o),cn("br",o),...An(n)])})(e.previousSibling,e)}))}}));const db=["fontWeight","fontStyle","color","fontSize","fontFamily"],cb=(e,t)=>{const n=e.get(t);return p(n)?Q(n,(e=>nm(e)&&"span"===e.inline&&(e=>f(e.styles)&&H(ue(e.styles),(e=>j(db,e))))(e))):M.none()},ub=(e,t)=>Jc(t,xi.fromRangeStart(e)).isNone(),mb=(e,t)=>!1===Qc(t,xi.fromRangeEnd(e)).exists((e=>!Wo(e.getNode())||Qc(t,e).isSome())),fb=e=>t=>Zo(t)&&"false"!==e.getContentEditableParent(t),gb=e=>K(e.getSelectedBlocks(),fb(e.dom)),pb=Tt.each,hb=e=>To(e)&&!pu(e)&&!nu(e)&&!Mo(e),bb=(e,t)=>{for(let n=e;n;n=n[t]){if(zo(n)&&We(n.data))return e;if(To(n)&&!pu(n))return n}return e},vb=(e,t,n)=>{const o=Ch(e),r=To(t)&&Uu(t),s=To(n)&&Uu(n);if(r&&s){const r=bb(t,"previousSibling"),s=bb(n,"nextSibling");if(o.compare(r,s)){for(let e=r.nextSibling;e&&e!==s;){const t=e;e=e.nextSibling,r.appendChild(t)}return e.dom.remove(s),Tt.each(Tt.grep(s.childNodes),(e=>{r.appendChild(e)})),r}}return n},yb=(e,t,n,o)=>{var r;if(o&&!1!==t.merge_siblings){const t=null!==(r=vb(e,Hu(o),o))&&void 0!==r?r:o;vb(e,t,Hu(t,!0))}},Cb=(e,t,n)=>{pb(e.childNodes,(e=>{hb(e)&&(t(e)&&n(e),e.hasChildNodes()&&Cb(e,t,n))}))},wb=(e,t)=>n=>!(!n||!Xu(e,n,t)),xb=(e,t,n)=>o=>{e.setStyle(o,t,n),""===o.getAttribute("style")&&o.removeAttribute("style"),((e,t)=>{"SPAN"===t.nodeName&&0===e.getAttribs(t).length&&e.remove(t,!0)})(e,o)},kb=Ki([{keep:[]},{rename:["name"]},{removed:[]}]),Sb=/^(src|href|style)$/,_b=Tt.each,Eb=Gu,Nb=(e,t,n)=>e.isChildOf(t,n)&&t!==n&&!e.isBlock(n),Rb=(e,t,n)=>{let o=t[n?"startContainer":"endContainer"],r=t[n?"startOffset":"endOffset"];if(To(o)){const e=o.childNodes.length-1;!n&&r&&r--,o=o.childNodes[r>e?e:r]}return zo(o)&&n&&r>=o.data.length&&(o=new Ro(o,e.getBody()).next()||o),zo(o)&&!n&&0===r&&(o=new Ro(o,e.getBody()).prev()||o),o},Ab=(e,t)=>{const n=t?"firstChild":"lastChild",o=e[n];return(e=>/^(TR|TH|TD)$/.test(e.nodeName))(e)&&o?"TR"===e.nodeName&&o[n]||o:e},Ob=(e,t,n,o)=>{var r;const s=e.create(n,o);return null===(r=t.parentNode)||void 0===r||r.insertBefore(s,t),s.appendChild(t),s},Tb=(e,t,n,o,r)=>{const s=mn(t),a=mn(e.create(o,r)),i=n?Rn(s):Nn(s);return to(a,i),n?(Qn(s,a),Zn(a,s)):(Jn(s,a),eo(a,s)),a.dom},Bb=(e,t,n)=>{const o=t.parentNode;let r;const s=e.dom,a=gl(e);em(n)&&o===s.getRoot()&&(n.list_block&&Eb(t,n.list_block)||V(de(t.childNodes),(t=>{Vu(e,a,t.nodeName.toLowerCase())?r?r.appendChild(t):(r=Ob(s,t,a),s.setAttribs(r,pl(e))):r=null}))),(e=>tm(e)&&nm(e)&&Bt(we(e,"mixed"),!0))(n)&&!Eb(n.inline,t)||s.remove(t,!0)},Db=(e,t,n)=>x(e)?{name:t,value:null}:{name:e,value:Ku(t,n)},Pb=(e,t)=>{""===e.getAttrib(t,"style")&&(t.removeAttribute("style"),t.removeAttribute("data-mce-style"))},Lb=(e,t,n,o,r)=>{let s=!1;_b(n.styles,((a,i)=>{const{name:l,value:d}=Db(i,a,o),c=Yu(d,l);(n.remove_similar||h(d)||!To(r)||Eb(Xu(e,r,l),c))&&e.setStyle(t,l,""),s=!0})),s&&Pb(e,t)},Mb=(e,t,n,o,r)=>{const s=e.dom,a=Ch(e),i=e.schema;if(nm(t)&&fs(i,t.inline)&&ps(i,o)&&o.parentElement===e.getBody())return Bb(e,o,t),kb.removed();if(!t.ceFalseOverride&&o&&"false"===s.getContentEditableParent(o))return kb.keep();if(o&&!Kh(s,o,t)&&!((e,t)=>t.links&&"A"===e.nodeName)(o,t))return kb.keep();const l=o,d=t.preserve_attributes;if(nm(t)&&"all"===t.remove&&p(d)){const e=K(s.getAttribs(l),(e=>j(d,e.name.toLowerCase())));if(s.removeAllAttribs(l),V(e,(e=>s.setAttrib(l,e.name,e.value))),e.length>0)return kb.rename("span")}if("all"!==t.remove){Lb(s,l,t,n,r),_b(t.attributes,((e,o)=>{const{name:a,value:i}=Db(o,e,n);if(t.remove_similar||h(i)||!To(r)||Eb(s.getAttrib(r,a),i)){if("class"===a){const e=s.getAttrib(l,a);if(e){let t="";if(V(e.split(/\s+/),(e=>{/mce\-\w+/.test(e)&&(t+=(t?" ":"")+e)})),t)return void s.setAttrib(l,a,t)}}if(Sb.test(a)&&l.removeAttribute("data-mce-"+a),"style"===a&&Do(["li"])(l)&&"none"===s.getStyle(l,"list-style-type"))return l.removeAttribute(a),void s.setStyle(l,"list-style-type","none");"class"===a&&l.removeAttribute("className"),l.removeAttribute(a)}})),_b(t.classes,(e=>{e=Ku(e,n),To(r)&&!s.hasClass(r,e)||s.removeClass(l,e)}));const e=s.getAttribs(l);for(let t=0;t<e.length;t++){const n=e[t].nodeName;if(!a.isAttributeInternal(n))return kb.keep()}}return"none"!==t.remove?(Bb(e,l,t),kb.removed()):kb.keep()},Ib=(e,t,n,o,r)=>Mb(e,t,n,o,r).fold(P,(t=>(e.dom.rename(o,t),!0)),L),Fb=(e,t,n,o)=>Mb(e,t,n,o,o).fold(N(o),(t=>(e.dom.createFragment().appendChild(o),e.dom.rename(o,t))),N(null)),Ub=(e,t,n,o,r)=>{const s=e.formatter.get(t),a=s[0],i=e.dom,l=e.selection,d=o=>{const i=((e,t,n,o,r)=>{let s;return t.parentNode&&V(Ju(e.dom,t.parentNode).reverse(),(t=>{if(!s&&To(t)&&"_start"!==t.id&&"_end"!==t.id){const a=Yh(e,t,n,o,r);a&&!1!==a.split&&(s=t)}})),s})(e,o,t,n,r);return((e,t,n,o,r,s,a,i)=>{var l,d;let c,u;const m=e.dom;if(n){const s=n.parentNode;for(let n=o.parentNode;n&&n!==s;n=n.parentNode){let o=m.clone(n,!1);for(let n=0;n<t.length&&(o=Fb(e,t[n],i,o),null!==o);n++);o&&(c&&o.appendChild(c),u||(u=o),c=o)}a.mixed&&m.isBlock(n)||(o=null!==(l=m.split(n,o))&&void 0!==l?l:o),c&&u&&(null===(d=r.parentNode)||void 0===d||d.insertBefore(c,r),u.appendChild(r),nm(a)&&yb(e,a,0,c))}return o})(e,s,i,o,o,0,a,n)},c=t=>H(s,(o=>Ib(e,o,n,t,t))),u=t=>{const n=de(t.childNodes),o=c(t)||H(s,(e=>Kh(i,t,e))),r=t.parentNode;if(!o&&C(r)&&om(a)&&c(r),a.deep&&n.length)for(let e=0;e<n.length;e++)u(n[e]);V(["underline","line-through","overline"],(n=>{To(t)&&e.dom.getStyle(t,"text-decoration")===n&&t.parentNode&&Qu(i,t.parentNode)===n&&Ib(e,{deep:!1,exact:!0,inline:"span",styles:{textDecoration:n}},void 0,t)}))},m=e=>{const t=i.get(e?"_start":"_end");if(t){let n=t[e?"firstChild":"lastChild"];return(e=>pu(e)&&To(e)&&("_start"===e.id||"_end"===e.id))(n)&&(n=n[e?"firstChild":"lastChild"]),zo(n)&&0===n.data.length&&(n=e?t.previousSibling||t.nextSibling:t.nextSibling||t.previousSibling),i.remove(t,!0),n}return null},f=t=>{let n,o,r=vm(i,t,s,t.collapsed);if(a.split){if(r=uf(r),n=Rb(e,r,!0),o=Rb(e,r),n!==o){if(n=Ab(n,!0),o=Ab(o,!1),Nb(i,n,o)){const e=M.from(n.firstChild).getOr(n);return d(Tb(i,e,!0,"span",{id:"_start","data-mce-type":"bookmark"})),void m(!0)}if(Nb(i,o,n)){const e=M.from(o.lastChild).getOr(o);return d(Tb(i,e,!1,"span",{id:"_end","data-mce-type":"bookmark"})),void m(!1)}n=Ob(i,n,"span",{id:"_start","data-mce-type":"bookmark"}),o=Ob(i,o,"span",{id:"_end","data-mce-type":"bookmark"});const e=i.createRng();e.setStartAfter(n),e.setEndBefore(o),ym(i,e,(e=>{V(e,(e=>{pu(e)||pu(e.parentNode)||d(e)}))})),d(n),d(o),n=m(!0),o=m()}else n=o=d(n);r.startContainer=n.parentNode?n.parentNode:n,r.startOffset=i.nodeIndex(n),r.endContainer=o.parentNode?o.parentNode:o,r.endOffset=i.nodeIndex(o)+1}ym(i,r,(e=>{V(e,u)}))};if(o){if(Iu(o)){const e=i.createRng();e.setStartBefore(o),e.setEndAfter(o),f(e)}else f(o);Am(e,t,o,n)}else l.isCollapsed()&&nm(a)&&!Ru(e).length?sb(e,t,n,r):(zu(e,(()=>Lu(e,f)),(o=>nm(a)&&Xh(e,t,n,o))),e.nodeChanged()),((e,t,n)=>{"removeformat"===t?V(gb(e.selection),(t=>{V(db,(n=>e.dom.setStyle(t,n,""))),Pb(e.dom,t)})):cb(e.formatter,t).each((t=>{V(gb(e.selection),(o=>Lb(e.dom,o,t,n,null)))}))})(e,t,n),Am(e,t,o,n)},zb=Tt.each,jb=Tt.each,Hb=(e,t,n,o)=>{if(jb(n.styles,((n,r)=>{e.setStyle(t,r,Ku(n,o))})),n.styles){const n=e.getAttrib(t,"style");n&&e.setAttrib(t,"data-mce-style",n)}},$b=(e,t,n,o)=>{const r=e.formatter.get(t),s=r[0],a=!o&&e.selection.isCollapsed(),i=e.dom,l=e.selection,d=(e,t=s)=>{w(t.onformat)&&t.onformat(e,t,n,o),Hb(i,e,t,n),jb(t.attributes,((t,o)=>{i.setAttrib(e,o,Ku(t,n))})),jb(t.classes,(t=>{const o=Ku(t,n);i.hasClass(e,o)||i.addClass(e,o)}))},c=(e,t)=>{let n=!1;return jb(e,(e=>!(!tm(e)||("false"!==i.getContentEditable(t)||e.ceFalseOverride)&&(!C(e.collapsed)||e.collapsed===a)&&i.is(t,e.selector)&&!nu(t)&&(d(t,e),n=!0,1)))),n},u=e=>{if(m(e)){const t=i.create(e);return d(t),t}return null},f=(o,a,i)=>{const l=[];let m=!0;const f=s.inline||s.block,g=u(f);ym(o,a,(a=>{let u;const p=a=>{let h=!1,b=m,v=!1;const y=a.parentNode,w=y.nodeName.toLowerCase(),x=o.getContentEditable(a);C(x)&&(b=m,m="true"===x,h=!0,v=Wu(e,a));const k=m&&!h;if(Wo(a)&&!((e,t,n,o)=>{if(Zl(e)&&nm(t)&&n.parentNode){const t=Ys(e.schema),r=jh(mn(n),(e=>nu(e.dom)));return ke(t,o)&&os(mn(n.parentNode),!1)&&!r}return!1})(e,s,a,w))return u=null,void(em(s)&&o.remove(a));if((o=>(e=>em(e)&&!0===e.wrapper)(s)&&Yh(e,o,t,n))(a))u=null;else{if(((t,n,o)=>{const r=(e=>em(e)&&!0!==e.wrapper)(s)&&$u(e.schema,t)&&Vu(e,n,f);return o&&r})(a,w,k)){const e=o.rename(a,f);return d(e),l.push(e),void(u=null)}if(tm(s)){let e=c(r,a);if(!e&&C(y)&&om(s)&&(e=c(r,y)),!nm(s)||e)return void(u=null)}C(g)&&((t,n,r,a)=>{const l=t.nodeName.toLowerCase(),d=Vu(e,f,l)&&Vu(e,n,f),c=!i&&zo(t)&&Sr(t.data),u=nu(t),m=!nm(s)||!o.isBlock(t);return(r||a)&&d&&!c&&!u&&m})(a,w,k,v)?(u||(u=o.clone(g,!1),y.insertBefore(u,a),l.push(u)),v&&h&&(m=b),u.appendChild(a)):(u=null,V(de(a.childNodes),p),h&&(m=b),u=null)}};V(a,p)})),!0===s.links&&V(l,(e=>{const t=e=>{"A"===e.nodeName&&d(e,s),V(de(e.childNodes),t)};t(e)})),V(l,(a=>{const i=(e=>{let t=0;return V(e.childNodes,(e=>{(e=>C(e)&&zo(e)&&0===e.length)(e)||pu(e)||t++})),t})(a);!(l.length>1)&&o.isBlock(a)||0!==i?(nm(s)||em(s)&&s.wrapper)&&(s.exact||1!==i||(a=(e=>{const t=Q(e.childNodes,Fu).filter((e=>"false"!==o.getContentEditable(e)&&Kh(o,e,s)));return t.map((t=>{const n=o.clone(t,!1);return d(n),o.replace(n,e,!0),o.remove(t,!0),n})).getOr(e)})(a)),((e,t,n,o)=>{zb(t,(t=>{nm(t)&&zb(e.dom.select(t.inline,o),(o=>{hb(o)&&Ib(e,t,n,o,t.exact?o:null)})),((e,t,n)=>{if(t.clear_child_styles){const o=t.links?"*:not(a)":"*";pb(e.select(o,n),(n=>{hb(n)&&Uu(n)&&pb(t.styles,((t,o)=>{e.setStyle(n,o,"")}))}))}})(e.dom,t,o)}))})(e,r,n,a),((e,t,n,o,r)=>{const s=r.parentNode;Yh(e,s,n,o)&&Ib(e,t,o,r)||t.merge_with_parents&&s&&e.dom.getParent(s,(s=>!!Yh(e,s,n,o)&&(Ib(e,t,o,r),!0)))})(e,s,t,n,a),((e,t,n,o)=>{if(t.styles&&t.styles.backgroundColor){const r=wb(e,"fontSize");Cb(o,(e=>r(e)&&Uu(e)),xb(e,"backgroundColor",Ku(t.styles.backgroundColor,n)))}})(o,s,n,a),((e,t,n,o)=>{const r=t=>{if(To(t)&&To(t.parentNode)&&Uu(t)){const n=Qu(e,t.parentNode);e.getStyle(t,"color")&&n?e.setStyle(t,"text-decoration",n):e.getStyle(t,"text-decoration")===n&&e.setStyle(t,"text-decoration",null)}};t.styles&&(t.styles.color||t.styles.textDecoration)&&(Tt.walk(o,r,"childNodes"),r(o))})(o,s,0,a),((e,t,n,o)=>{if(nm(t)&&("sub"===t.inline||"sup"===t.inline)){const n=wb(e,"fontSize");Cb(o,(e=>n(e)&&Uu(e)),xb(e,"fontSize",""));const r=K(e.select("sup"===t.inline?"sub":"sup",o),Uu);e.remove(r,!0)}})(o,s,0,a),yb(e,s,0,a)):o.remove(a,!0)}))},g=Iu(o)?o:l.getNode();if("false"===i.getContentEditable(g)&&!Wu(e,g))return c(r,o=g),void Rm(e,t,o,n);if(s){if(o)if(Iu(o)){if(!c(r,o)){const e=i.createRng();e.setStartBefore(o),e.setEndAfter(o),f(i,vm(i,e,r),!0)}}else f(i,o,!0);else a&&nm(s)&&!Ru(e).length?((e,t,n)=>{let o;const r=e.selection,s=e.formatter.get(t);if(!s)return;const a=r.getRng();let i=a.startOffset;const l=a.startContainer.nodeValue;o=ou(e.getBody(),r.getStart());const d=/[^\s\u00a0\u00ad\u200b\ufeff]/;if(l&&i>0&&i<l.length&&d.test(l.charAt(i))&&d.test(l.charAt(i-1))){const o=r.getBookmark();a.collapse(!0);let i=vm(e.dom,a,s);i=uf(i),e.formatter.apply(t,n,i),r.moveToBookmark(o)}else{let s=o?Zh(o):null;o&&(null==s?void 0:s.data)===Qh||(c=e.getDoc(),u=eb(!0).dom,o=c.importNode(u,!0),s=o.firstChild,a.insertNode(o),i=1),e.formatter.apply(t,n,o),r.setCursorLocation(s,i)}var c,u})(e,t,n):(l.setRng(Oh(l.getRng())),zu(e,(()=>{Lu(e,((e,t)=>{const n=t?e:vm(i,e,r);f(i,n,!1)}))}),L),e.nodeChanged()),cb(e.formatter,t).each((t=>{V((e=>K((e=>{const t=e.getSelectedBlocks(),n=e.getRng();if(e.isCollapsed())return[];if(1===t.length)return ub(n,t[0])&&mb(n,t[0])?t:[];{const e=ie(t).filter((e=>ub(n,e))).toArray(),o=le(t).filter((e=>mb(n,e))).toArray(),r=t.slice(1,-1);return e.concat(r).concat(o)}})(e),fb(e.dom)))(e.selection),(e=>Hb(i,e,t,n)))}));((e,t)=>{xe(ib,e)&&V(ib[e],(e=>{e(t)}))})(t,e)}Rm(e,t,o,n)},Vb=e=>xe(e,"vars"),qb=e=>e.selection.getStart(),Wb=(e,t,n,o,r)=>X(t,(t=>{const s=e.formatter.matchNode(t,n,null!=r?r:{},o);return!v(s)}),(t=>!!qh(e,t,n)||!o&&C(e.formatter.matchNode(t,n,r,!0)))),Kb=(e,t)=>{const n=null!=t?t:qb(e);return K(Ju(e.dom,n),(e=>To(e)&&!Mo(e)))},Gb=(e,t,n)=>{const o=Kb(e,t);fe(n,((n,r)=>{const s=n=>{const s=Wb(e,o,r,n.similar,Vb(n)?n.vars:void 0),a=s.isSome();if(n.state.get()!==a){n.state.set(a);const e=s.getOr(t);Vb(n)?n.callback(a,{node:e,format:r,parents:o}):V(n.callbacks,(t=>t(a,{node:e,format:r,parents:o})))}};V([n.withSimilar,n.withoutSimilar],s),V(n.withVars,s)}))};function Yb(e){return Yb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yb(e)}function Xb(e,t){return Xb=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Xb(e,t)}function Qb(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function Jb(e,t,n){return Jb=Qb()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&Xb(r,n.prototype),r},Jb.apply(null,arguments)}function Zb(e){return function(e){if(Array.isArray(e))return ev(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return ev(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ev(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ev(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var tv=Object.hasOwnProperty,nv=Object.setPrototypeOf,ov=Object.isFrozen,rv=Object.getPrototypeOf,sv=Object.getOwnPropertyDescriptor,av=Object.freeze,iv=Object.seal,lv=Object.create,dv="undefined"!=typeof Reflect&&Reflect,cv=dv.apply,uv=dv.construct;cv||(cv=function(e,t,n){return e.apply(t,n)}),av||(av=function(e){return e}),iv||(iv=function(e){return e}),uv||(uv=function(e,t){return Jb(e,Zb(t))});var mv,fv=kv(Array.prototype.forEach),gv=kv(Array.prototype.pop),pv=kv(Array.prototype.push),hv=kv(String.prototype.toLowerCase),bv=kv(String.prototype.match),vv=kv(String.prototype.replace),yv=kv(String.prototype.indexOf),Cv=kv(String.prototype.trim),wv=kv(RegExp.prototype.test),xv=(mv=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return uv(mv,t)});function kv(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return cv(e,t,o)}}function Sv(e,t){nv&&nv(e,null);for(var n=t.length;n--;){var o=t[n];if("string"==typeof o){var r=hv(o);r!==o&&(ov(t)||(t[n]=r),o=r)}e[o]=!0}return e}function _v(e){var t,n=lv(null);for(t in e)cv(tv,e,[t])&&(n[t]=e[t]);return n}function Ev(e,t){for(;null!==e;){var n=sv(e,t);if(n){if(n.get)return kv(n.get);if("function"==typeof n.value)return kv(n.value)}e=rv(e)}return function(e){return console.warn("fallback value for",e),null}}var Nv=av(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Rv=av(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Av=av(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ov=av(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Tv=av(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),Bv=av(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Dv=av(["#text"]),Pv=av(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),Lv=av(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Mv=av(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Iv=av(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Fv=iv(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Uv=iv(/<%[\w\W]*|[\w\W]*%>/gm),zv=iv(/^data-[\-\w.\u00B7-\uFFFF]/),jv=iv(/^aria-[\-\w]+$/),Hv=iv(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),$v=iv(/^(?:\w+script|data):/i),Vv=iv(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qv=iv(/^html$/i),Wv=function(){return"undefined"==typeof window?null:window},Kv=function(e,t){if("object"!==Yb(e)||"function"!=typeof e.createPolicy)return null;var n=null,o="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(o)&&(n=t.currentScript.getAttribute(o));var r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Gv=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Wv(),n=function(t){return e(t)};if(n.version="2.3.8",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var o=t.document,r=t.document,s=t.DocumentFragment,a=t.HTMLTemplateElement,i=t.Node,l=t.Element,d=t.NodeFilter,c=t.NamedNodeMap,u=void 0===c?t.NamedNodeMap||t.MozNamedAttrMap:c,m=t.HTMLFormElement,f=t.DOMParser,g=t.trustedTypes,p=l.prototype,h=Ev(p,"cloneNode"),b=Ev(p,"nextSibling"),v=Ev(p,"childNodes"),y=Ev(p,"parentNode");if("function"==typeof a){var C=r.createElement("template");C.content&&C.content.ownerDocument&&(r=C.content.ownerDocument)}var w=Kv(g,o),x=w?w.createHTML(""):"",k=r,S=k.implementation,_=k.createNodeIterator,E=k.createDocumentFragment,N=k.getElementsByTagName,R=o.importNode,A={};try{A=_v(r).documentMode?r.documentMode:{}}catch(e){}var O={};n.isSupported="function"==typeof y&&S&&void 0!==S.createHTMLDocument&&9!==A;var T,B,D=Fv,P=Uv,L=zv,M=jv,I=$v,F=Vv,U=Hv,z=null,j=Sv({},[].concat(Zb(Nv),Zb(Rv),Zb(Av),Zb(Tv),Zb(Dv))),H=null,$=Sv({},[].concat(Zb(Pv),Zb(Lv),Zb(Mv),Zb(Iv))),V=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),q=null,W=null,K=!0,G=!0,Y=!1,X=!1,Q=!1,J=!1,Z=!1,ee=!1,te=!1,ne=!1,oe=!0,re=!0,se=!1,ae={},ie=null,le=Sv({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),de=null,ce=Sv({},["audio","video","img","source","image","track"]),ue=null,me=Sv({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),fe="http://www.w3.org/1998/Math/MathML",ge="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml",he=pe,be=!1,ve=["application/xhtml+xml","text/html"],ye="text/html",Ce=null,we=r.createElement("form"),xe=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){Ce&&Ce===e||(e&&"object"===Yb(e)||(e={}),e=_v(e),z="ALLOWED_TAGS"in e?Sv({},e.ALLOWED_TAGS):j,H="ALLOWED_ATTR"in e?Sv({},e.ALLOWED_ATTR):$,ue="ADD_URI_SAFE_ATTR"in e?Sv(_v(me),e.ADD_URI_SAFE_ATTR):me,de="ADD_DATA_URI_TAGS"in e?Sv(_v(ce),e.ADD_DATA_URI_TAGS):ce,ie="FORBID_CONTENTS"in e?Sv({},e.FORBID_CONTENTS):le,q="FORBID_TAGS"in e?Sv({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?Sv({},e.FORBID_ATTR):{},ae="USE_PROFILES"in e&&e.USE_PROFILES,K=!1!==e.ALLOW_ARIA_ATTR,G=!1!==e.ALLOW_DATA_ATTR,Y=e.ALLOW_UNKNOWN_PROTOCOLS||!1,X=e.SAFE_FOR_TEMPLATES||!1,Q=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ne=e.RETURN_TRUSTED_TYPE||!1,Z=e.FORCE_BODY||!1,oe=!1!==e.SANITIZE_DOM,re=!1!==e.KEEP_CONTENT,se=e.IN_PLACE||!1,U=e.ALLOWED_URI_REGEXP||U,he=e.NAMESPACE||pe,e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(V.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(V.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(V.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),T=T=-1===ve.indexOf(e.PARSER_MEDIA_TYPE)?ye:e.PARSER_MEDIA_TYPE,B="application/xhtml+xml"===T?function(e){return e}:hv,X&&(G=!1),te&&(ee=!0),ae&&(z=Sv({},Zb(Dv)),H=[],!0===ae.html&&(Sv(z,Nv),Sv(H,Pv)),!0===ae.svg&&(Sv(z,Rv),Sv(H,Lv),Sv(H,Iv)),!0===ae.svgFilters&&(Sv(z,Av),Sv(H,Lv),Sv(H,Iv)),!0===ae.mathMl&&(Sv(z,Tv),Sv(H,Mv),Sv(H,Iv))),e.ADD_TAGS&&(z===j&&(z=_v(z)),Sv(z,e.ADD_TAGS)),e.ADD_ATTR&&(H===$&&(H=_v(H)),Sv(H,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&Sv(ue,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(ie===le&&(ie=_v(ie)),Sv(ie,e.FORBID_CONTENTS)),re&&(z["#text"]=!0),Q&&Sv(z,["html","head","body"]),z.table&&(Sv(z,["tbody"]),delete q.tbody),av&&av(e),Ce=e)},Se=Sv({},["mi","mo","mn","ms","mtext"]),_e=Sv({},["foreignobject","desc","title","annotation-xml"]),Ee=Sv({},["title","style","font","a","script"]),Ne=Sv({},Rv);Sv(Ne,Av),Sv(Ne,Ov);var Re=Sv({},Tv);Sv(Re,Bv);var Ae=function(e){var t=y(e);t&&t.tagName||(t={namespaceURI:pe,tagName:"template"});var n=hv(e.tagName),o=hv(t.tagName);return e.namespaceURI===ge?t.namespaceURI===pe?"svg"===n:t.namespaceURI===fe?"svg"===n&&("annotation-xml"===o||Se[o]):Boolean(Ne[n]):e.namespaceURI===fe?t.namespaceURI===pe?"math"===n:t.namespaceURI===ge?"math"===n&&_e[o]:Boolean(Re[n]):e.namespaceURI===pe&&!(t.namespaceURI===ge&&!_e[o])&&!(t.namespaceURI===fe&&!Se[o])&&!Re[n]&&(Ee[n]||!Ne[n])},Oe=function(e){pv(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=x}catch(t){e.remove()}}},Te=function(e,t){try{pv(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){pv(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!H[e])if(ee||te)try{Oe(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Be=function(e){var t,n;if(Z)e="<remove></remove>"+e;else{var o=bv(e,/^[\r\n\t ]+/);n=o&&o[0]}"application/xhtml+xml"===T&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var s=w?w.createHTML(e):e;if(he===pe)try{t=(new f).parseFromString(s,T)}catch(e){}if(!t||!t.documentElement){t=S.createDocument(he,"template",null);try{t.documentElement.innerHTML=be?"":s}catch(e){}}var a=t.body||t.documentElement;return e&&n&&a.insertBefore(r.createTextNode(n),a.childNodes[0]||null),he===pe?N.call(t,Q?"html":"body")[0]:Q?t.documentElement:a},De=function(e){return _.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},Pe=function(e){return e instanceof m&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},Le=function(e){return"object"===Yb(i)?e instanceof i:e&&"object"===Yb(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Me=function(e,t,o){O[e]&&fv(O[e],(function(e){e.call(n,t,o,Ce)}))},Ie=function(e){var t;if(Me("beforeSanitizeElements",e,null),Pe(e))return Oe(e),!0;if(wv(/[\u0080-\uFFFF]/,e.nodeName))return Oe(e),!0;var o=B(e.nodeName);if(Me("uponSanitizeElement",e,{tagName:o,allowedTags:z}),e.hasChildNodes()&&!Le(e.firstElementChild)&&(!Le(e.content)||!Le(e.content.firstElementChild))&&wv(/<[/\w]/g,e.innerHTML)&&wv(/<[/\w]/g,e.textContent))return Oe(e),!0;if("select"===o&&wv(/<template/i,e.innerHTML))return Oe(e),!0;if(!z[o]||q[o]){if(!q[o]&&Ue(o)){if(V.tagNameCheck instanceof RegExp&&wv(V.tagNameCheck,o))return!1;if(V.tagNameCheck instanceof Function&&V.tagNameCheck(o))return!1}if(re&&!ie[o]){var r=y(e)||e.parentNode,s=v(e)||e.childNodes;if(s&&r)for(var a=s.length-1;a>=0;--a)r.insertBefore(h(s[a],!0),b(e))}return Oe(e),!0}return e instanceof l&&!Ae(e)?(Oe(e),!0):"noscript"!==o&&"noembed"!==o||!wv(/<\/no(script|embed)/i,e.innerHTML)?(X&&3===e.nodeType&&(t=e.textContent,t=vv(t,D," "),t=vv(t,P," "),e.textContent!==t&&(pv(n.removed,{element:e.cloneNode()}),e.textContent=t)),Me("afterSanitizeElements",e,null),!1):(Oe(e),!0)},Fe=function(e,t,n){if(oe&&("id"===t||"name"===t)&&(n in r||n in we))return!1;if(G&&!W[t]&&wv(L,t));else if(K&&wv(M,t));else if(!H[t]||W[t]){if(!(Ue(e)&&(V.tagNameCheck instanceof RegExp&&wv(V.tagNameCheck,e)||V.tagNameCheck instanceof Function&&V.tagNameCheck(e))&&(V.attributeNameCheck instanceof RegExp&&wv(V.attributeNameCheck,t)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(t))||"is"===t&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&wv(V.tagNameCheck,n)||V.tagNameCheck instanceof Function&&V.tagNameCheck(n))))return!1}else if(ue[t]);else if(wv(U,vv(n,F,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==yv(n,"data:")||!de[e])if(Y&&!wv(I,vv(n,F,"")));else if(n)return!1;return!0},Ue=function(e){return e.indexOf("-")>0},ze=function(e){var t,n,o,r;Me("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H};for(r=s.length;r--;){var i=t=s[r],l=i.name,d=i.namespaceURI;n="value"===l?t.value:Cv(t.value),o=B(l);var c=n;if(a.attrName=o,a.attrValue=n,a.keepAttr=!0,a.forceKeepAttr=void 0,Me("uponSanitizeAttribute",e,a),n=a.attrValue,!a.forceKeepAttr)if(a.keepAttr)if(wv(/\/>/i,n))Te(l,e);else{X&&(n=vv(n,D," "),n=vv(n,P," "));var u=B(e.nodeName);if(Fe(u,o,n)){if(n!==c)try{d?e.setAttributeNS(d,l,n):e.setAttribute(l,n)}catch(t){Te(l,e)}}else Te(l,e)}else Te(l,e)}Me("afterSanitizeAttributes",e,null)}},je=function e(t){var n,o=De(t);for(Me("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)Me("uponSanitizeShadowNode",n,null),Ie(n)||(n.content instanceof s&&e(n.content),ze(n));Me("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,r){var a,l,d,c,u;if((be=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Le(e)){if("function"!=typeof e.toString)throw xv("toString is not a function");if("string"!=typeof(e=e.toString()))throw xv("dirty is not a string, aborting")}if(!n.isSupported){if("object"===Yb(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Le(e))return t.toStaticHTML(e.outerHTML)}return e}if(J||ke(r),n.removed=[],"string"==typeof e&&(se=!1),se){if(e.nodeName){var m=B(e.nodeName);if(!z[m]||q[m])throw xv("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof i)1===(l=(a=Be("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?a=l:a.appendChild(l);else{if(!ee&&!X&&!Q&&-1===e.indexOf("<"))return w&&ne?w.createHTML(e):e;if(!(a=Be(e)))return ee?null:ne?x:""}a&&Z&&Oe(a.firstChild);for(var f=De(se?e:a);d=f.nextNode();)3===d.nodeType&&d===c||Ie(d)||(d.content instanceof s&&je(d.content),ze(d),c=d);if(c=null,se)return e;if(ee){if(te)for(u=E.call(a.ownerDocument);a.firstChild;)u.appendChild(a.firstChild);else u=a;return H.shadowroot&&(u=R.call(o,u,!0)),u}var g=Q?a.outerHTML:a.innerHTML;return Q&&z["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&wv(qv,a.ownerDocument.doctype.name)&&(g="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+g),X&&(g=vv(g,D," "),g=vv(g,P," ")),w&&ne?w.createHTML(g):g},n.setConfig=function(e){ke(e),J=!0},n.clearConfig=function(){Ce=null,J=!1},n.isValidAttribute=function(e,t,n){Ce||ke({});var o=B(e),r=B(t);return Fe(o,r,n)},n.addHook=function(e,t){"function"==typeof t&&(O[e]=O[e]||[],pv(O[e],t))},n.removeHook=function(e){if(O[e])return gv(O[e])},n.removeHooks=function(e){O[e]&&(O[e]=[])},n.removeAllHooks=function(){O={}},n}();const Yv=Tt.explode,Xv=()=>{const e={};return{addFilter:(t,n)=>{V(Yv(t),(t=>{xe(e,t)||(e[t]={name:t,callbacks:[]}),e[t].callbacks.push(n)}))},getFilters:()=>Ce(e),removeFilter:(t,n)=>{V(Yv(t),(t=>{if(xe(e,t))if(C(n)){const o=e[t],r=K(o.callbacks,(e=>e!==n));r.length>0?o.callbacks=r:delete e[t]}else delete e[t]}))}}},Qv=(e,t,n)=>{var o;const r=Js();t.convert_fonts_to_spans&&((e,t,n)=>{e.addNodeFilter("font",(e=>{V(e,(e=>{const o=t.parse(e.attr("style")),r=e.attr("color"),s=e.attr("face"),a=e.attr("size");r&&(o.color=r),s&&(o["font-family"]=s),a&&Ge(a).each((e=>{o["font-size"]=n[e-1]})),e.name="span",e.attr("style",t.serialize(o)),((e,t)=>{V(["color","face","size"],(t=>{e.attr(t,null)}))})(e)}))}))})(e,r,Tt.explode(null!==(o=t.font_size_legacy_values)&&void 0!==o?o:"")),((e,t,n)=>{e.addNodeFilter("strike",(e=>{const o="html4"!==t.type;V(e,(e=>{if(o)e.name="s";else{const t=n.parse(e.attr("style"));t["text-decoration"]="line-through",e.name="span",e.attr("style",n.serialize(t))}}))}))})(e,n,r)},Jv=e=>{const[t,...n]=e.split(","),o=n.join(","),r=/data:([^/]+\/[^;]+)(;.+)?/.exec(t);if(r){const e=";base64"===r[2],t=e?(e=>{const t=/([a-z0-9+\/=\s]+)/i.exec(e);return t?t[1]:""})(o):decodeURIComponent(o);return M.some({type:r[1],data:t,base64Encoded:e})}return M.none()},Zv=(e,t,n=!0)=>{let o=t;if(n)try{o=atob(t)}catch(e){return M.none()}const r=new Uint8Array(o.length);for(let e=0;e<r.length;e++)r[e]=o.charCodeAt(e);return M.some(new Blob([r],{type:e}))},ey=e=>new Promise(((t,n)=>{const o=new FileReader;o.onloadend=()=>{t(o.result)},o.onerror=()=>{var e;n(null===(e=o.error)||void 0===e?void 0:e.message)},o.readAsDataURL(e)}));let ty=0;const ny=(e,t,n)=>Jv(e).bind((({data:e,type:o,base64Encoded:r})=>{if(t&&!r)return M.none();{const t=r?e:btoa(e);return n(t,o)}})),oy=(e,t,n)=>{const o=e.create("blobid"+ty++,t,n);return e.add(o),o},ry=(e,t,n=!1)=>ny(t,n,((t,n)=>M.from(e.getByData(t,n)).orThunk((()=>Zv(n,t).map((n=>oy(e,n,t))))))),sy=Tt.each,ay=Tt.trim,iy=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],ly={ftp:21,http:80,https:443,mailto:25},dy=["img","video"],cy=(e,t,n)=>{const o=(e=>{try{return decodeURIComponent(e)}catch(t){return unescape(e)}})(t);return!e.allow_script_urls&&(!!/((java|vb)script|mhtml):/i.test(o)||!e.allow_html_data_urls&&(/^data:image\//i.test(o)?((e,t)=>C(e)?!e:!C(t)||!j(dy,t))(e.allow_svg_data_urls,n)&&/^data:image\/svg\+xml/i.test(o):/^data:/i.test(o)))};class uy{constructor(e,t={}){this.path="",this.directory="",e=ay(e),this.settings=t;const n=t.base_uri,o=this;if(/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e))return void(o.source=e);const r=0===e.indexOf("//");if(0!==e.indexOf("/")||r||(e=(n&&n.protocol||"http")+"://mce_host"+e),!/^[\w\-]*:?\/\//.test(e)){const t=n?n.path:new uy(document.location.href).directory;if(""===(null==n?void 0:n.protocol))e="//mce_host"+o.toAbsPath(t,e);else{const r=/([^#?]*)([#?]?.*)/.exec(e);r&&(e=(n&&n.protocol||"http")+"://mce_host"+o.toAbsPath(t,r[1])+r[2])}}e=e.replace(/@@/g,"(mce_at)");const s=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);s&&sy(iy,((e,t)=>{let n=s[t];n&&(n=n.replace(/\(mce_at\)/g,"@@")),o[e]=n})),n&&(o.protocol||(o.protocol=n.protocol),o.userInfo||(o.userInfo=n.userInfo),o.port||"mce_host"!==o.host||(o.port=n.port),o.host&&"mce_host"!==o.host||(o.host=n.host),o.source=""),r&&(o.protocol="")}static parseDataUri(e){let t;const n=decodeURIComponent(e).split(","),o=/data:([^;]+)/.exec(n[0]);return o&&(t=o[1]),{type:t,data:n[1]}}static isDomSafe(e,t,n={}){if(n.allow_script_urls)return!0;{const o=Fs.decode(e).replace(/[\s\u0000-\u001F]+/g,"");return!cy(n,o,t)}}static getDocumentBaseUrl(e){var t;let n;return n=0!==e.protocol.indexOf("http")&&"file:"!==e.protocol?null!==(t=e.href)&&void 0!==t?t:"":e.protocol+"//"+e.host+e.pathname,/^[^:]+:\/\/\/?[^\/]+\//.test(n)&&(n=n.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(n)||(n+="/")),n}setPath(e){const t=/^(.*?)\/?(\w+)?$/.exec(e);t&&(this.path=t[0],this.directory=t[1],this.file=t[2]),this.source="",this.getURI()}toRelative(e){if("./"===e)return e;const t=new uy(e,{base_uri:this});if("mce_host"!==t.host&&this.host!==t.host&&t.host||this.port!==t.port||this.protocol!==t.protocol&&""!==t.protocol)return t.getURI();const n=this.getURI(),o=t.getURI();if(n===o||"/"===n.charAt(n.length-1)&&n.substr(0,n.length-1)===o)return n;let r=this.toRelPath(this.path,t.path);return t.query&&(r+="?"+t.query),t.anchor&&(r+="#"+t.anchor),r}toAbsolute(e,t){const n=new uy(e,{base_uri:this});return n.getURI(t&&this.isSameOrigin(n))}isSameOrigin(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;const t=this.protocol?ly[this.protocol]:null;if(t&&(this.port||t)==(e.port||t))return!0}return!1}toRelPath(e,t){let n,o,r=0,s="";const a=e.substring(0,e.lastIndexOf("/")).split("/"),i=t.split("/");if(a.length>=i.length)for(n=0,o=a.length;n<o;n++)if(n>=i.length||a[n]!==i[n]){r=n+1;break}if(a.length<i.length)for(n=0,o=i.length;n<o;n++)if(n>=a.length||a[n]!==i[n]){r=n+1;break}if(1===r)return t;for(n=0,o=a.length-(r-1);n<o;n++)s+="../";for(n=r-1,o=i.length;n<o;n++)s+=n!==r-1?"/"+i[n]:i[n];return s}toAbsPath(e,t){let n=0;const o=/\/$/.test(t)?"/":"",r=e.split("/"),s=t.split("/"),a=[];sy(r,(e=>{e&&a.push(e)}));const i=[];for(let e=s.length-1;e>=0;e--)0!==s[e].length&&"."!==s[e]&&(".."!==s[e]?n>0?n--:i.push(s[e]):n++);const l=a.length-n;let d;return d=l<=0?ne(i).join("/"):a.slice(0,l).join("/")+"/"+ne(i).join("/"),0!==d.indexOf("/")&&(d="/"+d),o&&d.lastIndexOf("/")!==d.length-1&&(d+=o),d}getURI(e=!1){let t;return this.source&&!e||(t="",e||(this.protocol?t+=this.protocol+"://":t+="//",this.userInfo&&(t+=this.userInfo+"@"),this.host&&(t+=this.host),this.port&&(t+=":"+this.port)),this.path&&(t+=this.path),this.query&&(t+="?"+this.query),this.anchor&&(t+="#"+this.anchor),this.source=t),this.source}}const my=Tt.makeMap,fy=Tt.extend,gy={IN_PLACE:!0,ALLOW_UNKNOWN_PROTOCOLS:!0,ALLOWED_TAGS:["#comment","#cdata-section","body"],ALLOWED_ATTR:[]},py=Tt.makeMap("src,href,data,background,action,formaction,poster,xlink:href"),hy="data-mce-type",by=(e,t)=>{const n=Gv(),o=t.getSpecialElements(),r=e.validate;let s=0;return n.addHook("uponSanitizeElement",((n,a)=>{var i,l,d;8===n.nodeType&&!e.allow_conditional_comments&&/^\[if/i.test(null!==(i=n.nodeValue)&&void 0!==i?i:"")&&(n.nodeValue=" "+n.nodeValue);const c=a.tagName;if(1!==n.nodeType||"body"===c)return;const u=mn(n),f=c.toLowerCase(),g=Gt(u,hy),p=Wt(u,"data-mce-bogus");if(!g&&m(p))return void("all"===p?oo(u):ro(u));const h=t.getElementRule(f);if(!r||h){if(a.allowedTags[c]=!0,r&&h&&!g){if(V(null!==(l=h.attributesForced)&&void 0!==l?l:[],(e=>{Vt(u,e.name,"{$uid}"===e.value?"mce_"+s++:e.value)})),V(null!==(d=h.attributesDefault)&&void 0!==d?d:[],(e=>{Gt(u,e.name)||Vt(u,e.name,"{$uid}"===e.value?"mce_"+s++:e.value)})),h.attributesRequired&&!H(h.attributesRequired,(e=>Gt(u,e))))return void ro(u);if(h.removeEmptyAttrs&&(e=>{const t=e.dom.attributes;return null==t||0===t.length})(u))return void ro(u);h.outputName&&h.outputName!==f&&((e,t)=>{const n=((e,t)=>{const n=cn(t),o=Xt(e);return qt(n,o),n})(e,t);Jn(e,n);const o=An(e);to(n,o),oo(e)})(u,h.outputName)}}else xe(o,f)?oo(u):ro(u)})),n.addHook("uponSanitizeAttribute",((n,o)=>{const s=n.tagName.toLowerCase(),{attrName:a,attrValue:i}=o;o.keepAttr=!r||t.isValid(s,a)||ze(a,"data-")||ze(a,"aria-"),a in py&&cy(e,i,s)&&(o.keepAttr=!1),o.keepAttr?(o.allowedAttributes[a]=!0,a in t.getBoolAttrs()&&(o.attrValue=a),e.allow_svg_data_urls&&ze(i,"data:image/svg+xml")&&(o.forceKeepAttr=!0)):!n.hasAttribute(hy)||"id"!==a&&"class"!==a&&"style"!==a||(o.forceKeepAttr=!0)})),n},vy=(e,t,n)=>{const o=e.name,r=o in n&&"title"!==o&&"textarea"!==o,s=t.childNodes;for(let t=0,o=s.length;t<o;t++){const o=s[t],a=new pg(o.nodeName.toLowerCase(),o.nodeType);if(To(o)){const e=o.attributes;for(let t=0,n=e.length;t<n;t++){const n=e[t];a.attr(n.name,n.value)}}else zo(o)?(a.value=o.data,r&&(a.raw=!0)):($o(o)||jo(o)||Ho(o))&&(a.value=o.data);vy(a,o,n),e.append(a)}},yy=(e={},t=Qs())=>{const n=Xv(),o=Xv(),r={validate:!0,root_name:"body",...e},s=new DOMParser,a=by(r,t),i=n.addFilter,l=n.getFilters,d=n.removeFilter,c=o.addFilter,u=o.getFilters,f=o.removeFilter,g=(e,n)=>{const o=m(n.attr(hy)),r=1===n.type&&!xe(e,n.name)&&!((e,t)=>1===t.type&&fs(e,t.name)&&m(t.attr(rs)))(t,n);return 3===n.type||r&&!o},p={schema:t,addAttributeFilter:c,getAttributeFilters:u,removeAttributeFilter:f,addNodeFilter:i,getNodeFilters:l,removeNodeFilter:d,parse:(e,n={})=>{var o;const i=r.validate,d=null!==(o=n.context)&&void 0!==o?o:r.root_name,c=((e,n,o="html")=>{const i="xhtml"===o?"application/xhtml+xml":"text/html",l=xe(t.getSpecialElements(),n.toLowerCase()),d=l?`<${n}>${e}</${n}>`:e,c="xhtml"===o?`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>${d}</body></html>`:`<body>${d}</body>`,u=s.parseFromString(c,i).body;return a.sanitize(u,((e,t)=>{const n={...gy};return n.PARSER_MEDIA_TYPE=t,e.allow_script_urls?n.ALLOWED_URI_REGEXP=/.*/:e.allow_html_data_urls&&(n.ALLOWED_URI_REGEXP=/^(?!(\w+script|mhtml):)/i),n})(r,i)),a.removed=[],l?u.firstChild:u})(e,d,n.format);cs(t,c);const m=new pg(d,11);vy(m,c,t.getSpecialElements()),c.innerHTML="";const[f,p]=((e,t,n,o)=>{const r=n.validate,s=t.getNonEmptyElements(),a=t.getWhitespaceElements(),i=fy(my("script,style,head,html,body,title,meta,param"),t.getBlockElements()),l=Ys(t),d=/[ \t\r\n]+/g,c=/^[ \t\r\n]+/,u=/[ \t\r\n]+$/,m=e=>{let t=e.parent;for(;C(t);){if(t.name in a)return!0;t=t.parent}return!1},f=e=>e.name in i&&!hs(t,e),g=(t,n)=>{const r=n?t.prev:t.next;return!C(r)&&!y(t.parent)&&f(t.parent)&&(t.parent!==e||!0===o.isRootContent)};return[e=>{var t;if(3===e.type&&!m(e)){let n=null!==(t=e.value)&&void 0!==t?t:"";n=n.replace(d," "),(((e,t)=>C(e)&&(t(e)||"br"===e.name))(e.prev,f)||g(e,!0))&&(n=n.replace(c,"")),0===n.length?e.remove():e.value=n}},e=>{var n;if(1===e.type){const n=t.getElementRule(e.name);if(r&&n){const r=Eh(t,s,a,e);n.paddInEmptyBlock&&r&&(e=>{let n=e;for(;C(n);){if(n.name in l)return Eh(t,s,a,n);n=n.parent}return!1})(e)?Sh(o,f,e):n.removeEmpty&&r?f(e)?e.remove():e.unwrap():n.paddEmpty&&(r||(e=>{var t;return _h(e,"#text")&&(null===(t=null==e?void 0:e.firstChild)||void 0===t?void 0:t.value)===tr})(e))&&Sh(o,f,e)}}else if(3===e.type&&!m(e)){let t=null!==(n=e.value)&&void 0!==n?n:"";(e.next&&f(e.next)||g(e,!1))&&(t=t.replace(u,"")),0===t.length?e.remove():e.value=t}}]})(m,t,r,n),h=[],b=i?e=>((e,n)=>{Ah(t,e)&&n.push(e)})(e,h):S,v={nodes:{},attributes:{}},w=e=>wh(l(),u(),e,v);if(((e,t,n)=>{const o=[];for(let n=e,r=n;n;r=n,n=n.walk()){const s=n;V(t,(e=>e(s))),y(s.parent)&&s!==e?n=r:o.push(s)}for(let e=o.length-1;e>=0;e--){const t=o[e];V(n,(e=>e(t)))}})(m,[f,w],[p,b]),h.reverse(),i&&h.length>0)if(n.context){const{pass:e,fail:o}=W(h,(e=>e.parent===m));Rh(o,t,w),n.invalid=e.length>0}else Rh(h,t,w);const x=((e,t)=>{var n;const o=null!==(n=t.forced_root_block)&&void 0!==n?n:e.forced_root_block;return!1===o?"":!0===o?"p":o})(r,n);return x&&("body"===m.name||n.isRootContent)&&((e,n)=>{const o=fy(my("script,style,head,html,body,title,meta,param"),t.getBlockElements()),s=/^[ \t\r\n]+/,a=/[ \t\r\n]+$/;let i=e.firstChild,l=null;const d=e=>{var t,n;e&&(i=e.firstChild,i&&3===i.type&&(i.value=null===(t=i.value)||void 0===t?void 0:t.replace(s,"")),i=e.lastChild,i&&3===i.type&&(i.value=null===(n=i.value)||void 0===n?void 0:n.replace(a,"")))};if(t.isValidChild(e.name,n.toLowerCase())){for(;i;){const t=i.next;g(o,i)?(l||(l=new pg(n,1),l.attr(r.forced_root_block_attrs),e.insert(l,i)),l.append(i)):(d(l),l=null),i=t}d(l)}})(m,x),n.invalid||xh(v,n),m}};return((e,t)=>{const n=e.schema;t.remove_trailing_brs&&e.addNodeFilter("br",((e,t,o)=>{const r=Tt.extend({},n.getBlockElements()),s=n.getNonEmptyElements(),a=n.getWhitespaceElements();r.body=1;const i=e=>e.name in r&&hs(n,e);for(let t=0,l=e.length;t<l;t++){let l=e[t],d=l.parent;if(d&&r[d.name]&&l===d.lastChild){let e=l.prev;for(;e;){const t=e.name;if("span"!==t||"bookmark"!==e.attr("data-mce-type")){"br"===t&&(l=null);break}e=e.prev}if(l&&(l.remove(),Eh(n,s,a,d))){const e=n.getElementRule(d.name);e&&(e.removeEmpty?d.remove():e.paddEmpty&&Sh(o,i,d))}}else{let e=l;for(;d&&d.firstChild===e&&d.lastChild===e&&(e=d,!r[d.name]);)d=d.parent;if(e===d){const e=new pg("#text",3);e.value=tr,l.replace(e)}}}})),e.addAttributeFilter("href",(e=>{let n=e.length;const o=e=>{const t=e?Tt.trim(e):"";return/\b(noopener)\b/g.test(t)?t:(e=>e.split(" ").filter((e=>e.length>0)).concat(["noopener"]).sort().join(" "))(t)};if(!t.allow_unsafe_link_target)for(;n--;){const t=e[n];"a"===t.name&&"_blank"===t.attr("target")&&t.attr("rel",o(t.attr("rel")))}})),t.allow_html_in_named_anchor||e.addAttributeFilter("id,name",(e=>{let t,n,o,r,s=e.length;for(;s--;)if(r=e[s],"a"===r.name&&r.firstChild&&!r.attr("href"))for(o=r.parent,t=r.lastChild;t&&o;)n=t.prev,o.insert(t,r),t=n})),t.fix_list_elements&&e.addNodeFilter("ul,ol",(e=>{let t,n,o=e.length;for(;o--;)if(t=e[o],n=t.parent,n&&("ul"===n.name||"ol"===n.name))if(t.prev&&"li"===t.prev.name)t.prev.append(t);else{const e=new pg("li",1);e.attr("style","list-style-type: none"),t.wrap(e)}}));const o=n.getValidClasses();t.validate&&o&&e.addAttributeFilter("class",(e=>{var t;let n=e.length;for(;n--;){const r=e[n],s=null!==(t=r.attr("class"))&&void 0!==t?t:"",a=Tt.explode(s," ");let i="";for(let e=0;e<a.length;e++){const t=a[e];let n=!1,s=o["*"];s&&s[t]&&(n=!0),s=o[r.name],!n&&s&&s[t]&&(n=!0),n&&(i&&(i+=" "),i+=t)}i.length||(i=null),r.attr("class",i)}})),((e,t)=>{const{blob_cache:n}=t;if(n){const t=e=>{const t=e.attr("src");(e=>e.attr("src")===Nt.transparentSrc||C(e.attr("data-mce-placeholder")))(e)||(e=>C(e.attr("data-mce-bogus")))(e)||y(t)||ry(n,t,!0).each((t=>{e.attr("src",t.blobUri())}))};e.addAttributeFilter("src",(e=>V(e,t)))}})(e,t)})(p,r),((e,t,n)=>{t.inline_styles&&Qv(e,t,n)})(p,r,t),p},Cy=(e,t)=>{const n=(e=>Uh(e)?_g({validate:!1}).serialize(e):e)(e),o=t(n);if(o.isDefaultPrevented())return o;if(Uh(e)){if(o.content!==n){const t=yy({validate:!1,forced_root_block:!1}).parse(o.content,{context:e.name});return{...o,content:t}}return{...o,content:e}}return o},wy=(e,t)=>{if(t.no_events)return Wi.value(t);{const n=((e,t)=>e.dispatch("BeforeGetContent",t))(e,t);return n.isDefaultPrevented()?Wi.error(Tm(e,{content:"",...n}).content):Wi.value(n)}},xy=(e,t,n)=>n.no_events?t:Cy(t,(t=>Tm(e,{...n,content:t}))).content,ky=(e,t)=>{if(t.no_events)return Wi.value(t);{const n=Cy(t.content,(n=>((e,t)=>e.dispatch("BeforeSetContent",t))(e,{...t,content:n})));return n.isDefaultPrevented()?(Om(e,n),Wi.error(void 0)):Wi.value(n)}},Sy=(e,t,n)=>{n.no_events||Om(e,{...n,content:t})},_y=(e,t,n)=>({element:e,width:t,rows:n}),Ey=(e,t)=>({element:e,cells:t}),Ny=(e,t)=>({x:e,y:t}),Ry=(e,t)=>Kt(e,t).bind(Ge).getOr(1),Ay=(e,t,n)=>{const o=e.rows;return!!(o[n]?o[n].cells:[])[t]},Oy=e=>Y(e,((e,t)=>t.cells.length>e?t.cells.length:e),0),Ty=(e,t)=>{const n=e.rows;for(let e=0;e<n.length;e++){const o=n[e].cells;for(let n=0;n<o.length;n++)if(bn(o[n],t))return M.some(Ny(n,e))}return M.none()},By=(e,t,n,o,r)=>{const s=[],a=e.rows;for(let e=n;e<=r;e++){const n=a[e].cells,r=t<o?n.slice(t,o+1):n.slice(o,t+1);s.push(Ey(a[e].element,r))}return s},Dy=e=>((e,t)=>{const n=Va(e.element),o=cn("tbody");return to(o,t),eo(n,o),n})(e,(e=>$(e.rows,(e=>{const t=$(e.cells,(e=>{const t=qa(e);return Yt(t,"colspan"),Yt(t,"rowspan"),t})),n=Va(e.element);return to(n,t),n})))(e)),Py=(e,t)=>{const n=mn(t.commonAncestorContainer),o=Wg(n,e),r=K(o,yr),s=((e,t)=>Q(e,(e=>"li"===Lt(e)&&Bu(e,t))).fold(N([]),(t=>(e=>Q(e,(e=>"ul"===Lt(e)||"ol"===Lt(e))))(e).map((e=>{const t=cn(Lt(e)),n=ve(Yn(e),((e,t)=>ze(t,"list-style")));return qn(t,n),[cn("li"),t]})).getOr([]))))(o,t),a=r.concat(s.length?s:(e=>gr(e)?xn(e).filter(fr).fold(N([]),(t=>[e,t])):fr(e)?[e]:[])(n));return $(a,Va)},Ly=()=>Jm([]),My=(e,t)=>((e,t)=>So(t,"table",O(bn,e)))(e,t[0]).bind((e=>{const n=t[0],o=t[t.length-1],r=(e=>{const t=_y(Va(e),0,[]);return V(or(e,"tr"),((e,n)=>{V(or(e,"td,th"),((o,r)=>{((e,t,n,o,r)=>{const s=Ry(r,"rowspan"),a=Ry(r,"colspan"),i=e.rows;for(let e=n;e<n+s;e++){i[e]||(i[e]=Ey(qa(o),[]));for(let o=t;o<t+a;o++)i[e].cells[o]=e===n&&o===t?r:Va(r)}})(t,((e,t,n)=>{for(;Ay(e,t,n);)t++;return t})(t,r,n),n,e,o)}))})),_y(t.element,Oy(t.rows),t.rows)})(e);return((e,t,n)=>Ty(e,t).bind((t=>Ty(e,n).map((n=>((e,t,n)=>{const o=t.x,r=t.y,s=n.x,a=n.y,i=r<a?By(e,o,r,s,a):By(e,o,a,s,r);return _y(e.element,Oy(i),i)})(e,t,n))))))(r,n,o).map((e=>Jm([Dy(e)])))})).getOrThunk(Ly),Iy=(e,t)=>{const n=Nu(t,e);return n.length>0?My(e,n):((e,t)=>t.length>0&&t[0].collapsed?Ly():((e,t)=>((e,t)=>{const n=Y(t,((e,t)=>(eo(t,e),t)),e);return t.length>0?Jm([n]):n})(mn(t.cloneContents()),Py(e,t)))(e,t[0]))(e,t)},Fy=(e,t)=>t>=0&&t<e.length&&bu(e.charAt(t)),Uy=e=>_r(e.innerText),zy=e=>To(e)?e.outerHTML:zo(e)?Fs.encodeRaw(e.data,!1):$o(e)?"\x3c!--"+e.data+"--\x3e":"",jy=(e,t)=>(((e,t)=>{let n=0;V(e,(e=>{0===e[0]?n++:1===e[0]?(((e,t,n)=>{const o=(e=>{let t;const n=document.createElement("div"),o=document.createDocumentFragment();for(e&&(n.innerHTML=e);t=n.firstChild;)o.appendChild(t);return o})(t);if(e.hasChildNodes()&&n<e.childNodes.length){const t=e.childNodes[n];e.insertBefore(o,t)}else e.appendChild(o)})(t,e[1],n),n++):2===e[0]&&((e,t)=>{if(e.hasChildNodes()&&t<e.childNodes.length){const n=e.childNodes[t];e.removeChild(n)}})(t,n)}))})(((e,t)=>{const n=e.length+t.length+2,o=new Array(n),r=new Array(n),s=(n,o,r,a,l)=>{const d=i(n,o,r,a);if(null===d||d.start===o&&d.diag===o-a||d.end===n&&d.diag===n-r){let s=n,i=r;for(;s<o||i<a;)s<o&&i<a&&e[s]===t[i]?(l.push([0,e[s]]),++s,++i):o-n>a-r?(l.push([2,e[s]]),++s):(l.push([1,t[i]]),++i)}else{s(n,d.start,r,d.start-d.diag,l);for(let t=d.start;t<d.end;++t)l.push([0,e[t]]);s(d.end,o,d.end-d.diag,a,l)}},a=(n,o,r,s)=>{let a=n;for(;a-o<s&&a<r&&e[a]===t[a-o];)++a;return((e,t,n)=>({start:e,end:t,diag:n}))(n,a,o)},i=(n,s,i,l)=>{const d=s-n,c=l-i;if(0===d||0===c)return null;const u=d-c,m=c+d,f=(m%2==0?m:m+1)/2;let g,p,h,b,v;for(o[1+f]=n,r[1+f]=s+1,g=0;g<=f;++g){for(p=-g;p<=g;p+=2){for(h=p+f,p===-g||p!==g&&o[h-1]<o[h+1]?o[h]=o[h+1]:o[h]=o[h-1]+1,b=o[h],v=b-n+i-p;b<s&&v<l&&e[b]===t[v];)o[h]=++b,++v;if(u%2!=0&&u-g<=p&&p<=u+g&&r[h-u]<=o[h])return a(r[h-u],p+n-i,s,l)}for(p=u-g;p<=u+g;p+=2){for(h=p+f-u,p===u-g||p!==u+g&&r[h+1]<=r[h-1]?r[h]=r[h+1]-1:r[h]=r[h-1],b=r[h]-1,v=b-n+i-p;b>=n&&v>=i&&e[b]===t[v];)r[h]=b--,v--;if(u%2==0&&-g<=p&&p<=g&&r[h]<=o[h+u])return a(r[h],p+n-i,s,l)}}return null},l=[];return s(0,e.length,0,t.length,l),l})($(de(t.childNodes),zy),e),t),t),Hy=De((()=>document.implementation.createHTMLDocument("undo"))),$y=e=>{const t=(n=e.getBody(),K($(de(n.childNodes),zy),(e=>e.length>0)));var n;const o=ee(t,(t=>{const n=vg(e.serializer,t);return n.length>0?[n]:[]})),r=o.join("");return(e=>-1!==e.indexOf("</iframe>"))(r)?(e=>({type:"fragmented",fragments:e,content:"",bookmark:null,beforeBookmark:null}))(o):(e=>({type:"complete",fragments:null,content:e,bookmark:null,beforeBookmark:null}))(r)},Vy=(e,t,n)=>{const o=n?t.beforeBookmark:t.bookmark;"fragmented"===t.type?jy(t.fragments,e.getBody()):e.setContent(t.content,{format:"raw",no_selection:!C(o)||!su(o)||!o.isFakeCaret}),o&&(e.selection.moveToBookmark(o),e.selection.scrollIntoView())},qy=e=>"fragmented"===e.type?e.fragments.join(""):e.content,Wy=e=>{const t=cn("body",Hy());return io(t,qy(e)),V(or(t,"*[data-mce-bogus]"),ro),ao(t)},Ky=(e,t)=>!(!e||!t)&&(!!((e,t)=>qy(e)===qy(t))(e,t)||((e,t)=>Wy(e)===Wy(t))(e,t)),Gy=e=>0===e.get(),Yy=(e,t,n)=>{Gy(n)&&(e.typing=t)},Xy=(e,t)=>{e.typing&&(Yy(e,!1,t),e.add())},Qy=e=>({init:{bindEvents:S},undoManager:{beforeChange:(t,n)=>((e,t,n)=>{Gy(t)&&n.set($i(e.selection))})(e,t,n),add:(t,n,o,r,s,a)=>((e,t,n,o,r,s,a)=>{const i=$y(e),l=Tt.extend(s||{},i);if(!Gy(o)||e.removed)return null;const d=t.data[n.get()];if(e.dispatch("BeforeAddUndo",{level:l,lastLevel:d,originalEvent:a}).isDefaultPrevented())return null;if(d&&Ky(d,l))return null;t.data[n.get()]&&r.get().each((e=>{t.data[n.get()].beforeBookmark=e}));const c=id(e);if(c&&t.data.length>c){for(let e=0;e<t.data.length-1;e++)t.data[e]=t.data[e+1];t.data.length--,n.set(t.data.length)}l.bookmark=$i(e.selection),n.get()<t.data.length-1&&(t.data.length=n.get()+1),t.data.push(l),n.set(t.data.length-1);const u={level:l,lastLevel:d,originalEvent:a};return n.get()>0?(e.setDirty(!0),e.dispatch("AddUndo",u),e.dispatch("change",u)):e.dispatch("AddUndo",u),l})(e,t,n,o,r,s,a),undo:(t,n,o)=>((e,t,n,o)=>{let r;return t.typing&&(t.add(),t.typing=!1,Yy(t,!1,n)),o.get()>0&&(o.set(o.get()-1),r=t.data[o.get()],Vy(e,r,!0),e.setDirty(!0),e.dispatch("Undo",{level:r})),r})(e,t,n,o),redo:(t,n)=>((e,t,n)=>{let o;return t.get()<n.length-1&&(t.set(t.get()+1),o=n[t.get()],Vy(e,o,!1),e.setDirty(!0),e.dispatch("Redo",{level:o})),o})(e,t,n),clear:(t,n)=>((e,t,n)=>{t.data=[],n.set(0),t.typing=!1,e.dispatch("ClearUndos")})(e,t,n),reset:e=>(e=>{e.clear(),e.add()})(e),hasUndo:(t,n)=>((e,t,n)=>n.get()>0||t.typing&&t.data[0]&&!Ky($y(e),t.data[0]))(e,t,n),hasRedo:(e,t)=>((e,t)=>t.get()<e.data.length-1&&!e.typing)(e,t),transact:(e,t,n)=>((e,t,n)=>(Xy(e,t),e.beforeChange(),e.ignore(n),e.add()))(e,t,n),ignore:(e,t)=>((e,t)=>{try{e.set(e.get()+1),t()}finally{e.set(e.get()-1)}})(e,t),extra:(t,n,o,r)=>((e,t,n,o,r)=>{if(t.transact(o)){const o=t.data[n.get()].bookmark,s=t.data[n.get()-1];Vy(e,s,!0),t.transact(r)&&(t.data[n.get()-1].beforeBookmark=o)}})(e,t,n,o,r)},formatter:{match:(t,n,o,r)=>Xh(e,t,n,o,r),matchAll:(t,n)=>((e,t,n)=>{const o=[],r={},s=e.selection.getStart();return e.dom.getParent(s,(s=>{for(let a=0;a<t.length;a++){const i=t[a];!r[i]&&Yh(e,s,i,n)&&(r[i]=!0,o.push(i))}}),e.dom.getRoot()),o})(e,t,n),matchNode:(t,n,o,r)=>Yh(e,t,n,o,r),canApply:t=>((e,t)=>{const n=e.formatter.get(t),o=e.dom;if(n){const t=e.selection.getStart(),r=Ju(o,t);for(let e=n.length-1;e>=0;e--){const t=n[e];if(!tm(t))return!0;for(let e=r.length-1;e>=0;e--)if(o.is(r[e],t.selector))return!0}}return!1})(e,t),closest:t=>((e,t)=>{const n=t=>bn(t,mn(e.getBody()));return M.from(e.selection.getStart(!0)).bind((o=>$h(mn(o),(n=>ce(t,(t=>((t,n)=>Yh(e,t.dom,n)?M.some(n):M.none())(n,t)))),n))).getOrNull()})(e,t),apply:(t,n,o)=>$b(e,t,n,o),remove:(t,n,o,r)=>Ub(e,t,n,o,r),toggle:(t,n,o)=>((e,t,n,o)=>{const r=e.formatter.get(t);r&&(!Xh(e,t,n,o)||"toggle"in r[0]&&!r[0].toggle?$b(e,t,n,o):Ub(e,t,n,o))})(e,t,n,o),formatChanged:(t,n,o,r,s)=>((e,t,n,o,r,s)=>(((e,t,n,o,r,s)=>{const a=t.get();V(n.split(","),(t=>{const n=we(a,t).getOrThunk((()=>{const e={withSimilar:{state:Ca(!1),similar:!0,callbacks:[]},withoutSimilar:{state:Ca(!1),similar:!1,callbacks:[]},withVars:[]};return a[t]=e,e})),i=()=>{const n=Kb(e);return Wb(e,n,t,r,s).isSome()};if(v(s)){const e=r?n.withSimilar:n.withoutSimilar;e.callbacks.push(o),1===e.callbacks.length&&e.state.set(i())}else n.withVars.push({state:Ca(i()),similar:r,vars:s,callback:o})})),t.set(a)})(e,t,n,o,r,s),{unbind:()=>((e,t,n)=>{const o=e.get();V(t.split(","),(e=>we(o,e).each((t=>{o[e]={withSimilar:{...t.withSimilar,callbacks:K(t.withSimilar.callbacks,(e=>e!==n))},withoutSimilar:{...t.withoutSimilar,callbacks:K(t.withoutSimilar.callbacks,(e=>e!==n))},withVars:K(t.withVars,(e=>e.callback!==n))}})))),e.set(o)})(t,n,o)}))(e,t,n,o,r,s)},editor:{getContent:t=>((e,t)=>M.from(e.getBody()).fold(N("tree"===t.format?new pg("body",11):""),(n=>xg(e,t,n))))(e,t),setContent:(t,n)=>((e,t,n)=>M.from(e.getBody()).map((o=>Uh(t)?((e,t,n,o)=>{kh(e.parser.getNodeFilters(),e.parser.getAttributeFilters(),n);const r=_g({validate:!1},e.schema).serialize(n),s=br(mn(t))?r:Tt.trim(r);return zh(e,s,o.no_selection),{content:n,html:s}})(e,o,t,n):((e,t,n,o)=>{if(0===n.length||/^\s+$/.test(n)){const r='<br data-mce-bogus="1">';"TABLE"===t.nodeName?n="<tr><td>"+r+"</td></tr>":/^(UL|OL)$/.test(t.nodeName)&&(n="<li>"+r+"</li>");const s=gl(e);return e.schema.isValidChild(t.nodeName.toLowerCase(),s.toLowerCase())?(n=r,n=e.dom.createHTML(s,pl(e),n)):n||(n=r),zh(e,n,o.no_selection),{content:n,html:n}}{"raw"!==o.format&&(n=_g({validate:!1},e.schema).serialize(e.parser.parse(n,{isRootContent:!0,insert:!0})));const r=br(mn(t))?n:Tt.trim(n);return zh(e,r,o.no_selection),{content:r,html:r}}})(e,o,t,n))).getOr({content:t,html:Uh(n.content)?"":n.content}))(e,t,n),insertContent:(t,n)=>Fh(e,t,n),addVisual:t=>((e,t)=>{const n=e.dom,o=C(t)?t:e.getBody();V(n.select("table,a",o),(t=>{switch(t.nodeName){case"TABLE":const o=pd(e),r=n.getAttrib(t,"border");r&&"0"!==r||!e.hasVisual?n.removeClass(t,o):n.addClass(t,o);break;case"A":if(!n.getAttrib(t,"href")){const o=n.getAttrib(t,"name")||t.id,r=hd(e);o&&e.hasVisual?n.addClass(t,r):n.removeClass(t,r)}}})),e.dispatch("VisualAid",{element:t,hasVisual:e.hasVisual})})(e,t)},selection:{getContent:(t,n)=>((e,t,n={})=>{const o=((e,t)=>({...e,format:t,get:!0,selection:!0,getInner:!0}))(n,t);return wy(e,o).fold(R,(t=>{const n=((e,t)=>{if("text"===t.format)return(e=>M.from(e.selection.getRng()).map((t=>{var n;const o=M.from(e.dom.getParent(t.commonAncestorContainer,e.dom.isBlock)),r=e.getBody(),s=(e=>e.map((e=>e.nodeName)).getOr("div").toLowerCase())(o),a=mn(t.cloneContents());Cg(a),wg(a);const i=e.dom.add(r,s,{"data-mce-bogus":"all",style:"overflow: hidden; opacity: 0;"},a.dom),l=Uy(i),d=_r(null!==(n=i.textContent)&&void 0!==n?n:"");if(e.dom.remove(i),Fy(d,0)||Fy(d,d.length-1)){const e=o.getOr(r),t=Uy(e),n=t.indexOf(l);return-1===n?l:(Fy(t,n-1)?" ":"")+l+(Fy(t,n+l.length)?" ":"")}return l})).getOr(""))(e);{const n=((e,t)=>{const n=e.selection.getRng(),o=e.dom.create("body"),r=e.selection.getSel(),s=sg(e,Eu(r)),a=t.contextual?Iy(mn(e.getBody()),s).dom:n.cloneContents();return a&&o.appendChild(a),e.selection.serializer.serialize(o,t)})(e,t);return"tree"===t.format?n:e.selection.isCollapsed()?"":n}})(e,t);return xy(e,n,t)}))})(e,t,n)},autocompleter:{addDecoration:t=>dg(e,t),removeDecoration:()=>((e,t)=>cg(t).each((t=>{const n=e.selection.getBookmark();ro(t),e.selection.moveToBookmark(n)})))(e,mn(e.getBody()))},raw:{getModel:()=>M.none()}}),Jy=e=>xe(e.plugins,"rtc"),Zy=e=>e.rtcInstance?e.rtcInstance:Qy(e),eC=e=>{const t=e.rtcInstance;if(t)return t;throw new Error("Failed to get RTC instance not yet initialized.")},tC=e=>eC(e).init.bindEvents(),nC=e=>0===e.dom.length?(oo(e),M.none()):M.some(e),oC=(e,t,n,o)=>{e.bind((e=>((o?kp:xp)(e.dom,o?e.dom.length:0),t.filter(Ut).map((t=>((e,t,n,o)=>{const r=e.dom,s=t.dom,a=o?r.length:s.length;o?(Sp(r,s,!1,!o),n.setStart(s,a)):(Sp(s,r,!1,!o),n.setEnd(s,a))})(e,t,n,o)))))).orThunk((()=>{const e=((e,t)=>e.filter((e=>_m.isBookmarkNode(e.dom))).bind(t?En:_n))(t,o).or(t).filter(Ut);return e.map((e=>((e,t)=>{xn(e).each((n=>{const o=e.dom;t&&fp(n,xi(o,0))?xp(o,0):!t&&gp(n,xi(o,o.length))&&kp(o,o.length)}))})(e,o)))}))},rC=(e,t,n)=>{if(xe(e,t)){const o=K(e[t],(e=>e!==n));0===o.length?delete e[t]:e[t]=o}};const sC=e=>!(!e||!e.ownerDocument)&&vn(mn(e.ownerDocument),mn(e)),aC=(e,t,n,o)=>{let r,s;const{selectorChangedWithUnbind:a}=((e,t)=>{let n,o;const r=(t,n)=>Q(n,(n=>e.is(n,t))),s=t=>e.getParents(t,void 0,e.getRoot());return{selectorChangedWithUnbind:(e,a)=>(n||(n={},o={},t.on("NodeChange",(e=>{const t=e.element,a=s(t),i={};fe(n,((e,t)=>{r(t,a).each((n=>{o[t]||(V(e,(e=>{e(!0,{node:n,selector:t,parents:a})})),o[t]=e),i[t]=e}))})),fe(o,((e,n)=>{i[n]||(delete o[n],V(e,(e=>{e(!1,{node:t,selector:n,parents:a})})))}))}))),n[e]||(n[e]=[]),n[e].push(a),r(e,s(t.selection.getStart())).each((()=>{o[e]=n[e]})),{unbind:()=>{rC(n,e,a),rC(o,e,a)}})}})(e,o),i=(e,t)=>((e,t,n={})=>{const o=((e,t)=>({format:"html",...e,set:!0,selection:!0,content:t}))(n,t);ky(e,o).each((t=>{const n=((e,t)=>{if("raw"!==t.format){const n=e.selection.getRng(),o=e.dom.getParent(n.commonAncestorContainer,e.dom.isBlock),r=o?{context:o.nodeName.toLowerCase()}:{},s=e.parser.parse(t.content,{forced_root_block:!1,...r,...t});return _g({validate:!1},e.schema).serialize(s)}return t.content})(e,t),o=e.selection.getRng();((e,t)=>{const n=M.from(t.firstChild).map(mn),o=M.from(t.lastChild).map(mn);e.deleteContents(),e.insertNode(t);const r=n.bind(_n).filter(Ut).bind(nC),s=o.bind(En).filter(Ut).bind(nC);oC(r,n,e,!0),oC(s,o,e,!1),e.collapse(!1)})(o,o.createContextualFragment(n)),e.selection.setRng(o),Bf(e,o),Sy(e,n,t)}))})(o,e,t),l=e=>{const t=c();t.collapse(!!e),u(t)},d=()=>t.getSelection?t.getSelection():t.document.selection,c=()=>{let n;const a=(e,t,n)=>{try{return t.compareBoundaryPoints(e,n)}catch(e){return-1}},i=t.document;if(C(o.bookmark)&&!Zf(o)){const e=$f(o);if(e.isSome())return e.map((e=>sg(o,[e])[0])).getOr(i.createRange())}try{const e=d();e&&!Oo(e.anchorNode)&&(n=e.rangeCount>0?e.getRangeAt(0):i.createRange(),n=sg(o,[n])[0])}catch(e){}if(n||(n=i.createRange()),Vo(n.startContainer)&&n.collapsed){const t=e.getRoot();n.setStart(t,0),n.setEnd(t,0)}return r&&s&&(0===a(n.START_TO_START,n,r)&&0===a(n.END_TO_END,n,r)?n=s:(r=null,s=null)),n},u=(e,t)=>{if(!(e=>!!e&&sC(e.startContainer)&&sC(e.endContainer))(e))return;const n=d();if(e=o.dispatch("SetSelectionRange",{range:e,forward:t}).range,n){s=e;try{n.removeAllRanges(),n.addRange(e)}catch(e){}!1===t&&n.extend&&(n.collapse(e.endContainer,e.endOffset),n.extend(e.startContainer,e.startOffset)),r=n.rangeCount>0?n.getRangeAt(0):null}if(!e.collapsed&&e.startContainer===e.endContainer&&(null==n?void 0:n.setBaseAndExtent)&&e.endOffset-e.startOffset<2&&e.startContainer.hasChildNodes()){const t=e.startContainer.childNodes[e.startOffset];t&&"IMG"===t.nodeName&&(n.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset),n.anchorNode===e.startContainer&&n.focusNode===e.endContainer||n.setBaseAndExtent(t,0,t,1))}o.dispatch("AfterSetSelectionRange",{range:e,forward:t})},m=()=>{const t=d(),n=null==t?void 0:t.anchorNode,o=null==t?void 0:t.focusNode;if(!t||!n||!o||Oo(n)||Oo(o))return!0;const r=e.createRng(),s=e.createRng();try{r.setStart(n,t.anchorOffset),r.collapse(!0),s.setStart(o,t.focusOffset),s.collapse(!0)}catch(e){return!0}return r.compareBoundaryPoints(r.START_TO_START,s)<=0},f={dom:e,win:t,serializer:n,editor:o,expand:(t={type:"word"})=>u(mf(e).expand(c(),t)),collapse:l,setCursorLocation:(t,n)=>{const r=e.createRng();C(t)&&C(n)?(r.setStart(t,n),r.setEnd(t,n),u(r),l(!1)):(Du(e,r,o.getBody(),!0),u(r))},getContent:e=>((e,t={})=>((e,t,n)=>eC(e).selection.getContent(t,n))(e,t.format?t.format:"html",t))(o,e),setContent:i,getBookmark:(e,t)=>g.getBookmark(e,t),moveToBookmark:e=>g.moveToBookmark(e),select:(t,n)=>(((e,t,n)=>M.from(t).bind((t=>M.from(t.parentNode).map((o=>{const r=e.nodeIndex(t),s=e.createRng();return s.setStart(o,r),s.setEnd(o,r+1),n&&(Du(e,s,t,!0),Du(e,s,t,!1)),s})))))(e,t,n).each(u),t),isCollapsed:()=>{const e=c(),t=d();return!(!e||e.item)&&(e.compareEndPoints?0===e.compareEndPoints("StartToEnd",e):!t||e.collapsed)},isForward:m,setNode:t=>(i(e.getOuterHTML(t)),t),getNode:()=>((e,t)=>{if(!t)return e;let n=t.startContainer,o=t.endContainer;const r=t.startOffset,s=t.endOffset;let a=t.commonAncestorContainer;t.collapsed||(n===o&&s-r<2&&n.hasChildNodes()&&(a=n.childNodes[r]),zo(n)&&zo(o)&&(n=n.length===r?rg(n.nextSibling,!0):n.parentNode,o=0===s?rg(o.previousSibling,!1):o.parentNode,n&&n===o&&(a=n)));const i=zo(a)?a.parentNode:a;return To(i)?i:e})(o.getBody(),c()),getSel:d,setRng:u,getRng:c,getStart:e=>ng(o.getBody(),c(),e),getEnd:e=>og(o.getBody(),c(),e),getSelectedBlocks:(t,n)=>((e,t,n,o)=>{const r=[],s=e.getRoot(),a=e.getParent(n||ng(s,t,t.collapsed),e.isBlock),i=e.getParent(o||og(s,t,t.collapsed),e.isBlock);if(a&&a!==s&&r.push(a),a&&i&&a!==i){let t=a;const n=new Ro(a,s);for(;(t=n.next())&&t!==i;)e.isBlock(t)&&r.push(t)}return i&&a!==i&&i!==s&&r.push(i),r})(e,c(),t,n),normalize:()=>{const t=c(),n=d();if(!(Eu(n).length>1)&&Pu(o)){const n=df(e,t);return n.each((e=>{u(e,m())})),n.getOr(t)}return t},selectorChanged:(e,t)=>(a(e,t),f),selectorChangedWithUnbind:a,getScrollContainer:()=>{let t,n=e.getRoot();for(;n&&"BODY"!==n.nodeName;){if(n.scrollHeight>n.clientHeight){t=n;break}n=n.parentNode}return t},scrollIntoView:(e,t)=>{C(e)?((e,t,n)=>{(e.inline?Af:Tf)(e,t,n)})(o,e,t):Bf(o,c(),t)},placeCaretAt:(e,t)=>u(ef(e,t,o.getDoc())),getBoundingClientRect:()=>{const e=c();return e.collapsed?xi.fromRangeStart(e).getClientRects()[0]:e.getBoundingClientRect()},destroy:()=>{t=r=s=null,p.destroy()}},g=_m(f),p=Fm(f,o);return f.bookmarkManager=g,f.controlSelection=p,f},iC=(e,t,n)=>{-1===Tt.inArray(t,n)&&(e.addAttributeFilter(n,((e,t)=>{let n=e.length;for(;n--;)e[n].attr(t,null)})),t.push(n))},lC=(e,t)=>{const n=["data-mce-selected"],o=t&&t.dom?t.dom:ba.DOM,r=t&&t.schema?t.schema:Qs(e);e.entity_encoding=e.entity_encoding||"named",e.remove_trailing_brs=!("remove_trailing_brs"in e)||e.remove_trailing_brs;const s=yy(e,r);return((e,t,n)=>{e.addAttributeFilter("data-mce-tabindex",((e,t)=>{let n=e.length;for(;n--;){const o=e[n];o.attr("tabindex",o.attr("data-mce-tabindex")),o.attr(t,null)}})),e.addAttributeFilter("src,href,style",((e,o)=>{const r="data-mce-"+o,s=t.url_converter,a=t.url_converter_scope;let i=e.length;for(;i--;){const t=e[i];let l=t.attr(r);void 0!==l?(t.attr(o,l.length>0?l:null),t.attr(r,null)):(l=t.attr(o),"style"===o?l=n.serializeStyle(n.parseStyle(l),t.name):s&&(l=s.call(a,l,o,t.name)),t.attr(o,l.length>0?l:null))}})),e.addAttributeFilter("class",(e=>{let t=e.length;for(;t--;){const n=e[t];let o=n.attr("class");o&&(o=o.replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),n.attr("class",o.length>0?o:null))}})),e.addAttributeFilter("data-mce-type",((e,t,n)=>{let o=e.length;for(;o--;){const t=e[o];if("bookmark"===t.attr("data-mce-type")&&!n.cleanup){const e=M.from(t.firstChild).exists((e=>{var t;return!Sr(null!==(t=e.value)&&void 0!==t?t:"")}));e?t.unwrap():t.remove()}}})),e.addNodeFilter("noscript",(e=>{var t;let n=e.length;for(;n--;){const o=e[n].firstChild;o&&(o.value=Fs.decode(null!==(t=o.value)&&void 0!==t?t:""))}})),e.addNodeFilter("script,style",((e,n)=>{var o;const r=e=>e.replace(/(<!--\[CDATA\[|\]\]-->)/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi,"").replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"");let s=e.length;for(;s--;){const a=e[s],i=a.firstChild,l=null!==(o=null==i?void 0:i.value)&&void 0!==o?o:"";if("script"===n){const e=a.attr("type");e&&a.attr("type","mce-no/type"===e?null:e.replace(/^mce\-/,"")),"xhtml"===t.element_format&&i&&l.length>0&&(i.value="// <![CDATA[\n"+r(l)+"\n// ]]>")}else"xhtml"===t.element_format&&i&&l.length>0&&(i.value="\x3c!--\n"+r(l)+"\n--\x3e")}})),e.addNodeFilter("#comment",(e=>{let o=e.length;for(;o--;){const r=e[o],s=r.value;t.preserve_cdata&&0===(null==s?void 0:s.indexOf("[CDATA["))?(r.name="#cdata",r.type=4,r.value=n.decode(s.replace(/^\[CDATA\[|\]\]$/g,""))):0===(null==s?void 0:s.indexOf("mce:protected "))&&(r.name="#text",r.type=3,r.raw=!0,r.value=unescape(s).substr(14))}})),e.addNodeFilter("xml:namespace,input",((e,t)=>{let n=e.length;for(;n--;){const o=e[n];7===o.type?o.remove():1===o.type&&("input"!==t||o.attr("type")||o.attr("type","text"))}})),e.addAttributeFilter("data-mce-type",(t=>{V(t,(t=>{"format-caret"===t.attr("data-mce-type")&&(t.isEmpty(e.schema.getNonEmptyElements())?t.remove():t.unwrap())}))})),e.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-block,data-mce-type,data-mce-resize,data-mce-placeholder",((e,t)=>{let n=e.length;for(;n--;)e[n].attr(t,null)}))})(s,e,o),{schema:r,addNodeFilter:s.addNodeFilter,addAttributeFilter:s.addAttributeFilter,serialize:(n,a={})=>{const i={format:"html",...a},l=((e,t,n)=>((e,t)=>C(e)&&e.hasEventListeners("PreProcess")&&!t.no_events)(e,n)?((e,t,n)=>{let o;const r=e.dom;let s=t.cloneNode(!0);const a=document.implementation;if(a.createHTMLDocument){const e=a.createHTMLDocument("");Tt.each("BODY"===s.nodeName?s.childNodes:[s],(t=>{e.body.appendChild(e.importNode(t,!0))})),s="BODY"!==s.nodeName?e.body.firstChild:e.body,o=r.doc,r.doc=e}return((e,t)=>{e.dispatch("PreProcess",t)})(e,{...n,node:s}),o&&(r.doc=o),s})(e,t,n):t)(t,n,i),d=((e,t,n)=>{const o=_r(n.getInner?t.innerHTML:e.getOuterHTML(t));return n.selection||br(mn(t))?o:Tt.trim(o)})(o,l,i),c=((e,t,n)=>{const o=n.selection?{forced_root_block:!1,...n}:n,r=e.parse(t,o);return(e=>{const t=e=>"br"===(null==e?void 0:e.name),n=e.lastChild;if(t(n)){const e=n.prev;t(e)&&(n.remove(),e.remove())}})(r),r})(s,d,i);return"tree"===i.format?c:((e,t,n,o,r)=>{const s=((e,t,n)=>_g(e,t).serialize(n))(t,n,o);return((e,t,n)=>{if(!t.no_events&&e){const o=((e,t)=>e.dispatch("PostProcess",t))(e,{...t,content:n});return o.content}return n})(e,r,s)})(t,e,r,c,i)},addRules:r.addValidElements,setRules:r.setValidElements,addTempAttr:O(iC,s,n),getTempAttrs:N(n),getNodeFilters:s.getNodeFilters,getAttributeFilters:s.getAttributeFilters,removeNodeFilter:s.removeNodeFilter,removeAttributeFilter:s.removeAttributeFilter}},dC=(e,t)=>{const n=lC(e,t);return{schema:n.schema,addNodeFilter:n.addNodeFilter,addAttributeFilter:n.addAttributeFilter,serialize:n.serialize,addRules:n.addRules,setRules:n.setRules,addTempAttr:n.addTempAttr,getTempAttrs:n.getTempAttrs,getNodeFilters:n.getNodeFilters,getAttributeFilters:n.getAttributeFilters,removeNodeFilter:n.removeNodeFilter,removeAttributeFilter:n.removeAttributeFilter}},cC=(e,t,n={})=>{const o=((e,t)=>({format:"html",...e,set:!0,content:t}))(n,t);return ky(e,o).map((t=>{const n=((e,t,n)=>Zy(e).editor.setContent(t,n))(e,t.content,t);return Sy(e,n.html,t),n.content})).getOr(t)},uC="autoresize_on_init,content_editable_state,padd_empty_with_br,block_elements,boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,tab_focus,tabfocus_elements,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,paste_enable_default_filters,paste_filter_drop,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists".split(","),mC="bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor".split(","),fC=e=>{const t=K(uC,(t=>xe(e,t))),n=e.forced_root_block;return!1!==n&&""!==n||t.push("forced_root_block (false only)"),se(t)},gC=e=>{const t=Tt.makeMap(e.plugins," "),n=K(mC,(e=>xe(t,e)));return se(n)},pC=ba.DOM,hC=e=>M.from(e).each((e=>e.destroy())),bC=(()=>{const e={};return{add:(t,n)=>{e[t]=n},get:t=>e[t]?e[t]:{icons:{}},has:t=>xe(e,t)}})(),vC=_a.ModelManager,yC=(e,t)=>t.dom[e],CC=(e,t)=>parseInt(Wn(t,e),10),wC=O(yC,"clientWidth"),xC=O(yC,"clientHeight"),kC=O(CC,"margin-top"),SC=O(CC,"margin-left"),_C=e=>{const t=[],n=()=>{const t=e.theme;return t&&t.getNotificationManagerImpl?t.getNotificationManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a NotificationManager implementation.")};return{open:e,close:e,getArgs:e}})()},o=()=>M.from(t[0]),r=()=>{V(t,(e=>{e.reposition()}))},s=e=>{J(t,(t=>t===e)).each((e=>{t.splice(e,1)}))},a=(a,i=!0)=>e.removed||!(e=>{return(t=e.inline?e.getBody():e.getContentAreaContainer(),M.from(t).map(mn)).map(Hn).getOr(!1);var t})(e)?{}:(i&&e.dispatch("BeforeOpenNotification",{notification:a}),Q(t,(e=>{return t=n().getArgs(e),o=a,!(t.type!==o.type||t.text!==o.text||t.progressBar||t.timeout||o.progressBar||o.timeout);var t,o})).getOrThunk((()=>{e.editorManager.setActive(e);const i=n().open(a,(()=>{s(i),r(),o().fold((()=>e.focus()),(e=>Df(mn(e.getEl()))))}));return(e=>{t.push(e)})(i),r(),e.dispatch("OpenNotification",{notification:{...i}}),i}))),i=N(t);return(e=>{e.on("SkinLoaded",(()=>{const t=ql(e);t&&a({text:t,type:"warning",timeout:0},!1),r()})),e.on("show ResizeEditor ResizeWindow NodeChange",(()=>{requestAnimationFrame(r)})),e.on("remove",(()=>{V(t.slice(),(e=>{n().close(e)}))}))})(e),{open:a,close:()=>{o().each((e=>{n().close(e),s(e),r()}))},getNotifications:i}},EC=_a.PluginManager,NC=_a.ThemeManager,RC=e=>{let t=[];const n=()=>{const t=e.theme;return t&&t.getWindowManagerImpl?t.getWindowManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a WindowManager implementation.")};return{open:e,openUrl:e,alert:e,confirm:e,close:e}})()},o=(e,t)=>(...n)=>t?t.apply(e,n):void 0,r=n=>{(t=>{e.dispatch("CloseWindow",{dialog:t})})(n),t=K(t,(e=>e!==n)),0===t.length&&e.focus()},s=n=>{e.editorManager.setActive(e),Hf(e),e.ui.show();const o=n();return(n=>{t.push(n),(t=>{e.dispatch("OpenWindow",{dialog:t})})(n)})(o),o};return e.on("remove",(()=>{V(t,(e=>{n().close(e)}))})),{open:(e,t)=>s((()=>n().open(e,t,r))),openUrl:e=>s((()=>n().openUrl(e,r))),alert:(e,t,r)=>{const s=n();s.alert(e,o(r||s,t))},confirm:(e,t,r)=>{const s=n();s.confirm(e,o(r||s,t))},close:()=>{M.from(t[t.length-1]).each((e=>{n().close(e),r(e)}))}}},AC=(e,t)=>{e.notificationManager.open({type:"error",text:t})},OC=(e,t)=>{e._skinLoaded?AC(e,t):e.on("SkinLoaded",(()=>{AC(e,t)}))},TC=(e,t,n)=>{Nm(e,t,{message:n}),console.error(n)},BC=(e,t,n)=>n?`Failed to load ${e}: ${n} from url ${t}`:`Failed to load ${e} url: ${t}`,DC=(e,...t)=>{const n=window.console;n&&(n.error?n.error(e,...t):n.log(e,...t))},PC=(e,t)=>{const n=e.editorManager.baseURL+"/skins/content",o=`content${e.editorManager.suffix}.css`;return $(t,(t=>(e=>/^[a-z0-9\-]+$/i.test(e))(t)&&!e.inline?`${n}/${t}/${o}`:e.documentBaseURI.toAbsolute(t)))},LC=L,MC=(e,t)=>{const n={};return{findAll:(o,r=L)=>{const s=K((e=>e?de(e.getElementsByTagName("img")):[])(o),(t=>{const n=t.src;return!t.hasAttribute("data-mce-bogus")&&!t.hasAttribute("data-mce-placeholder")&&!(!n||n===Nt.transparentSrc)&&(ze(n,"blob:")?!e.isUploaded(n)&&r(t):!!ze(n,"data:")&&r(t))})),a=$(s,(e=>{const o=e.src;if(xe(n,o))return n[o].then((t=>m(t)?t:{image:e,blobInfo:t.blobInfo}));{const r=((e,t)=>{const n=()=>Promise.reject("Invalid data URI");if(ze(t,"blob:")){const s=e.getByUri(t);return C(s)?Promise.resolve(s):(o=t,ze(o,"blob:")?(e=>fetch(e).then((e=>e.ok?e.blob():Promise.reject())).catch((()=>Promise.reject(`Cannot convert ${e} to Blob. Resource might not exist or is inaccessible.`))))(o):ze(o,"data:")?(r=o,new Promise(((e,t)=>{Jv(r).bind((({type:e,data:t,base64Encoded:n})=>Zv(e,t,n))).fold((()=>t("Invalid data URI")),e)}))):Promise.reject("Unknown URI format")).then((t=>ey(t).then((o=>ny(o,!1,(n=>M.some(oy(e,t,n)))).getOrThunk(n)))))}var o,r;return ze(t,"data:")?ry(e,t).fold(n,(e=>Promise.resolve(e))):Promise.reject("Unknown image data format")})(t,o).then((t=>(delete n[o],{image:e,blobInfo:t}))).catch((e=>(delete n[o],e)));return n[o]=r,r}}));return Promise.all(a)}}},IC=()=>{let e={};const t=(e,t)=>({status:e,resultUri:t}),n=t=>t in e;return{hasBlobUri:n,getResultUri:t=>{const n=e[t];return n?n.resultUri:null},isPending:t=>!!n(t)&&1===e[t].status,isUploaded:t=>!!n(t)&&2===e[t].status,markPending:n=>{e[n]=t(1,null)},markUploaded:(n,o)=>{e[n]=t(2,o)},removeFailed:t=>{delete e[t]},destroy:()=>{e={}}}};let FC=0;const UC=(e,t)=>{const n={},o=(e,n)=>new Promise(((o,r)=>{const s=new XMLHttpRequest;s.open("POST",t.url),s.withCredentials=t.credentials,s.upload.onprogress=e=>{n(e.loaded/e.total*100)},s.onerror=()=>{r("Image upload failed due to a XHR Transport error. Code: "+s.status)},s.onload=()=>{if(s.status<200||s.status>=300)return void r("HTTP Error: "+s.status);const e=JSON.parse(s.responseText);var n,a;e&&m(e.location)?o((n=t.basePath,a=e.location,n?n.replace(/\/$/,"")+"/"+a.replace(/^\//,""):a)):r("Invalid JSON: "+s.responseText)};const a=new FormData;a.append("file",e.blob(),e.filename()),s.send(a)})),r=w(t.handler)?t.handler:o,s=(e,t)=>({url:t,blobInfo:e,status:!0}),a=(e,t)=>({url:"",blobInfo:e,status:!1,error:t}),i=(e,t)=>{Tt.each(n[e],(e=>{e(t)})),delete n[e]};return{upload:(l,d)=>t.url||r!==o?((t,o)=>(t=Tt.grep(t,(t=>!e.isUploaded(t.blobUri()))),Promise.all(Tt.map(t,(t=>e.isPending(t.blobUri())?(e=>{const t=e.blobUri();return new Promise((e=>{n[t]=n[t]||[],n[t].push(e)}))})(t):((t,n,o)=>(e.markPending(t.blobUri()),new Promise((r=>{let l,d;try{const c=()=>{l&&(l.close(),d=S)},u=n=>{c(),e.markUploaded(t.blobUri(),n),i(t.blobUri(),s(t,n)),r(s(t,n))},f=n=>{c(),e.removeFailed(t.blobUri()),i(t.blobUri(),a(t,n)),r(a(t,n))};d=e=>{e<0||e>100||M.from(l).orThunk((()=>M.from(o).map(B))).each((t=>{l=t,t.progressBar.value(e)}))},n(t,d).then(u,(e=>{f(m(e)?{message:e}:e)}))}catch(e){r(a(t,e))}}))))(t,r,o))))))(l,d):new Promise((e=>{e([])}))}},zC=e=>()=>e.notificationManager.open({text:e.translate("Image uploading..."),type:"info",timeout:-1,progressBar:!0}),jC=(e,t)=>UC(t,{url:El(e),basePath:Nl(e),credentials:Rl(e),handler:Al(e)}),HC=e=>{const t=(()=>{let e=[];const t=e=>{if(!e.blob||!e.base64)throw new Error("blob and base64 representations of the image are required for BlobInfo to be created");const t=e.id||"blobid"+FC+++(()=>{const e=()=>Math.round(4294967295*Math.random()).toString(36);return"s"+(new Date).getTime().toString(36)+e()+e()+e()})(),n=e.name||t,o=e.blob;var r;return{id:N(t),name:N(n),filename:N(e.filename||n+"."+(r=o.type,{"image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/png":"png","image/apng":"apng","image/avif":"avif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff"}[r.toLowerCase()]||"dat")),blob:N(o),base64:N(e.base64),blobUri:N(e.blobUri||URL.createObjectURL(o)),uri:N(e.uri)}},n=t=>Q(e,t).getOrUndefined(),o=e=>n((t=>t.id()===e));return{create:(e,n,o,r,s)=>{if(m(e))return t({id:e,name:r,filename:s,blob:n,base64:o});if(f(e))return t(e);throw new Error("Unknown input type")},add:t=>{o(t.id())||e.push(t)},get:o,getByUri:e=>n((t=>t.blobUri()===e)),getByData:(e,t)=>n((n=>n.base64()===e&&n.blob().type===t)),findFirst:n,removeByUri:t=>{e=K(e,(e=>e.blobUri()!==t||(URL.revokeObjectURL(e.blobUri()),!1)))},destroy:()=>{V(e,(e=>{URL.revokeObjectURL(e.blobUri())})),e=[]}}})();let n,o;const r=IC(),s=[],a=t=>n=>e.selection?t(n):[],i=(e,t,n)=>{let o=0;do{o=e.indexOf(t,o),-1!==o&&(e=e.substring(0,o)+n+e.substr(o+t.length),o+=n.length-t.length+1)}while(-1!==o);return e},l=(e,t,n)=>{const o=`src="${n}"${n===Nt.transparentSrc?' data-mce-placeholder="1"':""}`;return e=i(e,`src="${t}"`,o),i(e,'data-mce-src="'+t+'"','data-mce-src="'+n+'"')},d=(t,n)=>{V(e.undoManager.data,(e=>{"fragmented"===e.type?e.fragments=$(e.fragments,(e=>l(e,t,n))):e.content=l(e.content,t,n)}))},c=()=>(n||(n=jC(e,r)),p().then(a((o=>{const r=$(o,(e=>e.blobInfo));return n.upload(r,zC(e)).then(a((n=>{const r=[];let s=!1;const a=$(n,((n,a)=>{const{blobInfo:i,image:l}=o[a];let c=!1;return n.status&&kl(e)?(n.url&&!Ue(l.src,n.url)&&(s=!0),t.removeByUri(l.src),Jy(e)||((t,n)=>{const o=e.convertURL(n,"src");var r;d(t.src,n),qt(mn(t),{src:xl(e)?(r=n,r+(-1===r.indexOf("?")?"?":"&")+(new Date).getTime()):n,"data-mce-src":o})})(l,n.url)):n.error&&(n.error.remove&&(d(l.src,Nt.transparentSrc),r.push(l),c=!0),((e,t)=>{OC(e,Sa.translate(["Failed to upload image: {0}",t]))})(e,n.error.message)),{element:l,status:n.status,uploadUri:n.url,blobInfo:i,removed:c}}));return r.length>0&&!Jy(e)?e.undoManager.transact((()=>{V(r,(n=>{e.dom.remove(n),t.removeByUri(n.src)}))})):s&&e.undoManager.dispatchChange(),a})))})))),u=()=>wl(e)?c():Promise.resolve([]),g=e=>te(s,(t=>t(e))),p=()=>(o||(o=MC(r,t)),o.findAll(e.getBody(),g).then(a((t=>{const n=K(t,(t=>!m(t)||(OC(e,t),!1)));return Jy(e)||V(n,(e=>{d(e.image.src,e.blobInfo.blobUri()),e.image.src=e.blobInfo.blobUri(),e.image.removeAttribute("data-mce-src")})),n})))),h=n=>n.replace(/src="(blob:[^"]+)"/g,((n,o)=>{const s=r.getResultUri(o);if(s)return'src="'+s+'"';let a=t.getByUri(o);return a||(a=Y(e.editorManager.get(),((e,t)=>e||t.editorUpload&&t.editorUpload.blobCache.getByUri(o)),void 0)),a?'src="data:'+a.blob().type+";base64,"+a.base64()+'"':n}));return e.on("SetContent",(()=>{wl(e)?u():p()})),e.on("RawSaveContent",(e=>{e.content=h(e.content)})),e.on("GetContent",(e=>{e.source_view||"raw"===e.format||"tree"===e.format||(e.content=h(e.content))})),e.on("PostRender",(()=>{e.parser.addNodeFilter("img",(e=>{V(e,(e=>{const n=e.attr("src");if(!n||t.getByUri(n))return;const o=r.getResultUri(n);o&&e.attr("src",o)}))}))})),{blobCache:t,addFilter:e=>{s.push(e)},uploadImages:c,uploadImagesAuto:u,scanForImages:p,destroy:()=>{t.destroy(),r.destroy(),o=n=null}}},$C={remove_similar:!0,inherit:!1},VC={selector:"td,th",...$C},qC={tablecellbackgroundcolor:{styles:{backgroundColor:"%value"},...VC},tablecellverticalalign:{styles:{"vertical-align":"%value"},...VC},tablecellbordercolor:{styles:{borderColor:"%value"},...VC},tablecellclass:{classes:["%value"],...VC},tableclass:{selector:"table",classes:["%value"],...$C},tablecellborderstyle:{styles:{borderStyle:"%value"},...VC},tablecellborderwidth:{styles:{borderWidth:"%value"},...VC}},WC=N(qC),KC=Tt.each,GC=ba.DOM,YC=e=>C(e)&&f(e),XC=(e,t)=>{const n=t&&t.schema||Qs({}),o=e=>{const t=m(e)?{name:e,classes:[],attrs:{}}:e,n=GC.create(t.name);return((e,t)=>{t.classes.length>0&&GC.addClass(e,t.classes.join(" ")),GC.setAttribs(e,t.attrs)})(n,t),n},r=(e,t,s)=>{let a;const i=t[0],l=YC(i)?i.name:void 0,d=((e,t)=>{const o=n.getElementRule(e.nodeName.toLowerCase()),r=null==o?void 0:o.parentsRequired;return!(!r||!r.length)&&(t&&j(r,t)?t:r[0])})(e,l);if(d)l===d?(a=i,t=t.slice(1)):a=d;else if(i)a=i,t=t.slice(1);else if(!s)return e;const c=a?o(a):GC.create("div");c.appendChild(e),s&&Tt.each(s,(t=>{const n=o(t);c.insertBefore(n,e)}));const u=YC(a)?a.siblings:void 0;return r(c,t,u)},s=GC.create("div");if(e.length>0){const t=e[0],n=o(t),a=YC(t)?t.siblings:void 0;s.appendChild(r(n,e.slice(1),a))}return s},QC=e=>{let t="div";const n={name:t,classes:[],attrs:{},selector:e=Tt.trim(e)};return"*"!==e&&(t=e.replace(/(?:([#\.]|::?)([\w\-]+)|(\[)([^\]]+)\]?)/g,((e,t,o,r,s)=>{switch(t){case"#":n.attrs.id=o;break;case".":n.classes.push(o);break;case":":-1!==Tt.inArray("checked disabled enabled read-only required".split(" "),o)&&(n.attrs[o]=o)}if("["===r){const e=s.match(/([\w\-]+)(?:\=\"([^\"]+))?/);e&&(n.attrs[e[1]]=e[2])}return""}))),n.name=t||"div",n},JC=(e,t)=>{let n="",o=Jl(e);if(""===o)return"";const r=e=>m(e)?e.replace(/%(\w+)/g,""):"",s=(t,n)=>GC.getStyle(null!=n?n:e.getBody(),t,!0);if(m(t)){const n=e.formatter.get(t);if(!n)return"";t=n[0]}if("preview"in t){const e=t.preview;if(!1===e)return"";o=e||o}let a,i=t.block||t.inline||"span";const l=(d=t.selector,m(d)?(d=(d=d.split(/\s*,\s*/)[0]).replace(/\s*(~\+|~|\+|>)\s*/g,"$1"),Tt.map(d.split(/(?:>|\s+(?![^\[\]]+\]))/),(e=>{const t=Tt.map(e.split(/(?:~\+|~|\+)/),QC),n=t.pop();return t.length&&(n.siblings=t),n})).reverse()):[]);var d;l.length>0?(l[0].name||(l[0].name=i),i=t.selector,a=XC(l,e)):a=XC([i],e);const c=GC.select(i,a)[0]||a.firstChild;KC(t.styles,((e,t)=>{const n=r(e);n&&GC.setStyle(c,t,n)})),KC(t.attributes,((e,t)=>{const n=r(e);n&&GC.setAttrib(c,t,n)})),KC(t.classes,(e=>{const t=r(e);GC.hasClass(c,t)||GC.addClass(c,t)})),e.dispatch("PreviewFormats"),GC.setStyles(a,{position:"absolute",left:-65535}),e.getBody().appendChild(a);const u=s("fontSize"),f=/px$/.test(u)?parseInt(u,10):0;return KC(o.split(" "),(e=>{let t=s(e,c);if(!("background-color"===e&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(t)&&(t=s(e),"#ffffff"===_u(t).toLowerCase())||"color"===e&&"#000000"===_u(t).toLowerCase())){if("font-size"===e&&/em|%$/.test(t)){if(0===f)return;t=parseFloat(t)/(/%$/.test(t)?100:1)*f+"px"}"border"===e&&t&&(n+="padding:0 2px;"),n+=e+":"+t+";"}})),e.dispatch("AfterPreviewFormats"),GC.remove(a),n},ZC=e=>{const t=(e=>{const t={},n=(e,o)=>{e&&(m(e)?(p(o)||(o=[o]),V(o,(e=>{v(e.deep)&&(e.deep=!tm(e)),v(e.split)&&(e.split=!tm(e)||nm(e)),v(e.remove)&&tm(e)&&!nm(e)&&(e.remove="none"),tm(e)&&nm(e)&&(e.mixed=!0,e.block_expand=!0),m(e.classes)&&(e.classes=e.classes.split(/\s+/))})),t[e]=o):fe(e,((e,t)=>{n(t,e)})))};return n((e=>{const t=e.dom,n=e.schema.type,o={valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}],alignleft:[{selector:"figure.image",collapsed:!1,classes:"align-left",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"left"},inherit:!1,preview:!1},{selector:"img,audio,video",collapsed:!1,styles:{float:"left"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginLeft:"0px",marginRight:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"left"}}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"center"},inherit:!1,preview:"font-family font-size"},{selector:"figure.image",collapsed:!1,classes:"align-center",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{display:"block",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"table",collapsed:!1,styles:{marginLeft:"auto",marginRight:"auto"},preview:"font-family font-size"},{selector:".mce-preview-object",ceFalseOverride:!0,styles:{display:"table",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{marginLeft:"auto",marginRight:"auto"},preview:!1}],alignright:[{selector:"figure.image",collapsed:!1,classes:"align-right",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"right"},inherit:!1,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{float:"right"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginRight:"0px",marginLeft:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"right"},preview:!1}],alignjustify:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"justify"},inherit:!1,preview:"font-family font-size"}],bold:[{inline:"strong",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b",remove:"all",preserve_attributes:["class","style"]}],italic:[{inline:"em",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i",remove:"all",preserve_attributes:["class","style"]}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:!0},{inline:"u",remove:"all",preserve_attributes:["class","style"]}],strikethrough:(()=>{const e={inline:"span",styles:{textDecoration:"line-through"},exact:!0},t={inline:"strike",remove:"all",preserve_attributes:["class","style"]},o={inline:"s",remove:"all",preserve_attributes:["class","style"]};return"html4"!==n?[o,e,t]:[e,o,t]})(),forecolor:{inline:"span",styles:{color:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},fontname:{inline:"span",toggle:!1,styles:{fontFamily:"%value"},clear_child_styles:!0},fontsize:{inline:"span",toggle:!1,styles:{fontSize:"%value"},clear_child_styles:!0},lineheight:{selector:"h1,h2,h3,h4,h5,h6,p,li,td,th,div",styles:{lineHeight:"%value"}},fontsize_class:{inline:"span",attributes:{class:"%value"}},blockquote:{block:"blockquote",wrapper:!0,remove:"all"},subscript:{inline:"sub"},superscript:{inline:"sup"},code:{inline:"code"},link:{inline:"a",selector:"a",remove:"all",split:!0,deep:!0,onmatch:(e,t,n)=>To(e)&&e.hasAttribute("href"),onformat:(e,n,o)=>{Tt.each(o,((n,o)=>{t.setAttrib(e,o,n)}))}},lang:{inline:"span",clear_child_styles:!0,remove_similar:!0,attributes:{lang:"%value","data-mce-lang":e=>{var t;return null!==(t=null==e?void 0:e.customValue)&&void 0!==t?t:null}}},removeformat:[{selector:"b,strong,em,i,font,u,strike,s,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,small",remove:"all",split:!0,expand:!1,block_expand:!0,deep:!0},{selector:"span",attributes:["style","class"],remove:"empty",split:!0,expand:!1,deep:!0},{selector:"*",attributes:["style","class"],split:!1,expand:!1,deep:!0}]};return Tt.each("p h1 h2 h3 h4 h5 h6 div address pre dt dd samp".split(/\s/),(e=>{o[e]={block:e,remove:"all"}})),o})(e)),n(WC()),n(Ql(e)),{get:e=>C(e)?t[e]:t,has:e=>xe(t,e),register:n,unregister:e=>(e&&t[e]&&delete t[e],t)}})(e),n=Ca({});return(e=>{e.addShortcut("meta+b","","Bold"),e.addShortcut("meta+i","","Italic"),e.addShortcut("meta+u","","Underline");for(let t=1;t<=6;t++)e.addShortcut("access+"+t,"",["FormatBlock",!1,"h"+t]);e.addShortcut("access+7","",["FormatBlock",!1,"p"]),e.addShortcut("access+8","",["FormatBlock",!1,"div"]),e.addShortcut("access+9","",["FormatBlock",!1,"address"])})(e),(e=>{e.on("mouseup keydown",(t=>{((e,t)=>{const n=e.selection,o=e.getBody();nb(e,null,!1),8!==t&&46!==t||!n.isCollapsed()||n.getStart().innerHTML!==Qh||nb(e,ou(o,n.getStart())),37!==t&&39!==t||nb(e,ou(o,n.getStart()))})(e,t.keyCode)}))})(e),Jy(e)||((e,t)=>{e.set({}),t.on("NodeChange",(n=>{Gb(t,n.element,e.get())})),t.on("FormatApply FormatRemove",(n=>{const o=M.from(n.node).map((e=>Iu(e)?e:e.startContainer)).bind((e=>To(e)?M.some(e):M.from(e.parentElement))).getOrThunk((()=>qb(t)));Gb(t,o,e.get())}))})(n,e),{get:t.get,has:t.has,register:t.register,unregister:t.unregister,apply:(t,n,o)=>{((e,t,n,o)=>{eC(e).formatter.apply(t,n,o)})(e,t,n,o)},remove:(t,n,o,r)=>{((e,t,n,o,r)=>{eC(e).formatter.remove(t,n,o,r)})(e,t,n,o,r)},toggle:(t,n,o)=>{((e,t,n,o)=>{eC(e).formatter.toggle(t,n,o)})(e,t,n,o)},match:(t,n,o,r)=>((e,t,n,o,r)=>eC(e).formatter.match(t,n,o,r))(e,t,n,o,r),closest:t=>((e,t)=>eC(e).formatter.closest(t))(e,t),matchAll:(t,n)=>((e,t,n)=>eC(e).formatter.matchAll(t,n))(e,t,n),matchNode:(t,n,o,r)=>((e,t,n,o,r)=>eC(e).formatter.matchNode(t,n,o,r))(e,t,n,o,r),canApply:t=>((e,t)=>eC(e).formatter.canApply(t))(e,t),formatChanged:(t,o,r,s)=>((e,t,n,o,r,s)=>eC(e).formatter.formatChanged(t,n,o,r,s))(e,n,t,o,r,s),getCssText:O(JC,e)}},ew=e=>{switch(e.toLowerCase()){case"undo":case"redo":case"mcefocus":return!0;default:return!1}},tw=e=>{const t=Na(),n=Ca(0),o=Ca(0),r={data:[],typing:!1,beforeChange:()=>{((e,t,n)=>{eC(e).undoManager.beforeChange(t,n)})(e,n,t)},add:(s,a)=>((e,t,n,o,r,s,a)=>eC(e).undoManager.add(t,n,o,r,s,a))(e,r,o,n,t,s,a),dispatchChange:()=>{e.setDirty(!0);const t=$y(e);t.bookmark=$i(e.selection),e.dispatch("change",{level:t,lastLevel:ae(r.data,o.get()).getOrUndefined()})},undo:()=>((e,t,n,o)=>eC(e).undoManager.undo(t,n,o))(e,r,n,o),redo:()=>((e,t,n)=>eC(e).undoManager.redo(t,n))(e,o,r.data),clear:()=>{((e,t,n)=>{eC(e).undoManager.clear(t,n)})(e,r,o)},reset:()=>{((e,t)=>{eC(e).undoManager.reset(t)})(e,r)},hasUndo:()=>((e,t,n)=>eC(e).undoManager.hasUndo(t,n))(e,r,o),hasRedo:()=>((e,t,n)=>eC(e).undoManager.hasRedo(t,n))(e,r,o),transact:t=>((e,t,n,o)=>eC(e).undoManager.transact(t,n,o))(e,r,n,t),ignore:t=>{((e,t,n)=>{eC(e).undoManager.ignore(t,n)})(e,n,t)},extra:(t,n)=>{((e,t,n,o,r)=>{eC(e).undoManager.extra(t,n,o,r)})(e,r,o,t,n)}};return Jy(e)||((e,t,n)=>{const o=Ca(!1),r=e=>{Yy(t,!1,n),t.add({},e)};e.on("init",(()=>{t.add()})),e.on("BeforeExecCommand",(e=>{const o=e.command;ew(o)||(Xy(t,n),t.beforeChange())})),e.on("ExecCommand",(e=>{const t=e.command;ew(t)||r(e)})),e.on("ObjectResizeStart cut",(()=>{t.beforeChange()})),e.on("SaveContent ObjectResized blur",r),e.on("dragend",r),e.on("keyup",(n=>{const s=n.keyCode;n.isDefaultPrevented()||((s>=33&&s<=36||s>=37&&s<=40||45===s||n.ctrlKey)&&(r(),e.nodeChanged()),46!==s&&8!==s||e.nodeChanged(),o.get()&&t.typing&&!Ky($y(e),t.data[0])&&(e.isDirty()||e.setDirty(!0),e.dispatch("TypingUndo"),o.set(!1),e.nodeChanged()))})),e.on("keydown",(e=>{const s=e.keyCode;if(e.isDefaultPrevented())return;if(s>=33&&s<=36||s>=37&&s<=40||45===s)return void(t.typing&&r(e));const a=e.ctrlKey&&!e.altKey||e.metaKey;!(s<16||s>20)||224===s||91===s||t.typing||a||(t.beforeChange(),Yy(t,!0,n),t.add({},e),o.set(!0))})),e.on("mousedown",(e=>{t.typing&&r(e)})),e.on("input",(e=>{var t;e.inputType&&("insertReplacementText"===e.inputType||"insertText"===(t=e).inputType&&null===t.data||(e=>"insertFromPaste"===e.inputType||"insertFromDrop"===e.inputType)(e))&&r(e)})),e.on("AddUndo Undo Redo ClearUndos",(t=>{t.isDefaultPrevented()||e.nodeChanged()}))})(e,r,n),(e=>{e.addShortcut("meta+z","","Undo"),e.addShortcut("meta+y,meta+shift+z","","Redo")})(e),r},nw=[9,27,Dm.HOME,Dm.END,19,20,44,144,145,33,34,45,16,17,18,91,92,93,Dm.DOWN,Dm.UP,Dm.LEFT,Dm.RIGHT].concat(Nt.browser.isFirefox()?[224]:[]),ow="data-mce-placeholder",rw=e=>"keydown"===e.type||"keyup"===e.type,sw=e=>{const t=e.keyCode;return t===Dm.BACKSPACE||t===Dm.DELETE},aw=(e,t)=>({from:e,to:t}),iw=(e,t)=>{const n=mn(e),o=mn(t.container());return Hp(n,o).map((e=>((e,t)=>({block:e,position:t}))(e,t)))},lw=(e,t)=>ko(t,(e=>hr(e)||Go(e.dom)),(t=>bn(t,e))).filter(Ft).getOr(e),dw=e=>{const t=(e=>{const t=An(e);return J(t,dr).fold(N(t),(e=>t.slice(0,e)))})(e);return V(t,oo),t},cw=(e,t)=>{const n=Wg(t,e);return Q(n.reverse(),(e=>os(e))).each(oo)},uw=(e,t,n,o)=>{if(os(n))return wr(n),Zc(n.dom);0===K(Nn(o),(e=>!os(e))).length&&os(t)&&Qn(o,cn("br"));const r=Jc(n.dom,xi.before(o.dom));return V(dw(t),(e=>{Qn(o,e)})),cw(e,t),r},mw=(e,t,n)=>{if(os(n))return oo(n),os(t)&&wr(t),Zc(t.dom);const o=eu(n.dom);return V(dw(t),(e=>{eo(n,e)})),cw(e,t),o},fw=(e,t)=>{Xc(e,t.dom).bind((e=>M.from(e.getNode()))).map(mn).filter(ur).each(oo)},gw=(e,t,n)=>(fw(!0,t),fw(!1,n),((e,t)=>vn(t,e)?((e,t)=>{const n=Wg(t,e);return M.from(n[n.length-1])})(t,e):M.none())(t,n).fold(O(mw,e,t,n),O(uw,e,t,n))),pw=(e,t,n,o)=>t?gw(e,o,n):gw(e,n,o),hw=(e,t)=>{const n=mn(e.getBody()),o=((e,t,n)=>n.collapsed?((e,t,n)=>{const o=iw(e,xi.fromRangeStart(n)),r=o.bind((n=>Kc(t,e,n.position).bind((n=>iw(e,n).map((n=>((e,t,n)=>Wo(n.position.getNode())&&!os(n.block)?Xc(!1,n.block.dom).bind((o=>o.isEqual(n.position)?Kc(t,e,o).bind((t=>iw(e,t))):M.some(n))).getOr(n):n)(e,t,n)))))));return Dt(o,r,aw).filter((t=>(e=>!bn(e.from.block,e.to.block))(t)&&((e,t)=>{const n=mn(e);return bn(lw(n,t.from.block),lw(n,t.to.block))})(e,t)&&(e=>!1===Yo(e.from.block.dom)&&!1===Yo(e.to.block.dom))(t)&&(e=>{const t=e=>mr(e)||ms(e.dom);return t(e.from.block)&&t(e.to.block)})(t)))})(e,t,n):M.none())(n.dom,t,e.selection.getRng()).map((o=>()=>{pw(n,t,o.from.block,o.to.block).each((t=>{e.selection.setRng(t.toRange())}))}));return o},bw=(e,t)=>{const n=mn(t),o=O(bn,e);return xo(n,hr,o).isSome()},vw=e=>{const t=mn(e.getBody());return((e,t)=>{const n=Jc(e.dom,xi.fromRangeStart(t)).isNone(),o=Qc(e.dom,xi.fromRangeEnd(t)).isNone();return!((e,t)=>bw(e,t.startContainer)||bw(e,t.endContainer))(e,t)&&n&&o})(t,e.selection.getRng())?(e=>M.some((()=>{e.setContent(""),e.selection.setCursorLocation()})))(e):((e,t)=>{const n=t.getRng();return Dt(Hp(e,mn(n.startContainer)),Hp(e,mn(n.endContainer)),((o,r)=>bn(o,r)?M.none():M.some((()=>{n.deleteContents(),pw(e,!0,o,r).each((e=>{t.setRng(e.toRange())}))})))).getOr(M.none())})(t,e.selection)},yw=(e,t)=>e.selection.isCollapsed()?M.none():vw(e),Cw=(e,t,n,o,r)=>M.from(t._selectionOverrides.showCaret(e,n,o,r)),ww=(e,t)=>e.dispatch("BeforeObjectSelected",{target:t}).isDefaultPrevented()?M.none():M.some((e=>{const t=e.ownerDocument.createRange();return t.selectNode(e),t})(t)),xw=(e,t,n)=>t.collapsed?((e,t,n)=>{const o=Ec(1,e.getBody(),t),r=xi.fromRangeStart(o),s=r.getNode();if(oc(s))return Cw(1,e,s,!r.isAtEnd(),!1);const a=r.getNode(!0);if(oc(a))return Cw(1,e,a,!1,!1);const i=bh(e.dom.getRoot(),r.getNode());return oc(i)?Cw(1,e,i,!1,n):M.none()})(e,t,n).getOr(t):t,kw=e=>$g(e)||Ug(e),Sw=e=>Vg(e)||zg(e),_w=(e,t,n,o,r,s)=>{Cw(o,e,s.getNode(!r),r,!0).each((n=>{if(t.collapsed){const e=t.cloneRange();r?e.setEnd(n.startContainer,n.startOffset):e.setStart(n.endContainer,n.endOffset),e.deleteContents()}else t.deleteContents();e.selection.setRng(n)})),((e,t)=>{zo(t)&&0===t.data.length&&e.remove(t)})(e.dom,n)},Ew=(e,t)=>((e,t)=>{const n=e.selection.getRng();if(!zo(n.commonAncestorContainer))return M.none();const o=t?Bc.Forwards:Bc.Backwards,r=$c(e.getBody()),s=O(Oc,t?r.next:r.prev),a=t?kw:Sw,i=Rc(o,e.getBody(),n),l=s(i),d=l?Mp(t,l):l;if(!d||!Tc(i,d))return M.none();if(a(d))return M.some((()=>_w(e,n,i.getNode(),o,t,d)));const c=s(d);return c&&a(c)&&Tc(d,c)?M.some((()=>_w(e,n,i.getNode(),o,t,c))):M.none()})(e,t),Nw=(e,t)=>{const n=e.getBody();return t?Zc(n).filter($g):eu(n).filter(Vg)},Rw=e=>{const t=e.selection.getRng();return!t.collapsed&&(Nw(e,!0).exists((e=>e.isEqual(xi.fromRangeStart(t))))||Nw(e,!1).exists((e=>e.isEqual(xi.fromRangeEnd(t)))))},Aw=Ki([{remove:["element"]},{moveToElement:["element"]},{moveToPosition:["position"]}]),Ow=(e,t,n)=>Kc(t,e,n).bind((o=>{return r=o.getNode(),C(r)&&(hr(mn(r))||gr(mn(r)))||((e,t,n,o)=>{const r=t=>cr(mn(t))&&!yc(n,o,e);return Nc(!t,n).fold((()=>Nc(t,o).fold(P,r)),r)})(e,t,n,o)?M.none():t&&Yo(o.getNode())||!t&&Yo(o.getNode(!0))?((e,t,n,o)=>{const r=o.getNode(!t);return Hp(mn(e),mn(n.getNode())).map((e=>os(e)?Aw.remove(e.dom):Aw.moveToElement(r))).orThunk((()=>M.some(Aw.moveToElement(r))))})(e,t,n,o):t&&Vg(n)||!t&&$g(n)?M.some(Aw.moveToPosition(o)):M.none();var r})),Tw=(e,t)=>M.from(bh(e.getBody(),t)),Bw=(e,t)=>{const n=e.selection.getNode();return Tw(e,n).filter(Yo).fold((()=>((e,t,n)=>{const o=Ec(t?1:-1,e,n),r=xi.fromRangeStart(o),s=mn(e);return!t&&Vg(r)?M.some(Aw.remove(r.getNode(!0))):t&&$g(r)?M.some(Aw.remove(r.getNode())):!t&&$g(r)&&rp(s,r)?sp(s,r).map((e=>Aw.remove(e.getNode()))):t&&Vg(r)&&op(s,r)?ap(s,r).map((e=>Aw.remove(e.getNode()))):((e,t,n)=>((e,t)=>{const n=t.getNode(!e),o=e?"after":"before";return To(n)&&n.getAttribute("data-mce-caret")===o})(t,n)?((e,t)=>y(t)?M.none():e&&Yo(t.nextSibling)?M.some(Aw.moveToElement(t.nextSibling)):!e&&Yo(t.previousSibling)?M.some(Aw.moveToElement(t.previousSibling)):M.none())(t,n.getNode(!t)).orThunk((()=>Ow(e,t,n))):Ow(e,t,n).bind((t=>((e,t,n)=>n.fold((e=>M.some(Aw.remove(e))),(e=>M.some(Aw.moveToElement(e))),(n=>yc(t,n,e)?M.none():M.some(Aw.moveToPosition(n)))))(e,n,t))))(e,t,r)})(e.getBody(),t,e.selection.getRng()).map((n=>()=>n.fold(((e,t)=>n=>(e._selectionOverrides.hideFakeCaret(),Bp(e,t,mn(n)),!0))(e,t),((e,t)=>n=>{const o=t?xi.before(n):xi.after(n);return e.selection.setRng(o.toRange()),!0})(e,t),(e=>t=>(e.selection.setRng(t.toRange()),!0))(e))))),(()=>M.some(S)))},Dw=e=>{const t=e.dom,n=e.selection,o=bh(e.getBody(),n.getNode());if(Go(o)&&t.isBlock(o)&&t.isEmpty(o)){const e=t.create("br",{"data-mce-bogus":"1"});t.setHTML(o,""),o.appendChild(e),n.setRng(xi.before(e).toRange())}return!0},Pw=(e,t)=>e.selection.isCollapsed()?Bw(e,t):((e,t)=>{const n=e.selection.getNode();return Yo(n)&&!Xo(n)?Tw(e,n.parentNode).filter(Yo).fold((()=>M.some((()=>{var n;n=mn(e.getBody()),V(or(n,".mce-offscreen-selection"),oo),Bp(e,t,mn(e.selection.getNode())),$p(e)}))),(()=>M.some(S))):Rw(e)?M.some((()=>{qp(e,e.selection.getRng(),mn(e.getBody()))})):M.none()})(e,t),Lw=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const n=xi.fromRangeStart(e.selection.getRng());return Kc(t,e.getBody(),n).filter((e=>t?Ig(e):Fg(e))).bind((e=>Cc(t?0:-1,e))).map((t=>()=>e.selection.select(t)))})(e,t):M.none(),Mw=zo,Iw=e=>Mw(e)&&e.data[0]===kr,Fw=e=>Mw(e)&&e.data[e.data.length-1]===kr,Uw=e=>{var t;return(null!==(t=e.ownerDocument)&&void 0!==t?t:document).createTextNode(kr)},zw=(e,t)=>e?(e=>{var t;if(Mw(e.previousSibling))return Fw(e.previousSibling)||e.previousSibling.appendData(kr),e.previousSibling;if(Mw(e))return Iw(e)||e.insertData(0,kr),e;{const n=Uw(e);return null===(t=e.parentNode)||void 0===t||t.insertBefore(n,e),n}})(t):(e=>{var t,n;if(Mw(e.nextSibling))return Iw(e.nextSibling)||e.nextSibling.insertData(0,kr),e.nextSibling;if(Mw(e))return Fw(e)||e.appendData(kr),e;{const o=Uw(e);return e.nextSibling?null===(t=e.parentNode)||void 0===t||t.insertBefore(o,e.nextSibling):null===(n=e.parentNode)||void 0===n||n.appendChild(o),o}})(t),jw=O(zw,!0),Hw=O(zw,!1),$w=(e,t)=>zo(e.container())?zw(t,e.container()):zw(t,e.getNode()),Vw=(e,t)=>{const n=t.get();return n&&e.container()===n&&Ar(n)},qw=(e,t)=>t.fold((t=>{Xd(e.get());const n=jw(t);return e.set(n),M.some(xi(n,n.length-1))}),(t=>Zc(t).map((t=>{if(Vw(t,e)){const t=e.get();return xi(t,1)}{Xd(e.get());const n=$w(t,!0);return e.set(n),xi(n,1)}}))),(t=>eu(t).map((t=>{if(Vw(t,e)){const t=e.get();return xi(t,t.length-1)}{Xd(e.get());const n=$w(t,!1);return e.set(n),xi(n,n.length-1)}}))),(t=>{Xd(e.get());const n=Hw(t);return e.set(n),M.some(xi(n,1))})),Ww=(e,t)=>{for(let n=0;n<e.length;n++){const o=e[n].apply(null,t);if(o.isSome())return o}return M.none()},Kw=Ki([{before:["element"]},{start:["element"]},{end:["element"]},{after:["element"]}]),Gw=(e,t)=>vc(t,e)||e,Yw=(e,t,n)=>{const o=Ip(n),r=Gw(t,o.container());return Lp(e,r,o).fold((()=>Qc(r,o).bind(O(Lp,e,r)).map((e=>Kw.before(e)))),M.none)},Xw=(e,t)=>null===ou(e,t),Qw=(e,t,n)=>Lp(e,t,n).filter(O(Xw,t)),Jw=(e,t,n)=>{const o=Fp(n);return Qw(e,t,o).bind((e=>Jc(e,o).isNone()?M.some(Kw.start(e)):M.none()))},Zw=(e,t,n)=>{const o=Ip(n);return Qw(e,t,o).bind((e=>Qc(e,o).isNone()?M.some(Kw.end(e)):M.none()))},ex=(e,t,n)=>{const o=Fp(n),r=Gw(t,o.container());return Lp(e,r,o).fold((()=>Jc(r,o).bind(O(Lp,e,r)).map((e=>Kw.after(e)))),M.none)},tx=e=>{return t=ox(e),!("rtl"===ba.DOM.getStyle(t,"direction",!0)||(e=>Dp.test(e))(null!==(n=t.textContent)&&void 0!==n?n:""));var t,n},nx=(e,t,n)=>Ww([Yw,Jw,Zw,ex],[e,t,n]).filter(tx),ox=e=>e.fold(R,R,R,R),rx=e=>e.fold(N("before"),N("start"),N("end"),N("after")),sx=e=>e.fold(Kw.before,Kw.before,Kw.after,Kw.after),ax=e=>e.fold(Kw.start,Kw.start,Kw.end,Kw.end),ix=(e,t,n,o,r,s)=>Dt(Lp(t,n,o),Lp(t,n,r),((t,o)=>t!==o&&((e,t,n)=>{const o=vc(t,e),r=vc(n,e);return C(o)&&o===r})(n,t,o)?Kw.after(e?t:o):s)).getOr(s),lx=(e,t)=>e.fold(L,(e=>{return o=t,!(rx(n=e)===rx(o)&&ox(n)===ox(o));var n,o})),dx=(e,t)=>e?t.fold(_(M.some,Kw.start),M.none,_(M.some,Kw.after),M.none):t.fold(M.none,_(M.some,Kw.before),M.none,_(M.some,Kw.end)),cx=(e,t,n)=>{const o=e?1:-1;return t.setRng(xi(n.container(),n.offset()+o).toRange()),t.getSel().modify("move",e?"forward":"backward","word"),!0};var ux;!function(e){e[e.Br=0]="Br",e[e.Block=1]="Block",e[e.Wrap=2]="Wrap",e[e.Eol=3]="Eol"}(ux||(ux={}));const mx=(e,t)=>e===Bc.Backwards?ne(t):t,fx=(e,t,n)=>e===Bc.Forwards?t.next(n):t.prev(n),gx=(e,t,n,o)=>Wo(o.getNode(t===Bc.Forwards))?ux.Br:!1===yc(n,o)?ux.Block:ux.Wrap,px=(e,t,n,o)=>{const r=$c(n);let s=o;const a=[];for(;s;){const n=fx(t,r,s);if(!n)break;if(Wo(n.getNode(!1)))return t===Bc.Forwards?{positions:mx(t,a).concat([n]),breakType:ux.Br,breakAt:M.some(n)}:{positions:mx(t,a),breakType:ux.Br,breakAt:M.some(n)};if(n.isVisible()){if(e(s,n)){const e=gx(0,t,s,n);return{positions:mx(t,a),breakType:e,breakAt:M.some(n)}}a.push(n),s=n}else s=n}return{positions:mx(t,a),breakType:ux.Eol,breakAt:M.none()}},hx=(e,t,n,o)=>t(n,o).breakAt.map((o=>{const r=t(n,o).positions;return e===Bc.Backwards?r.concat(o):[o].concat(r)})).getOr([]),bx=(e,t)=>Y(e,((e,n)=>e.fold((()=>M.some(n)),(o=>Dt(ie(o.getClientRects()),ie(n.getClientRects()),((e,r)=>{const s=Math.abs(t-e.left);return Math.abs(t-r.left)<=s?n:o})).or(e)))),M.none()),vx=(e,t)=>ie(t.getClientRects()).bind((t=>bx(e,t.left))),yx=O(px,xi.isAbove,-1),Cx=O(px,xi.isBelow,1),wx=O(hx,-1,yx),xx=O(hx,1,Cx),kx=(e,t)=>vx(wx(e,t),t),Sx=(e,t)=>vx(xx(e,t),t),_x=Yo,Ex=(e,t)=>Math.abs(e.left-t),Nx=(e,t)=>Math.abs(e.right-t),Rx=(e,t)=>Oe(e,((e,n)=>{const o=Math.min(Ex(e,t),Nx(e,t)),r=Math.min(Ex(n,t),Nx(n,t));return r===o&&ke(n,"node")&&_x(n.node)||r<o?n:e})),Ax=e=>{const t=t=>$(t,(t=>{const n=Ya(t);return n.node=e,n}));if(To(e))return t(e.getClientRects());if(zo(e)){const n=e.ownerDocument.createRange();return n.setStart(e,0),n.setEnd(e,e.data.length),t(n.getClientRects())}return[]},Ox=e=>ee(e,Ax);var Tx;!function(e){e[e.Up=-1]="Up",e[e.Down=1]="Down"}(Tx||(Tx={}));const Bx=(e,t,n,o,r,s)=>{let a=0;const i=[],l=o=>{let s=Ox([o]);-1===e&&(s=s.reverse());for(let e=0;e<s.length;e++){const o=s[e];if(!n(o,d)){if(i.length>0&&t(o,Be(i))&&a++,o.line=a,r(o))return!0;i.push(o)}}return!1},d=Be(s.getClientRects());if(!d)return i;const c=s.getNode();return c&&(l(c),((e,t,n,o)=>{let r=o;for(;r=bc(r,e,Gr,t);)if(n(r))return})(e,o,l,c)),i},Dx=O(Bx,Tx.Up,Ja,Za),Px=O(Bx,Tx.Down,Za,Ja),Lx=e=>Be(e.getClientRects()),Mx=e=>t=>((e,t)=>t.line>e)(e,t),Ix=e=>t=>((e,t)=>t.line===e)(e,t),Fx=(e,t)=>{e.selection.setRng(t),Bf(e,e.selection.getRng())},Ux=(e,t,n)=>M.some(xw(e,t,n)),zx=(e,t,n,o,r,s)=>{const a=t===Bc.Forwards,i=$c(e.getBody()),l=O(Oc,a?i.next:i.prev),d=a?o:r;if(!n.collapsed){const o=ti(n);if(s(o))return Cw(t,e,o,t===Bc.Backwards,!1);if(Rw(e)){const e=n.cloneRange();return e.collapse(t===Bc.Backwards),M.from(e)}}const c=Rc(t,e.getBody(),n);if(d(c))return ww(e,c.getNode(!a));let u=l(c);const m=Ir(n);if(!u)return m?M.some(n):M.none();if(u=Mp(a,u),d(u))return Cw(t,e,u.getNode(!a),a,!1);const f=l(u);return f&&d(f)&&Tc(u,f)?Cw(t,e,f.getNode(!a),a,!1):m?Ux(e,u.toRange(),!1):M.none()},jx=(e,t,n,o,r,s)=>{const a=Rc(t,e.getBody(),n),i=Be(a.getClientRects()),l=t===Tx.Down,d=e.getBody();if(!i)return M.none();if(Rw(e)){const e=l?xi.fromRangeEnd(n):xi.fromRangeStart(n);return(l?Sx:kx)(d,e).orThunk((()=>M.from(e))).map((e=>e.toRange()))}const c=(l?Px:Dx)(d,Mx(1),a),u=K(c,Ix(1)),m=i.left,f=Rx(u,m);if(f&&s(f.node)){const n=Math.abs(m-f.left),o=Math.abs(m-f.right);return Cw(t,e,f.node,n<o,!1)}let g;if(g=o(a)?a.getNode():r(a)?a.getNode(!0):ti(n),g){const n=((e,t,n,o)=>{const r=$c(t);let s,a,i,l;const d=[];let c=0;1===e?(s=r.next,a=Za,i=Ja,l=xi.after(o)):(s=r.prev,a=Ja,i=Za,l=xi.before(o));const u=Lx(l);do{if(!l.isVisible())continue;const e=Lx(l);if(i(e,u))continue;d.length>0&&a(e,Be(d))&&c++;const t=Ya(e);if(t.position=l,t.line=c,n(t))return d;d.push(t)}while(l=s(l));return d})(t,d,Mx(1),g);let o=Rx(K(n,Ix(1)),m);if(o)return Ux(e,o.position.toRange(),!1);if(o=Be(K(n,Ix(0))),o)return Ux(e,o.position.toRange(),!1)}return 0===u.length?Hx(e,l).filter(l?r:o).map((t=>xw(e,t.toRange(),!1))):M.none()},Hx=(e,t)=>{const n=e.selection.getRng(),o=t?xi.fromRangeEnd(n):xi.fromRangeStart(n),r=(s=o.container(),a=e.getBody(),xo(mn(s),(e=>sc(e.dom)),(e=>e.dom===a)).map((e=>e.dom)).getOr(a));var s,a;if(t){const e=Cx(r,o);return le(e.positions)}{const e=yx(r,o);return ie(e.positions)}},$x=(e,t,n)=>Hx(e,t).filter(n).exists((t=>(e.selection.setRng(t.toRange()),!0))),Vx=(e,t)=>{const n=e.dom.createRng();n.setStart(t.container(),t.offset()),n.setEnd(t.container(),t.offset()),e.selection.setRng(n)},qx=(e,t)=>{e?t.setAttribute("data-mce-selected","inline-boundary"):t.removeAttribute("data-mce-selected")},Wx=(e,t,n)=>qw(t,n).map((t=>(Vx(e,t),n))),Kx=(e,t,n)=>{const o=e.getBody(),r=((e,t,n)=>{const o=xi.fromRangeStart(e);if(e.collapsed)return o;{const r=xi.fromRangeEnd(e);return n?Jc(t,r).getOr(r):Qc(t,o).getOr(o)}})(e.selection.getRng(),o,n);return((e,t,n,o)=>{const r=Mp(e,o),s=nx(t,n,r);return nx(t,n,r).bind(O(dx,e)).orThunk((()=>((e,t,n,o,r)=>{const s=Mp(e,r);return Kc(e,n,s).map(O(Mp,e)).fold((()=>o.map(sx)),(r=>nx(t,n,r).map(O(ix,e,t,n,s,r)).filter(O(lx,o)))).filter(tx)})(e,t,n,s,o)))})(n,O(Pp,e),o,r).bind((n=>Wx(e,t,n)))},Gx=(e,t,n)=>!!Xl(e)&&Kx(e,t,n).isSome(),Yx=(e,t,n)=>!!Xl(t)&&((e,t)=>{const n=t.selection.getRng(),o=e?xi.fromRangeEnd(n):xi.fromRangeStart(n);return!!(e=>w(e.selection.getSel().modify))(t)&&(e&&Br(o)?cx(!0,t.selection,o):!(e||!Dr(o))&&cx(!1,t.selection,o))})(e,t),Xx=e=>{const t=Ca(null),n=O(Pp,e);return e.on("NodeChange",(o=>{Xl(e)&&(((e,t,n)=>{const o=$(or(mn(t.getRoot()),'*[data-mce-selected="inline-boundary"]'),(e=>e.dom)),r=K(o,e),s=K(n,e);V(oe(r,s),O(qx,!1)),V(oe(s,r),O(qx,!0))})(n,e.dom,o.parents),((e,t)=>{const n=t.get();if(e.selection.isCollapsed()&&!e.composing&&n){const o=xi.fromRangeStart(e.selection.getRng());xi.isTextPosition(o)&&!(e=>Br(e)||Dr(e))(o)&&(Vx(e,Yd(n,o)),t.set(null))}})(e,t),((e,t,n,o)=>{if(t.selection.isCollapsed()){const r=K(o,e);V(r,(o=>{const r=xi.fromRangeStart(t.selection.getRng());nx(e,t.getBody(),r).bind((e=>Wx(t,n,e)))}))}})(n,e,t,o.parents))})),t},Qx=O(Yx,!0),Jx=O(Yx,!1),Zx=(e,t,n)=>{if(Xl(e)){const o=Hx(e,t).getOrThunk((()=>{const n=e.selection.getRng();return t?xi.fromRangeEnd(n):xi.fromRangeStart(n)}));return nx(O(Pp,e),e.getBody(),o).exists((t=>{const o=sx(t);return qw(n,o).exists((t=>(Vx(e,t),!0)))}))}return!1},ek=(e,t)=>n=>qw(t,n).map((t=>()=>Vx(e,t))),tk=(e,t,n,o)=>{const r=e.getBody(),s=O(Pp,e);e.undoManager.ignore((()=>{e.selection.setRng(((e,t)=>{const n=document.createRange();return n.setStart(e.container(),e.offset()),n.setEnd(t.container(),t.offset()),n})(n,o)),zp(e),nx(s,r,xi.fromRangeStart(e.selection.getRng())).map(ax).bind(ek(e,t)).each(D)})),e.nodeChanged()},nk=(e,t,n)=>{if(e.selection.isCollapsed()&&Xl(e)){const o=xi.fromRangeStart(e.selection.getRng());return((e,t,n,o)=>{const r=((e,t)=>vc(t,e)||e)(e.getBody(),o.container()),s=O(Pp,e),a=nx(s,r,o);return a.bind((e=>n?e.fold(N(M.some(ax(e))),M.none,N(M.some(sx(e))),M.none):e.fold(M.none,N(M.some(sx(e))),M.none,N(M.some(ax(e)))))).map(ek(e,t)).getOrThunk((()=>{const i=Gc(n,r,o),l=i.bind((e=>nx(s,r,e)));return Dt(a,l,(()=>Lp(s,r,o).bind((t=>(e=>Dt(Zc(e),eu(e),((t,n)=>{const o=Mp(!0,t),r=Mp(!1,n);return Qc(e,o).forall((e=>e.isEqual(r)))})).getOr(!0))(t)?M.some((()=>{Bp(e,n,mn(t))})):M.none())))).getOrThunk((()=>l.bind((()=>i.map((r=>()=>{n?tk(e,t,o,r):tk(e,t,r,o)}))))))}))})(e,t,n,o)}return M.none()},ok=e=>1===Dn(e),rk=(e,t)=>{const n=mn(e.getBody()),o=mn(e.selection.getStart()),r=K(((e,t)=>{const n=Wg(t,e);return J(n,dr).fold(N(n),(e=>n.slice(0,e)))})(n,o),ok);return le(r).bind((n=>{const o=xi.fromRangeStart(e.selection.getRng());return!((e,t,n)=>Dt(Zc(n),eu(n),((o,r)=>{const s=Mp(!0,o),a=Mp(!1,r),i=Mp(!1,t);return e?Qc(n,i).exists((e=>e.isEqual(a)&&t.isEqual(s))):Jc(n,i).exists((e=>e.isEqual(s)&&t.isEqual(a)))})).getOr(!0))(t,o,n.dom)||nu((s=n).dom)&&Jh(s.dom)?M.none():M.some((()=>((e,t,n,o)=>{const r=O(ab,t),s=$(K(o,r),(e=>e.dom));if(0===s.length)Bp(t,e,n);else{const e=((e,t)=>{const n=eb(!1),o=rb(t,n.dom);return Qn(mn(e),n),oo(mn(e)),xi(o,0)})(n.dom,s);t.selection.setRng(e.toRange())}})(t,e,n,r)));var s}))},sk=(e,t)=>e.selection.isCollapsed()?rk(e,t):M.none(),ak=(e,t,n)=>C(n)?M.some((()=>{e._selectionOverrides.hideFakeCaret(),Bp(e,t,mn(n))})):M.none(),ik=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const n=t?Ug:zg,o=t?Bc.Forwards:Bc.Backwards,r=Rc(o,e.getBody(),e.selection.getRng());return n(r)?ak(e,t,r.getNode(!t)):M.from(Mp(t,r)).filter((e=>n(e)&&Tc(r,e))).bind((n=>ak(e,t,n.getNode(!t))))})(e,t):((e,t)=>{const n=e.selection.getNode();return Jo(n)?ak(e,t,n):M.none()})(e,t),lk=e=>Ge(null!=e?e:"").getOr(0),dk=(e,t)=>(e||"table"===Lt(t)?"margin":"padding")+("rtl"===Wn(t,"direction")?"-right":"-left"),ck=e=>{const t=mk(e);return!e.mode.isReadOnly()&&(t.length>1||((e,t)=>te(t,(t=>{const n=dk(Pl(e),t),o=Gn(t,n).map(lk).getOr(0);return"false"!==e.dom.getContentEditable(t.dom)&&o>0})))(e,t))},uk=e=>fr(e)||gr(e),mk=e=>K(so(e.selection.getSelectedBlocks()),(e=>!uk(e)&&!(e=>xn(e).exists(uk))(e)&&ko(e,(e=>Go(e.dom)||Yo(e.dom))).exists((e=>Go(e.dom))))),fk=(e,t)=>{var n,o;const{dom:r}=e,s=Ll(e),a=null!==(o=null===(n=/[a-z%]+$/i.exec(s))||void 0===n?void 0:n[0])&&void 0!==o?o:"px",i=lk(s),l=Pl(e);V(mk(e),(e=>{((e,t,n,o,r,s)=>{const a=dk(n,mn(s)),i=lk(e.getStyle(s,a));if("outdent"===t){const t=Math.max(0,i-o);e.setStyle(s,a,t?t+r:"")}else{const t=i+o+r;e.setStyle(s,a,t)}})(r,t,l,i,a,e.dom)}))},gk=e=>fk(e,"outdent"),pk=e=>{if(e.selection.isCollapsed()&&ck(e)){const t=e.dom,n=e.selection.getRng(),o=xi.fromRangeStart(n),r=t.getParent(n.startContainer,t.isBlock);if(null!==r&&Qg(mn(r),o))return M.some((()=>gk(e)))}return M.none()},hk=(e,t,n)=>ce([pk,Pw,Ew,(e,n)=>nk(e,t,n),hw,hh,Lw,ik,yw,sk],(t=>t(e,n))),bk=(e,t)=>{e.addCommand("delete",(()=>{((e,t)=>{hk(e,t,!1).fold((()=>{zp(e),$p(e)}),D)})(e,t)})),e.addCommand("forwardDelete",(()=>{((e,t)=>{hk(e,t,!0).fold((()=>(e=>Up(e,"ForwardDelete"))(e)),D)})(e,t)}))},vk=e=>void 0===e.touches||1!==e.touches.length?M.none():M.some(e.touches[0]),yk=(e,t)=>xe(e,t.nodeName),Ck=(e,t)=>!!zo(t)||!!To(t)&&!yk(e.getBlockElements(),t)&&!pu(t)&&!ps(e,t),wk=(e,t)=>{if(zo(t)){if(0===t.data.length)return!0;if(/^\s+$/.test(t.data)&&(!t.nextSibling||yk(e,t.nextSibling)))return!0}return!1},xk=e=>e.dom.create(gl(e),pl(e)),kk=e=>{const t=e.dom,n=e.selection,o=e.schema,r=o.getBlockElements(),s=n.getStart(),a=e.getBody();let i,l,d=!1;const c=gl(e);if(!s||!To(s))return;const u=a.nodeName.toLowerCase();if(!o.isValidChild(u,c.toLowerCase())||((e,t,n)=>H(qg(mn(n),mn(t)),(t=>yk(e,t.dom))))(r,a,s))return;const m=n.getRng(),{startContainer:f,startOffset:g,endContainer:p,endOffset:h}=m,b=Zf(e);let v=a.firstChild;for(;v;)if(To(v)&&us(o,v),Ck(o,v)){if(wk(r,v)){l=v,v=v.nextSibling,t.remove(l);continue}i||(i=xk(e),a.insertBefore(i,v),d=!0),l=v,v=v.nextSibling,i.appendChild(l)}else i=null,v=v.nextSibling;d&&b&&(m.setStart(f,g),m.setEnd(p,h),n.setRng(m),e.nodeChanged())},Sk=(e,t,n)=>{const o=mn(xk(e)),r=Cr();eo(o,r),n(t,o);const s=document.createRange();return s.setStartBefore(r.dom),s.setEndBefore(r.dom),s},_k=e=>t=>-1!==(" "+t.attr("class")+" ").indexOf(e),Ek=(e,t,n)=>function(o){const r=arguments,s=r[r.length-2],a=s>0?t.charAt(s-1):"";if('"'===a)return o;if(">"===a){const e=t.lastIndexOf("<",s);if(-1!==e&&-1!==t.substring(e,s).indexOf('contenteditable="false"'))return o}return'<span class="'+n+'" data-mce-content="'+e.dom.encode(r[0])+'">'+e.dom.encode("string"==typeof r[1]?r[1]:r[0])+"</span>"},Nk=(e,t)=>{t.hasAttribute("data-mce-caret")&&(Mr(t),e.selection.setRng(e.selection.getRng()),e.selection.scrollIntoView(t))},Rk=(e,t)=>{const n=(e=>_o(mn(e.getBody()),"*[data-mce-caret]").map((e=>e.dom)).getOrNull())(e);if(n)return"compositionstart"===t.type?(t.preventDefault(),t.stopPropagation(),void Nk(e,n)):void(Tr(n)&&(Nk(e,n),e.undoManager.add()))},Ak=Yo,Ok=(e,t,n)=>{const o=$c(e.getBody()),r=O(Oc,1===t?o.next:o.prev);if(n.collapsed){const o=e.dom.getParent(n.startContainer,"PRE");if(!o)return;if(!r(xi.fromRangeStart(n))){const n=mn((e=>{const t=e.dom.create(gl(e));return t.innerHTML='<br data-mce-bogus="1">',t})(e));1===t?Jn(mn(o),n):Qn(mn(o),n),e.selection.select(n.dom,!0),e.selection.collapse()}}},Tk=(e,t)=>((e,t)=>{const n=t?Bc.Forwards:Bc.Backwards,o=e.selection.getRng();return((e,t,n)=>zx(t,e,n,$g,Vg,Ak))(n,e,o).orThunk((()=>(Ok(e,n,o),M.none())))})(e,t).exists((t=>(Fx(e,t),!0))),Bk=(e,t)=>((e,t)=>{const n=t?1:-1,o=e.selection.getRng();return((e,t,n)=>jx(t,e,n,(e=>$g(e)||jg(e)),(e=>Vg(e)||Hg(e)),Ak))(n,e,o).orThunk((()=>(Ok(e,n,o),M.none())))})(e,t).exists((t=>(Fx(e,t),!0))),Dk=(e,t)=>$x(e,t,t?Vg:$g),Pk=(e,t)=>Nw(e,!t).map((n=>{const o=n.toRange(),r=e.selection.getRng();return t?o.setStart(r.startContainer,r.startOffset):o.setEnd(r.endContainer,r.endOffset),o})).exists((t=>(Fx(e,t),!0))),Lk=e=>j(["figcaption"],Lt(e)),Mk=(e,t)=>{const n=mn(e.getBody()),o=xi.fromRangeStart(e.selection.getRng());return((e,t)=>{const n=O(bn,t);return ko(mn(e.container()),dr,n).filter(Lk)})(o,n).exists((()=>{if(((e,t,n)=>t?((e,t)=>Cx(e,t).breakAt.isNone())(e.dom,n):((e,t)=>yx(e,t).breakAt.isNone())(e.dom,n))(n,t,o)){const o=Sk(e,n,t?eo:Zn);return e.selection.setRng(o),!0}return!1}))},Ik=(e,t)=>!!e.selection.isCollapsed()&&Mk(e,t),Fk={shiftKey:!1,altKey:!1,ctrlKey:!1,metaKey:!1,keyCode:0},Uk=(e,t)=>t.keyCode===e.keyCode&&t.shiftKey===e.shiftKey&&t.altKey===e.altKey&&t.ctrlKey===e.ctrlKey&&t.metaKey===e.metaKey,zk=(e,...t)=>()=>e.apply(null,t),jk=(e,t)=>Q(((e,t)=>ee((e=>$(e,(e=>({...Fk,...e}))))(e),(e=>Uk(e,t)?[e]:[])))(e,t),(e=>e.action())),Hk=(e,t)=>ce(((e,t)=>ee((e=>$(e,(e=>({...Fk,...e}))))(e),(e=>Uk(e,t)?[e]:[])))(e,t),(e=>e.action())),$k=(e,t)=>{const n=t?Bc.Forwards:Bc.Backwards,o=e.selection.getRng();return zx(e,n,o,Ug,zg,Jo).exists((t=>(Fx(e,t),!0)))},Vk=(e,t)=>{const n=t?1:-1,o=e.selection.getRng();return jx(e,n,o,Ug,zg,Jo).exists((t=>(Fx(e,t),!0)))},qk=(e,t)=>$x(e,t,t?zg:Ug),Wk=Ki([{none:["current"]},{first:["current"]},{middle:["current","target"]},{last:["current"]}]),Kk={...Wk,none:e=>Wk.none(e)},Gk=(e,t,n)=>ee(An(e),(e=>pn(e,t)?n(e)?[e]:[]:Gk(e,t,n))),Yk=(e,t)=>Eo(e,"table",t),Xk=(e,t,n,o,r=L)=>{const s=1===o;if(!s&&n<=0)return Kk.first(e[0]);if(s&&n>=e.length-1)return Kk.last(e[e.length-1]);{const s=n+o,a=e[s];return r(a)?Kk.middle(t,a):Xk(e,t,s,o,r)}},Qk=(e,t)=>Yk(e,t).bind((t=>{const n=Gk(t,"th,td",L);return J(n,(t=>bn(e,t))).map((e=>({index:e,all:n})))})),Jk=(e,t=!1)=>{return Hn(e)?e.dom.isContentEditable:(n=e,Eo(n,"[contenteditable]")).fold(N(t),(e=>"true"===Zk(e)));var n},Zk=e=>e.dom.contentEditable,eS=(e,t,n,o,r)=>{const s=or(mn(n),"td,th,caption").map((e=>e.dom)),a=K(((e,t)=>ee(t,(t=>{const n=((e,t)=>({left:e.left-t,top:e.top-t,right:e.right+-2,bottom:e.bottom+-2,width:e.width+t,height:e.height+t}))(Ya(t.getBoundingClientRect()),-1);return[{x:n.left,y:e(n),cell:t},{x:n.right,y:e(n),cell:t}]})))(e,s),(e=>t(e,r)));return((e,t,n)=>Y(e,((e,o)=>e.fold((()=>M.some(o)),(e=>{const r=Math.sqrt(Math.abs(e.x-t)+Math.abs(e.y-n)),s=Math.sqrt(Math.abs(o.x-t)+Math.abs(o.y-n));return M.some(s<r?o:e)}))),M.none()))(a,o,r).map((e=>e.cell))},tS=O(eS,(e=>e.bottom),((e,t)=>e.y<t)),nS=O(eS,(e=>e.top),((e,t)=>e.y>t)),oS=(e,t,n)=>{const o=e(t,n);return(e=>e.breakType===ux.Wrap&&0===e.positions.length)(o)||!Wo(n.getNode())&&(e=>e.breakType===ux.Br&&1===e.positions.length)(o)?!((e,t,n)=>n.breakAt.exists((n=>e(t,n).breakAt.isSome())))(e,t,o):o.breakAt.isNone()},rS=O(oS,yx),sS=O(oS,Cx),aS=(e,t,n,o)=>{const r=e.selection.getRng(),s=t?1:-1;return!(!nc()||!((e,t,n)=>{const o=xi.fromRangeStart(t);return Xc(!e,n).exists((e=>e.isEqual(o)))})(t,r,n)||(Cw(s,e,n,!t,!1).each((t=>{Fx(e,t)})),0))},iS=(e,t,n)=>{const o=((e,t)=>{const n=t.getNode(e);return Io(n)?M.some(n):M.none()})(!!t,n),r=!1===t;o.fold((()=>Fx(e,n.toRange())),(o=>Xc(r,e.getBody()).filter((e=>e.isEqual(n))).fold((()=>Fx(e,n.toRange())),(n=>((e,t,n)=>{t.undoManager.transact((()=>{const o=e?Jn:Qn,r=Sk(t,mn(n),o);Fx(t,r)}))})(t,e,o)))))},lS=(e,t,n,o)=>{const r=e.selection.getRng(),s=xi.fromRangeStart(r),a=e.getBody();if(!t&&rS(o,s)){const o=((e,t,n)=>((e,t)=>ie(t.getClientRects()).bind((t=>tS(e,t.left,t.top))).bind((e=>{return vx(eu(n=e).map((e=>yx(n,e).positions.concat(e))).getOr([]),t);var n})))(t,n).orThunk((()=>ie(n.getClientRects()).bind((n=>bx(wx(e,xi.before(t)),n.left))))).getOr(xi.before(t)))(a,n,s);return iS(e,t,o),!0}if(t&&sS(o,s)){const o=((e,t,n)=>((e,t)=>le(t.getClientRects()).bind((t=>nS(e,t.left,t.top))).bind((e=>{return vx(Zc(n=e).map((e=>[e].concat(Cx(n,e).positions))).getOr([]),t);var n})))(t,n).orThunk((()=>ie(n.getClientRects()).bind((n=>bx(xx(e,xi.after(t)),n.left))))).getOr(xi.after(t)))(a,n,s);return iS(e,t,o),!0}return!1},dS=(e,t,n)=>M.from(e.dom.getParent(e.selection.getNode(),"td,th")).bind((o=>M.from(e.dom.getParent(o,"table")).map((r=>n(e,t,r,o))))).getOr(!1),cS=(e,t)=>dS(e,t,aS),uS=(e,t)=>dS(e,t,lS),mS=(e,t,n)=>n.fold(M.none,M.none,((e,t)=>{return(n=t,((e,t)=>{const n=e=>{for(let o=0;o<e.childNodes.length;o++){const r=mn(e.childNodes[o]);if(t(r))return M.some(r);const s=n(e.childNodes[o]);if(s.isSome())return s}return M.none()};return n(e.dom)})(n,ig)).map((e=>(e=>{const t=Gm.exact(e,0,e,0);return Zm(t)})(e)));var n}),(n=>(e.execCommand("mceTableInsertRowAfter"),fS(e,t,n)))),fS=(e,t,n)=>{return mS(e,t,(r=Jk,Qk(o=n,void 0).fold((()=>Kk.none(o)),(e=>Xk(e.all,o,e.index,1,r)))));var o,r},gS=(e,t,n)=>{return mS(e,t,(r=Jk,Qk(o=n,void 0).fold((()=>Kk.none()),(e=>Xk(e.all,o,e.index,-1,r)))));var o,r},pS=(e,t)=>{const n=["table","li","dl"],o=mn(e.getBody()),r=e=>{const t=Lt(e);return bn(e,o)||j(n,t)},s=e.selection.getRng();return((e,t)=>((e,t,n=P)=>n(t)?M.none():j(e,Lt(t))?M.some(t):So(t,e.join(","),(e=>pn(e,"table")||n(e))))(["td","th"],e,t))(mn(t?s.endContainer:s.startContainer),r).map((n=>(Yk(n,r).each((t=>{e.model.table.clearSelectedCells(t.dom)})),e.selection.collapse(!t),(t?fS:gS)(e,r,n).each((t=>{e.selection.setRng(t)})),!0))).getOr(!1)},hS=(e,t)=>({container:e,offset:t}),bS=ba.DOM,vS=e=>t=>e===t?-1:0,yS=(e,t,n)=>{if(zo(e)&&t>=0)return M.some(hS(e,t));{const o=Ka(bS);return M.from(o.backwards(e,t,vS(e),n)).map((e=>hS(e.container,e.container.data.length)))}},CS=(e,t,n)=>{if(!zo(e))return M.none();const o=e.data;if(t>=0&&t<=o.length)return M.some(hS(e,t));{const o=Ka(bS);return M.from(o.backwards(e,t,vS(e),n)).bind((e=>{const o=e.container.data;return CS(e.container,t+o.length,n)}))}},wS=(e,t,n)=>{if(!zo(e))return M.none();const o=e.data;if(t<=o.length)return M.some(hS(e,t));{const r=Ka(bS);return M.from(r.forwards(e,t,vS(e),n)).bind((e=>wS(e.container,t-o.length,n)))}},xS=(e,t,n,o,r)=>{const s=Ka(e,(e=>t=>e.isBlock(t)||j(["BR","IMG","HR","INPUT"],t.nodeName)||"false"===e.getContentEditable(t))(e));return M.from(s.backwards(t,n,o,r))},kS=e=>_r(e.toString().replace(/\u00A0/g," ")),SS=e=>""!==e&&-1!==" \xa0\f\n\r\t\v".indexOf(e),_S=(e,t)=>e.substring(t.length),ES=(e,t,n,o=0)=>{return(r=mn(t.startContainer),Eo(r,lg)).fold((()=>((e,t,n,o=0)=>{if(!(r=t).collapsed||!zo(r.startContainer))return M.none();var r;const s={text:"",offset:0},a=e.getParent(t.startContainer,e.isBlock)||e.getRoot();return xS(e,t.startContainer,t.startOffset,((e,t,o)=>(s.text=o+s.text,s.offset+=t,((e,t,n)=>{let o;const r=n.charAt(0);for(o=t-1;o>=0;o--){const s=e.charAt(o);if(SS(s))return M.none();if(r===s&&Ue(e,n,o,t))break}return M.some(o)})(s.text,s.offset,n).getOr(t))),a).bind((e=>{const r=t.cloneRange();if(r.setStart(e.container,e.offset),r.setEnd(t.endContainer,t.endOffset),r.collapsed)return M.none();const s=kS(r);return 0!==s.lastIndexOf(n)||_S(s,n).length<o?M.none():M.some({text:_S(s,n),range:r,trigger:n})}))})(e,t,n,o)),(t=>{const o=e.createRng();o.selectNode(t.dom);const r=kS(o);return M.some({range:o,text:_S(r,n),trigger:n})}));var r},NS=e=>{if((e=>3===e.nodeType)(e))return hS(e,e.data.length);{const t=e.childNodes;return t.length>0?NS(t[t.length-1]):hS(e,t.length)}},RS=(e,t)=>{const n=e.childNodes;return n.length>0&&t<n.length?RS(n[t],0):n.length>0&&(e=>1===e.nodeType)(e)&&n.length===t?NS(n[n.length-1]):hS(e,t)},AS=(e,t,n,o={})=>{var r;const s=t(),a=null!==(r=e.selection.getRng().startContainer.nodeValue)&&void 0!==r?r:"",i=K(s.lookupByTrigger(n.trigger),(t=>n.text.length>=t.minChars&&t.matches.getOrThunk((()=>(e=>t=>{const n=RS(t.startContainer,t.startOffset);return!((e,t)=>{var n;const o=null!==(n=e.getParent(t.container,e.isBlock))&&void 0!==n?n:e.getRoot();return xS(e,t.container,t.offset,((e,t)=>0===t?-1:t),o).filter((e=>{const t=e.container.data.charAt(e.offset-1);return!SS(t)})).isSome()})(e,n)})(e.dom)))(n.range,a,n.text)));if(0===i.length)return M.none();const l=Promise.all($(i,(e=>e.fetch(n.text,e.maxResults,o).then((t=>({matchText:n.text,items:t,columns:e.columns,onAction:e.onAction,highlightOn:e.highlightOn}))))));return M.some({lookupData:l,context:n})};var OS;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(OS||(OS={}));const TS=(e,t,n)=>e.stype===OS.Error?t(e.serror):n(e.svalue),BS=e=>({stype:OS.Value,svalue:e}),DS=e=>({stype:OS.Error,serror:e}),PS=TS,LS=e=>f(e)&&ue(e).length>100?" removed due to size":JSON.stringify(e,null,2),MS=(e,t)=>DS([{path:e,getErrorInfo:t}]),IS=(e,t)=>({extract:(n,o)=>we(o,e).fold((()=>((e,t)=>MS(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(n,e)),(e=>((e,t,n,o)=>we(n,o).fold((()=>((e,t,n)=>MS(e,(()=>'The chosen schema: "'+n+'" did not exist in branches: '+LS(t))))(e,n,o)),(n=>n.extract(e.concat(["branch: "+o]),t))))(n,o,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+ue(t)}),FS=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const n={};for(let o=0;o<t.length;o++){const r=t[o];for(const t in r)xe(r,t)&&(n[t]=e(n[t],r[t]))}return n},US=FS(((e,t)=>g(e)&&g(t)?US(e,t):t)),zS=(FS(((e,t)=>t)),e=>({tag:"defaultedThunk",process:N(e)})),jS=e=>{const t=(e=>{const t=[],n=[];return V(e,(e=>{TS(e,(e=>n.push(e)),(e=>t.push(e)))})),{values:t,errors:n}})(e);return t.errors.length>0?(n=t.errors,_(DS,Z)(n)):BS(t.values);var n},HS=(e,t,n)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return n(e.newKey,e.instantiator)}},$S=e=>({extract:(t,n)=>{return o=e(n),r=e=>((e,t)=>MS(e,N(t)))(t,e),o.stype===OS.Error?r(o.serror):o;var o,r},toString:N("val")}),VS=$S(BS),qS=(e,t,n,o)=>o(we(e,t).getOrThunk((()=>n(e)))),WS=(e,t,n,o,r)=>{const s=e=>r.extract(t.concat([o]),e),a=e=>e.fold((()=>BS(M.none())),(e=>{const n=r.extract(t.concat([o]),e);return s=n,a=M.some,s.stype===OS.Value?{stype:OS.Value,svalue:a(s.svalue)}:s;var s,a}));switch(e.tag){case"required":return((e,t,n,o)=>we(t,n).fold((()=>((e,t,n)=>MS(e,(()=>'Could not find valid *required* value for "'+t+'" in '+LS(n))))(e,n,t)),o))(t,n,o,s);case"defaultedThunk":return qS(n,o,e.process,s);case"option":return((e,t,n)=>n(we(e,t)))(n,o,a);case"defaultedOptionThunk":return((e,t,n,o)=>o(we(e,t).map((t=>!0===t?n(e):t))))(n,o,e.process,a);case"mergeWithThunk":return qS(n,o,N({}),(t=>{const o=US(e.process(n),t);return s(o)}))}},KS=e=>({extract:(t,n)=>((e,t,n)=>{const o={},r=[];for(const s of n)HS(s,((n,s,a,i)=>{const l=WS(a,e,t,n,i);PS(l,(e=>{r.push(...e)}),(e=>{o[s]=e}))}),((e,n)=>{o[e]=n(t)}));return r.length>0?DS(r):BS(o)})(t,n,e),toString:()=>{const t=$(e,(e=>HS(e,((e,t,n,o)=>e+" -> "+o.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),GS=e=>({extract:(t,n)=>{const o=$(n,((n,o)=>e.extract(t.concat(["["+o+"]"]),n)));return jS(o)},toString:()=>"array("+e.toString()+")"}),YS=(e,t,n)=>{return o=((e,t,n)=>((e,t)=>e.stype===OS.Error?{stype:OS.Error,serror:t(e.serror)}:e)(t.extract([e],n),(e=>({input:n,errors:e}))))(e,t,n),TS(o,Wi.error,Wi.value);var o},XS=(e,t)=>IS(e,ge(t,KS)),QS=N(VS),JS=(e,t)=>$S((n=>{const o=typeof n;return e(n)?BS(n):DS(`Expected type: ${t} but got: ${o}`)})),ZS=JS(x,"number"),e_=JS(m,"string"),t_=JS(b,"boolean"),n_=JS(w,"function"),o_=(e,t,n,o)=>({tag:"field",key:e,newKey:t,presence:n,prop:o}),r_=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),s_=(e,t)=>o_(e,e,{tag:"required",process:{}},t),a_=e=>s_(e,e_),i_=e=>s_(e,n_),l_=(e,t)=>o_(e,e,{tag:"option",process:{}},t),d_=e=>l_(e,e_),c_=(e,t,n)=>o_(e,e,zS(t),n),u_=(e,t)=>c_(e,t,ZS),m_=(e,t,n)=>c_(e,t,(e=>{return t=t=>j(e,t)?Wi.value(t):Wi.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`),$S((e=>t(e).fold(DS,BS)));var t})(n)),f_=(e,t)=>c_(e,t,t_),g_=(e,t)=>c_(e,t,n_),p_=a_("type"),h_=i_("fetch"),b_=i_("onAction"),v_=g_("onSetup",(()=>S)),y_=d_("text"),C_=d_("icon"),w_=d_("tooltip"),x_=d_("label"),k_=f_("active",!1),S_=f_("enabled",!0),__=f_("primary",!1),E_=e=>((e,t)=>c_("type",t,e_))(0,e),N_=KS([p_,a_("trigger"),u_("minChars",1),(1,((e,t)=>o_(e,e,zS(1),QS()))("columns")),u_("maxResults",10),("matches",l_("matches",n_)),h_,b_,(R_=e_,c_("highlightOn",[],GS(R_)))]);var R_;const A_=[S_,w_,C_,y_,v_],O_=[k_].concat(A_),T_=[g_("predicate",P),m_("scope","node",["node","editor"]),m_("position","selection",["node","selection","line"])],B_=A_.concat([E_("contextformbutton"),__,b_,r_("original",R)]),D_=O_.concat([E_("contextformbutton"),__,b_,r_("original",R)]),P_=A_.concat([E_("contextformbutton")]),L_=O_.concat([E_("contextformtogglebutton")]),M_=XS("type",{contextformbutton:B_,contextformtogglebutton:D_});KS([E_("contextform"),g_("initValue",N("")),x_,((e,t)=>o_(e,e,{tag:"required",process:{}},GS(t)))("commands",M_),l_("launch",XS("type",{contextformbutton:P_,contextformtogglebutton:L_}))].concat(T_));const I_=e=>{const t=e.ui.registry.getAll().popups,n=ge(t,(e=>{return(t=e,YS("Autocompleter",N_,{trigger:t.ch,...t})).fold((e=>{throw new Error("Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:N("... (only showing first ten failures)")}]):e;return $(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})((t=e).errors).join("\n")+"\n\nInput object: "+LS(t.input));var t}),R);var t})),o=Se(ye(n,(e=>e.trigger))),r=Ce(n);return{dataset:n,triggers:o,lookupByTrigger:e=>K(r,(t=>t.trigger===e))}},F_=e=>{const t=Na(),n=Ca(!1),o=t.isSet,r=()=>{o()&&((e=>{eC(e).autocompleter.removeDecoration()})(e),(e=>{e.dispatch("AutocompleterEnd")})(e),n.set(!1),t.clear())},s=De((()=>I_(e))),a=a=>{(n=>t.get().map((t=>ES(e.dom,e.selection.getRng(),t.trigger).bind((t=>AS(e,s,t,n))))).getOrThunk((()=>((e,t)=>{const n=t(),o=e.selection.getRng();return((e,t,n)=>ce(n.triggers,(n=>ES(e,t,n))))(e.dom,o,n).bind((n=>AS(e,t,n)))})(e,s))))(a).fold(r,(s=>{(n=>{o()||(((e,t)=>{eC(e).autocompleter.addDecoration(t)})(e,n.range),t.set({trigger:n.trigger,matchLength:n.text.length}))})(s.context),s.lookupData.then((o=>{t.get().map((a=>{const i=s.context;a.trigger===i.trigger&&(i.text.length-a.matchLength>=10?r():(t.set({...a,matchLength:i.text.length}),n.get()?((e,t)=>{e.dispatch("AutocompleterUpdate",t)})(e,{lookupData:o}):(n.set(!0),((e,t)=>{e.dispatch("AutocompleterStart",t)})(e,{lookupData:o}))))}))}))}))};e.addCommand("mceAutocompleterReload",((e,t)=>{const n=f(t)?t.fetchOptions:{};a(n)})),e.addCommand("mceAutocompleterClose",r),((e,t)=>{const n=Aa(t.load,50);e.on("keypress compositionend",(e=>{27!==e.which&&n.throttle()})),e.on("keydown",(e=>{const o=e.which;8===o?n.throttle():27===o&&t.cancelIfNecessary()})),e.on("remove",n.cancel)})(e,{cancelIfNecessary:r,load:a})},U_=e=>(t,n,o={})=>{const r=t.getBody(),s={bubbles:!0,composed:!0,data:null,isComposing:!1,detail:0,view:null,target:r,currentTarget:r,eventPhase:Event.AT_TARGET,originalTarget:r,explicitOriginalTarget:r,isTrusted:!1,srcElement:r,cancelable:!1,preventDefault:S,inputType:n},a=ea(new InputEvent(e));return t.dispatch(e,{...a,...s,...o})},z_=U_("input"),j_=U_("beforeinput"),H_=(e,t)=>{const n=e.dom,o=e.schema.getMoveCaretBeforeOnEnterElements();if(!t)return;if(/^(LI|DT|DD)$/.test(t.nodeName)){const e=(e=>{for(;e;){if(To(e)||zo(e)&&e.data&&/[\r\n\s]/.test(e.data))return e;e=e.nextSibling}return null})(t.firstChild);e&&/^(UL|OL|DL)$/.test(e.nodeName)&&t.insertBefore(n.doc.createTextNode(tr),t.firstChild)}const r=n.createRng();if(t.normalize(),t.hasChildNodes()){const e=new Ro(t,t);let n,s=t;for(;n=e.current();){if(zo(n)){r.setStart(n,0),r.setEnd(n,0);break}if(o[n.nodeName.toLowerCase()]){r.setStartBefore(n),r.setEndBefore(n);break}s=n,n=e.next()}n||(r.setStart(s,0),r.setEnd(s,0))}else Wo(t)?t.nextSibling&&n.isBlock(t.nextSibling)?(r.setStartBefore(t),r.setEndBefore(t)):(r.setStartAfter(t),r.setEndAfter(t)):(r.setStart(t,0),r.setEnd(t,0));e.selection.setRng(r),Bf(e,r)},$_=(e,t)=>{const n=e.getRoot();let o,r=t;for(;r!==n&&r&&"false"!==e.getContentEditable(r);)"true"===e.getContentEditable(r)&&(o=r),r=r.parentNode;return r!==n?o:n},V_=e=>M.from(e.dom.getParent(e.selection.getStart(!0),e.dom.isBlock)),q_=(e,t)=>{const n=null==e?void 0:e.parentNode;return C(n)&&n.nodeName===t},W_=e=>C(e)&&/^(OL|UL|LI)$/.test(e.nodeName),K_=e=>{const t=e.parentNode;return C(n=t)&&/^(LI|DT|DD)$/.test(n.nodeName)?t:e;var n},G_=(e,t,n)=>{let o=e[n?"firstChild":"lastChild"];for(;o&&!To(o);)o=o[n?"nextSibling":"previousSibling"];return o===t},Y_=(e,t)=>t&&"A"===t.nodeName&&e.isEmpty(t),X_=e=>{e.innerHTML='<br data-mce-bogus="1">'},Q_=(e,t)=>e.nodeName===t||e.previousSibling&&e.previousSibling.nodeName===t,J_=(e,t)=>C(t)&&e.isBlock(t)&&!/^(TD|TH|CAPTION|FORM)$/.test(t.nodeName)&&!/^(fixed|absolute)/i.test(t.style.position)&&"true"!==e.getContentEditable(t),Z_=(e,t,n)=>zo(t)?e?1===n&&t.data.charAt(n-1)===kr?0:n:n===t.data.length-1&&t.data.charAt(n)===kr?t.data.length:n:n,eE=(e,t)=>{gl(e).toLowerCase()===t.tagName.toLowerCase()&&((e,t,n)=>{const o=e.dom;M.from(n.style).map(o.parseStyle).each((e=>{const n={...Yn(mn(t)),...e};o.setStyles(t,n)}));const r=M.from(n.class).map((e=>e.split(/\s+/))),s=M.from(t.className).map((e=>K(e.split(/\s+/),(e=>""!==e))));Dt(r,s,((e,n)=>{const r=K(n,(t=>!j(e,t))),s=[...e,...r];o.setAttrib(t,"class",s.join(" "))}));const a=["style","class"],i=ve(n,((e,t)=>!j(a,t)));o.setAttribs(t,i)})(e,t,pl(e))},tE={insert:(e,t)=>{let n,o,r,s,a=!1;const i=e.dom,l=e.schema,d=l.getNonEmptyElements(),c=e.selection.getRng(),u=gl(e),f=t=>{let o=n;const s=l.getTextInlineElements();let a;a=t||"TABLE"===r||"HR"===r?i.create(t||u):w.cloneNode(!1);let d=a;if(!1===yl(e))i.setAttrib(a,"style",null),i.setAttrib(a,"class",null);else do{if(s[o.nodeName]){if(nu(o)||pu(o))continue;const e=o.cloneNode(!1);i.setAttrib(e,"id",""),a.hasChildNodes()?(e.appendChild(a.firstChild),a.appendChild(e)):(d=e,a.appendChild(e))}}while((o=o.parentNode)&&o!==v);return eE(e,a),X_(d),a},g=e=>{const t=Z_(e,n,o);if(zo(n)&&(e?t>0:t<n.data.length))return!1;if(n.parentNode===w&&a&&!e)return!0;if(e&&To(n)&&n===w.firstChild)return!0;if(Q_(n,"TABLE")||Q_(n,"HR"))return a&&!e||!a&&e;const r=new Ro(n,w);let s;for(zo(n)&&(e&&0===t?r.prev():e||t!==n.data.length||r.next());s=r.current();){if(To(s)){if(!s.getAttribute("data-mce-bogus")){const e=s.nodeName.toLowerCase();if(d[e]&&"br"!==e)return!1}}else if(zo(s)&&!Xr(s.data))return!1;e?r.prev():r.next()}return!0},p=()=>{let t;return t=/^(H[1-6]|PRE|FIGURE)$/.test(r)&&"HGROUP"!==x?f(u):f(),((e,t)=>{const n=Cl(e);return!y(t)&&(m(n)?j(Tt.explode(n),t.nodeName.toLowerCase()):n)})(e,s)&&J_(i,s)&&i.isEmpty(w)?t=i.split(s,w):i.insertAfter(t,w),H_(e,t),t};df(i,c).each((e=>{c.setStart(e.startContainer,e.startOffset),c.setEnd(e.endContainer,e.endOffset)})),n=c.startContainer,o=c.startOffset;const h=!(!t||!t.shiftKey),b=!(!t||!t.ctrlKey);To(n)&&n.hasChildNodes()&&(a=o>n.childNodes.length-1,n=n.childNodes[Math.min(o,n.childNodes.length-1)]||n,o=a&&zo(n)?n.data.length:0);const v=$_(i,n);if(!v||((e,t)=>{const n=e.dom.getParent(t,"ol,ul,dl");return null!==n&&"false"===e.dom.getContentEditableParent(n)})(e,n))return;h||(n=((e,t,n,o,r)=>{var s;const a=e.dom,i=null!==(s=$_(a,o))&&void 0!==s?s:a.getRoot();let l=a.getParent(o,a.isBlock);if(!l||!J_(a,l)){let s;if(l=l||i,s=l===e.getBody()||Qo(l)?l.nodeName.toLowerCase():l.parentNode?l.parentNode.nodeName.toLowerCase():"",!l.hasChildNodes()){const o=a.create(t);return eE(e,o),l.appendChild(o),n.setStart(o,0),n.setEnd(o,0),o}let d,c=o;for(;c&&c.parentNode!==l;)c=c.parentNode;for(;c&&!a.isBlock(c);)d=c,c=c.previousSibling;if(d&&e.schema.isValidChild(s,t.toLowerCase())){const s=d.parentNode,i=a.create(t);for(eE(e,i),s.insertBefore(i,d),c=d;c&&!a.isBlock(c);){const e=c.nextSibling;i.appendChild(c),c=e}n.setStart(o,r),n.setEnd(o,r)}}return o})(e,u,c,n,o));let w=i.getParent(n,i.isBlock)||i.getRoot();s=C(null==w?void 0:w.parentNode)?i.getParent(w.parentNode,i.isBlock):null,r=w?w.nodeName.toUpperCase():"";const x=s?s.nodeName.toUpperCase():"";if("LI"!==x||b||(w=s,s=s.parentNode,r=x),/^(LI|DT|DD)$/.test(r)&&To(s)&&i.isEmpty(w))return void((e,t,n,o,r)=>{const s=e.dom,a=e.selection.getRng(),i=n.parentNode;if(n===e.getBody()||!i)return;var l;W_(l=n)&&W_(l.parentNode)&&(r="LI");let d=t(r);if(G_(n,o,!0)&&G_(n,o,!1))if(q_(n,"LI")){const e=K_(n);s.insertAfter(d,e),(e=>{var t;return(null===(t=e.parentNode)||void 0===t?void 0:t.firstChild)===e})(n)?s.remove(e):s.remove(n)}else s.replace(d,n);else if(G_(n,o,!0))q_(n,"LI")?(s.insertAfter(d,K_(n)),d.appendChild(s.doc.createTextNode(" ")),d.appendChild(n)):i.insertBefore(d,n),s.remove(o);else if(G_(n,o,!1))s.insertAfter(d,K_(n)),s.remove(o);else{n=K_(n);const e=a.cloneRange();e.setStartAfter(o),e.setEndAfter(n);const t=e.extractContents();"LI"===r&&((e,t)=>e.firstChild&&"LI"===e.firstChild.nodeName)(t)?(d=t.firstChild,s.insertAfter(t,n)):(s.insertAfter(t,n),s.insertAfter(d,n)),s.remove(o)}H_(e,d)})(e,f,s,w,u);if(w===e.getBody())return;const k=w.parentNode;let S;if(Rr(w))S=Mr(w),i.isEmpty(w)&&X_(w),eE(e,S),H_(e,S);else if(g(!1))S=p();else if(g(!0)&&k)S=k.insertBefore(f(),w),H_(e,Q_(w,"HR")?S:w);else{const t=(e=>{const t=e.cloneRange();return t.setStart(e.startContainer,Z_(!0,e.startContainer,e.startOffset)),t.setEnd(e.endContainer,Z_(!1,e.endContainer,e.endOffset)),t})(c).cloneRange();t.setEndAfter(w);const n=t.extractContents();(e=>{V(Co(mn(e),Ut),(e=>{const t=e.dom;t.nodeValue=_r(t.data)}))})(n),(e=>{let t=e;do{zo(t)&&(t.data=t.data.replace(/^[\r\n]+/,"")),t=t.firstChild}while(t)})(n),S=n.firstChild,i.insertAfter(n,w),((e,t,n)=>{var o;const r=[];if(!n)return;let s=n;for(;s=s.firstChild;){if(e.isBlock(s))return;To(s)&&!t[s.nodeName.toLowerCase()]&&r.push(s)}let a=r.length;for(;a--;)s=r[a],(!s.hasChildNodes()||s.firstChild===s.lastChild&&""===(null===(o=s.firstChild)||void 0===o?void 0:o.nodeValue)||Y_(e,s))&&e.remove(s)})(i,d,S),((e,t)=>{t.normalize();const n=t.lastChild;(!n||To(n)&&/^(left|right)$/gi.test(e.getStyle(n,"float",!0)))&&e.add(t,"br")})(i,w),i.isEmpty(w)&&X_(w),S.normalize(),i.isEmpty(S)?(i.remove(S),p()):(eE(e,S),H_(e,S))}i.setAttrib(S,"id",""),e.dispatch("NewBlock",{newBlock:S})},fakeEventName:"insertParagraph"},nE=(e,t,n)=>{const o=e.dom.createRng();n?(o.setStartBefore(t),o.setEndBefore(t)):(o.setStartAfter(t),o.setEndAfter(t)),e.selection.setRng(o),Bf(e,o)},oE=(e,t)=>{const n=cn("br");Qn(mn(t),n),e.undoManager.add()},rE=(e,t)=>{sE(e.getBody(),t)||Jn(mn(t),cn("br"));const n=cn("br");Jn(mn(t),n),nE(e,n.dom,!1),e.undoManager.add()},sE=(e,t)=>{return n=xi.after(t),!!Wo(n.getNode())||Qc(e,xi.after(t)).map((e=>Wo(e.getNode()))).getOr(!1);var n},aE=e=>e&&"A"===e.nodeName&&"href"in e,iE=e=>e.fold(P,aE,aE,P),lE=(e,t)=>{t.fold(S,O(oE,e),O(rE,e),S)},dE={insert:(e,t)=>{const n=(e=>{const t=O(Pp,e),n=xi.fromRangeStart(e.selection.getRng());return nx(t,e.getBody(),n).filter(iE)})(e);n.isSome()?n.each(O(lE,e)):((e,t)=>{const n=e.selection,o=e.dom,r=n.getRng();let s,a=!1;df(o,r).each((e=>{r.setStart(e.startContainer,e.startOffset),r.setEnd(e.endContainer,e.endOffset)}));let i=r.startOffset,l=r.startContainer;if(To(l)&&l.hasChildNodes()){const e=i>l.childNodes.length-1;l=l.childNodes[Math.min(i,l.childNodes.length-1)]||l,i=e&&zo(l)?l.data.length:0}let d=o.getParent(l,o.isBlock);const c=d&&d.parentNode?o.getParent(d.parentNode,o.isBlock):null,u=c?c.nodeName.toUpperCase():"",m=!(!t||!t.ctrlKey);"LI"!==u||m||(d=c),zo(l)&&i>=l.data.length&&(((e,t,n)=>{const o=new Ro(t,n);let r;const s=e.getNonEmptyElements();for(;r=o.next();)if(s[r.nodeName.toLowerCase()]||zo(r)&&r.length>0)return!0;return!1})(e.schema,l,d||o.getRoot())||(s=o.create("br"),r.insertNode(s),r.setStartAfter(s),r.setEndAfter(s),a=!0)),s=o.create("br"),Si(o,r,s),nE(e,s,a),e.undoManager.add()})(e,t)},fakeEventName:"insertLineBreak"},cE=(e,t)=>V_(e).filter((e=>t.length>0&&pn(mn(e),t))).isSome(),uE=Ki([{br:[]},{block:[]},{none:[]}]),mE=(e,t)=>(e=>cE(e,vl(e)))(e),fE=e=>(t,n)=>(e=>V_(e).filter((e=>gr(mn(e)))).isSome())(t)===e,gE=(e,t)=>(n,o)=>{const r=(e=>V_(e).fold(N(""),(e=>e.nodeName.toUpperCase())))(n)===e.toUpperCase();return r===t},pE=e=>{const t=$_(e.dom,e.selection.getStart());return y(t)},hE=e=>gE("pre",e),bE=e=>(t,n)=>fl(t)===e,vE=(e,t)=>(e=>cE(e,bl(e)))(e),yE=(e,t)=>t,CE=e=>{const t=gl(e),n=$_(e.dom,e.selection.getStart());return C(n)&&e.schema.isValidChild(n.nodeName,t)},wE=(e,t)=>(n,o)=>Y(e,((e,t)=>e&&t(n,o)),!0)?M.some(t):M.none(),xE=(e,t,n)=>{t.selection.isCollapsed()||(e=>{e.execCommand("delete")})(t),C(n)&&j_(t,e.fakeEventName).isDefaultPrevented()||(e.insert(t,n),C(n)&&z_(t,e.fakeEventName))},kE=(e,t)=>{const n=()=>xE(dE,e,t),o=()=>xE(tE,e,t),r=((e,t)=>Ww([wE([mE],uE.none()),wE([hE(!0),pE],uE.none()),wE([gE("summary",!0)],uE.br()),wE([hE(!0),bE(!1),yE],uE.br()),wE([hE(!0),bE(!1)],uE.block()),wE([hE(!0),bE(!0),yE],uE.block()),wE([hE(!0),bE(!0)],uE.br()),wE([fE(!0),yE],uE.br()),wE([fE(!0)],uE.block()),wE([vE],uE.br()),wE([yE],uE.br()),wE([CE],uE.block())],[e,!(!t||!t.shiftKey)]).getOr(uE.none()))(e,t);switch(hl(e)){case"linebreak":r.fold(n,n,S);break;case"block":r.fold(o,o,S);break;case"invert":r.fold(o,n,S);break;default:r.fold(n,o,S)}},SE=Ct(),_E=e=>e.stopImmediatePropagation(),EE=e=>e.keyCode===Dm.PAGE_UP||e.keyCode===Dm.PAGE_DOWN,NE=(e,t,n)=>{n&&!e.get()?t.on("NodeChange",_E,!0):!n&&e.get()&&t.off("NodeChange",_E),e.set(n)},RE=(e,t)=>{const n=t.container(),o=t.offset();return zo(n)?(n.insertData(o,e),M.some(xi(n,o+e.length))):Ac(t).map((n=>{const o=un(e);return t.isAtEnd()?Jn(n,o):Qn(n,o),xi(o.dom,e.length)}))},AE=O(RE,tr),OE=O(RE," "),TE=(e,t)=>n=>((e,t)=>!up(t)&&(((e,t)=>((e,t)=>Jc(e.dom,t).isNone())(e,t)||((e,t)=>Qc(e.dom,t).isNone())(e,t)||Qg(e,t)||Jg(e,t)||rp(e,t)||op(e,t))(e,t)||dp(e,t)||cp(e,t)))(e,n)?AE(t):OE(t),BE=e=>{const t=xi.fromRangeStart(e.selection.getRng()),n=mn(e.getBody());if(e.selection.isCollapsed()){const o=O(Pp,e),r=xi.fromRangeStart(e.selection.getRng());return nx(o,e.getBody(),r).bind((e=>t=>t.fold((t=>Jc(e.dom,xi.before(t))),(e=>Zc(e)),(e=>eu(e)),(t=>Qc(e.dom,xi.after(t)))))(n)).map((o=>()=>TE(n,t)(o).each((e=>t=>(e.selection.setRng(t.toRange()),e.nodeChanged(),!0))(e))))}return M.none()},DE=e=>Hd(e)?[{keyCode:Dm.TAB,action:zk(pS,e,!0)},{keyCode:Dm.TAB,shiftKey:!0,action:zk(pS,e,!1)}]:[],PE=e=>{if(e.addShortcut("Meta+P","","mcePrint"),F_(e),Jy(e))return Ca(null);{const t=Xx(e);return(e=>{e.on("keyup compositionstart",O(Rk,e))})(e),((e,t)=>{e.on("keydown",(n=>{n.isDefaultPrevented()||((e,t,n)=>{const o=Nt.os.isMacOS()||Nt.os.isiOS();jk([{keyCode:Dm.RIGHT,action:zk(Tk,e,!0)},{keyCode:Dm.LEFT,action:zk(Tk,e,!1)},{keyCode:Dm.UP,action:zk(Bk,e,!1)},{keyCode:Dm.DOWN,action:zk(Bk,e,!0)},...o?[{keyCode:Dm.UP,action:zk(Pk,e,!1),metaKey:!0,shiftKey:!0},{keyCode:Dm.DOWN,action:zk(Pk,e,!0),metaKey:!0,shiftKey:!0}]:[],{keyCode:Dm.RIGHT,action:zk(cS,e,!0)},{keyCode:Dm.LEFT,action:zk(cS,e,!1)},{keyCode:Dm.UP,action:zk(uS,e,!1)},{keyCode:Dm.DOWN,action:zk(uS,e,!0)},{keyCode:Dm.RIGHT,action:zk($k,e,!0)},{keyCode:Dm.LEFT,action:zk($k,e,!1)},{keyCode:Dm.UP,action:zk(Vk,e,!1)},{keyCode:Dm.DOWN,action:zk(Vk,e,!0)},{keyCode:Dm.RIGHT,action:zk(Gx,e,t,!0)},{keyCode:Dm.LEFT,action:zk(Gx,e,t,!1)},{keyCode:Dm.RIGHT,ctrlKey:!o,altKey:o,action:zk(Qx,e,t)},{keyCode:Dm.LEFT,ctrlKey:!o,altKey:o,action:zk(Jx,e,t)},{keyCode:Dm.UP,action:zk(Ik,e,!1)},{keyCode:Dm.DOWN,action:zk(Ik,e,!0)}],n).each((e=>{n.preventDefault()}))})(e,t,n)}))})(e,t),((e,t)=>{e.on("keydown",(n=>{n.isDefaultPrevented()||((e,t,n)=>{const o=n.keyCode===Dm.BACKSPACE?"deleteContentBackward":"deleteContentForward";Hk([{keyCode:Dm.BACKSPACE,action:zk(pk,e)},{keyCode:Dm.BACKSPACE,action:zk(Pw,e,!1)},{keyCode:Dm.DELETE,action:zk(Pw,e,!0)},{keyCode:Dm.BACKSPACE,action:zk(Ew,e,!1)},{keyCode:Dm.DELETE,action:zk(Ew,e,!0)},{keyCode:Dm.BACKSPACE,action:zk(nk,e,t,!1)},{keyCode:Dm.DELETE,action:zk(nk,e,t,!0)},{keyCode:Dm.BACKSPACE,action:zk(hh,e,!1)},{keyCode:Dm.DELETE,action:zk(hh,e,!0)},{keyCode:Dm.BACKSPACE,action:zk(Lw,e,!1)},{keyCode:Dm.DELETE,action:zk(Lw,e,!0)},{keyCode:Dm.BACKSPACE,action:zk(ik,e,!1)},{keyCode:Dm.DELETE,action:zk(ik,e,!0)},{keyCode:Dm.BACKSPACE,action:zk(yw,e,!1)},{keyCode:Dm.DELETE,action:zk(yw,e,!0)},{keyCode:Dm.BACKSPACE,action:zk(hw,e,!1)},{keyCode:Dm.DELETE,action:zk(hw,e,!0)},{keyCode:Dm.BACKSPACE,action:zk(sk,e,!1)},{keyCode:Dm.DELETE,action:zk(sk,e,!0)}],n).each((t=>{n.preventDefault(),j_(e,o).isDefaultPrevented()||(t(),z_(e,o))}))})(e,t,n)})),e.on("keyup",(t=>{t.isDefaultPrevented()||((e,t)=>{jk([{keyCode:Dm.BACKSPACE,action:zk(Dw,e)},{keyCode:Dm.DELETE,action:zk(Dw,e)}],t)})(e,t)}))})(e,t),(e=>{e.on("keydown",(t=>{t.keyCode===Dm.ENTER&&((e,t)=>{var n;t.isDefaultPrevented()||(t.preventDefault(),(n=e.undoManager).typing&&(n.typing=!1,n.add()),e.undoManager.transact((()=>{kE(e,t)})))})(e,t)}))})(e),(e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{Hk([{keyCode:Dm.SPACEBAR,action:zk(BE,e)}],t).each((n=>{t.preventDefault(),j_(e,"insertText",{data:" "}).isDefaultPrevented()||(n(),z_(e,"insertText",{data:" "}))}))})(e,t)}))})(e),(e=>{e.on("input",(t=>{t.isComposing||(e=>{const t=mn(e.getBody());e.selection.isCollapsed()&&Cp(t,xi.fromRangeStart(e.selection.getRng())).each((t=>{e.selection.setRng(t.toRange())}))})(e)}))})(e),(e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{jk([...DE(e)],t).each((e=>{t.preventDefault()}))})(e,t)}))})(e),((e,t)=>{e.on("keydown",(n=>{n.isDefaultPrevented()||((e,t,n)=>{const o=Nt.os.isMacOS()||Nt.os.isiOS();jk([{keyCode:Dm.END,action:zk(Dk,e,!0)},{keyCode:Dm.HOME,action:zk(Dk,e,!1)},...o?[]:[{keyCode:Dm.HOME,action:zk(Pk,e,!1),ctrlKey:!0,shiftKey:!0},{keyCode:Dm.END,action:zk(Pk,e,!0),ctrlKey:!0,shiftKey:!0}],{keyCode:Dm.END,action:zk(qk,e,!0)},{keyCode:Dm.HOME,action:zk(qk,e,!1)},{keyCode:Dm.END,action:zk(Zx,e,!0,t)},{keyCode:Dm.HOME,action:zk(Zx,e,!1,t)}],n).each((e=>{n.preventDefault()}))})(e,t,n)}))})(e,t),((e,t)=>{if(SE.os.isMacOS())return;const n=Ca(!1);e.on("keydown",(t=>{EE(t)&&NE(n,e,!0)})),e.on("keyup",(o=>{o.isDefaultPrevented()||((e,t,n)=>{jk([{keyCode:Dm.PAGE_UP,action:zk(Zx,e,!1,t)},{keyCode:Dm.PAGE_DOWN,action:zk(Zx,e,!0,t)}],n)})(e,t,o),EE(o)&&n.get()&&(NE(n,e,!1),e.nodeChanged())}))})(e,t),t}};class LE{constructor(e){let t;this.lastPath=[],this.editor=e;const n=this;"onselectionchange"in e.getDoc()||e.on("NodeChange click mouseup keyup focus",(n=>{const o=e.selection.getRng(),r={startContainer:o.startContainer,startOffset:o.startOffset,endContainer:o.endContainer,endOffset:o.endOffset};"nodechange"!==n.type&&tf(r,t)||e.dispatch("SelectionChange"),t=r})),e.on("contextmenu",(()=>{e.dispatch("SelectionChange")})),e.on("SelectionChange",(()=>{const t=e.selection.getStart(!0);t&&Pu(e)&&!n.isSameElementPath(t)&&e.dom.isChildOf(t,e.getBody())&&e.nodeChanged({selectionChange:!0})})),e.on("mouseup",(t=>{!t.isDefaultPrevented()&&Pu(e)&&("IMG"===e.selection.getNode().nodeName?qf.setEditorTimeout(e,(()=>{e.nodeChanged()})):e.nodeChanged())}))}nodeChanged(e={}){const t=this.editor.selection;let n;if(this.editor.initialized&&t&&!ld(this.editor)&&!this.editor.mode.isReadOnly()){const o=this.editor.getBody();n=t.getStart(!0)||o,n.ownerDocument===this.editor.getDoc()&&this.editor.dom.isChildOf(n,o)||(n=o);const r=[];this.editor.dom.getParent(n,(e=>e===o||(r.push(e),!1))),this.editor.dispatch("NodeChange",{...e,element:n,parents:r})}}isSameElementPath(e){let t;const n=this.editor,o=ne(n.dom.getParents(e,L,n.getBody()));if(o.length===this.lastPath.length){for(t=o.length;t>=0&&o[t]===this.lastPath[t];t--);if(-1===t)return this.lastPath=o,!0}return this.lastPath=o,!1}}const ME=N("x-tinymce/html"),IE="\x3c!-- x-tinymce/html --\x3e",FE=e=>IE+e,UE=e=>-1!==e.indexOf(IE),zE="%MCEPASTEBIN%",jE=e=>e.dom.get("mcepastebin"),HE=e=>C(e)&&"mcepastebin"===e.id,$E=e=>e===zE,VE=(e,t)=>(Tt.each(t,(t=>{e=u(t,RegExp)?e.replace(t,""):e.replace(t[0],t[1])})),e),qE=e=>VE(e,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,(e,t,n)=>t||n?tr:" "],/<br class="Apple-interchange-newline">/g,/<br>$/i]),WE=(e,t)=>({content:e,cancelled:t}),KE=(e,t)=>(e.insertContent(t,{merge:Od(e),paste:!0}),!0),GE=e=>/^https?:\/\/[\w\-\/+=.,!;:&%@^~(){}?#]+$/i.test(e),YE=(e,t,n)=>!(e.selection.isCollapsed()||!GE(t))&&((e,t,n)=>(e.undoManager.extra((()=>{n(e,t)}),(()=>{e.execCommand("mceInsertLink",!1,t)})),!0))(e,t,n),XE=(e,t,n)=>!!((e,t)=>GE(t)&&H(jd(e),(e=>je(t.toLowerCase(),`.${e.toLowerCase()}`))))(e,t)&&((e,t,n)=>(e.undoManager.extra((()=>{n(e,t)}),(()=>{e.insertContent('<img src="'+t+'">')})),!0))(e,t,n),QE=(e=>{let t=0;return()=>"mceclip"+t++})(),JE=(e,t,n,o)=>{const r=((e,t,n)=>((e,t,n)=>{const o=((e,t,n)=>e.dispatch("PastePreProcess",{content:t,internal:n}))(e,t,n),r=((e,t)=>{const n=yy({},e.schema);n.addNodeFilter("meta",(e=>{Tt.each(e,(e=>{e.remove()}))}));const o=n.parse(t,{forced_root_block:!1,isRootContent:!0});return _g({validate:!0},e.schema).serialize(o)})(e,o.content);return e.hasEventListeners("PastePostProcess")&&!o.isDefaultPrevented()?((e,t,n)=>{const o=e.dom.create("div",{style:"display:none"},t),r=((e,t,n)=>e.dispatch("PastePostProcess",{node:t,internal:n}))(e,o,n);return WE(r.node.innerHTML,r.isDefaultPrevented())})(e,r,n):WE(r,o.isDefaultPrevented())})(e,t,n))(e,t,n);r.cancelled||((e,t,n)=>{n||!Td(e)?KE(e,t):((e,t)=>{Tt.each([YE,XE,KE],(n=>!n(e,t,KE)))})(e,t)})(e,r.content,o)},ZE=(e,t,n)=>{const o=n||UE(t);JE(e,(e=>e.replace(IE,""))(t),o,!1)},eN=(e,t)=>{const n=e.dom.encode(t).replace(/\r\n/g,"\n"),o=((e,t,n)=>{const o=e.split(/\n\n/),r=((e,t)=>{let n="<"+e;const o=ye(t,((e,t)=>t+'="'+Fs.encodeAllRaw(e)+'"'));return o.length&&(n+=" "+o.join(" ")),n+">"})(t,n),s="</"+t+">",a=$(o,(e=>e.split(/\n/).join("<br />")));return 1===a.length?a[0]:$(a,(e=>r+e+s)).join("")})(Jr(n,Dd(e)),gl(e),pl(e));JE(e,o,!1,!0)},tN=e=>{const t={};if(e&&e.types)for(let n=0;n<e.types.length;n++){const o=e.types[n];try{t[o]=e.getData(o)}catch(e){t[o]=""}}return t},nN=(e,t)=>t in e&&e[t].length>0,oN=e=>nN(e,"text/html")||nN(e,"text/plain"),rN=(e,t,n)=>{const o="paste"===t.type?t.clipboardData:t.dataTransfer;var r;if(_d(e)&&o){const s=((e,t)=>{const n=t.items?ee(de(t.items),(e=>"file"===e.kind?[e.getAsFile()]:[])):[],o=t.files?de(t.files):[];return K(n.length>0?n:o,(e=>{const t=jd(e);return e=>ze(e.type,"image/")&&H(t,(t=>(e=>{const t=e.toLowerCase(),n={jpg:"jpeg",jpe:"jpeg",jfi:"jpeg",jif:"jpeg",jfif:"jpeg",pjpeg:"jpeg",pjp:"jpeg",svg:"svg+xml"};return Tt.hasOwn(n,t)?"image/"+n[t]:"image/"+t})(t)===e.type))})(e))})(e,o);if(s.length>0)return t.preventDefault(),(r=s,Promise.all($(r,(e=>ey(e).then((t=>({file:e,uri:t}))))))).then((t=>{n&&e.selection.setRng(n),V(t,(t=>{((e,t)=>{Jv(t.uri).each((({data:n,type:o,base64Encoded:r})=>{const s=r?n:btoa(n),a=t.file,i=e.editorUpload.blobCache,l=i.getByData(s,o),d=null!=l?l:((e,t,n,o)=>{const r=QE(),s=xl(e)&&C(n.name),a=s?((e,t)=>{const n=t.match(/([\s\S]+?)(?:\.[a-z0-9.]+)$/i);return C(n)?e.dom.encode(n[1]):void 0})(e,n.name):r,i=s?n.name:void 0,l=t.create(r,n,o,a,i);return t.add(l),l})(e,i,a,s);ZE(e,`<img src="${d.blobUri()}">`,!1)}))})(e,t)}))})),!0}return!1},sN=(e,t,n,o)=>{let r=qE(n);const s=nN(t,ME())||UE(n),a=!s&&(e=>!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(e))(r),i=GE(r);($E(r)||!r.length||a&&!i)&&(o=!0),(o||i)&&(r=nN(t,"text/plain")&&a?t["text/plain"]:(e=>{const t=Qs(),n=yy({},t);let o="";const r=t.getVoidElements(),s=Tt.makeMap("script noscript style textarea video audio iframe object"," "),a=t.getBlockElements(),i=e=>{const n=e.name,l=e;if("br"!==n){if("wbr"!==n)if(r[n]&&(o+=" "),s[n])o+=" ";else{if(3===e.type&&(o+=e.value),!(e.name in t.getVoidElements())){let t=e.firstChild;if(t)do{i(t)}while(t=t.next)}a[n]&&l.next&&(o+="\n","p"===n&&(o+="\n"))}}else o+="\n"};return e=VE(e,[/<!\[[^\]]+\]>/g]),i(n.parse(e)),o})(r)),$E(r)||(o?eN(e,r):ZE(e,r,s))},aN=(e,t,n)=>{((e,t,n)=>{let o;e.on("keydown",(e=>{(e=>Dm.metaKeyPressed(e)&&86===e.keyCode||e.shiftKey&&45===e.keyCode)(e)&&!e.isDefaultPrevented()&&(o=e.shiftKey&&86===e.keyCode)})),e.on("paste",(r=>{if(r.isDefaultPrevented()||(e=>{var t,n;return Nt.os.isAndroid()&&0===(null===(n=null===(t=e.clipboardData)||void 0===t?void 0:t.items)||void 0===n?void 0:n.length)})(r))return;const s="text"===n.get()||o;o=!1;const a=tN(r.clipboardData);!oN(a)&&rN(e,r,t.getLastRng()||e.selection.getRng())||(nN(a,"text/html")?(r.preventDefault(),sN(e,a,a["text/html"],s)):(t.create(),qf.setEditorTimeout(e,(()=>{const n=t.getHtml();t.remove(),sN(e,a,n,s)}),0)))}))})(e,t,n),(e=>{const t=e=>ze(e,"webkit-fake-url"),n=e=>ze(e,"data:");e.parser.addNodeFilter("img",((o,r,s)=>{if(!_d(e)&&(e=>{var t;return!0===(null===(t=e.data)||void 0===t?void 0:t.paste)})(s))for(const r of o){const o=r.attr("src");m(o)&&!r.attr("data-mce-object")&&o!==Nt.transparentSrc&&(t(o)||!Pd(e)&&n(o))&&r.remove()}}))})(e)},iN=(e,t,n,o)=>{((e,t,n)=>{if(!e)return!1;try{return e.clearData(),e.setData("text/html",t),e.setData("text/plain",n),e.setData(ME(),t),!0}catch(e){return!1}})(e.clipboardData,t.html,t.text)?(e.preventDefault(),o()):n(t.html,o)},lN=e=>(t,n)=>{const{dom:o,selection:r}=e,s=o.create("div",{contenteditable:"false","data-mce-bogus":"all"}),a=o.create("div",{contenteditable:"true"},t);o.setStyles(s,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),s.appendChild(a),o.add(e.getBody(),s);const i=r.getRng();a.focus();const l=o.createRng();l.selectNodeContents(a),r.setRng(l),qf.setEditorTimeout(e,(()=>{r.setRng(i),o.remove(s),n()}),0)},dN=e=>({html:FE(e.selection.getContent({contextual:!0})),text:e.selection.getContent({format:"text"})}),cN=e=>!e.selection.isCollapsed()||(e=>!!e.dom.getParent(e.selection.getStart(),"td[data-mce-selected],th[data-mce-selected]",e.getBody()))(e),uN=(e,t)=>{var n,o;return mf.getCaretRangeFromPoint(null!==(n=t.clientX)&&void 0!==n?n:0,null!==(o=t.clientY)&&void 0!==o?o:0,e.getDoc())},mN=(e,t)=>{e.focus(),t&&e.selection.setRng(t)},fN=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,gN=e=>Tt.trim(e).replace(fN,_u).toLowerCase(),pN=(e,t,n)=>{const o=Rd(e);if(n||"all"===o||!Ad(e))return t;const r=o?o.split(/[, ]/):[];if(r&&"none"!==o){const n=e.dom,o=e.selection.getNode();t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,((e,t,s,a)=>{const i=n.parseStyle(n.decode(s)),l={};for(let e=0;e<r.length;e++){const t=i[r[e]];let s=t,a=n.getStyle(o,r[e],!0);/color/.test(r[e])&&(s=gN(s),a=gN(a)),a!==s&&(l[r[e]]=t)}const d=n.serializeStyle(l,"span");return d?t+' style="'+d+'"'+a:t+a}))}else t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return t=t.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,((e,t,n,o)=>t+' style="'+n+'"'+o)),t},hN=e=>{const t=Ca(!1),n=Ca(Bd(e)?"text":"html"),o=(e=>{const t=Ca(null);return{create:()=>((e,t)=>{const{dom:n,selection:o}=e,r=e.getBody();t.set(o.getRng());const s=n.add(e.getBody(),"div",{id:"mcepastebin",class:"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},zE);Nt.browser.isFirefox()&&n.setStyle(s,"left","rtl"===n.getStyle(r,"direction",!0)?65535:-65535),n.bind(s,"beforedeactivate focusin focusout",(e=>{e.stopPropagation()})),s.focus(),o.select(s,!0)})(e,t),remove:()=>((e,t)=>{const n=e.dom;if(jE(e)){let o;const r=t.get();for(;o=jE(e);)n.remove(o),n.unbind(o);r&&e.selection.setRng(r)}t.set(null)})(e,t),getEl:()=>jE(e),getHtml:()=>(e=>{const t=e.dom,n=(e,n)=>{e.appendChild(n),t.remove(n,!0)},[o,...r]=K(e.getBody().childNodes,HE);V(r,(e=>{n(o,e)}));const s=t.select("div[id=mcepastebin]",o);for(let e=s.length-1;e>=0;e--){const r=t.create("div");o.insertBefore(r,s[e]),n(r,s[e])}return o?o.innerHTML:""})(e),getLastRng:t.get}})(e);(e=>{(Nt.browser.isChromium()||Nt.browser.isSafari())&&((e,t)=>{e.on("PastePreProcess",(n=>{n.content=t(e,n.content,n.internal)}))})(e,pN)})(e),((e,t)=>{e.addCommand("mceTogglePlainTextPaste",(()=>{((e,t)=>{"text"===t.get()?(t.set("html"),Bm(e,!1)):(t.set("text"),Bm(e,!0)),e.focus()})(e,t)})),e.addCommand("mceInsertClipboardContent",((t,n)=>{n.html&&ZE(e,n.html,n.internal),n.text&&eN(e,n.text)}))})(e,n),(e=>{const t=t=>n=>{t(e,n)},n=Ed(e);w(n)&&e.on("PastePreProcess",t(n));const o=Nd(e);w(o)&&e.on("PastePostProcess",t(o))})(e),e.on("PreInit",(()=>{(e=>{e.on("cut",(e=>t=>{!t.isDefaultPrevented()&&cN(e)&&iN(t,dN(e),lN(e),(()=>{if(Nt.browser.isChromium()||Nt.browser.isFirefox()){const t=e.selection.getRng();qf.setEditorTimeout(e,(()=>{e.selection.setRng(t),e.execCommand("Delete")}),0)}else e.execCommand("Delete")}))})(e)),e.on("copy",(e=>t=>{!t.isDefaultPrevented()&&cN(e)&&iN(t,dN(e),lN(e),S)})(e))})(e),((e,t)=>{Sd(e)&&e.on("dragend dragover draggesture dragdrop drop drag",(e=>{e.preventDefault(),e.stopPropagation()})),_d(e)||e.on("drop",(e=>{const t=e.dataTransfer;t&&(e=>H(e.files,(e=>/^image\//.test(e.type))))(t)&&e.preventDefault()})),e.on("drop",(n=>{if(n.isDefaultPrevented()||t.get())return;const o=uN(e,n);if(y(o))return;const r=tN(n.dataTransfer),s=nN(r,ME());if((!oN(r)||(e=>{const t=e["text/plain"];return!!t&&0===t.indexOf("file://")})(r))&&rN(e,n,o))return;const a=r[ME()],i=a||r["text/html"]||r["text/plain"];i&&(n.preventDefault(),qf.setEditorTimeout(e,(()=>{e.undoManager.transact((()=>{a&&e.execCommand("Delete"),mN(e,o);const t=qE(i);r["text/html"]?ZE(e,t,s):eN(e,t)}))})))})),e.on("dragstart",(e=>{t.set(!0)})),e.on("dragover dragend",(n=>{_d(e)&&!t.get()&&(n.preventDefault(),mN(e,uN(e,n))),"dragend"===n.type&&t.set(!1)}))})(e,t),aN(e,o,n)}))},bN=Wo,vN=zo,yN=e=>Yo(e.dom),CN=e=>t=>bn(mn(e),t),wN=(e,t)=>ko(mn(e),yN,CN(t)),xN=(e,t,n)=>{const o=new Ro(e,t),r=n?o.next.bind(o):o.prev.bind(o);let s=e;for(let t=n?e:r();t&&!bN(t);t=r())Wr(t)&&(s=t);return s},kN=e=>{const t=((e,t)=>{const n=xi.fromRangeStart(e).getNode(),o=((e,t)=>ko(mn(e),(e=>(e=>Go(e.dom))(e)||dr(e)),CN(t)).getOr(mn(t)).dom)(n,t),r=xN(n,o,!1),s=xN(n,o,!0),a=document.createRange();return wN(r,o).fold((()=>{vN(r)?a.setStart(r,0):a.setStartBefore(r)}),(e=>a.setStartBefore(e.dom))),wN(s,o).fold((()=>{vN(s)?a.setEnd(s,s.data.length):a.setEndAfter(s)}),(e=>a.setEndAfter(e.dom))),a})(e.selection.getRng(),e.getBody());e.selection.setRng(Oh(t))};var SN;!function(e){e.Before="before",e.After="after"}(SN||(SN={}));const _N=(e,t)=>Math.abs(e.left-t),EN=(e,t)=>Math.abs(e.right-t),NN=(e,t)=>(e=>Y(e,((e,t)=>e.fold((()=>M.some(t)),(e=>{const n=Math.min(t.left,e.left),o=Math.min(t.top,e.top),r=Math.max(t.right,e.right),s=Math.max(t.bottom,e.bottom);return M.some({top:o,right:r,bottom:s,left:n,width:r-n,height:s-o})}))),M.none()))(K(e,(e=>{return(n=t)>=(o=e).top&&n<=o.bottom;var n,o}))).fold((()=>[[],e]),(t=>{const{pass:n,fail:o}=W(e,(e=>((e,t)=>{const n=((e,t)=>Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)))(e,t)/Math.min(e.height,t.height);return((e,t)=>e.top<t.bottom&&e.bottom>t.top)(e,t)&&n>.5})(e,t)));return[n,o]})),RN=(e,t,n)=>t>e.left&&t<e.right?0:Math.min(Math.abs(e.left-t),Math.abs(e.right-t)),AN=(e,t,n)=>{const o=e=>Wr(e.node)?M.some(e):To(e.node)?AN(de(e.node.childNodes),t,n):M.none(),r=(e,r)=>{const s=se(e,((e,o)=>r(e,t,n)-r(o,t,n)));return((e,r)=>{if(e.length>=2){const s=o(e[0]).getOr(e[0]),a=o(e[1]).getOr(e[1]);if(Math.abs(r(s,t,n)-r(a,t,n))<2){if(zo(s.node))return M.some(s);if(zo(a.node))return M.some(a)}}return M.none()})(s,r).orThunk((()=>ce(s,o)))},[s,a]=NN(Ox(e),n),{pass:i,fail:l}=W(a,(e=>e.top<n));return r(s,RN).orThunk((()=>r(l,ei))).orThunk((()=>r(i,ei)))},ON=(e,t,n)=>((e,t,n)=>{const o=mn(e),r=Cn(o),s=fn(r,t,n).filter((e=>vn(o,e))).getOr(o);return((e,t,n,o)=>{const r=(t,s)=>{const a=K(t.dom.childNodes,T((e=>To(e)&&e.classList.contains("mce-drag-container"))));return s.fold((()=>AN(a,n,o)),(e=>{const t=K(a,(t=>t!==e.dom));return AN(t,n,o)})).orThunk((()=>(bn(t,e)?M.none():kn(t)).bind((e=>r(e,M.some(t))))))};return r(t,M.none())})(o,s,t,n)})(e,t,n).filter((e=>rc(e.node))).map((e=>((e,t)=>({node:e.node,position:_N(e,t)<EN(e,t)?SN.Before:SN.After}))(e,t))),TN=e=>{var t,n;const o=e.getBoundingClientRect(),r=e.ownerDocument,s=r.documentElement,a=r.defaultView;return{top:o.top+(null!==(t=null==a?void 0:a.scrollY)&&void 0!==t?t:0)-s.clientTop,left:o.left+(null!==(n=null==a?void 0:a.scrollX)&&void 0!==n?n:0)-s.clientLeft}},BN=Yo,DN=((...e)=>t=>{for(let n=0;n<e.length;n++)if(e[n](t))return!0;return!1})(BN,Go),PN=(e,t,n,o)=>{const r=e.dom,s=t.cloneNode(!0);r.setStyles(s,{width:n,height:o}),r.setAttrib(s,"data-mce-selected",null);const a=r.create("div",{class:"mce-drag-container","data-mce-bogus":"all",unselectable:"on",contenteditable:"false"});return r.setStyles(a,{position:"absolute",opacity:.5,overflow:"hidden",border:0,padding:0,margin:0,width:n,height:o}),r.setStyles(s,{margin:0,boxSizing:"border-box"}),a.appendChild(s),a},LN=(e,t)=>n=>()=>{const o="left"===e?n.scrollX:n.scrollY;n.scroll({[e]:o+t,behavior:"smooth"})},MN=LN("left",-32),IN=LN("left",32),FN=LN("top",-32),UN=LN("top",32),zN=e=>{e&&e.parentNode&&e.parentNode.removeChild(e)},jN=(e,t)=>{const n=Ra(((e,n)=>{t._selectionOverrides.hideFakeCaret(),ON(t.getBody(),e,n).fold((()=>t.selection.placeCaretAt(e,n)),(o=>{const r=t._selectionOverrides.showCaret(1,o.node,o.position===SN.Before,!1);r?t.selection.setRng(r):t.selection.placeCaretAt(e,n)}))}),0);t.on("remove",n.cancel);const o=e;return r=>e.on((e=>{const s=Math.max(Math.abs(r.screenX-e.screenX),Math.abs(r.screenY-e.screenY));if(!e.dragging&&s>10){if(t.dispatch("dragstart",{target:e.element}).isDefaultPrevented())return;e.dragging=!0,t.focus()}if(e.dragging){const s=r.currentTarget===t.getDoc().documentElement,l=((e,t)=>({pageX:t.pageX-e.relX,pageY:t.pageY+5}))(e,((e,t)=>{return n=(e=>e.inline?TN(e.getBody()):{left:0,top:0})(e),o=(e=>{const t=e.getBody();return e.inline?{left:t.scrollLeft,top:t.scrollTop}:{left:0,top:0}})(e),r=((e,t)=>{if(t.target.ownerDocument!==e.getDoc()){const n=TN(e.getContentAreaContainer()),o=(e=>{const t=e.getBody(),n=e.getDoc().documentElement,o={left:t.scrollLeft,top:t.scrollTop},r={left:t.scrollLeft||n.scrollLeft,top:t.scrollTop||n.scrollTop};return e.inline?o:r})(e);return{left:t.pageX-n.left+o.left,top:t.pageY-n.top+o.top}}return{left:t.pageX,top:t.pageY}})(e,t),{pageX:r.left-n.left+o.left,pageY:r.top-n.top+o.top};var n,o,r})(t,r));a=e.ghost,i=t.getBody(),a.parentNode!==i&&i.appendChild(a),((e,t,n,o,r,s,a,i,l,d,c,u)=>{let m=0,f=0;e.style.left=t.pageX+"px",e.style.top=t.pageY+"px",t.pageX+n>r&&(m=t.pageX+n-r),t.pageY+o>s&&(f=t.pageY+o-s),e.style.width=n-m+"px",e.style.height=o-f+"px";const g=l.clientHeight,p=l.clientWidth,h=a+l.getBoundingClientRect().top,b=i+l.getBoundingClientRect().left;c.on((e=>{e.intervalId.clear(),e.dragging&&u&&(a+8>=g?e.intervalId.set(UN(d)):a-8<=0?e.intervalId.set(FN(d)):i+8>=p?e.intervalId.set(IN(d)):i-8<=0?e.intervalId.set(MN(d)):h+16>=window.innerHeight?e.intervalId.set(UN(window)):h-16<=0?e.intervalId.set(FN(window)):b+16>=window.innerWidth?e.intervalId.set(IN(window)):b-16<=0&&e.intervalId.set(MN(window)))}))})(e.ghost,l,e.width,e.height,e.maxX,e.maxY,r.clientY,r.clientX,t.getContentAreaContainer(),t.getWin(),o,s),n.throttle(r.clientX,r.clientY)}var a,i}))},HN=e=>{e.on((e=>{e.intervalId.clear(),zN(e.ghost)})),e.clear()},$N=e=>{const t=Na(),n=ba.DOM,o=document,r=((e,t)=>n=>{if((e=>0===e.button)(n)){const s=Q(t.dom.getParents(n.target),DN).getOr(null);if(C(s)&&(o=t.getBody(),BN(r=s)&&r!==o)){const o=t.dom.getPos(s),r=t.getBody(),a=t.getDoc().documentElement;e.set({element:s,dragging:!1,screenX:n.screenX,screenY:n.screenY,maxX:(t.inline?r.scrollWidth:a.offsetWidth)-2,maxY:(t.inline?r.scrollHeight:a.offsetHeight)-2,relX:n.pageX-o.x,relY:n.pageY-o.y,width:s.offsetWidth,height:s.offsetHeight,ghost:PN(t,s,s.offsetWidth,s.offsetHeight),intervalId:Ea(100)})}}var o,r})(t,e),s=jN(t,e),a=((e,t)=>n=>{e.on((e=>{if(e.intervalId.clear(),e.dragging){if(((e,t,n)=>!y(t)&&t!==n&&!e.dom.isChildOf(t,n)&&!BN(t))(t,(e=>{const t=e.getSel();if(C(t)){const e=t.getRangeAt(0).startContainer;return zo(e)?e.parentNode:e}return null})(t.selection),e.element)){const o=(e=>{const t=e.cloneNode(!0);return t.removeAttribute("data-mce-selected"),t})(e.element);t.dispatch("drop",{clientX:n.clientX,clientY:n.clientY}).isDefaultPrevented()||t.undoManager.transact((()=>{zN(e.element),t.insertContent(t.dom.getOuterHTML(o)),t._selectionOverrides.hideFakeCaret()}))}t.dispatch("dragend")}})),HN(e)})(t,e),i=((e,t)=>()=>{e.on((e=>{e.intervalId.clear(),e.dragging&&t.dispatch("dragend")})),HN(e)})(t,e);e.on("mousedown",r),e.on("mousemove",s),e.on("mouseup",a),n.bind(o,"mousemove",s),n.bind(o,"mouseup",i),e.on("remove",(()=>{n.unbind(o,"mousemove",s),n.unbind(o,"mouseup",i)})),e.on("keydown",(e=>{e.keyCode===Dm.ESC&&i()}))},VN=Yo,qN=(e,t)=>bh(e.getBody(),t),WN=e=>{const t=e.selection,n=e.dom,o=e.getBody(),r=tc(e,o,n.isBlock,(()=>Zf(e))),s="sel-"+n.uniqueId(),a="data-mce-selected";let i;const l=e=>e!==o&&(VN(e)||Jo(e))&&n.isChildOf(e,o),d=(n,o,s,a=!0)=>e.dispatch("ShowCaret",{target:o,direction:n,before:s}).isDefaultPrevented()?null:(a&&t.scrollIntoView(o,-1===n),r.show(s,o)),c=e=>Or(e)||Pr(e)||Lr(e),u=e=>c(e.startContainer)||c(e.endContainer),m=t=>{const o=e.schema.getVoidElements(),r=n.createRng(),s=t.startContainer,a=t.startOffset,i=t.endContainer,l=t.endOffset;return xe(o,s.nodeName.toLowerCase())?0===a?r.setStartBefore(s):r.setStartAfter(s):r.setStart(s,a),xe(o,i.nodeName.toLowerCase())?0===l?r.setEndBefore(i):r.setEndAfter(i):r.setEnd(i,l),r},f=(r,c)=>{if(!r)return null;if(r.collapsed){if(!u(r)){const e=c?1:-1,t=Rc(e,o,r),s=t.getNode(!c);if(C(s)){if(rc(s))return d(e,s,!!c&&!t.isAtEnd(),!1);if(Ar(s)&&Yo(s.nextSibling)){const e=n.createRng();return e.setStart(s,0),e.setEnd(s,0),e}}const a=t.getNode(c);if(C(a)){if(rc(a))return d(e,a,!c&&!t.isAtEnd(),!1);if(Ar(a)&&Yo(a.previousSibling)){const e=n.createRng();return e.setStart(a,1),e.setEnd(a,1),e}}}return null}let m=r.startContainer,f=r.startOffset;const g=r.endOffset;if(zo(m)&&0===f&&VN(m.parentNode)&&(m=m.parentNode,f=n.nodeIndex(m),m=m.parentNode),!To(m))return null;if(g===f+1&&m===r.endContainer){const o=m.childNodes[f];if(l(o))return(o=>{const r=o.cloneNode(!0),l=e.dispatch("ObjectSelected",{target:o,targetClone:r});if(l.isDefaultPrevented())return null;const d=((o,r)=>{const a=mn(e.getBody()),i=e.getDoc(),l=_o(a,"#"+s).getOrThunk((()=>{const e=dn('<div data-mce-bogus="all" class="mce-offscreen-selection"></div>',i);return Vt(e,"id",s),eo(a,e),e})),d=n.createRng();no(l),to(l,[un(tr,i),mn(r),un(tr,i)]),d.setStart(l.dom.firstChild,1),d.setEnd(l.dom.lastChild,0),qn(l,{top:n.getPos(o,e.getBody()).y+"px"}),Df(l);const c=t.getSel();return c&&(c.removeAllRanges(),c.addRange(d)),d})(o,l.targetClone),c=mn(o);return V(or(mn(e.getBody()),"*[data-mce-selected]"),(e=>{bn(c,e)||Yt(e,a)})),n.getAttrib(o,a)||o.setAttribute(a,"1"),i=o,p(),d})(o)}return null},g=()=>{i&&i.removeAttribute(a),_o(mn(e.getBody()),"#"+s).each(oo),i=null},p=()=>{r.hide()};return Jy(e)||(e.on("click",(t=>{const n=qN(e,t.target);n&&VN(n)&&(t.preventDefault(),e.focus())})),e.on("blur NewBlock",g),e.on("ResizeWindow FullscreenStateChanged",r.reposition),e.on("tap",(t=>{const n=t.target,o=qN(e,n);VN(o)?(t.preventDefault(),ww(e,o).each(f)):l(n)&&ww(e,n).each(f)}),!0),e.on("mousedown",(r=>{const s=r.target;if(s!==o&&"HTML"!==s.nodeName&&!n.isChildOf(s,o))return;if(!((e,t,n)=>{const o=mn(e.getBody()),r=e.inline?o:mn(Cn(o).dom.documentElement),s=((e,t,n,o)=>{const r=(e=>e.dom.getBoundingClientRect())(t);return{x:n-(e?r.left+t.dom.clientLeft+SC(t):0),y:o-(e?r.top+t.dom.clientTop+kC(t):0)}})(e.inline,r,t,n);return((e,t,n)=>{const o=wC(e),r=xC(e);return t>=0&&n>=0&&t<=o&&n<=r})(r,s.x,s.y)})(e,r.clientX,r.clientY))return;g(),p();const a=qN(e,s);VN(a)?(r.preventDefault(),ww(e,a).each(f)):ON(o,r.clientX,r.clientY).each((n=>{var o;r.preventDefault(),(o=d(1,n.node,n.position===SN.Before,!1))&&t.setRng(o),To(a)?a.focus():e.getBody().focus()}))})),e.on("keypress",(e=>{Dm.modifierPressed(e)||VN(t.getNode())&&e.preventDefault()})),e.on("GetSelectionRange",(e=>{let t=e.range;if(i){if(!i.parentNode)return void(i=null);t=t.cloneRange(),t.selectNode(i),e.range=t}})),e.on("SetSelectionRange",(e=>{e.range=m(e.range);const t=f(e.range,e.forward);t&&(e.range=t)})),e.on("AfterSetSelectionRange",(e=>{const t=e.range,o=t.startContainer.parentElement;var r;u(t)||To(r=o)&&"mcepastebin"===r.id||p(),(e=>C(e)&&n.hasClass(e,"mce-offscreen-selection"))(o)||g()})),(e=>{$N(e),fd(e)&&(e=>{const t=t=>{if(!t.isDefaultPrevented()){const n=t.dataTransfer;n&&(j(n.types,"Files")||n.files.length>0)&&(t.preventDefault(),"drop"===t.type&&OC(e,"Dropped file type is not supported"))}},n=n=>{Gf(e,n.target)&&t(n)},o=()=>{const o=ba.DOM,r=e.dom,s=document,a=e.inline?e.getBody():e.getDoc(),i=["drop","dragover"];V(i,(e=>{o.bind(s,e,n),r.bind(a,e,t)})),e.on("remove",(()=>{V(i,(e=>{o.unbind(s,e,n),r.unbind(a,e,t)}))}))};e.on("init",(()=>{qf.setEditorTimeout(e,o,0)}))})(e)})(e),(e=>{const t=Ra((()=>{if(!e.removed&&e.getBody().contains(document.activeElement)){const t=e.selection.getRng();if(t.collapsed){const n=xw(e,t,!1);e.selection.setRng(n)}}}),0);e.on("focus",(()=>{t.throttle()})),e.on("blur",(()=>{t.cancel()}))})(e),(e=>{e.on("init",(()=>{e.on("focusin",(t=>{const n=t.target;if(Jo(n)){const t=bh(e.getBody(),n),o=Yo(t)?t:n;e.selection.getNode()!==o&&ww(e,o).each((t=>e.selection.setRng(t)))}}))}))})(e)),{showCaret:d,showBlockCaretContainer:e=>{e.hasAttribute("data-mce-caret")&&(Mr(e),t.scrollIntoView(e))},hideFakeCaret:p,destroy:()=>{r.destroy(),i=null}}},KN=(e,t)=>{let n=t;for(let t=e.previousSibling;zo(t);t=t.previousSibling)n+=t.data.length;return n},GN=(e,t,n,o,r)=>{if(zo(n)&&(o<0||o>n.data.length))return[];const s=r&&zo(n)?[KN(n,o)]:[o];let a=n;for(;a!==t&&a.parentNode;)s.push(e.nodeIndex(a,r)),a=a.parentNode;return a===t?s.reverse():[]},YN=(e,t,n,o,r,s,a=!1)=>({start:GN(e,t,n,o,a),end:GN(e,t,r,s,a)}),XN=(e,t)=>{const n=t.slice(),o=n.pop();return x(o)?Y(n,((e,t)=>e.bind((e=>M.from(e.childNodes[t])))),M.some(e)).bind((e=>zo(e)&&(o<0||o>e.data.length)?M.none():M.some({node:e,offset:o}))):M.none()},QN=(e,t)=>XN(e,t.start).bind((({node:n,offset:o})=>XN(e,t.end).map((({node:e,offset:t})=>{const r=document.createRange();return r.setStart(n,o),r.setEnd(e,t),r})))),JN=(e,t,n)=>{if(t&&e.isEmpty(t)&&!n(t)){const o=t.parentNode;e.remove(t),JN(e,o,n)}},ZN=(e,t,n,o=!0)=>{const r=t.startContainer.parentNode,s=t.endContainer.parentNode;t.deleteContents(),o&&!n(t.startContainer)&&(zo(t.startContainer)&&0===t.startContainer.data.length&&e.remove(t.startContainer),zo(t.endContainer)&&0===t.endContainer.data.length&&e.remove(t.endContainer),JN(e,r,n),r!==s&&JN(e,s,n))},eR=(e,t)=>M.from(e.dom.getParent(t.startContainer,e.dom.isBlock)),tR=(e,t,n)=>{const o=e.dynamicPatternsLookup({text:n,block:t});return{...e,blockPatterns:Qi(o).concat(e.blockPatterns),inlinePatterns:Ji(o).concat(e.inlinePatterns)}},nR=(e,t,n,o)=>{const r=e.createRng();return r.setStart(t,0),r.setEnd(n,o),r.toString()},oR=(e,t,n)=>{((e,t,n)=>{if(zo(e)&&0>=e.length)return M.some(hS(e,0));{const t=Ka(bS);return M.from(t.forwards(e,0,vS(e),n)).map((e=>hS(e.container,0)))}})(t,0,t).each((o=>{const r=o.container;wS(r,n.start.length,t).each((n=>{const o=e.createRng();o.setStart(r,0),o.setEnd(n.container,n.offset),ZN(e,o,(e=>e===t))}))}))},rR=(e,t)=>e.create("span",{"data-mce-type":"bookmark",id:t}),sR=(e,t)=>{const n=e.createRng();return n.setStartAfter(t.start),n.setEndBefore(t.end),n},aR=(e,t,n)=>{const o=QN(e.getRoot(),n).getOrDie("Unable to resolve path range"),r=o.startContainer,s=o.endContainer,a=0===o.endOffset?s:s.splitText(o.endOffset),i=0===o.startOffset?r:r.splitText(o.startOffset),l=i.parentNode;return{prefix:t,end:a.parentNode.insertBefore(rR(e,t+"-end"),a),start:l.insertBefore(rR(e,t+"-start"),i)}},iR=(e,t,n)=>{JN(e,e.get(t.prefix+"-end"),n),JN(e,e.get(t.prefix+"-start"),n)},lR=e=>0===e.start.length,dR=(e,t,n,o)=>{const r=t.start;var s;return xS(e,o.container,o.offset,(s=r,(e,t)=>{const n=e.data.substring(0,t),o=n.lastIndexOf(s.charAt(s.length-1)),r=n.lastIndexOf(s);return-1!==r?r+s.length:-1!==o?o+1:-1}),n).bind((o=>{var s,a;const i=null!==(a=null===(s=n.textContent)||void 0===s?void 0:s.indexOf(r))&&void 0!==a?a:-1;if(-1!==i&&o.offset>=i+r.length){const t=e.createRng();return t.setStart(o.container,o.offset-r.length),t.setEnd(o.container,o.offset),M.some(t)}{const s=o.offset-r.length;return CS(o.container,s,n).map((t=>{const n=e.createRng();return n.setStart(t.container,t.offset),n.setEnd(o.container,o.offset),n})).filter((e=>e.toString()===r)).orThunk((()=>dR(e,t,n,hS(o.container,0))))}}))},cR=(e,t,n,o)=>{const r=e.dom,s=r.getRoot(),a=n.pattern,i=n.position.container,l=n.position.offset;return CS(i,l-n.pattern.end.length,t).bind((d=>{const c=YN(r,s,d.container,d.offset,i,l,o);if(lR(a))return M.some({matches:[{pattern:a,startRng:c,endRng:c}],position:d});{const i=uR(e,n.remainingPatterns,d.container,d.offset,t,o),l=i.getOr({matches:[],position:d}),u=l.position,m=((e,t,n,o,r,s=!1)=>{if(0===t.start.length&&!s){const t=e.createRng();return t.setStart(n,o),t.setEnd(n,o),M.some(t)}return yS(n,o,r).bind((n=>dR(e,t,r,n).bind((e=>{var t;if(s){if(e.endContainer===n.container&&e.endOffset===n.offset)return M.none();if(0===n.offset&&(null===(t=e.endContainer.textContent)||void 0===t?void 0:t.length)===e.endOffset)return M.none()}return M.some(e)}))))})(r,a,u.container,u.offset,t,i.isNone());return m.map((e=>{const t=((e,t,n,o=!1)=>YN(e,t,n.startContainer,n.startOffset,n.endContainer,n.endOffset,o))(r,s,e,o);return{matches:l.matches.concat([{pattern:a,startRng:t,endRng:c}]),position:hS(e.startContainer,e.startOffset)}}))}}))},uR=(e,t,n,o,r,s)=>{const a=e.dom;return yS(n,o,a.getRoot()).bind((i=>{const l=nR(a,r,n,o);for(let a=0;a<t.length;a++){const d=t[a];if(!je(l,d.end))continue;const c=t.slice();c.splice(a,1);const u=cR(e,r,{pattern:d,remainingPatterns:c,position:i},s);if(u.isNone()&&o>0)return uR(e,t,n,o-1,r,s);if(u.isSome())return u}return M.none()}))},mR=(e,t,n)=>{e.selection.setRng(n),"inline-format"===t.type?V(t.format,(t=>{e.formatter.apply(t)})):e.execCommand(t.cmd,!1,t.value)},fR=(e,t,n,o,r,s)=>{var a;return((e,t)=>{const n=te(e,(e=>H(t,(t=>e.pattern.start===t.pattern.start&&e.pattern.end===t.pattern.end))));return e.length===t.length?n?e:t:e.length>t.length?e:t})(uR(e,r.inlinePatterns,n,o,t,s).fold((()=>[]),(e=>e.matches)),uR(e,(a=r.inlinePatterns,se(a,((e,t)=>t.end.length-e.end.length))),n,o,t,s).fold((()=>[]),(e=>e.matches)))},gR=(e,t)=>{if(0===t.length)return;const n=e.dom,o=e.selection.getBookmark(),r=((e,t)=>{const n=Ha("mce_textpattern"),o=G(t,((t,o)=>{const r=aR(e,n+`_end${t.length}`,o.endRng);return t.concat([{...o,endMarker:r}])}),[]);return G(o,((t,r)=>{const s=o.length-t.length-1,a=lR(r.pattern)?r.endMarker:aR(e,n+`_start${s}`,r.startRng);return t.concat([{...r,startMarker:a}])}),[])})(n,t);V(r,(t=>{const o=n.getParent(t.startMarker.start,n.isBlock),r=e=>e===o;lR(t.pattern)?((e,t,n,o)=>{const r=sR(e.dom,n);ZN(e.dom,r,o),mR(e,t,r)})(e,t.pattern,t.endMarker,r):((e,t,n,o,r)=>{const s=e.dom,a=sR(s,o),i=sR(s,n);ZN(s,i,r),ZN(s,a,r);const l={prefix:n.prefix,start:n.end,end:o.start},d=sR(s,l);mR(e,t,d)})(e,t.pattern,t.startMarker,t.endMarker,r),iR(n,t.endMarker,r),iR(n,t.startMarker,r)})),e.selection.moveToBookmark(o)},pR=(e,t)=>{const n=e.selection.getRng();return eR(e,n).map((o=>{var r;const s=Math.max(0,n.startOffset),a=tR(t,o,null!==(r=o.textContent)&&void 0!==r?r:""),i=fR(e,o,n.startContainer,s,a,!0),l=((e,t,n,o)=>{var r;const s=e.dom,a=gl(e);if(!s.is(t,a))return[];const i=null!==(r=t.textContent)&&void 0!==r?r:"";return((e,t)=>{const n=(e=>se(e,((e,t)=>t.start.length-e.start.length)))(e),o=t.replace(tr," ");return Q(n,(e=>0===t.indexOf(e.start)||0===o.indexOf(e.start)))})(n.blockPatterns,i).map((e=>Tt.trim(i).length===e.start.length?[]:[{pattern:e,range:YN(s,s.getRoot(),t,0,t,0,true)}])).getOr([])})(e,o,a);return(l.length>0||i.length>0)&&(e.undoManager.add(),e.undoManager.extra((()=>{e.execCommand("mceInsertNewLine")}),(()=>{e.insertContent(er),gR(e,i),((e,t)=>{if(0===t.length)return;const n=e.selection.getBookmark();V(t,(t=>((e,t)=>{const n=e.dom,o=t.pattern,r=QN(n.getRoot(),t.range).getOrDie("Unable to resolve path range");return eR(e,r).each((t=>{"block-format"===o.type?((e,t)=>{const n=t.get(e);return p(n)&&ie(n).exists((e=>xe(e,"block")))})(o.format,e.formatter)&&e.undoManager.transact((()=>{oR(e.dom,t,o),e.formatter.apply(o.format)})):"block-command"===o.type&&e.undoManager.transact((()=>{oR(e.dom,t,o),e.execCommand(o.cmd,!1,o.value)}))})),!0})(e,t))),e.selection.moveToBookmark(n)})(e,l);const t=e.selection.getRng(),n=yS(t.startContainer,t.startOffset,e.dom.getRoot());e.execCommand("mceInsertNewLine"),n.each((t=>{const n=t.container;n.data.charAt(t.offset-1)===er&&(n.deleteData(t.offset-1,1),JN(e.dom,n.parentNode,(t=>t===e.dom.getRoot())))}))})),!0)})).getOr(!1)},hR=(e,t,n)=>{for(let o=0;o<e.length;o++)if(n(e[o],t))return!0;return!1},bR=e=>{const t=Tt.each,n=Dm.BACKSPACE,o=Dm.DELETE,r=e.dom,s=e.selection,a=e.parser,i=Nt.browser,l=i.isFirefox(),d=i.isChromium()||i.isSafari(),c=Nt.deviceType.isiPhone()||Nt.deviceType.isiPad(),u=Nt.os.isMacOS()||Nt.os.isiOS(),m=(t,n)=>{try{e.getDoc().execCommand(t,!1,String(n))}catch(e){}},f=e=>e.isDefaultPrevented(),g=()=>{e.shortcuts.add("meta+a",null,"SelectAll")},p=()=>{e.inline||r.bind(e.getDoc(),"mousedown mouseup",(t=>{let n;if(t.target===e.getDoc().documentElement)if(n=s.getRng(),e.getBody().focus(),"mousedown"===t.type){if(Or(n.startContainer))return;s.placeCaretAt(t.clientX,t.clientY)}else s.setRng(n)}))},h=()=>{Range.prototype.getClientRects||e.on("mousedown",(t=>{if(!f(t)&&"HTML"===t.target.nodeName){const t=e.getBody();t.blur(),qf.setEditorTimeout(e,(()=>{t.focus()}))}}))},b=()=>{const t=hd(e);e.on("click",(n=>{const o=n.target;/^(IMG|HR)$/.test(o.nodeName)&&"false"!==r.getContentEditableParent(o)&&(n.preventDefault(),e.selection.select(o),e.nodeChanged()),"A"===o.nodeName&&r.hasClass(o,t)&&0===o.childNodes.length&&(n.preventDefault(),s.select(o))}))},v=()=>{e.on("keydown",(e=>{if(!f(e)&&e.keyCode===n&&s.isCollapsed()&&0===s.getRng().startOffset){const t=s.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}return!0}))},y=()=>{dd(e)||e.on("BeforeExecCommand mousedown",(()=>{m("StyleWithCSS",!1),m("enableInlineTableEditing",!1),jl(e)||m("enableObjectResizing",!1)}))},C=()=>{e.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")},w=()=>{e.inline||e.on("keydown",(()=>{document.activeElement===document.body&&e.getWin().focus()}))},x=()=>{e.inline||(e.contentStyles.push("body {min-height: 150px}"),e.on("click",(t=>{let n;"HTML"===t.target.nodeName&&(n=e.selection.getRng(),e.getBody().focus(),e.selection.setRng(n),e.selection.normalize(),e.nodeChanged())})))},k=()=>{u&&e.on("keydown",(t=>{!Dm.metaKeyPressed(t)||t.shiftKey||37!==t.keyCode&&39!==t.keyCode||(t.preventDefault(),e.selection.getSel().modify("move",37===t.keyCode?"backward":"forward","lineboundary"))}))},_=()=>{e.on("click",(e=>{let t=e.target;do{if("A"===t.tagName)return void e.preventDefault()}while(t=t.parentNode)})),e.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")},E=()=>{e.on("init",(()=>{e.dom.bind(e.getBody(),"submit",(e=>{e.preventDefault()}))}))},N=S;return Jy(e)?(d&&(p(),b(),E(),g(),c&&(w(),x(),_())),l&&(h(),y(),C(),k())):(e.on("keydown",(t=>{if(f(t)||t.keyCode!==Dm.BACKSPACE)return;let n=s.getRng();const o=n.startContainer,a=n.startOffset,i=r.getRoot();let l=o;if(n.collapsed&&0===a){for(;l.parentNode&&l.parentNode.firstChild===l&&l.parentNode!==i;)l=l.parentNode;"BLOCKQUOTE"===l.nodeName&&(e.formatter.toggle("blockquote",void 0,l),n=r.createRng(),n.setStart(o,0),n.setEnd(o,0),s.setRng(n))}})),(()=>{const t=e=>{const t=r.create("body"),n=e.cloneContents();return t.appendChild(n),s.serializer.serialize(t,{format:"html"})};e.on("keydown",(s=>{const a=s.keyCode;if(!f(s)&&(a===o||a===n)){const n=e.selection.isCollapsed(),o=e.getBody();if(n&&!r.isEmpty(o))return;if(!n&&!(n=>{const o=t(n),s=r.createRng();return s.selectNode(e.getBody()),o===t(s)})(e.selection.getRng()))return;s.preventDefault(),e.setContent(""),o.firstChild&&r.isBlock(o.firstChild)?e.selection.setCursorLocation(o.firstChild,0):e.selection.setCursorLocation(o,0),e.nodeChanged()}}))})(),Nt.windowsPhone||e.on("keyup focusin mouseup",(t=>{Dm.modifierPressed(t)||(e=>{const t=e.getBody(),n=e.selection.getRng();return n.startContainer===n.endContainer&&n.startContainer===t&&0===n.startOffset&&n.endOffset===t.childNodes.length})(e)||s.normalize()}),!0),d&&(p(),b(),e.on("init",(()=>{m("DefaultParagraphSeparator",gl(e))})),E(),v(),a.addNodeFilter("br",(e=>{let t=e.length;for(;t--;)"Apple-interchange-newline"===e[t].attr("class")&&e[t].remove()})),c?(w(),x(),_()):g()),l&&(e.on("keydown",(t=>{if(!f(t)&&t.keyCode===n){if(!e.getBody().getElementsByTagName("hr").length)return;if(s.isCollapsed()&&0===s.getRng().startOffset){const e=s.getNode(),n=e.previousSibling;if("HR"===e.nodeName)return r.remove(e),void t.preventDefault();n&&n.nodeName&&"hr"===n.nodeName.toLowerCase()&&(r.remove(n),t.preventDefault())}}})),h(),(()=>{const n=()=>{const n=r.getAttribs(s.getStart().cloneNode(!1));return()=>{const o=s.getStart();o!==e.getBody()&&(r.setAttrib(o,"style",null),t(n,(e=>{o.setAttributeNode(e.cloneNode(!0))})))}},o=()=>!s.isCollapsed()&&r.getParent(s.getStart(),r.isBlock)!==r.getParent(s.getEnd(),r.isBlock);e.on("keypress",(t=>{let r;return!(!(f(t)||8!==t.keyCode&&46!==t.keyCode)&&o()&&(r=n(),e.getDoc().execCommand("delete",!1),r(),t.preventDefault(),1))})),r.bind(e.getDoc(),"cut",(t=>{if(!f(t)&&o()){const t=n();qf.setEditorTimeout(e,(()=>{t()}))}}))})(),y(),e.on("SetContent ExecCommand",(e=>{"setcontent"!==e.type&&"mceInsertLink"!==e.command||t(r.select("a:not([data-mce-block])"),(e=>{var t;let n=e.parentNode;const o=r.getRoot();if((null==n?void 0:n.lastChild)===e){for(;n&&!r.isBlock(n);){if((null===(t=n.parentNode)||void 0===t?void 0:t.lastChild)!==n||n===o)return;n=n.parentNode}r.add(n,"br",{"data-mce-bogus":1})}}))})),C(),k(),v())),{refreshContentEditable:N,isHidden:()=>{if(!l||e.removed)return!1;const t=e.selection.getSel();return!t||!t.rangeCount||0===t.rangeCount}}},vR=ba.DOM,yR=e=>e.inline?e.getElement().nodeName.toLowerCase():void 0,CR=e=>ve(e,(e=>!1===v(e))),wR=e=>{const t=e.options.get,n=e.editorUpload.blobCache;return CR({allow_conditional_comments:t("allow_conditional_comments"),allow_html_data_urls:t("allow_html_data_urls"),allow_svg_data_urls:t("allow_svg_data_urls"),allow_html_in_named_anchor:t("allow_html_in_named_anchor"),allow_script_urls:t("allow_script_urls"),allow_unsafe_link_target:t("allow_unsafe_link_target"),convert_fonts_to_spans:t("convert_fonts_to_spans"),fix_list_elements:t("fix_list_elements"),font_size_legacy_values:t("font_size_legacy_values"),forced_root_block:t("forced_root_block"),forced_root_block_attrs:t("forced_root_block_attrs"),preserve_cdata:t("preserve_cdata"),remove_trailing_brs:t("remove_trailing_brs"),inline_styles:t("inline_styles"),root_name:yR(e),validate:!0,blob_cache:n,document:e.getDoc()})},xR=e=>{const t=e.options.get;return CR({custom_elements:t("custom_elements"),extended_valid_elements:t("extended_valid_elements"),invalid_elements:t("invalid_elements"),invalid_styles:t("invalid_styles"),schema:t("schema"),valid_children:t("valid_children"),valid_classes:t("valid_classes"),valid_elements:t("valid_elements"),valid_styles:t("valid_styles"),verify_html:t("verify_html"),padd_empty_block_inline_children:t("format_empty_lines")})},kR=e=>e.inline?e.ui.styleSheetLoader:e.dom.styleSheetLoader,SR=e=>{const t=kR(e),n=Fl(e),o=e.contentCSS,r=()=>{t.unloadAll(o),e.inline||e.ui.styleSheetLoader.unloadAll(n)},s=()=>{e.removed?r():e.on("remove",r)};if(e.contentStyles.length>0){let t="";Tt.each(e.contentStyles,(e=>{t+=e+"\r\n"})),e.dom.addStyle(t)}const a=Promise.all(((e,t,n)=>{const o=[kR(e).loadAll(t)];return e.inline?o:o.concat([e.ui.styleSheetLoader.loadAll(n)])})(e,o,n)).then(s).catch(s),i=Il(e);return i&&((e,t)=>{const n=mn(e.getBody()),o=Fn(In(n)),r=cn("style");Vt(r,"type","text/css"),eo(r,un(t)),eo(o,r),e.on("remove",(()=>{oo(r)}))})(e,i),a},_R=e=>{!0!==e.removed&&((e=>{Jy(e)||e.load({initial:!0,format:"html"}),e.startContent=e.getContent({format:"raw"})})(e),(e=>{e.bindPendingEventDelegates(),e.initialized=!0,(e=>{e.dispatch("Init")})(e),e.focus(!0),(e=>{const t=e.dom.getRoot();e.inline||Pu(e)&&e.selection.getStart(!0)!==t||Zc(t).each((t=>{const n=t.getNode(),o=Io(n)?Zc(n).getOr(t):t;e.selection.setRng(o.toRange())}))})(e),e.nodeChanged({initial:!0});const t=yd(e);w(t)&&t.call(e,e),(e=>{const t=wd(e);t&&qf.setEditorTimeout(e,(()=>{let n;n=!0===t?e:e.editorManager.get(t),n&&!n.destroyed&&(n.focus(),n.selection.scrollIntoView())}),100)})(e)})(e))},ER=e=>{const t=e.getElement();let n=e.getDoc();e.inline&&(vR.addClass(t,"mce-content-body"),e.contentDocument=n=document,e.contentWindow=window,e.bodyElement=t,e.contentAreaContainer=t);const o=e.getBody();o.disabled=!0,e.readonly=dd(e),e.readonly||(e.inline&&"static"===vR.getStyle(o,"position",!0)&&(o.style.position="relative"),o.contentEditable="true"),o.disabled=!1,e.editorUpload=HC(e),e.schema=Qs(xR(e)),e.dom=ba(n,{keep_values:!0,url_converter:e.convertURL,url_converter_scope:e,update_styles:!0,root_element:e.inline?e.getBody():null,collect:e.inline,schema:e.schema,contentCssCors:Ol(e),referrerPolicy:Tl(e),onSetAttrib:t=>{e.dispatch("SetAttrib",t)}}),e.parser=(e=>{const t=yy(wR(e),e.schema);return t.addAttributeFilter("src,href,style,tabindex",((t,n)=>{const o=e.dom,r="data-mce-"+n;let s=t.length;for(;s--;){const a=t[s];let i=a.attr(n);if(i&&!a.attr(r)){if(0===i.indexOf("data:")||0===i.indexOf("blob:"))continue;"style"===n?(i=o.serializeStyle(o.parseStyle(i),a.name),i.length||(i=null),a.attr(r,i),a.attr(n,i)):"tabindex"===n?(a.attr(r,i),a.attr(n,null)):a.attr(r,e.convertURL(i,n,a.name))}}})),t.addNodeFilter("script",(e=>{let t=e.length;for(;t--;){const n=e[t],o=n.attr("type")||"no/type";0!==o.indexOf("mce-")&&n.attr("type","mce-"+o)}})),zd(e)&&t.addNodeFilter("#cdata",(t=>{var n;let o=t.length;for(;o--;){const r=t[o];r.type=8,r.name="#comment",r.value="[CDATA["+e.dom.encode(null!==(n=r.value)&&void 0!==n?n:"")+"]]"}})),t.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",(t=>{let n=t.length;const o=e.schema.getNonEmptyElements();for(;n--;){const e=t[n];e.isEmpty(o)&&0===e.getAll("br").length&&e.append(new pg("br",1))}})),t})(e),e.serializer=dC((e=>{const t=e.options.get;return{...wR(e),...xR(e),...CR({url_converter:t("url_converter"),url_converter_scope:t("url_converter_scope"),element_format:t("element_format"),entities:t("entities"),entity_encoding:t("entity_encoding"),indent:t("indent"),indent_after:t("indent_after"),indent_before:t("indent_before")})}})(e),e),e.selection=aC(e.dom,e.getWin(),e.serializer,e),e.annotator=Sm(e),e.formatter=ZC(e),e.undoManager=tw(e),e._nodeChangeDispatcher=new LE(e),e._selectionOverrides=WN(e),(e=>{const t=Na(),n=Ca(!1),o=Aa((t=>{e.dispatch("longpress",{...t,type:"longpress"}),n.set(!0)}),400);e.on("touchstart",(e=>{vk(e).each((r=>{o.cancel();const s={x:r.clientX,y:r.clientY,target:e.target};o.throttle(e),n.set(!1),t.set(s)}))}),!0),e.on("touchmove",(r=>{o.cancel(),vk(r).each((o=>{t.on((r=>{((e,t)=>{const n=Math.abs(e.clientX-t.x),o=Math.abs(e.clientY-t.y);return n>5||o>5})(o,r)&&(t.clear(),n.set(!1),e.dispatch("longpresscancel"))}))}))}),!0),e.on("touchend touchcancel",(r=>{o.cancel(),"touchcancel"!==r.type&&t.get().filter((e=>e.target.isEqualNode(r.target))).each((()=>{n.get()?r.preventDefault():e.dispatch("tap",{...r,type:"tap"})}))}),!0)})(e),(e=>{(e=>{e.on("click",(t=>{e.dom.getParent(t.target,"details")&&t.preventDefault()}))})(e),(e=>{e.parser.addNodeFilter("details",(e=>{V(e,(e=>{e.attr("data-mce-open",e.attr("open")),e.attr("open","open")}))})),e.serializer.addNodeFilter("details",(e=>{V(e,(e=>{const t=e.attr("data-mce-open");e.attr("open",m(t)?t:null),e.attr("data-mce-open",null)}))}))})(e)})(e),(e=>{const t="contenteditable",n=" "+Tt.trim(Fd(e))+" ",o=" "+Tt.trim(Id(e))+" ",r=_k(n),s=_k(o),a=Ud(e);a.length>0&&e.on("BeforeSetContent",(t=>{((e,t,n)=>{let o=t.length,r=n.content;if("raw"!==n.format){for(;o--;)r=r.replace(t[o],Ek(e,r,Id(e)));n.content=r}})(e,a,t)})),e.parser.addAttributeFilter("class",(e=>{let n=e.length;for(;n--;){const o=e[n];r(o)?o.attr(t,"true"):s(o)&&o.attr(t,"false")}})),e.serializer.addAttributeFilter(t,(e=>{let n=e.length;for(;n--;){const o=e[n];(r(o)||s(o))&&(a.length>0&&o.attr("data-mce-content")?(o.name="#text",o.type=3,o.raw=!0,o.value=o.attr("data-mce-content")):o.attr(t,null))}}))})(e),Jy(e)||((e=>{e.on("mousedown",(t=>{t.detail>=3&&(t.preventDefault(),kN(e))}))})(e),(e=>{(e=>{const t=[",",".",";",":","!","?"],n=[32],o=()=>{return t=Ld(e),n=Md(e),{inlinePatterns:Ji(t),blockPatterns:Qi(t),dynamicPatternsLookup:n};var t,n},r=()=>(e=>e.options.isSet("text_patterns_lookup"))(e);e.on("keydown",(t=>{if(13===t.keyCode&&!Dm.modifierPressed(t)&&e.selection.isCollapsed()){const n=o();(n.inlinePatterns.length>0||n.blockPatterns.length>0||r())&&pR(e,n)&&t.preventDefault()}}),!0);const s=()=>{if(e.selection.isCollapsed()){const t=o();(t.inlinePatterns.length>0||r())&&((e,t)=>{const n=e.selection.getRng();eR(e,n).map((o=>{const r=Math.max(0,n.startOffset-1),s=nR(e.dom,o,n.startContainer,r),a=tR(t,o,s),i=fR(e,o,n.startContainer,r,a,!1);i.length>0&&e.undoManager.transact((()=>{gR(e,i)}))}))})(e,t)}};e.on("keyup",(e=>{hR(n,e,((e,t)=>e===t.keyCode&&!Dm.modifierPressed(t)))&&s()})),e.on("keypress",(n=>{hR(t,n,((e,t)=>e.charCodeAt(0)===t.charCode))&&qf.setEditorTimeout(e,s)}))})(e)})(e));const r=PE(e);bk(e,r),(e=>{e.on("NodeChange",O(kk,e))})(e),(e=>{var t;const n=e.dom,o=gl(e),r=null!==(t=$l(e))&&void 0!==t?t:"",s=(t,a)=>{if((e=>{if(rw(e)){const t=e.keyCode;return!sw(e)&&(Dm.metaKeyPressed(e)||e.altKey||t>=112&&t<=123||j(nw,t))}return!1})(t))return;const i=e.getBody(),l=!(e=>rw(e)&&!(sw(e)||"keyup"===e.type&&229===e.keyCode))(t)&&((e,t,n)=>{if(os(mn(t),!1)){const o=t.firstElementChild;return!o||!e.getStyle(t.firstElementChild,"padding-left")&&!e.getStyle(t.firstElementChild,"padding-right")&&n===o.nodeName.toLowerCase()}return!1})(n,i,o);(""!==n.getAttrib(i,ow)!==l||a)&&(n.setAttrib(i,ow,l?r:null),n.setAttrib(i,"aria-placeholder",l?r:null),((e,t)=>{e.dispatch("PlaceholderToggle",{state:t})})(e,l),e.on(l?"keydown":"keyup",s),e.off(l?"keyup":"keydown",s))};We(r)&&e.on("init",(t=>{s(t,!0),e.on("change SetContent ExecCommand",s),e.on("paste",(t=>qf.setEditorTimeout(e,(()=>s(t)))))}))})(e),hN(e);const s=(e=>{const t=e;return(e=>we(e.plugins,"rtc").bind((e=>M.from(e.setup))))(e).fold((()=>(t.rtcInstance=Qy(e),M.none())),(e=>(t.rtcInstance=(()=>{const e=N(null),t=N("");return{init:{bindEvents:S},undoManager:{beforeChange:S,add:e,undo:e,redo:e,clear:S,reset:S,hasUndo:P,hasRedo:P,transact:e,ignore:S,extra:S},formatter:{match:P,matchAll:N([]),matchNode:N(void 0),canApply:P,closest:t,apply:S,remove:S,toggle:S,formatChanged:N({unbind:S})},editor:{getContent:t,setContent:N({content:"",html:""}),insertContent:N(""),addVisual:S},selection:{getContent:t},autocompleter:{addDecoration:S,removeDecoration:S},raw:{getModel:N(M.none())}}})(),M.some((()=>e().then((e=>(t.rtcInstance=(e=>{const t=e=>f(e)?e:{},{init:n,undoManager:o,formatter:r,editor:s,selection:a,autocompleter:i,raw:l}=e;return{init:{bindEvents:n.bindEvents},undoManager:{beforeChange:o.beforeChange,add:o.add,undo:o.undo,redo:o.redo,clear:o.clear,reset:o.reset,hasUndo:o.hasUndo,hasRedo:o.hasRedo,transact:(e,t,n)=>o.transact(n),ignore:(e,t)=>o.ignore(t),extra:(e,t,n,r)=>o.extra(n,r)},formatter:{match:(e,n,o,s)=>r.match(e,t(n),s),matchAll:r.matchAll,matchNode:r.matchNode,canApply:e=>r.canApply(e),closest:e=>r.closest(e),apply:(e,n,o)=>r.apply(e,t(n)),remove:(e,n,o,s)=>r.remove(e,t(n)),toggle:(e,n,o)=>r.toggle(e,t(n)),formatChanged:(e,t,n,o,s)=>r.formatChanged(t,n,o,s)},editor:{getContent:e=>s.getContent(e),setContent:(e,t)=>({content:s.setContent(e,t),html:""}),insertContent:(e,t)=>(s.insertContent(e),""),addVisual:s.addVisual},selection:{getContent:(e,t)=>a.getContent(t)},autocompleter:{addDecoration:i.addDecoration,removeDecoration:i.removeDecoration},raw:{getModel:()=>M.some(l.getRawModel())}}})(e),e.rtc.isRemote))))))))})(e);(e=>{const t=e.getDoc(),n=e.getBody();(e=>{e.dispatch("PreInit")})(e),xd(e)||(t.body.spellcheck=!1,vR.setAttrib(n,"spellcheck","false")),e.quirks=bR(e),(e=>{e.dispatch("PostRender")})(e);const o=Ul(e);void 0!==o&&(n.dir=o);const r=kd(e);r&&e.on("BeforeSetContent",(e=>{Tt.each(r,(t=>{e.content=e.content.replace(t,(e=>"\x3c!--mce:protected "+escape(e)+"--\x3e"))}))})),e.on("SetContent",(()=>{e.addVisual(e.getBody())})),e.on("compositionstart compositionend",(t=>{e.composing="compositionstart"===t.type}))})(e),s.fold((()=>{SR(e).then((()=>_R(e)))}),(t=>{e.setProgressState(!0),SR(e).then((()=>{t().then((t=>{e.setProgressState(!1),_R(e),tC(e)}),(t=>{e.notificationManager.open({type:"error",text:String(t)}),_R(e),tC(e)}))}))}))},NR=(e,t)=>{if(e.inline||(e.getElement().style.visibility=e.orgVisibility),t||e.inline)ER(e);else{const t=e.iframeElement,o=(n=mn(t),lo(n,"load",LC,(()=>{o.unbind(),e.contentDocument=t.contentDocument,ER(e)})));if(Nt.browser.isFirefox()){const t=e.getDoc();t.open(),t.write(e.iframeHTML),t.close()}else t.srcdoc=e.iframeHTML}var n},RR=ba.DOM,AR=ba.DOM,OR=(e,t)=>({editorContainer:e,iframeContainer:t,api:{}}),TR=e=>{const t=e.getElement();return e.inline?OR(null):(e=>{const t=AR.create("div");return AR.insertAfter(t,e),OR(t,t)})(t)},BR=e=>{e.dispatch("ScriptsLoaded"),(e=>{const t=Tt.trim(Sl(e)),n=e.ui.registry.getAll().icons,o={...bC.get("default").icons,...bC.get(t).icons};fe(o,((t,o)=>{xe(n,o)||e.ui.registry.addIcon(o,t)}))})(e),(e=>{const t=Wl(e);if(m(t)){const n=NC.get(t);e.theme=n(e,NC.urls[t])||{},w(e.theme.init)&&e.theme.init(e,NC.urls[t]||e.documentBaseUrl.replace(/\/$/,""))}else e.theme={}})(e),(e=>{const t=Gl(e),n=vC.get(t);e.model=n(e,vC.urls[t])})(e),(e=>{const t=[];V(ud(e),(n=>{((e,t,n)=>{const o=EC.get(n),r=EC.urls[n]||e.documentBaseUrl.replace(/\/$/,"");if(n=Tt.trim(n),o&&-1===Tt.inArray(t,n)){if(e.plugins[n])return;try{const s=o(e,r)||{};e.plugins[n]=s,w(s.init)&&(s.init(e,r),t.push(n))}catch(t){((e,t,n)=>{const o=Sa.translate(["Failed to initialize plugin: {0}",t]);Nm(e,"PluginLoadError",{message:o}),DC(o,n),OC(e,o)})(e,n,t)}}})(e,t,(e=>e.replace(/^\-/,""))(n))}))})(e);const t=(e=>{const t=e.getElement();return e.orgDisplay=t.style.display,m(Wl(e))?(e=>{const t=e.theme.renderUI;return t?t():TR(e)})(e):w(Wl(e))?(e=>{const t=e.getElement(),n=Wl(e)(e,t);return n.editorContainer.nodeType&&(n.editorContainer.id=n.editorContainer.id||e.id+"_parent"),n.iframeContainer&&n.iframeContainer.nodeType&&(n.iframeContainer.id=n.iframeContainer.id||e.id+"_iframecontainer"),n.height=n.iframeHeight?n.iframeHeight:t.offsetHeight,n})(e):TR(e)})(e);((e,t)=>{const n={show:M.from(t.show).getOr(S),hide:M.from(t.hide).getOr(S),isEnabled:M.from(t.isEnabled).getOr(L),setEnabled:n=>{e.mode.isReadOnly()||M.from(t.setEnabled).each((e=>e(n)))}};e.ui={...e.ui,...n}})(e,M.from(t.api).getOr({})),e.editorContainer=t.editorContainer,(e=>{e.contentCSS=e.contentCSS.concat((e=>PC(e,Ml(e)))(e),(e=>PC(e,Fl(e)))(e))})(e),e.inline?NR(e):((e,t)=>{((e,t)=>{const n=e.translate("Rich Text Area"),o=Kt(mn(e.getElement()),"tabindex").bind(Ge),r=((e,t,n,o)=>{const r=cn("iframe");return o.each((e=>Vt(r,"tabindex",e))),qt(r,n),qt(r,{id:e+"_ifr",frameBorder:"0",allowTransparency:"true",title:t}),nn(r,"tox-edit-area__iframe"),r})(e.id,n,il(e),o).dom;r.onload=()=>{r.onload=null,e.dispatch("load")},e.contentAreaContainer=t.iframeContainer,e.iframeElement=r,e.iframeHTML=(e=>{let t=ll(e)+"<html><head>";dl(e)!==e.documentBaseUrl&&(t+='<base href="'+e.documentBaseURI.getURI()+'" />'),t+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';const n=cl(e),o=ul(e),r=e.translate(bd(e));return ml(e)&&(t+='<meta http-equiv="Content-Security-Policy" content="'+ml(e)+'" />'),t+=`</head><body id="${n}" class="mce-content-body ${o}" data-id="${e.id}" aria-label="${r}"><br></body></html>`,t})(e),RR.add(t.iframeContainer,r)})(e,t),t.editorContainer&&(t.editorContainer.style.display=e.orgDisplay,e.hidden=RR.isHidden(t.editorContainer)),e.getElement().style.display="none",RR.setAttrib(e.id,"aria-hidden","true"),NR(e)})(e,{editorContainer:t.editorContainer,iframeContainer:t.iframeContainer})},DR=ba.DOM,PR=e=>"-"===e.charAt(0),LR=(e,t,n)=>M.from(t).filter((e=>We(e)&&!bC.has(e))).map((t=>({url:`${e.editorManager.baseURL}/icons/${t}/icons${n}.js`,name:M.some(t)}))),MR=(e,t)=>{const n=ya.ScriptLoader,o=()=>{!e.removed&&(e=>{const t=Wl(e);return!m(t)||C(NC.get(t))})(e)&&(e=>{const t=Gl(e);return C(vC.get(t))})(e)&&BR(e)};((e,t)=>{const n=Wl(e);if(m(n)&&!PR(n)&&!xe(NC.urls,n)){const o=Kl(e),r=o?e.documentBaseURI.toAbsolute(o):`themes/${n}/theme${t}.js`;NC.load(n,r).catch((()=>{((e,t,n)=>{TC(e,"ThemeLoadError",BC("theme",t,n))})(e,r,n)}))}})(e,t),((e,t)=>{const n=Gl(e);if("plugin"!==n&&!xe(vC.urls,n)){const o=Yl(e),r=m(o)?e.documentBaseURI.toAbsolute(o):`models/${n}/model${t}.js`;vC.load(n,r).catch((()=>{((e,t,n)=>{TC(e,"ModelLoadError",BC("model",t,n))})(e,r,n)}))}})(e,t),((e,t)=>{const n=Bl(t),o=Dl(t);if(!Sa.hasCode(n)&&"en"!==n){const r=We(o)?o:`${t.editorManager.baseURL}/langs/${n}.js`;e.add(r).catch((()=>{((e,t,n)=>{TC(e,"LanguageLoadError",BC("language",t,n))})(t,r,n)}))}})(n,e),((e,t,n)=>{const o=LR(t,"default",n),r=(e=>M.from(_l(e)).filter(We).map((e=>({url:e,name:M.none()}))))(t).orThunk((()=>LR(t,Sl(t),"")));V((e=>{const t=[],n=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(n);return t})([o,r]),(n=>{e.add(n.url).catch((()=>{((e,t,n)=>{TC(e,"IconsLoadError",BC("icons",t,n))})(t,n.url,n.name.getOrUndefined())}))}))})(n,e,t),((e,t)=>{const n=(t,n)=>{EC.load(t,n).catch((()=>{((e,t,n)=>{TC(e,"PluginLoadError",BC("plugin",t,n))})(e,n,t)}))};fe(md(e),((t,o)=>{n(o,t),e.options.set("plugins",ud(e).concat(o))})),V(ud(e),(e=>{!(e=Tt.trim(e))||EC.urls[e]||PR(e)||n(e,`plugins/${e}/plugin${t}.js`)}))})(e,t),n.loadQueue().then(o,o)},IR=Ct().deviceType,FR=IR.isPhone(),UR=IR.isTablet(),zR=e=>{if(y(e))return[];{const t=p(e)?e:e.split(/[ ,]/),n=$(t,$e);return K(n,We)}},jR=(e,t)=>{const n=((t,n)=>{const o={},r={};return be(t,((t,n)=>j(e,n)),he(o),he(r)),{t:o,f:r}})(t);return o=n.t,r=n.f,{sections:N(o),options:N(r)};var o,r},HR=(e,t)=>xe(e.sections(),t),$R=(e,t)=>({table_grid:!1,object_resizing:!1,resize:!1,toolbar_mode:we(e,"toolbar_mode").getOr("scrolling"),toolbar_sticky:!1,...t?{menubar:!1}:{}}),VR=(e,t)=>{var n;const o=null!==(n=t.external_plugins)&&void 0!==n?n:{};return e&&e.external_plugins?Tt.extend({},e.external_plugins,o):o},qR=(e,t,n,o,r)=>{var s;const a=e?{mobile:$R(null!==(s=r.mobile)&&void 0!==s?s:{},t)}:{},i=jR(["mobile"],US(a,r)),l=Tt.extend(n,o,i.options(),((e,t)=>e&&HR(t,"mobile"))(e,i)?((e,t,n={})=>{const o=e.sections(),r=we(o,t).getOr({});return Tt.extend({},n,r)})(i,"mobile"):{},{external_plugins:VR(o,i.options())});return((e,t,n,o)=>{const r=zR(n.forced_plugins),s=zR(o.plugins),a=((e,t)=>HR(e,t)?e.sections()[t]:{})(t,"mobile"),i=((e,t,n,o)=>e&&HR(t,"mobile")?o:n)(e,t,s,a.plugins?zR(a.plugins):s),l=((e,t)=>[...zR(e),...zR(t)])(r,i);return Tt.extend(o,{forced_plugins:r,plugins:l})})(e,i,o,l)},WR=e=>{(e=>{const t=t=>()=>{V("left,center,right,justify".split(","),(n=>{t!==n&&e.formatter.remove("align"+n)})),"none"!==t&&((t,n)=>{e.formatter.toggle(t,void 0),e.nodeChanged()})("align"+t)};e.editorCommands.addCommands({JustifyLeft:t("left"),JustifyCenter:t("center"),JustifyRight:t("right"),JustifyFull:t("justify"),JustifyNone:t("none")})})(e),(e=>{const t=t=>()=>{const n=e.selection,o=n.isCollapsed()?[e.dom.getParent(n.getNode(),e.dom.isBlock)]:n.getSelectedBlocks();return H(o,(n=>C(e.formatter.matchNode(n,t))))};e.editorCommands.addCommands({JustifyLeft:t("alignleft"),JustifyCenter:t("aligncenter"),JustifyRight:t("alignright"),JustifyFull:t("alignjustify")},"state")})(e)},KR=(e,t)=>{const n=e.selection,o=e.dom;return/^ | $/.test(t)?((e,t,n)=>{const o=mn(e.getRoot());return n=fp(o,xi.fromRangeStart(t))?n.replace(/^ /,"&nbsp;"):n.replace(/^&nbsp;/," "),gp(o,xi.fromRangeEnd(t))?n.replace(/(&nbsp;| )(<br( \/)>)?$/,"&nbsp;"):n.replace(/&nbsp;(<br( \/)?>)?$/," ")})(o,n.getRng(),t):t},GR=(e,t)=>{const{content:n,details:o}=(e=>{if("string"!=typeof e){const t=Tt.extend({paste:e.paste,data:{paste:e.paste}},e);return{content:e.content,details:t}}return{content:e,details:{}}})(t);ky(e,{...o,content:KR(e,n),format:"html",set:!1,selection:!0}).each((t=>{const n=((e,t,n)=>Zy(e).editor.insertContent(t,n))(e,t.content,o);Sy(e,n,t),e.addVisual()}))},YR={"font-size":"size","font-family":"face"},XR=Ht("font"),QR=e=>(t,n)=>M.from(n).map(mn).filter(Ft).bind((n=>((e,t,n)=>$h(mn(n),(t=>(t=>Gn(t,e).orThunk((()=>XR(t)?we(YR,e).bind((e=>Kt(t,e))):M.none())))(t)),(e=>bn(mn(t),e))))(e,t,n.dom).or(((e,t)=>M.from(ba.DOM.getStyle(t,e,!0)))(e,n.dom)))).getOr(""),JR=QR("font-size"),ZR=_((e=>e.replace(/[\'\"\\]/g,"").replace(/,\s+/g,",")),QR("font-family")),eA=e=>Zc(e.getBody()).bind((e=>{const t=e.container();return M.from(zo(t)?t.parentNode:t)})),tA=(e,t)=>((e,t)=>(e=>M.from(e.selection.getRng()).bind((t=>{const n=e.getBody();return t.startContainer===n&&0===t.startOffset?M.none():M.from(e.selection.getStart(!0))})))(e).orThunk(O(eA,e)).map(mn).filter(Ft).bind(t))(e,E(M.some,t)),nA=(e,t)=>{if(/^[0-9.]+$/.test(t)){const n=parseInt(t,10);if(n>=1&&n<=7){const o=(e=>Tt.explode(e.options.get("font_size_style_values")))(e),r=(e=>Tt.explode(e.options.get("font_size_classes")))(e);return r.length>0?r[n-1]||t:o[n-1]||t}return t}return t},oA=e=>{const t=e.split(/\s*,\s*/);return $(t,(e=>-1===e.indexOf(" ")||ze(e,'"')||ze(e,"'")?e:`'${e}'`)).join(",")},rA=e=>{WR(e),(e=>{e.editorCommands.addCommands({"Cut,Copy,Paste":t=>{const n=e.getDoc();let o;try{n.execCommand(t)}catch(e){o=!0}if("paste"!==t||n.queryCommandEnabled(t)||(o=!0),o||!n.queryCommandSupported(t)){let t=e.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.");(Nt.os.isMacOS()||Nt.os.isiOS())&&(t=t.replace(/Ctrl\+/g,"\u2318+")),e.notificationManager.open({text:t,type:"error"})}}})})(e),(e=>{e.editorCommands.addCommands({mceAddUndoLevel:()=>{e.undoManager.add()},mceEndUndoLevel:()=>{e.undoManager.add()},Undo:()=>{e.undoManager.undo()},Redo:()=>{e.undoManager.redo()}})})(e),(e=>{e.editorCommands.addCommands({mceSelectNodeDepth:(t,n,o)=>{let r=0;e.dom.getParent(e.selection.getNode(),(t=>!To(t)||r++!==o||(e.selection.select(t),!1)),e.getBody())},mceSelectNode:(t,n,o)=>{e.selection.select(o)},selectAll:()=>{const t=e.dom.getParent(e.selection.getStart(),Go);if(t){const n=e.dom.createRng();n.selectNodeContents(t),e.selection.setRng(n)}}})})(e),(e=>{e.editorCommands.addCommands({mceCleanup:()=>{const t=e.selection.getBookmark();e.setContent(e.getContent()),e.selection.moveToBookmark(t)},insertImage:(t,n,o)=>{GR(e,e.dom.createHTML("img",{src:o}))},insertHorizontalRule:()=>{e.execCommand("mceInsertContent",!1,"<hr>")},insertText:(t,n,o)=>{GR(e,e.dom.encode(o))},insertHTML:(t,n,o)=>{GR(e,o)},mceInsertContent:(t,n,o)=>{GR(e,o)},mceSetContent:(t,n,o)=>{e.setContent(o)},mceReplaceContent:(t,n,o)=>{e.execCommand("mceInsertContent",!1,o.replace(/\{\$selection\}/g,e.selection.getContent({format:"text"})))},mceNewDocument:()=>{e.setContent("")}})})(e),(e=>{const t=(t,n,o)=>{const r=m(o)?{href:o}:o,s=e.dom.getParent(e.selection.getNode(),"a");f(r)&&m(r.href)&&(r.href=r.href.replace(/ /g,"%20"),s&&r.href||e.formatter.remove("link"),r.href&&e.formatter.apply("link",r,s))};e.editorCommands.addCommands({unlink:()=>{if(e.selection.isCollapsed()){const t=e.dom.getParent(e.selection.getStart(),"a");t&&e.dom.remove(t,!0)}else e.formatter.remove("link")},mceInsertLink:t,createLink:t})})(e),(e=>{e.editorCommands.addCommands({Indent:()=>{(e=>{fk(e,"indent")})(e)},Outdent:()=>{gk(e)}}),e.editorCommands.addCommands({Outdent:()=>ck(e)},"state")})(e),(e=>{e.editorCommands.addCommands({insertParagraph:()=>{xE(tE,e)},mceInsertNewLine:(t,n,o)=>{kE(e,o)},InsertLineBreak:(t,n,o)=>{xE(dE,e)}})})(e),(e=>{(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{e.getDoc().execCommand(t);const n=e.dom.getParent(e.selection.getNode(),"ol,ul");if(n){const t=n.parentNode;if(t&&/^(H[1-6]|P|ADDRESS|PRE)$/.test(t.nodeName)){const o=e.selection.getBookmark();e.dom.split(t,n),e.selection.moveToBookmark(o)}}}})})(e),(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{const n=e.dom.getParent(e.selection.getNode(),"ul,ol");return n&&("insertunorderedlist"===t&&"UL"===n.tagName||"insertorderedlist"===t&&"OL"===n.tagName)}},"state")})(e)})(e),(e=>{(e=>{const t=(t,n)=>{e.formatter.toggle(t,n),e.nodeChanged()};e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>{t(e)},"ForeColor,HiliteColor":(e,n,o)=>{t(e,{value:o})},BackColor:(e,n,o)=>{t("hilitecolor",{value:o})},FontName:(t,n,o)=>{((e,t)=>{const n=nA(e,t);e.formatter.toggle("fontname",{value:oA(n)}),e.nodeChanged()})(e,o)},FontSize:(t,n,o)=>{((e,t)=>{e.formatter.toggle("fontsize",{value:nA(e,t)}),e.nodeChanged()})(e,o)},LineHeight:(t,n,o)=>{((e,t)=>{e.formatter.toggle("lineheight",{value:String(t)}),e.nodeChanged()})(e,o)},Lang:(e,n,o)=>{var r;t(e,{value:o.code,customValue:null!==(r=o.customCode)&&void 0!==r?r:null})},RemoveFormat:t=>{e.formatter.remove(t)},mceBlockQuote:()=>{t("blockquote")},FormatBlock:(e,n,o)=>{t(m(o)?o:"p")},mceToggleFormat:(e,n,o)=>{t(o)}})})(e),(e=>{const t=t=>e.formatter.match(t);e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>t(e),mceBlockQuote:()=>t("blockquote")},"state"),e.editorCommands.addQueryValueHandler("FontName",(()=>(e=>tA(e,(t=>ZR(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("FontSize",(()=>(e=>tA(e,(t=>JR(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("LineHeight",(()=>(e=>tA(e,(t=>{const n=mn(e.getBody()),o=$h(t,(e=>Gn(e,"line-height")),O(bn,n));return o.getOrThunk((()=>{const e=parseFloat(Wn(t,"line-height")),n=parseFloat(Wn(t,"font-size"));return String(e/n)}))})).getOr(""))(e)))})(e)})(e),(e=>{e.editorCommands.addCommands({mceRemoveNode:(t,n,o)=>{const r=null!=o?o:e.selection.getNode();if(r!==e.getBody()){const t=e.selection.getBookmark();e.dom.remove(r,!0),e.selection.moveToBookmark(t)}},mcePrint:()=>{e.getWin().print()},mceFocus:(t,n,o)=>{((e,t)=>{e.removed||(t?eg(e):(e=>{const t=e.selection,n=e.getBody();let o=t.getRng();e.quirks.refreshContentEditable(),C(e.bookmark)&&!Zf(e)&&$f(e).each((t=>{e.selection.setRng(t),o=t}));const r=((e,t)=>e.dom.getParent(t,(t=>"true"===e.dom.getContentEditable(t))))(e,t.getNode());if(r&&e.dom.isChildOf(r,n))return Jf(r),Qf(e,o),void eg(e);e.inline||(Nt.browser.isOpera()||Jf(n),e.getWin().focus()),(Nt.browser.isFirefox()||e.inline)&&(Jf(n),Qf(e,o)),eg(e)})(e))})(e,!0===o)},mceToggleVisualAid:()=>{e.hasVisual=!e.hasVisual,e.addVisual()}})})(e)},sA=["toggleview"],aA=e=>j(sA,e.toLowerCase());class iA{constructor(e){this.commands={state:{},exec:{},value:{}},this.editor=e}execCommand(e,t=!1,n,o){const r=this.editor,s=e.toLowerCase(),a=null==o?void 0:o.skip_focus;if(r.removed)return!1;if("mcefocus"!==s&&(/^(mceAddUndoLevel|mceEndUndoLevel)$/i.test(s)||a?(e=>{$f(e).each((t=>e.selection.setRng(t)))})(r):r.focus()),r.dispatch("BeforeExecCommand",{command:e,ui:t,value:n}).isDefaultPrevented())return!1;const i=this.commands.exec[s];return!!w(i)&&(i(s,t,n),r.dispatch("ExecCommand",{command:e,ui:t,value:n}),!0)}queryCommandState(e){if(!aA(e)&&this.editor.quirks.isHidden()||this.editor.removed)return!1;const t=e.toLowerCase(),n=this.commands.state[t];return!!w(n)&&n(t)}queryCommandValue(e){if(!aA(e)&&this.editor.quirks.isHidden()||this.editor.removed)return"";const t=e.toLowerCase(),n=this.commands.value[t];return w(n)?n(t):""}addCommands(e,t="exec"){const n=this.commands;fe(e,((e,o)=>{V(o.toLowerCase().split(","),(o=>{n[t][o]=e}))}))}addCommand(e,t,n){const o=e.toLowerCase();this.commands.exec[o]=(e,o,r)=>t.call(null!=n?n:this.editor,o,r)}queryCommandSupported(e){const t=e.toLowerCase();return!!this.commands.exec[t]}addQueryStateHandler(e,t,n){this.commands.state[e.toLowerCase()]=()=>t.call(null!=n?n:this.editor)}addQueryValueHandler(e,t,n){this.commands.value[e.toLowerCase()]=()=>t.call(null!=n?n:this.editor)}}const lA="data-mce-contenteditable",dA=(e,t,n)=>{try{e.getDoc().execCommand(t,!1,String(n))}catch(e){}},cA=(e,t)=>{e.dom.contentEditable=t?"true":"false"},uA=(e,t)=>{const n=mn(e.getBody());((e,t,n)=>{sn(e,t)&&!n?rn(e,t):n&&nn(e,t)})(n,"mce-content-readonly",t),t?(e.selection.controlSelection.hideResizeRect(),e._selectionOverrides.hideFakeCaret(),(e=>{M.from(e.selection.getNode()).each((e=>{e.removeAttribute("data-mce-selected")}))})(e),e.readonly=!0,cA(n,!1),V(or(n,'*[contenteditable="true"]'),(e=>{Vt(e,lA,"true"),cA(e,!1)}))):(e.readonly=!1,cA(n,!0),V(or(n,'*[data-mce-contenteditable="true"]'),(e=>{Yt(e,lA),cA(e,!0)})),dA(e,"StyleWithCSS",!1),dA(e,"enableInlineTableEditing",!1),dA(e,"enableObjectResizing",!1),(e=>Zf(e)||(e=>{const t=In(mn(e.getElement()));return Lf(t).filter((t=>!(e=>{const t=e.classList;return void 0!==t&&(t.contains("tox-edit-area")||t.contains("tox-edit-area__iframe")||t.contains("mce-content-body"))})(t.dom)&&Gf(e,t.dom))).isSome()})(e))(e)&&e.focus(),(e=>{e.selection.setRng(e.selection.getRng())})(e),e.nodeChanged())},mA=e=>e.readonly,fA=e=>{e.parser.addAttributeFilter("contenteditable",(t=>{mA(e)&&V(t,(e=>{e.attr(lA,e.attr("contenteditable")),e.attr("contenteditable","false")}))})),e.serializer.addAttributeFilter(lA,(t=>{mA(e)&&V(t,(e=>{e.attr("contenteditable",e.attr(lA))}))})),e.serializer.addTempAttr(lA)},gA=["copy"],pA=Tt.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel"," ");class hA{constructor(e){this.bindings={},this.settings=e||{},this.scope=this.settings.scope||this,this.toggleEvent=this.settings.toggleEvent||P}static isNative(e){return!!pA[e.toLowerCase()]}fire(e,t){return this.dispatch(e,t)}dispatch(e,t){const n=e.toLowerCase(),o=ta(n,null!=t?t:{},this.scope);this.settings.beforeFire&&this.settings.beforeFire(o);const r=this.bindings[n];if(r)for(let e=0,t=r.length;e<t;e++){const t=r[e];if(!t.removed){if(t.once&&this.off(n,t.func),o.isImmediatePropagationStopped())return o;if(!1===t.func.call(this.scope,o))return o.preventDefault(),o}}return o}on(e,t,n,o){if(!1===t&&(t=P),t){const r={func:t,removed:!1};o&&Tt.extend(r,o);const s=e.toLowerCase().split(" ");let a=s.length;for(;a--;){const e=s[a];let t=this.bindings[e];t||(t=[],this.toggleEvent(e,!0)),t=n?[r,...t]:[...t,r],this.bindings[e]=t}}return this}off(e,t){if(e){const n=e.toLowerCase().split(" ");let o=n.length;for(;o--;){const r=n[o];let s=this.bindings[r];if(!r)return fe(this.bindings,((e,t)=>{this.toggleEvent(t,!1),delete this.bindings[t]})),this;if(s){if(t){const e=W(s,(e=>e.func===t));s=e.fail,this.bindings[r]=s,V(e.pass,(e=>{e.removed=!0}))}else s.length=0;s.length||(this.toggleEvent(e,!1),delete this.bindings[r])}}}else fe(this.bindings,((e,t)=>{this.toggleEvent(t,!1)})),this.bindings={};return this}once(e,t,n){return this.on(e,t,n,{once:!0})}has(e){e=e.toLowerCase();const t=this.bindings[e];return!(!t||0===t.length)}}const bA=e=>(e._eventDispatcher||(e._eventDispatcher=new hA({scope:e,toggleEvent:(t,n)=>{hA.isNative(t)&&e.toggleNativeEvent&&e.toggleNativeEvent(t,n)}})),e._eventDispatcher),vA={fire(e,t,n){return this.dispatch(e,t,n)},dispatch(e,t,n){const o=this;if(o.removed&&"remove"!==e&&"detach"!==e)return ta(e.toLowerCase(),null!=t?t:{},o);const r=bA(o).dispatch(e,t);if(!1!==n&&o.parent){let t=o.parent();for(;t&&!r.isPropagationStopped();)t.dispatch(e,r,!1),t=t.parent?t.parent():void 0}return r},on(e,t,n){return bA(this).on(e,t,n)},off(e,t){return bA(this).off(e,t)},once(e,t){return bA(this).once(e,t)},hasEventListeners(e){return bA(this).has(e)}},yA=ba.DOM;let CA;const wA=(e,t)=>{if("selectionchange"===t)return e.getDoc();if(!e.inline&&/^mouse|touch|click|contextmenu|drop|dragover|dragend/.test(t))return e.getDoc().documentElement;const n=Vl(e);return n?(e.eventRoot||(e.eventRoot=yA.select(n)[0]),e.eventRoot):e.getBody()},xA=(e,t,n)=>{(e=>!e.hidden&&!mA(e))(e)?e.dispatch(t,n):mA(e)&&((e,t)=>{if((e=>"click"===e.type)(t)&&!Dm.metaKeyPressed(t)){const n=mn(t.target);((e,t)=>Eo(t,"a",(t=>bn(t,mn(e.getBody())))).bind((e=>Kt(e,"href"))))(e,n).each((n=>{if(t.preventDefault(),/^#/.test(n)){const t=e.dom.select(`${n},[name="${o=n,ze(o,"#")?((e,t)=>e.substring(t))(o,"#".length):o}"]`);t.length&&e.selection.scrollIntoView(t[0],!0)}else window.open(n,"_blank","rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes");var o}))}else(e=>j(gA,e.type))(t)&&e.dispatch(t.type,t)})(e,n)},kA=(e,t)=>{if(e.delegates||(e.delegates={}),e.delegates[t]||e.removed)return;const n=wA(e,t);if(Vl(e)){if(CA||(CA={},e.editorManager.on("removeEditor",(()=>{e.editorManager.activeEditor||CA&&(fe(CA,((t,n)=>{e.dom.unbind(wA(e,n))})),CA=null)}))),CA[t])return;const o=n=>{const o=n.target,r=e.editorManager.get();let s=r.length;for(;s--;){const e=r[s].getBody();(e===o||yA.isChildOf(o,e))&&xA(r[s],t,n)}};CA[t]=o,yA.bind(n,t,o)}else{const o=n=>{xA(e,t,n)};yA.bind(n,t,o),e.delegates[t]=o}},SA={...vA,bindPendingEventDelegates(){const e=this;Tt.each(e._pendingNativeEvents,(t=>{kA(e,t)}))},toggleNativeEvent(e,t){const n=this;"focus"!==e&&"blur"!==e&&(n.removed||(t?n.initialized?kA(n,e):n._pendingNativeEvents?n._pendingNativeEvents.push(e):n._pendingNativeEvents=[e]:n.initialized&&n.delegates&&(n.dom.unbind(wA(n,e),e,n.delegates[e]),delete n.delegates[e])))},unbindAllNativeEvents(){const e=this,t=e.getBody(),n=e.dom;e.delegates&&(fe(e.delegates,((t,n)=>{e.dom.unbind(wA(e,n),n,t)})),delete e.delegates),!e.inline&&t&&n&&(t.onload=null,n.unbind(e.getWin()),n.unbind(e.getDoc())),n&&(n.unbind(t),n.unbind(e.getContainer()))}},_A=e=>m(e)?{value:e.split(/[ ,]/),valid:!0}:k(e,m)?{value:e,valid:!0}:{valid:!1,message:"The value must be a string[] or a comma/space separated string."},EA=(e,t)=>e+(Ke(t.message)?"":`. ${t.message}`),NA=e=>e.valid,RA=(e,t,n="")=>{const o=t(e);return b(o)?o?{value:e,valid:!0}:{valid:!1,message:n}:o},AA=["design","readonly"],OA=(e,t,n,o)=>{const r=n[t.get()],s=n[o];try{s.activate()}catch(e){return void console.error(`problem while activating editor mode ${o}:`,e)}r.deactivate(),r.editorReadOnly!==s.editorReadOnly&&uA(e,s.editorReadOnly),t.set(o),((e,t)=>{e.dispatch("SwitchMode",{mode:t})})(e,o)},TA=Tt.each,BA=Tt.explode,DA={f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},PA=Tt.makeMap("alt,ctrl,shift,meta,access"),LA=e=>{const t={},n=Nt.os.isMacOS()||Nt.os.isiOS();TA(BA(e.toLowerCase(),"+"),(e=>{(e=>e in PA)(e)?t[e]=!0:/^[0-9]{2,}$/.test(e)?t.keyCode=parseInt(e,10):(t.charCode=e.charCodeAt(0),t.keyCode=DA[e]||e.toUpperCase().charCodeAt(0))}));const o=[t.keyCode];let r;for(r in PA)t[r]?o.push(r):t[r]=!1;return t.id=o.join(","),t.access&&(t.alt=!0,n?t.ctrl=!0:t.shift=!0),t.meta&&(n?t.meta=!0:(t.ctrl=!0,t.meta=!1)),t};class MA{constructor(e){this.shortcuts={},this.pendingPatterns=[],this.editor=e;const t=this;e.on("keyup keypress keydown",(e=>{!t.hasModifier(e)&&!t.isFunctionKey(e)||e.isDefaultPrevented()||(TA(t.shortcuts,(n=>{t.matchShortcut(e,n)&&(t.pendingPatterns=n.subpatterns.slice(0),"keydown"===e.type&&t.executeShortcutAction(n))})),t.matchShortcut(e,t.pendingPatterns[0])&&(1===t.pendingPatterns.length&&"keydown"===e.type&&t.executeShortcutAction(t.pendingPatterns[0]),t.pendingPatterns.shift()))}))}add(e,t,n,o){const r=this,s=r.normalizeCommandFunc(n);return TA(BA(Tt.trim(e)),(e=>{const n=r.createShortcut(e,t,s,o);r.shortcuts[n.id]=n})),!0}remove(e){const t=this.createShortcut(e);return!!this.shortcuts[t.id]&&(delete this.shortcuts[t.id],!0)}normalizeCommandFunc(e){const t=this,n=e;return"string"==typeof n?()=>{t.editor.execCommand(n,!1,null)}:Tt.isArray(n)?()=>{t.editor.execCommand(n[0],n[1],n[2])}:n}createShortcut(e,t,n,o){const r=Tt.map(BA(e,">"),LA);return r[r.length-1]=Tt.extend(r[r.length-1],{func:n,scope:o||this.editor}),Tt.extend(r[0],{desc:this.editor.translate(t),subpatterns:r.slice(1)})}hasModifier(e){return e.altKey||e.ctrlKey||e.metaKey}isFunctionKey(e){return"keydown"===e.type&&e.keyCode>=112&&e.keyCode<=123}matchShortcut(e,t){return!!t&&t.ctrl===e.ctrlKey&&t.meta===e.metaKey&&t.alt===e.altKey&&t.shift===e.shiftKey&&!!(e.keyCode===t.keyCode||e.charCode&&e.charCode===t.charCode)&&(e.preventDefault(),!0)}executeShortcutAction(e){return e.func?e.func.call(e.scope):null}}const IA=()=>{const e=(()=>{const e={},t={},n={},o={},r={},s={},a={},i={},l=(e,t)=>(n,o)=>{e[n.toLowerCase()]={...o,type:t}};return{addButton:l(e,"button"),addGroupToolbarButton:l(e,"grouptoolbarbutton"),addToggleButton:l(e,"togglebutton"),addMenuButton:l(e,"menubutton"),addSplitButton:l(e,"splitbutton"),addMenuItem:l(t,"menuitem"),addNestedMenuItem:l(t,"nestedmenuitem"),addToggleMenuItem:l(t,"togglemenuitem"),addAutocompleter:l(n,"autocompleter"),addContextMenu:l(r,"contextmenu"),addContextToolbar:l(s,"contexttoolbar"),addContextForm:l(s,"contextform"),addSidebar:l(a,"sidebar"),addView:l(i,"views"),addIcon:(e,t)=>o[e.toLowerCase()]=t,getAll:()=>({buttons:e,menuItems:t,icons:o,popups:n,contextMenus:r,contextToolbars:s,sidebars:a,views:i})}})();return{addAutocompleter:e.addAutocompleter,addButton:e.addButton,addContextForm:e.addContextForm,addContextMenu:e.addContextMenu,addContextToolbar:e.addContextToolbar,addIcon:e.addIcon,addMenuButton:e.addMenuButton,addMenuItem:e.addMenuItem,addNestedMenuItem:e.addNestedMenuItem,addSidebar:e.addSidebar,addSplitButton:e.addSplitButton,addToggleButton:e.addToggleButton,addGroupToolbarButton:e.addGroupToolbarButton,addToggleMenuItem:e.addToggleMenuItem,addView:e.addView,getAll:e.getAll}},FA=ba.DOM,UA=Tt.extend,zA=Tt.each;class jA{constructor(e,t,n){this.plugins={},this.contentCSS=[],this.contentStyles=[],this.loadedCSS={},this.isNotDirty=!1,this.composing=!1,this.destroyed=!1,this.hasHiddenInput=!1,this.iframeElement=null,this.initialized=!1,this.readonly=!1,this.removed=!1,this.startContent="",this._pendingNativeEvents=[],this._skinLoaded=!1,this.editorManager=n,this.documentBaseUrl=n.documentBaseURL,UA(this,SA);const o=this;this.id=e,this.hidden=!1;const r=((e,t)=>qR(FR||UR,FR,t,e,t))(n.defaultOptions,t);this.options=((e,t)=>{const n={},o={},r=(e,t,n)=>{const r=RA(t,n);return NA(r)?(o[e]=r.value,!0):(console.warn(EA(`Invalid value passed for the ${e} option`,r)),!1)},s=e=>xe(n,e);return{register:(e,s)=>{const a=(e=>m(e.processor))(s)?(e=>{const t=(()=>{switch(e){case"array":return p;case"boolean":return b;case"function":return w;case"number":return x;case"object":return f;case"string":return m;case"string[]":return _A;case"object[]":return e=>k(e,f);case"regexp":return e=>u(e,RegExp);default:return L}})();return n=>RA(n,t,`The value must be a ${e}.`)})(s.processor):s.processor,i=((e,t,n)=>{if(!v(t)){const o=RA(t,n);if(NA(o))return o.value;console.error(EA(`Invalid default value passed for the "${e}" option`,o))}})(e,s.default,a);n[e]={...s,default:i,processor:a},we(o,e).orThunk((()=>we(t,e))).each((t=>r(e,t,a)))},isRegistered:s,get:e=>we(o,e).orThunk((()=>we(n,e).map((e=>e.default)))).getOrUndefined(),set:(e,t)=>{if(s(e)){const o=n[e];return o.immutable?(console.error(`"${e}" is an immutable option and cannot be updated`),!1):r(e,t,o.processor)}return console.warn(`"${e}" is not a registered option. Ensure the option has been registered before setting a value.`),!1},unset:e=>{const t=s(e);return t&&delete o[e],t},isSet:e=>xe(o,e)}})(0,r),(e=>{const t=e.options.register;t("id",{processor:"string",default:e.id}),t("selector",{processor:"string"}),t("target",{processor:"object"}),t("suffix",{processor:"string"}),t("cache_suffix",{processor:"string"}),t("base_url",{processor:"string"}),t("referrer_policy",{processor:"string",default:""}),t("language_load",{processor:"boolean",default:!0}),t("inline",{processor:"boolean",default:!1}),t("iframe_attrs",{processor:"object",default:{}}),t("doctype",{processor:"string",default:"<!DOCTYPE html>"}),t("document_base_url",{processor:"string",default:e.documentBaseUrl}),t("body_id",{processor:al(e,"tinymce"),default:"tinymce"}),t("body_class",{processor:al(e),default:""}),t("content_security_policy",{processor:"string",default:""}),t("br_in_pre",{processor:"boolean",default:!0}),t("forced_root_block",{processor:e=>{const t=m(e)&&We(e);return t?{value:e,valid:t}:{valid:!1,message:"Must be a non-empty string."}},default:"p"}),t("forced_root_block_attrs",{processor:"object",default:{}}),t("newline_behavior",{processor:e=>{const t=j(["block","linebreak","invert","default"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: block, linebreak, invert or default."}},default:"default"}),t("br_newline_selector",{processor:"string",default:".mce-toc h2,figcaption,caption"}),t("no_newline_selector",{processor:"string",default:""}),t("keep_styles",{processor:"boolean",default:!0}),t("end_container_on_empty_block",{processor:e=>b(e)||m(e)?{valid:!0,value:e}:{valid:!1,message:"Must be boolean or a string"},default:"blockquote"}),t("font_size_style_values",{processor:"string",default:"xx-small,x-small,small,medium,large,x-large,xx-large"}),t("font_size_legacy_values",{processor:"string",default:"xx-small,small,medium,large,x-large,xx-large,300%"}),t("font_size_classes",{processor:"string",default:""}),t("automatic_uploads",{processor:"boolean",default:!0}),t("images_reuse_filename",{processor:"boolean",default:!1}),t("images_replace_blob_uris",{processor:"boolean",default:!0}),t("icons",{processor:"string",default:""}),t("icons_url",{processor:"string",default:""}),t("images_upload_url",{processor:"string",default:""}),t("images_upload_base_path",{processor:"string",default:""}),t("images_upload_credentials",{processor:"boolean",default:!1}),t("images_upload_handler",{processor:"function"}),t("language",{processor:"string",default:"en"}),t("language_url",{processor:"string",default:""}),t("entity_encoding",{processor:"string",default:"named"}),t("indent",{processor:"boolean",default:!0}),t("indent_before",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist"}),t("indent_after",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist"}),t("indent_use_margin",{processor:"boolean",default:!1}),t("indentation",{processor:"string",default:"40px"}),t("content_css",{processor:e=>{const t=!1===e||m(e)||k(e,m);return t?m(e)?{value:$(e.split(","),$e),valid:t}:p(e)?{value:e,valid:t}:!1===e?{value:[],valid:t}:{value:e,valid:t}:{valid:!1,message:"Must be false, a string or an array of strings."}},default:nd(e)?[]:["default"]}),t("content_style",{processor:"string"}),t("content_css_cors",{processor:"boolean",default:!1}),t("font_css",{processor:e=>{const t=m(e)||k(e,m);return t?{value:p(e)?e:$(e.split(","),$e),valid:t}:{valid:!1,message:"Must be a string or an array of strings."}},default:[]}),t("inline_boundaries",{processor:"boolean",default:!0}),t("inline_boundaries_selector",{processor:"string",default:"a[href],code,span.mce-annotation"}),t("object_resizing",{processor:e=>{const t=b(e)||m(e);return t?!1===e||el.isiPhone()||el.isiPad()?{value:"",valid:t}:{value:!0===e?"table,img,figure.image,div,video,iframe":e,valid:t}:{valid:!1,message:"Must be boolean or a string"}},default:!tl}),t("resize_img_proportional",{processor:"boolean",default:!0}),t("event_root",{processor:"object"}),t("service_message",{processor:"string"}),t("theme",{processor:e=>!1===e||m(e)||w(e),default:"silver"}),t("theme_url",{processor:"string"}),t("formats",{processor:"object"}),t("format_empty_lines",{processor:"boolean",default:!1}),t("format_noneditable_selector",{processor:"string",default:""}),t("preview_styles",{processor:e=>{const t=!1===e||m(e);return t?{value:!1===e?"":e,valid:t}:{valid:!1,message:"Must be false or a string"}},default:"font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow"}),t("custom_ui_selector",{processor:"string",default:""}),t("hidden_input",{processor:"boolean",default:!0}),t("submit_patch",{processor:"boolean",default:!0}),t("encoding",{processor:"string"}),t("add_form_submit_trigger",{processor:"boolean",default:!0}),t("add_unload_trigger",{processor:"boolean",default:!0}),t("custom_undo_redo_levels",{processor:"number",default:0}),t("disable_nodechange",{processor:"boolean",default:!1}),t("readonly",{processor:"boolean",default:!1}),t("plugins",{processor:"string[]",default:[]}),t("external_plugins",{processor:"object"}),t("forced_plugins",{processor:"string[]"}),t("model",{processor:"string",default:e.hasPlugin("rtc")?"plugin":"dom"}),t("model_url",{processor:"string"}),t("block_unsupported_drop",{processor:"boolean",default:!0}),t("visual",{processor:"boolean",default:!0}),t("visual_table_class",{processor:"string",default:"mce-item-table"}),t("visual_anchor_class",{processor:"string",default:"mce-item-anchor"}),t("iframe_aria_text",{processor:"string",default:"Rich Text Area. Press ALT-0 for help."}),t("setup",{processor:"function"}),t("init_instance_callback",{processor:"function"}),t("url_converter",{processor:"function",default:e.convertURL}),t("url_converter_scope",{processor:"object",default:e}),t("urlconverter_callback",{processor:"function"}),t("allow_conditional_comments",{processor:"boolean",default:!1}),t("allow_html_data_urls",{processor:"boolean",default:!1}),t("allow_svg_data_urls",{processor:"boolean"}),t("allow_html_in_named_anchor",{processor:"boolean",default:!1}),t("allow_script_urls",{processor:"boolean",default:!1}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("convert_fonts_to_spans",{processor:"boolean",default:!0,deprecated:!0}),t("fix_list_elements",{processor:"boolean",default:!1}),t("preserve_cdata",{processor:"boolean",default:!1}),t("remove_trailing_brs",{processor:"boolean"}),t("inline_styles",{processor:"boolean",default:!0,deprecated:!0}),t("element_format",{processor:"string",default:"html"}),t("entities",{processor:"string"}),t("schema",{processor:"string",default:"html5"}),t("convert_urls",{processor:"boolean",default:!0}),t("relative_urls",{processor:"boolean",default:!0}),t("remove_script_host",{processor:"boolean",default:!0}),t("custom_elements",{processor:"string"}),t("extended_valid_elements",{processor:"string"}),t("invalid_elements",{processor:"string"}),t("invalid_styles",{processor:sl}),t("valid_children",{processor:"string"}),t("valid_classes",{processor:sl}),t("valid_elements",{processor:"string"}),t("valid_styles",{processor:sl}),t("verify_html",{processor:"boolean",default:!0}),t("auto_focus",{processor:e=>m(e)||!0===e}),t("browser_spellcheck",{processor:"boolean",default:!1}),t("protect",{processor:"array"}),t("images_file_types",{processor:"string",default:"jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp"}),t("deprecation_warnings",{processor:"boolean",default:!0}),t("a11y_advanced_options",{processor:"boolean",default:!1}),t("api_key",{processor:"string"}),t("paste_block_drop",{processor:"boolean",default:!1}),t("paste_data_images",{processor:"boolean",default:!0}),t("paste_preprocess",{processor:"function"}),t("paste_postprocess",{processor:"function"}),t("paste_webkit_styles",{processor:"string",default:"none"}),t("paste_remove_styles_if_webkit",{processor:"boolean",default:!0}),t("paste_merge_formats",{processor:"boolean",default:!0}),t("smart_paste",{processor:"boolean",default:!0}),t("paste_as_text",{processor:"boolean",default:!1}),t("paste_tab_spaces",{processor:"number",default:4}),t("text_patterns",{processor:e=>k(e,f)||!1===e?{value:Zi(!1===e?[]:e),valid:!0}:{valid:!1,message:"Must be an array of objects or false."},default:[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}]}),t("text_patterns_lookup",{processor:e=>{return w(e)?{value:(t=e,e=>{const n=t(e);return Zi(n)}),valid:!0}:{valid:!1,message:"Must be a single function"};var t},default:e=>[]}),t("noneditable_class",{processor:"string",default:"mceNonEditable"}),t("editable_class",{processor:"string",default:"mceEditable"}),t("noneditable_regexp",{processor:e=>k(e,ol)?{value:e,valid:!0}:ol(e)?{value:[e],valid:!0}:{valid:!1,message:"Must be a RegExp or an array of RegExp."},default:[]}),t("table_tab_navigation",{processor:"boolean",default:!0}),e.on("ScriptsLoaded",(()=>{t("directionality",{processor:"string",default:Sa.isRtl()?"rtl":void 0}),t("placeholder",{processor:"string",default:nl.getAttrib(e.getElement(),"placeholder")})}))})(o);const s=this.options.get;s("deprecation_warnings")&&((e,t)=>{((e,t)=>{const n=fC(e),o=gC(t),r=o.length>0,s=n.length>0,a="mobile"===t.theme;if(r||s||a){const e="\n- ",t=a?`\n\nThemes:${e}mobile`:"",i=r?`\n\nPlugins:${e}${o.join(e)}`:"",l=s?`\n\nOptions:${e}${n.join(e)}`:"";console.warn("The following deprecated features are currently enabled and have been removed in TinyMCE 6.0. These features will no longer work and should be removed from the TinyMCE configuration. See https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/ for more information."+t+i+l)}})(e,t)})(t,r);const a=s("suffix");a&&(n.suffix=a),this.suffix=n.suffix;const i=s("base_url");i&&n._setBaseUrl(i),this.baseUri=n.baseURI;const l=Tl(o);l&&(ya.ScriptLoader._setReferrerPolicy(l),ba.DOM.styleSheetLoader._setReferrerPolicy(l));const d=cd(o);C(d)&&ba.DOM.styleSheetLoader._setContentCssCors(d),_a.languageLoad=s("language_load"),_a.baseURL=n.baseURL,this.setDirty(!1),this.documentBaseURI=new uy(dl(o),{base_uri:this.baseUri}),this.baseURI=this.baseUri,this.inline=nd(o),this.hasVisual=gd(o),this.shortcuts=new MA(this),this.editorCommands=new iA(this),rA(this);const c=s("cache_suffix");c&&(Nt.cacheSuffix=c.replace(/^[\?\&]+/,"")),this.ui={registry:IA(),styleSheetLoader:void 0,show:S,hide:S,setEnabled:S,isEnabled:L},this.mode=(e=>{const t=Ca("design"),n=Ca({design:{activate:S,deactivate:S,editorReadOnly:!1},readonly:{activate:S,deactivate:S,editorReadOnly:!0}});return(e=>{e.serializer?fA(e):e.on("PreInit",(()=>{fA(e)}))})(e),(e=>{e.on("ShowCaret",(t=>{mA(e)&&t.preventDefault()})),e.on("ObjectSelected",(t=>{mA(e)&&t.preventDefault()}))})(e),{isReadOnly:()=>mA(e),set:o=>((e,t,n,o)=>{if(o!==n.get()){if(!xe(t,o))throw new Error(`Editor mode '${o}' is invalid`);e.initialized?OA(e,n,t,o):e.on("init",(()=>OA(e,n,t,o)))}})(e,n.get(),t,o),get:()=>t.get(),register:(e,t)=>{n.set(((e,t,n)=>{if(j(AA,t))throw new Error(`Cannot override default mode ${t}`);return{...e,[t]:{...n,deactivate:()=>{try{n.deactivate()}catch(e){console.error(`problem while deactivating editor mode ${t}:`,e)}}}}})(n.get(),e,t))}}})(o),n.dispatch("SetupEditor",{editor:this});const g=vd(o);w(g)&&g.call(o,o)}render(){(e=>{const t=e.id;Sa.setCode(Bl(e));const n=()=>{DR.unbind(window,"ready",n),e.render()};if(!ia.Event.domLoaded)return void DR.bind(window,"ready",n);if(!e.getElement())return;const o=mn(e.getElement()),r=Xt(o);e.on("remove",(()=>{q(o.dom.attributes,(e=>Yt(o,e.name))),qt(o,r)})),e.ui.styleSheetLoader=((e,t)=>ws.forElement(e,{contentCssCors:cd(t),referrerPolicy:Tl(t)}))(o,e),nd(e)?e.inline=!0:(e.orgVisibility=e.getElement().style.visibility,e.getElement().style.visibility="hidden");const s=e.getElement().form||DR.getParent(t,"form");s&&(e.formElement=s,od(e)&&!Uo(e.getElement())&&(DR.insertAfter(DR.create("input",{type:"hidden",name:t}),t),e.hasHiddenInput=!0),e.formEventDelegate=t=>{e.dispatch(t.type,t)},DR.bind(s,"submit reset",e.formEventDelegate),e.on("reset",(()=>{e.resetContent()})),!rd(e)||s.submit.nodeType||s.submit.length||s._mceOldSubmit||(s._mceOldSubmit=s.submit,s.submit=()=>(e.editorManager.triggerSave(),e.setDirty(!1),s._mceOldSubmit(s)))),e.windowManager=RC(e),e.notificationManager=_C(e),(e=>"xml"===e.options.get("encoding"))(e)&&e.on("GetContent",(e=>{e.save&&(e.content=DR.encode(e.content))})),sd(e)&&e.on("submit",(()=>{e.initialized&&e.save()})),ad(e)&&(e._beforeUnload=()=>{!e.initialized||e.destroyed||e.isHidden()||e.save({format:"raw",no_events:!0,set_dirty:!1})},e.editorManager.on("BeforeUnload",e._beforeUnload)),e.editorManager.add(e),MR(e,e.suffix)})(this)}focus(e){this.execCommand("mceFocus",!1,e)}hasFocus(){return Zf(this)}translate(e){return Sa.translate(e)}getParam(e,t,n){const o=this.options;return o.isRegistered(e)||(C(n)?o.register(e,{processor:n,default:t}):o.register(e,{processor:L,default:t})),o.isSet(e)||v(t)?o.get(e):t}hasPlugin(e,t){return!(!j(ud(this),e)||t&&void 0===EC.get(e))}nodeChanged(e){this._nodeChangeDispatcher.nodeChanged(e)}addCommand(e,t,n){this.editorCommands.addCommand(e,t,n)}addQueryStateHandler(e,t,n){this.editorCommands.addQueryStateHandler(e,t,n)}addQueryValueHandler(e,t,n){this.editorCommands.addQueryValueHandler(e,t,n)}addShortcut(e,t,n,o){this.shortcuts.add(e,t,n,o)}execCommand(e,t,n,o){return this.editorCommands.execCommand(e,t,n,o)}queryCommandState(e){return this.editorCommands.queryCommandState(e)}queryCommandValue(e){return this.editorCommands.queryCommandValue(e)}queryCommandSupported(e){return this.editorCommands.queryCommandSupported(e)}show(){const e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable="true":(FA.show(e.getContainer()),FA.hide(e.id)),e.load(),e.dispatch("show"))}hide(){const e=this;e.hidden||(e.save(),e.inline?(e.getBody().contentEditable="false",e===e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(FA.hide(e.getContainer()),FA.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.dispatch("hide"))}isHidden(){return this.hidden}setProgressState(e,t){this.dispatch("ProgressState",{state:e,time:t})}load(e={}){const t=this,n=t.getElement();if(t.removed)return"";if(n){const o={...e,load:!0},r=Uo(n)?n.value:n.innerHTML,s=t.setContent(r,o);return o.no_events||t.dispatch("LoadContent",{...o,element:n}),s}return""}save(e={}){const t=this;let n=t.getElement();if(!n||!t.initialized||t.removed)return"";const o={...e,save:!0,element:n};let r=t.getContent(o);const s={...o,content:r};if(s.no_events||t.dispatch("SaveContent",s),"raw"===s.format&&t.dispatch("RawSaveContent",s),r=s.content,Uo(n))n.value=r;else{!e.is_removing&&t.inline||(n.innerHTML=r);const o=FA.getParent(t.id,"form");o&&zA(o.elements,(e=>e.name!==t.id||(e.value=r,!1)))}return s.element=o.element=n=null,!1!==s.set_dirty&&t.setDirty(!1),r}setContent(e,t){return cC(this,e,t)}getContent(e){return((e,t={})=>{const n=((e,t)=>({...e,format:t,get:!0,getInner:!0}))(t,t.format?t.format:"html");return wy(e,n).fold(R,(t=>{const n=((e,t)=>Zy(e).editor.getContent(t))(e,t);return xy(e,n,t)}))})(this,e)}insertContent(e,t){t&&(e=UA({content:e},t)),this.execCommand("mceInsertContent",!1,e)}resetContent(e){void 0===e?cC(this,this.startContent,{format:"raw"}):cC(this,e),this.undoManager.reset(),this.setDirty(!1),this.nodeChanged()}isDirty(){return!this.isNotDirty}setDirty(e){const t=!this.isNotDirty;this.isNotDirty=!e,e&&e!==t&&this.dispatch("dirty")}getContainer(){const e=this;return e.container||(e.container=e.editorContainer||FA.get(e.id+"_parent")),e.container}getContentAreaContainer(){return this.contentAreaContainer}getElement(){return this.targetElm||(this.targetElm=FA.get(this.id)),this.targetElm}getWin(){const e=this;if(!e.contentWindow){const t=e.iframeElement;t&&(e.contentWindow=t.contentWindow)}return e.contentWindow}getDoc(){const e=this;if(!e.contentDocument){const t=e.getWin();t&&(e.contentDocument=t.document)}return e.contentDocument}getBody(){var e,t;const n=this.getDoc();return null!==(t=null!==(e=this.bodyElement)&&void 0!==e?e:null==n?void 0:n.body)&&void 0!==t?t:null}convertURL(e,t,n){const o=this,r=o.options.get,s=Cd(o);return w(s)?s.call(o,e,n,!0,t):!r("convert_urls")||"link"===n||f(n)&&"LINK"===n.nodeName||0===e.indexOf("file:")||0===e.length?e:r("relative_urls")?o.documentBaseURI.toRelative(e):e=o.documentBaseURI.toAbsolute(e,r("remove_script_host"))}addVisual(e){((e,t)=>{((e,t)=>{eC(e).editor.addVisual(t)})(e,t)})(this,e)}remove(){(e=>{if(!e.removed){const{_selectionOverrides:t,editorUpload:n}=e,o=e.getBody(),r=e.getElement();o&&e.save({is_removing:!0}),e.removed=!0,e.unbindAllNativeEvents(),e.hasHiddenInput&&C(null==r?void 0:r.nextSibling)&&pC.remove(r.nextSibling),(e=>{e.dispatch("remove")})(e),e.editorManager.remove(e),!e.inline&&o&&(e=>{pC.setStyle(e.id,"display",e.orgDisplay)})(e),(e=>{e.dispatch("detach")})(e),pC.remove(e.getContainer()),hC(t),hC(n),e.destroy()}})(this)}destroy(e){((e,t)=>{const{selection:n,dom:o}=e;e.destroyed||(t||e.removed?(t||(e.editorManager.off("beforeunload",e._beforeUnload),e.theme&&e.theme.destroy&&e.theme.destroy(),hC(n),hC(o)),(e=>{const t=e.formElement;t&&(t._mceOldSubmit&&(t.submit=t._mceOldSubmit,delete t._mceOldSubmit),pC.unbind(t,"submit reset",e.formEventDelegate))})(e),(e=>{const t=e;t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null;const n=e.selection;if(n){const e=n.dom;t.selection=n.win=n.dom=e.doc=null}})(e),e.destroyed=!0):e.remove())})(this,e)}uploadImages(){return this.editorUpload.uploadImages()}_scanForImages(){return this.editorUpload.scanForImages()}}const HA=ba.DOM,$A=Tt.each;let VA,qA=!1,WA=[];const KA=e=>{const t=e.type;$A(QA.get(),(n=>{switch(t){case"scroll":n.dispatch("ScrollWindow",e);break;case"resize":n.dispatch("ResizeWindow",e)}}))},GA=e=>{if(e!==qA){const t=ba.DOM;e?(t.bind(window,"resize",KA),t.bind(window,"scroll",KA)):(t.unbind(window,"resize",KA),t.unbind(window,"scroll",KA)),qA=e}},YA=e=>{const t=WA;return WA=K(WA,(t=>e!==t)),QA.activeEditor===e&&(QA.activeEditor=WA.length>0?WA[0]:null),QA.focusedEditor===e&&(QA.focusedEditor=null),t.length!==WA.length},XA="CSS1Compat"!==document.compatMode,QA={...vA,baseURI:null,baseURL:null,defaultOptions:{},documentBaseURL:null,suffix:null,majorVersion:"6",minorVersion:"3.1",releaseDate:"2022-12-06",i18n:Sa,activeEditor:null,focusedEditor:null,setup(){const e=this;let t="",n="",o=uy.getDocumentBaseUrl(document.location);/^[^:]+:\/\/\/?[^\/]+\//.test(o)&&(o=o.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(o)||(o+="/"));const r=window.tinymce||window.tinyMCEPreInit;if(r)t=r.base||r.baseURL,n=r.suffix;else{const e=document.getElementsByTagName("script");for(let o=0;o<e.length;o++){const r=e[o].src||"";if(""===r)continue;const s=r.substring(r.lastIndexOf("/"));if(/tinymce(\.full|\.jquery|)(\.min|\.dev|)\.js/.test(r)){-1!==s.indexOf(".min")&&(n=".min"),t=r.substring(0,r.lastIndexOf("/"));break}}if(!t&&document.currentScript){const e=document.currentScript.src;-1!==e.indexOf(".min")&&(n=".min"),t=e.substring(0,e.lastIndexOf("/"))}}var s;e.baseURL=new uy(o).toAbsolute(t),e.documentBaseURL=o,e.baseURI=new uy(e.baseURL),e.suffix=n,(s=e).on("AddEditor",O(Yf,s)),s.on("RemoveEditor",O(Xf,s))},overrideDefaults(e){const t=e.base_url;t&&this._setBaseUrl(t);const n=e.suffix;n&&(this.suffix=n),this.defaultOptions=e;const o=e.plugin_base_urls;void 0!==o&&fe(o,((e,t)=>{_a.PluginManager.urls[t]=e}))},init(e){const t=this;let n;const o=Tt.makeMap("area base basefont br col frame hr img input isindex link meta param embed source wbr track colgroup option table tbody tfoot thead tr th td script noscript style textarea video audio iframe object menu"," ");let r=e=>{n=e};const s=()=>{let n=0;const a=[];let i;HA.unbind(window,"ready",s),(n=>{const o=e.onpageload;o&&o.apply(t,[])})(),i=((e,t)=>{const n=[],o=w(t)?e=>H(n,(n=>t(n,e))):e=>j(n,e);for(let t=0,r=e.length;t<r;t++){const r=e[t];o(r)||n.push(r)}return n})((e=>Nt.browser.isIE()||Nt.browser.isEdge()?(DC("TinyMCE does not support the browser you are using. For a list of supported browsers please see: https://www.tiny.cloud/docs/tinymce/6/support/#supportedwebbrowsers"),[]):XA?(DC("Failed to initialize the editor as the document is not in standards mode. TinyMCE requires standards mode."),[]):m(e.selector)?HA.select(e.selector):C(e.target)?[e.target]:[])(e)),Tt.each(i,(e=>{var n;(n=t.get(e.id))&&n.initialized&&!(n.getContainer()||n.getBody()).parentNode&&(YA(n),n.unbindAllNativeEvents(),n.destroy(!0),n.removed=!0)})),i=Tt.grep(i,(e=>!t.get(e.id))),0===i.length?r([]):$A(i,(s=>{((e,t)=>e.inline&&t.tagName.toLowerCase()in o)(e,s)?DC("Could not initialize inline editor on invalid inline target element",s):((e,o,s)=>{const l=new jA(e,o,t);a.push(l),l.on("init",(()=>{++n===i.length&&r(a)})),l.targetElm=l.targetElm||s,l.render()})((e=>{let t=e.id;return t||(t=we(e,"name").filter((e=>!HA.get(e))).getOrThunk(HA.uniqueId),e.setAttribute("id",t)),t})(s),e,s)}))};return HA.bind(window,"ready",s),new Promise((e=>{n?e(n):r=t=>{e(t)}}))},get(e){return 0===arguments.length?WA.slice(0):m(e)?Q(WA,(t=>t.id===e)).getOr(null):x(e)&&WA[e]?WA[e]:null},add(e){const t=this,n=t.get(e.id);return n===e||(null===n&&WA.push(e),GA(!0),t.activeEditor=e,t.dispatch("AddEditor",{editor:e}),VA||(VA=e=>{const n=t.dispatch("BeforeUnload");if(n.returnValue)return e.preventDefault(),e.returnValue=n.returnValue,n.returnValue},window.addEventListener("beforeunload",VA))),e},createEditor(e,t){return this.add(new jA(e,t,this))},remove(e){const t=this;let n;if(e){if(!m(e))return n=e,h(t.get(n.id))?null:(YA(n)&&t.dispatch("RemoveEditor",{editor:n}),0===WA.length&&window.removeEventListener("beforeunload",VA),n.remove(),GA(WA.length>0),n);$A(HA.select(e),(e=>{n=t.get(e.id),n&&t.remove(n)}))}else for(let e=WA.length-1;e>=0;e--)t.remove(WA[e])},execCommand(e,t,n){var o;const r=this,s=f(n)?null!==(o=n.id)&&void 0!==o?o:n.index:n;switch(e){case"mceAddEditor":if(!r.get(s)){const e=n.options;new jA(s,e,r).render()}return!0;case"mceRemoveEditor":{const e=r.get(s);return e&&e.remove(),!0}case"mceToggleEditor":{const e=r.get(s);return e?(e.isHidden()?e.show():e.hide(),!0):(r.execCommand("mceAddEditor",!1,n),!0)}}return!!r.activeEditor&&r.activeEditor.execCommand(e,t,n)},triggerSave:()=>{$A(WA,(e=>{e.save()}))},addI18n:(e,t)=>{Sa.add(e,t)},translate:e=>Sa.translate(e),setActive(e){const t=this.activeEditor;this.activeEditor!==e&&(t&&t.dispatch("deactivate",{relatedTarget:e}),e.dispatch("activate",{relatedTarget:t})),this.activeEditor=e},_setBaseUrl(e){this.baseURL=new uy(this.documentBaseURL).toAbsolute(e.replace(/\/+$/,"")),this.baseURI=new uy(this.baseURL)}};QA.setup();const JA=(()=>{const e=Na();return{FakeClipboardItem:e=>({items:e,types:ue(e),getType:t=>we(e,t).getOrUndefined()}),write:t=>{e.set(t)},read:()=>e.get().getOrUndefined(),clear:e.clear}})(),ZA=Math.min,eO=Math.max,tO=Math.round,nO=(e,t,n)=>{let o=t.x,r=t.y;const s=e.w,a=e.h,i=t.w,l=t.h,d=(n||"").split("");return"b"===d[0]&&(r+=l),"r"===d[1]&&(o+=i),"c"===d[0]&&(r+=tO(l/2)),"c"===d[1]&&(o+=tO(i/2)),"b"===d[3]&&(r-=a),"r"===d[4]&&(o-=s),"c"===d[3]&&(r-=tO(a/2)),"c"===d[4]&&(o-=tO(s/2)),oO(o,r,s,a)},oO=(e,t,n,o)=>({x:e,y:t,w:n,h:o}),rO={inflate:(e,t,n)=>oO(e.x-t,e.y-n,e.w+2*t,e.h+2*n),relativePosition:nO,findBestRelativePosition:(e,t,n,o)=>{for(let r=0;r<o.length;r++){const s=nO(e,t,o[r]);if(s.x>=n.x&&s.x+s.w<=n.w+n.x&&s.y>=n.y&&s.y+s.h<=n.h+n.y)return o[r]}return null},intersect:(e,t)=>{const n=eO(e.x,t.x),o=eO(e.y,t.y),r=ZA(e.x+e.w,t.x+t.w),s=ZA(e.y+e.h,t.y+t.h);return r-n<0||s-o<0?null:oO(n,o,r-n,s-o)},clamp:(e,t,n)=>{let o=e.x,r=e.y,s=e.x+e.w,a=e.y+e.h;const i=t.x+t.w,l=t.y+t.h,d=eO(0,t.x-o),c=eO(0,t.y-r),u=eO(0,s-i),m=eO(0,a-l);return o+=d,r+=c,n&&(s+=d,a+=c,o-=u,r-=m),s-=u,a-=m,oO(o,r,s-o,a-r)},create:oO,fromClientRect:e=>oO(e.left,e.top,e.width,e.height)},sO=(()=>{const e={},t={};return{load:(n,o)=>{const r=`Script at URL "${o}" failed to load`,s=`Script at URL "${o}" did not call \`tinymce.Resource.add('${n}', data)\` within 1 second`;if(void 0!==e[n])return e[n];{const a=new Promise(((e,a)=>{const i=((e,t,n=1e3)=>{let o=!1,r=null;const s=e=>(...t)=>{o||(o=!0,null!==r&&(clearTimeout(r),r=null),e.apply(null,t))},a=s(e),i=s(t);return{start:(...e)=>{o||null!==r||(r=setTimeout((()=>i.apply(null,e)),n))},resolve:a,reject:i}})(e,a);t[n]=i.resolve,ya.ScriptLoader.loadScript(o).then((()=>i.start(s)),(()=>i.reject(r)))}));return e[n]=a,a}},add:(n,o)=>{void 0!==t[n]&&(t[n](o),delete t[n]),e[n]=Promise.resolve(o)},unload:t=>{delete e[t]}}})();let aO;try{const e="__storage_test__";aO=window.localStorage,aO.setItem(e,e),aO.removeItem(e)}catch(e){aO=(()=>{let e={},t=[];const n={getItem:t=>e[t]||null,setItem:(n,o)=>{t.push(n),e[n]=String(o)},key:e=>t[e],removeItem:n=>{t=t.filter((e=>e===n)),delete e[n]},clear:()=>{t=[],e={}},length:0};return Object.defineProperty(n,"length",{get:()=>t.length,configurable:!1,enumerable:!1}),n})()}const iO={geom:{Rect:rO},util:{Delay:qf,Tools:Tt,VK:Dm,URI:uy,EventDispatcher:hA,Observable:vA,I18n:Sa,LocalStorage:aO,ImageUploader:e=>{const t=IC(),n=jC(e,t);return{upload:(t,o=!0)=>n.upload(t,o?zC(e):void 0)}}},dom:{EventUtils:ia,TreeWalker:Ro,TextSeeker:Ka,DOMUtils:ba,ScriptLoader:ya,RangeUtils:mf,Serializer:dC,StyleSheetLoader:Cs,ControlSelection:Fm,BookmarkManager:_m,Selection:aC,Event:ia.Event},html:{Styles:Js,Entities:Fs,Node:pg,Schema:Qs,DomParser:yy,Writer:Sg,Serializer:_g},Env:Nt,AddOnManager:_a,Annotator:Sm,Formatter:ZC,UndoManager:tw,EditorCommands:iA,WindowManager:RC,NotificationManager:_C,EditorObservable:SA,Shortcuts:MA,Editor:jA,FocusManager:Vf,EditorManager:QA,DOM:ba.DOM,ScriptLoader:ya.ScriptLoader,PluginManager:EC,ThemeManager:NC,ModelManager:vC,IconManager:bC,Resource:sO,FakeClipboard:JA,trim:Tt.trim,isArray:Tt.isArray,is:Tt.is,toArray:Tt.toArray,makeMap:Tt.makeMap,each:Tt.each,map:Tt.map,grep:Tt.grep,inArray:Tt.inArray,extend:Tt.extend,walk:Tt.walk,resolve:Tt.resolve,explode:Tt.explode,_addCacheSuffix:Tt._addCacheSuffix},lO=Tt.extend(QA,iO);(e=>{window.tinymce=e,window.tinyMCE=e})(lO),(e=>{if("object"==typeof module)try{module.exports=e}catch(e){}})(lO)}();
(function() {
  var configureSentryTags, initSentry;

  initSentry = function() {
    Sentry.init({
      dsn: "https://4c06c24120f6e8c66a4709432103af77@o4507097233817600.ingest.us.sentry.io/4507097236504576",
      release: window.finalforms.version(),
      environment: window.finalforms.environment,
      integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()],
      tracesSampleRate: 1.0,
      tracePropagationTargets: [/^https:\/\/finalforms\.me/, /^https:\/\/*.finalforms\.com/],
      replaysSessionSampleRate: 0.01,
      replaysOnErrorSampleRate: 0.1,
      enableInp: true,
      enabled: window.finalforms.environment === "production"
    });
    configureSentryTags();
    return $(window).on("zoom:page:done", function() {
      return configureSentryTags();
    });
  };

  configureSentryTags = function() {
    Sentry.setUser({
      id: window.finalforms.identity.sentryUserId
    });
    Sentry.setTag("state", window.finalforms.identity.state);
    Sentry.setTag("role", window.finalforms.identity.role);
    Sentry.setTag("subdomain", window.finalforms.database.subdomain);
    return Sentry.setTag("release", window.finalforms.version());
  };

  window.sentryOnLoad = function() {
    return initSentry();
  };

}).call(this);
tinymce.IconManager.add("default",{icons:{"accessibility-check":'<svg width="24" height="24"><path d="M12 2a2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2c0-1.1.9-2 2-2Zm8 7h-5v12c0 .6-.4 1-1 1a1 1 0 0 1-1-1v-5c0-.6-.4-1-1-1a1 1 0 0 0-1 1v5c0 .6-.4 1-1 1a1 1 0 0 1-1-1V9H4a1 1 0 1 1 0-2h16c.6 0 1 .4 1 1s-.4 1-1 1Z" fill-rule="nonzero"/></svg>',"action-next":'<svg width="24" height="24"><path fill-rule="nonzero" d="M5.7 7.3a1 1 0 0 0-1.4 1.4l7.7 7.7 7.7-7.7a1 1 0 1 0-1.4-1.4L12 13.6 5.7 7.3Z"/></svg>',"action-prev":'<svg width="24" height="24"><path fill-rule="nonzero" d="M18.3 15.7a1 1 0 0 0 1.4-1.4L12 6.6l-7.7 7.7a1 1 0 0 0 1.4 1.4L12 9.4l6.3 6.3Z"/></svg>',addtag:'<svg width="24" height="24"><path fill-rule="evenodd" clip-rule="evenodd" d="M15 5a2 2 0 0 1 1.6.8L21 12l-4.4 6.2a2 2 0 0 1-1.6.8h-3v-2h3l3.5-5L15 7H5v3H3V7c0-1.1.9-2 2-2h10Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M6 12a1 1 0 0 0-1 1v2H3a1 1 0 1 0 0 2h2v2a1 1 0 1 0 2 0v-2h2a1 1 0 1 0 0-2H7v-2c0-.6-.4-1-1-1Z"/></svg>',"align-center":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm3 4h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2Zm-3-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',"align-justify":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',"align-left":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',"align-none":'<svg width="24" height="24"><path d="M14.2 5 13 7H5a1 1 0 1 1 0-2h9.2Zm4 0h.8a1 1 0 0 1 0 2h-2l1.2-2Zm-6.4 4-1.2 2H5a1 1 0 0 1 0-2h6.8Zm4 0H19a1 1 0 0 1 0 2h-4.4l1.2-2Zm-6.4 4-1.2 2H5a1 1 0 0 1 0-2h4.4Zm4 0H19a1 1 0 0 1 0 2h-6.8l1.2-2ZM7 17l-1.2 2H5a1 1 0 0 1 0-2h2Zm4 0h8a1 1 0 0 1 0 2H9.8l1.2-2Zm5.2-13.5 1.3.7-9.7 16.3-1.3-.7 9.7-16.3Z" fill-rule="evenodd"/></svg>',"align-right":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm6 4h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm-6-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',"arrow-left":'<svg width="24" height="24"><path d="m5.6 13 12 6a1 1 0 0 0 1.4-1V6a1 1 0 0 0-1.4-.9l-12 6a1 1 0 0 0 0 1.8Z" fill-rule="evenodd"/></svg>',"arrow-right":'<svg width="24" height="24"><path d="m18.5 13-12 6A1 1 0 0 1 5 18V6a1 1 0 0 1 1.4-.9l12 6a1 1 0 0 1 0 1.8Z" fill-rule="evenodd"/></svg>',bold:'<svg width="24" height="24"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"/></svg>',bookmark:'<svg width="24" height="24"><path d="M6 4v17l6-4 6 4V4c0-.6-.4-1-1-1H7a1 1 0 0 0-1 1Z" fill-rule="nonzero"/></svg>',"border-style":'<svg width="24" height="24"><g fill-rule="evenodd"><rect width="18" height="2" x="3" y="6" rx="1"/><rect width="2.8" height="2" x="3" y="16" rx="1"/><rect width="2.8" height="2" x="6.8" y="16" rx="1"/><rect width="2.8" height="2" x="10.6" y="16" rx="1"/><rect width="2.8" height="2" x="14.4" y="16" rx="1"/><rect width="2.8" height="2" x="18.2" y="16" rx="1"/><rect width="8" height="2" x="3" y="11" rx="1"/><rect width="8" height="2" x="13" y="11" rx="1"/></g></svg>',"border-width":'<svg width="24" height="24"><g fill-rule="evenodd"><rect width="18" height="5" x="3" y="5" rx="1"/><rect width="18" height="3.5" x="3" y="11.5" rx="1"/><rect width="18" height="2" x="3" y="17" rx="1"/></g></svg>',brightness:'<svg width="24" height="24"><path d="M12 17c.3 0 .5.1.7.3.2.2.3.4.3.7v1c0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7v-1c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3Zm0-10a1 1 0 0 1-.7-.3A1 1 0 0 1 11 6V5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3.3 0 .5.1.7.3.2.2.3.4.3.7v1c0 .3-.1.5-.3.7a1 1 0 0 1-.7.3Zm7 4c.3 0 .5.1.7.3.2.2.3.4.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3h-1a1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h1ZM7 12c0 .3-.1.5-.3.7a1 1 0 0 1-.7.3H5a1 1 0 0 1-.7-.3A1 1 0 0 1 4 12c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h1c.3 0 .5.1.7.3.2.2.3.4.3.7Zm10 3.5.7.8c.2.1.3.4.3.6 0 .3-.1.6-.3.8a1 1 0 0 1-.8.3 1 1 0 0 1-.6-.3l-.8-.7a1 1 0 0 1-.3-.8c0-.2.1-.5.3-.7a1 1 0 0 1 1.4 0Zm-10-7-.7-.8a1 1 0 0 1-.3-.6c0-.3.1-.6.3-.8.2-.2.5-.3.8-.3.2 0 .5.1.7.3l.7.7c.2.2.3.5.3.8 0 .2-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.8-.3Zm10 0a1 1 0 0 1-.8.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.3.1-.6.3-.8l.8-.7c.1-.2.4-.3.6-.3.3 0 .6.1.8.3.2.2.3.5.3.8 0 .2-.1.5-.3.7l-.7.7Zm-10 7c.2-.2.5-.3.8-.3.2 0 .5.1.7.3a1 1 0 0 1 0 1.4l-.8.8a1 1 0 0 1-.6.3 1 1 0 0 1-.8-.3 1 1 0 0 1-.3-.8c0-.2.1-.5.3-.6l.7-.8ZM12 8a4 4 0 0 1 3.7 2.4 4 4 0 0 1 0 3.2A4 4 0 0 1 12 16a4 4 0 0 1-3.7-2.4 4 4 0 0 1 0-3.2A4 4 0 0 1 12 8Zm0 6.5c.7 0 1.3-.2 1.8-.7.5-.5.7-1.1.7-1.8s-.2-1.3-.7-1.8c-.5-.5-1.1-.7-1.8-.7s-1.3.2-1.8.7c-.5.5-.7 1.1-.7 1.8s.2 1.3.7 1.8c.5.5 1.1.7 1.8.7Z" fill-rule="evenodd"/></svg>',browse:'<svg width="24" height="24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-4v-2h4V8H5v10h4v2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 9.4-2.3 2.3a1 1 0 1 1-1.4-1.4l4-4a1 1 0 0 1 1.4 0l4 4a1 1 0 0 1-1.4 1.4L13 13.4V20a1 1 0 0 1-2 0v-6.6Z" fill-rule="nonzero"/></svg>',cancel:'<svg width="24" height="24"><path d="M12 4.6a7.4 7.4 0 1 1 0 14.8 7.4 7.4 0 0 1 0-14.8ZM12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 8L14.8 8l1 1.1-2.7 2.8 2.7 2.7-1.1 1.1-2.7-2.7-2.7 2.7-1-1.1 2.6-2.7-2.7-2.7 1-1.1 2.8 2.7Z" fill-rule="nonzero"/></svg>',"cell-background-color":'<svg width="24" height="24"><path d="m15.7 2 1.6 1.6-2.7 2.6 5.9 5.8c.7.7.7 1.7 0 2.4l-6.3 6.1a1.7 1.7 0 0 1-2.4 0l-6.3-6.1c-.7-.7-.7-1.7 0-2.4L15.7 2ZM18 12l-4.5-4L9 12h9ZM4 16s2 2.4 2 3.8C6 21 5.1 22 4 22s-2-1-2-2.2C2 18.4 4 16 4 16Z"/></svg>',"cell-border-color":'<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M5 13v5h2v2H5a2 2 0 0 1-2-2v-5h2zm8-7V4h6a2 2 0 0 1 2 2h-8z" opacity=".2"/><path fill-rule="nonzero" d="M13 4v2H5v7H3V6c0-1.1.9-2 2-2h8zm-2.6 14.1.1-.1.1.1.2.3.2.2.2.2c.4.6.8 1.2.8 1.7 0 .8-.7 1.5-1.5 1.5S9 21.3 9 20.5c0-.5.4-1.1.8-1.7l.2-.2.2-.2.2-.3z"/><path d="m13 11-2 2H5v-2h6V6h2z"/><path fill-rule="nonzero" d="m18.4 8 1 1-1.8 1.9 4 4c.5.4.5 1.1 0 1.6l-4.3 4.2a1.2 1.2 0 0 1-1.6 0l-4.4-4.2c-.4-.5-.4-1.2 0-1.7l7-6.8Zm1.6 7-3-3-3 3h6Z"/></g></svg>',"change-case":'<svg width="24" height="24"><path d="M18.4 18.2v-.6c-.5.8-1.3 1.2-2.4 1.2-2.2 0-3.3-1.6-3.3-4.8 0-3.1 1-4.7 3.3-4.7 1.1 0 1.8.3 2.4 1.1v-.6c0-.5.4-.8.8-.8s.8.3.8.8v8.4c0 .5-.4.8-.8.8a.8.8 0 0 1-.8-.8zm-2-7.4c-1.3 0-1.8.9-1.8 3.2 0 2.4.5 3.3 1.7 3.3 1.3 0 1.8-.9 1.8-3.2 0-2.4-.5-3.3-1.7-3.3zM10 15.7H5.5l-.8 2.6a1 1 0 0 1-1 .7h-.2a.7.7 0 0 1-.7-1l4-12a1 1 0 0 1 2 0l4 12a.7.7 0 0 1-.8 1h-.2a1 1 0 0 1-1-.7l-.8-2.6zm-.3-1.5-2-6.5-1.9 6.5h3.9z" fill-rule="evenodd"/></svg>',"character-count":'<svg width="24" height="24"><path d="M4 11.5h16v1H4v-1Zm4.8-6.8V10H7.7V5.8h-1v-1h2ZM11 8.3V9h2v1h-3V7.7l2-1v-.9h-2v-1h3v2.4l-2 1Zm6.3-3.4V10h-3.1V9h2.1V8h-2.1V6.8h2.1v-1h-2.1v-1h3.1ZM5.8 16.4c0-.5.2-.8.5-1 .2-.2.6-.3 1.2-.3l.8.1c.2 0 .4.2.5.3l.4.4v2.8l.2.3H8.2V18.7l-.6.3H7c-.4 0-.7 0-1-.2a1 1 0 0 1-.3-.9c0-.3 0-.6.3-.8.3-.2.7-.4 1.2-.4l.6-.2h.3v-.2l-.1-.2a.8.8 0 0 0-.5-.1 1 1 0 0 0-.4 0l-.3.4h-1Zm2.3.8h-.2l-.2.1-.4.1a1 1 0 0 0-.4.2l-.2.2.1.3.5.1h.4l.4-.4v-.6Zm2-3.4h1.2v1.7l.5-.3h.5c.5 0 .9.1 1.2.5.3.4.5.8.5 1.4 0 .6-.2 1.1-.5 1.5-.3.4-.7.6-1.3.6l-.6-.1-.4-.4v.4h-1.1v-5.4Zm1.1 3.3c0 .3 0 .6.2.8a.7.7 0 0 0 1.2 0l.2-.8c0-.4 0-.6-.2-.8a.7.7 0 0 0-.6-.3l-.6.3-.2.8Zm6.1-.5c0-.2 0-.3-.2-.4a.8.8 0 0 0-.5-.2c-.3 0-.5.1-.6.3l-.2.9c0 .3 0 .6.2.8.1.2.3.3.6.3.2 0 .4 0 .5-.2l.2-.4h1.1c0 .5-.3.8-.6 1.1a2 2 0 0 1-1.3.4c-.5 0-1-.2-1.3-.6a2 2 0 0 1-.5-1.4c0-.6.1-1.1.5-1.5.3-.4.8-.5 1.4-.5.5 0 1 0 1.2.3.4.3.5.7.5 1.2h-1v-.1Z" fill-rule="evenodd"/></svg>',"checklist-rtl":'<svg width="24" height="24"><path d="M5 17h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm14.2 11c.2-.4.6-.5.9-.3.3.2.4.6.2 1L18 20c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 0 1 0-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L18 14c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 0 1 0-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L18 8c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 0 1 0-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8z" fill-rule="evenodd"/></svg>',checklist:'<svg width="24" height="24"><path d="M11 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8a1 1 0 0 1 0 2h-8a1 1 0 0 1 0-2ZM7.2 16c.2-.4.6-.5.9-.3.3.2.4.6.2 1L6 20c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 0 1 0-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8Zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L6 14c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 0 1 0-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8Zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L6 8c-.2.3-.7.4-1 0L3.8 6.9a.7.7 0 0 1 0-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8Z" fill-rule="evenodd"/></svg>',checkmark:'<svg width="24" height="24"><path d="M18.2 5.4a1 1 0 0 1 1.6 1.2l-8 12a1 1 0 0 1-1.5.1l-5-5a1 1 0 1 1 1.4-1.4l4.1 4.1 7.4-11Z" fill-rule="nonzero"/></svg>',"chevron-down":'<svg width="10" height="10"><path d="M8.7 2.2c.3-.3.8-.3 1 0 .4.4.4.9 0 1.2L5.7 7.8c-.3.3-.9.3-1.2 0L.2 3.4a.8.8 0 0 1 0-1.2c.3-.3.8-.3 1.1 0L5 6l3.7-3.8Z" fill-rule="nonzero"/></svg>',"chevron-left":'<svg width="10" height="10"><path d="M7.8 1.3 4 5l3.8 3.7c.3.3.3.8 0 1-.4.4-.9.4-1.2 0L2.2 5.7a.8.8 0 0 1 0-1.2L6.6.2C7 0 7.4 0 7.8.2c.3.3.3.8 0 1.1Z" fill-rule="nonzero"/></svg>',"chevron-right":'<svg width="10" height="10"><path d="M2.2 1.3a.8.8 0 0 1 0-1c.4-.4.9-.4 1.2 0l4.4 4.1c.3.4.3.9 0 1.2L3.4 9.8c-.3.3-.8.3-1.2 0a.8.8 0 0 1 0-1.1L6 5 2.2 1.3Z" fill-rule="nonzero"/></svg>',"chevron-up":'<svg width="10" height="10"><path d="M8.7 7.8 5 4 1.3 7.8c-.3.3-.8.3-1 0a.8.8 0 0 1 0-1.2l4.1-4.4c.3-.3.9-.3 1.2 0l4.2 4.4c.3.3.3.9 0 1.2-.3.3-.8.3-1.1 0Z" fill-rule="nonzero"/></svg>',close:'<svg width="24" height="24"><path d="M17.3 8.2 13.4 12l3.9 3.8a1 1 0 0 1-1.5 1.5L12 13.4l-3.8 3.9a1 1 0 0 1-1.5-1.5l3.9-3.8-3.9-3.8a1 1 0 0 1 1.5-1.5l3.8 3.9 3.8-3.9a1 1 0 0 1 1.5 1.5Z" fill-rule="evenodd"/></svg>',"code-sample":'<svg width="24" height="26"><path d="M7.1 11a2.8 2.8 0 0 1-.8 2 2.8 2.8 0 0 1 .8 2v1.7c0 .3.1.6.4.8.2.3.5.4.8.4.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.7 0-1.4-.3-2-.8-.5-.6-.8-1.3-.8-2V15c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 0 1-.4-.4v-.8c0-.2.2-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V9.3c0-.7.3-1.4.8-2 .6-.5 1.3-.8 2-.8.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8V11Zm9.8 0V9.3c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 0 1-.4-.4V7c0-.2.1-.4.4-.4.7 0 1.4.3 2 .8.5.6.8 1.3.8 2V11c0 .3.1.6.4.8.2.3.5.4.8.4.2 0 .4.2.4.4v.8c0 .2-.2.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8v1.7c0 .7-.3 1.4-.8 2-.6.5-1.3.8-2 .8a.4.4 0 0 1-.4-.4v-.8c0-.2.1-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V15a2.8 2.8 0 0 1 .8-2 2.8 2.8 0 0 1-.8-2Zm-3.3-.4c0 .4-.1.8-.5 1.1-.3.3-.7.5-1.1.5-.4 0-.8-.2-1.1-.5-.4-.3-.5-.7-.5-1.1 0-.5.1-.9.5-1.2.3-.3.7-.4 1.1-.4.4 0 .8.1 1.1.4.4.3.5.7.5 1.2ZM12 13c.4 0 .8.1 1.1.5.4.3.5.7.5 1.1 0 1-.1 1.6-.5 2a3 3 0 0 1-1.1 1c-.4.3-.8.4-1.1.4a.5.5 0 0 1-.5-.5V17a3 3 0 0 0 1-.2l.6-.6c-.6 0-1-.2-1.3-.5-.2-.3-.3-.7-.3-1 0-.5.1-1 .5-1.2.3-.4.7-.5 1.1-.5Z" fill-rule="evenodd"/></svg>',"color-levels":'<svg width="24" height="24"><path d="M17.5 11.4A9 9 0 0 1 18 14c0 .5 0 1-.2 1.4 0 .4-.3.9-.5 1.3a6.2 6.2 0 0 1-3.7 3 5.7 5.7 0 0 1-3.2 0A5.9 5.9 0 0 1 7.6 18a6.2 6.2 0 0 1-1.4-2.6 6.7 6.7 0 0 1 0-2.8c0-.4.1-.9.3-1.3a13.6 13.6 0 0 1 2.3-4A20 20 0 0 1 12 4a26.4 26.4 0 0 1 3.2 3.4 18.2 18.2 0 0 1 2.3 4Zm-2 4.5c.4-.7.5-1.4.5-2a7.3 7.3 0 0 0-1-3.2c.2.6.2 1.2.2 1.9a4.5 4.5 0 0 1-1.3 3 5.3 5.3 0 0 1-2.3 1.5 4.9 4.9 0 0 1-2 .1 4.3 4.3 0 0 0 2.4.8 4 4 0 0 0 2-.6 4 4 0 0 0 1.5-1.5Z" fill-rule="evenodd"/></svg>',"color-picker":'<svg width="24" height="24"><path d="M12 3a9 9 0 0 0 0 18 1.5 1.5 0 0 0 1.1-2.5c-.2-.3-.4-.6-.4-1 0-.8.7-1.5 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Zm-5.5 9a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Zm3-4a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Zm5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Zm3 4a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Z" fill-rule="nonzero"/></svg>',"color-swatch-remove-color":'<svg width="24" height="24"><path stroke="#000" stroke-width="2" d="M21 3 3 21" fill-rule="evenodd"/></svg>',"color-swatch":'<svg width="24" height="24"><rect x="3" y="3" width="18" height="18" rx="1" fill-rule="evenodd"/></svg>',"comment-add":'<svg width="24" height="24"><g fill-rule="nonzero"><path d="m9 19 3-2h7c.6 0 1-.4 1-1V6c0-.6-.4-1-1-1H5a1 1 0 0 0-1 1v10c0 .6.4 1 1 1h4v2Zm-2 4v-4H5a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3h14a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3h-6.4L7 23Z"/><path d="M13 10h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V8a1 1 0 0 1 2 0v2Z"/></g></svg>',comment:'<svg width="24" height="24"><path fill-rule="nonzero" d="m9 19 3-2h7c.6 0 1-.4 1-1V6c0-.6-.4-1-1-1H5a1 1 0 0 0-1 1v10c0 .6.4 1 1 1h4v2Zm-2 4v-4H5a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3h14a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3h-6.4L7 23Z"/></svg>',contrast:'<svg width="24" height="24"><path d="M12 4a7.8 7.8 0 0 1 5.7 2.3A8 8 0 1 1 12 4Zm-6 8a6 6 0 0 0 6 6V6a6 6 0 0 0-6 6Z" fill-rule="evenodd"/></svg>',copy:'<svg width="24" height="24"><path d="M16 3H6a2 2 0 0 0-2 2v11h2V5h10V3Zm1 4a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-7a2 2 0 0 1-2-2V9c0-1.2.9-2 2-2h7Zm0 12V9h-7v10h7Z" fill-rule="nonzero"/></svg>',crop:'<svg width="24" height="24"><path d="M17 8v7h2c.6 0 1 .4 1 1s-.4 1-1 1h-2v2c0 .6-.4 1-1 1a1 1 0 0 1-1-1v-2H7V9H5a1 1 0 1 1 0-2h2V5c0-.6.4-1 1-1s1 .4 1 1v2h7l3-3 1 1-3 3ZM9 9v5l5-5H9Zm1 6h5v-5l-5 5Z" fill-rule="evenodd"/></svg>',"cut-column":'<svg width="24" height="24"><path fill-rule="evenodd" d="M7.2 4.5c.9 0 1.6.4 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7Zm12.3 5h-3v10h3v-10ZM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8Zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4ZM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8A2.5 2.5 0 0 0 7.7 6l-.4-.1H7Z"/></svg>',"cut-row":'<svg width="24" height="24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2 0-.9.4-1.6 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14ZM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18V18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5Zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3ZM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4Zm8.5-7.1h-11v2h11v-2Z"/></svg>',cut:'<svg width="24" height="24"><path d="M18 15c.6.7 1 1.4 1 2.3 0 .8-.2 1.5-.7 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2 0-.9.4-1.6 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l6 6 6-6 .5 1a3.3 3.3 0 0 1 0 2c0 .4-.3.7-.5 1l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8Zm-8.5 2.2.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2 1.6 1.6 0 0 0-.8 0 2.6 2.6 0 0 0-.8.3 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3 2.8 2.8 0 0 0 1-1Zm2.5-2.8c.4 0 .7-.1 1-.4.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4s-.7.1-1 .4c-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4Zm5.4 4 .2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3 1.5 1.5 0 0 0-.8 0 1 1 0 0 0-.4.2 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4l.3.4.3.4a2.8 2.8 0 0 0 .8.5l.4.1h.7l.5-.2Z" fill-rule="evenodd"/></svg>',"document-properties":'<svg width="24" height="24"><path d="M14.4 3H7a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h10a2 2 0 0 0 2-2V7.6L14.4 3ZM17 19H7V5h6v4h4v10Z" fill-rule="nonzero"/></svg>',drag:'<svg width="24" height="24"><path d="M13 5h2v2h-2V5Zm0 4h2v2h-2V9ZM9 9h2v2H9V9Zm4 4h2v2h-2v-2Zm-4 0h2v2H9v-2Zm0 4h2v2H9v-2Zm4 0h2v2h-2v-2ZM9 5h2v2H9V5Z" fill-rule="evenodd"/></svg>',"duplicate-column":'<svg width="24" height="24"><path d="M17 6v16h-7V6h7Zm-2 2h-3v12h3V8Zm-2-6v2H8v15H6V2h7Z"/></svg>',"duplicate-row":'<svg width="24" height="24"><path d="M22 11v7H6v-7h16Zm-2 2H8v3h12v-3Zm-1-6v2H4v5H2V7h17Z"/></svg>',duplicate:'<svg width="24" height="24"><g fill-rule="nonzero"><path d="M16 3v2H6v11H4V5c0-1.1.9-2 2-2h10Zm3 8h-2V9h-7v10h9a2 2 0 0 1-2 2h-7a2 2 0 0 1-2-2V9c0-1.2.9-2 2-2h7a2 2 0 0 1 2 2v2Z"/><path d="M17 14h1a1 1 0 0 1 0 2h-1v1a1 1 0 0 1-2 0v-1h-1a1 1 0 0 1 0-2h1v-1a1 1 0 0 1 2 0v1Z"/></g></svg>',"edit-block":'<svg width="24" height="24"><path fill-rule="nonzero" d="m19.8 8.8-9.4 9.4c-.2.2-.5.4-.9.4l-5.4 1.2 1.2-5.4.5-.8 9.4-9.4c.7-.7 1.8-.7 2.5 0l2.1 2.1c.7.7.7 1.8 0 2.5Zm-2-.2 1-.9v-.3l-2.2-2.2a.3.3 0 0 0-.3 0l-1 1L18 8.5Zm-1 1-2.5-2.4-6 6 2.5 2.5 6-6Zm-7 7.1-2.6-2.4-.3.3-.1.2-.7 3 3.1-.6h.1l.4-.5Z"/></svg>',"edit-image":'<svg width="24" height="24"><path d="M18 16h2V7a2 2 0 0 0-2-2H7v2h11v9ZM6 17h15a1 1 0 0 1 0 2h-1v1a1 1 0 0 1-2 0v-1H6a2 2 0 0 1-2-2V7H3a1 1 0 1 1 0-2h1V4a1 1 0 1 1 2 0v13Zm3-5.3 1.3 2 3-4.7 3.7 6H7l2-3.3Z" fill-rule="nonzero"/></svg>',"embed-page":'<svg width="24" height="24"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"/></svg>',embed:'<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"/></svg>',emoji:'<svg width="24" height="24"><path d="M9 11c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm6 0c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm-3 5.5c2.1 0 4-1.5 4.4-3.5H7.6c.5 2 2.3 3.5 4.4 3.5ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm0 14.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13Z" fill-rule="nonzero"/></svg>',export:'<svg width="24" height="24"><g fill-rule="nonzero"><path d="M14.4 3 18 7v1h-5V5H7v14h9a1 1 0 0 1 2 0c0 1-.8 2-1.9 2H7c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h7.5Z"/><path d="M18.1 12c.5 0 .9.4.9 1 0 .5-.3 1-.8 1h-7.3c-.5 0-.9-.4-.9-1 0-.5.3-1 .8-1h7.3Z"/><path d="M16.4 9.2a1 1 0 0 1 1.4.2l2.4 3.6-2.4 3.6a1 1 0 0 1-1.7-1v-.2l1.7-2.4-1.6-2.4a1 1 0 0 1 .2-1.4Z"/></g></svg>',fill:'<svg width="24" height="26"><path d="m16.6 12-9-9-1.4 1.4 2.4 2.4-5.2 5.1c-.5.6-.5 1.6 0 2.2L9 19.6a1.5 1.5 0 0 0 2.2 0l5.5-5.5c.5-.6.5-1.6 0-2.2ZM5.2 13 10 8.2l4.8 4.8H5.2ZM19 14.5s-2 2.2-2 3.5c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.3-2-3.5-2-3.5Z" fill-rule="nonzero"/></svg>',"flip-horizontally":'<svg width="24" height="24"><path d="M14 19h2v-2h-2v2Zm4-8h2V9h-2v2ZM4 7v10c0 1.1.9 2 2 2h3v-2H6V7h3V5H6a2 2 0 0 0-2 2Zm14-2v2h2a2 2 0 0 0-2-2Zm-7 16h2V3h-2v18Zm7-6h2v-2h-2v2Zm-4-8h2V5h-2v2Zm4 12a2 2 0 0 0 2-2h-2v2Z" fill-rule="nonzero"/></svg>',"flip-vertically":'<svg width="24" height="24"><path d="M5 14v2h2v-2H5Zm8 4v2h2v-2h-2Zm4-14H7a2 2 0 0 0-2 2v3h2V6h10v3h2V6a2 2 0 0 0-2-2Zm2 14h-2v2a2 2 0 0 0 2-2ZM3 11v2h18v-2H3Zm6 7v2h2v-2H9Zm8-4v2h2v-2h-2ZM5 18c0 1.1.9 2 2 2v-2H5Z" fill-rule="nonzero"/></svg>',footnote:'<svg width="24" height="24"><path d="M19 13c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2h14Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19 4v6h-1V5h-1.5V4h2.6Z"/><path d="M12 18c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2h7ZM14 8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2h9Z"/></svg>',"format-painter":'<svg width="24" height="24"><path d="M18 5V4c0-.5-.4-1-1-1H5a1 1 0 0 0-1 1v4c0 .6.5 1 1 1h12c.6 0 1-.4 1-1V7h1v4H9v9c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-7h8V5h-3Z" fill-rule="nonzero"/></svg>',format:'<svg width="24" height="24"><path fill-rule="evenodd" d="M17 5a1 1 0 0 1 0 2h-4v11a1 1 0 0 1-2 0V7H7a1 1 0 1 1 0-2h10Z"/></svg>',fullscreen:'<svg width="24" height="24"><path d="m15.3 10-1.2-1.3 2.9-3h-2.3a.9.9 0 1 1 0-1.7H19c.5 0 .9.4.9.9v4.4a.9.9 0 1 1-1.8 0V7l-2.9 3Zm0 4 3 3v-2.3a.9.9 0 1 1 1.7 0V19c0 .5-.4.9-.9.9h-4.4a.9.9 0 1 1 0-1.8H17l-3-2.9 1.3-1.2ZM10 15.4l-2.9 3h2.3a.9.9 0 1 1 0 1.7H5a.9.9 0 0 1-.9-.9v-4.4a.9.9 0 1 1 1.8 0V17l2.9-3 1.2 1.3ZM8.7 10 5.7 7v2.3a.9.9 0 0 1-1.7 0V5c0-.5.4-.9.9-.9h4.4a.9.9 0 0 1 0 1.8H7l3 2.9-1.3 1.2Z" fill-rule="nonzero"/></svg>',gallery:'<svg width="24" height="24"><path fill-rule="nonzero" d="m5 15.7 2.3-2.2c.3-.3.7-.3 1 0L11 16l5.1-5c.3-.4.8-.4 1 0l2 1.9V8H5v7.7ZM5 18V19h3l1.8-1.9-2-2L5 17.9Zm14-3-2.5-2.4-6.4 6.5H19v-4ZM4 6h16c.6 0 1 .4 1 1v13c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V7c0-.6.4-1 1-1Zm6 7a2 2 0 1 1 0-4 2 2 0 0 1 0 4ZM4.5 4h15a.5.5 0 1 1 0 1h-15a.5.5 0 0 1 0-1Zm2-2h11a.5.5 0 1 1 0 1h-11a.5.5 0 0 1 0-1Z"/></svg>',gamma:'<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm6.5 11.8V14L9.2 8.7a5.1 5.1 0 0 0-.4-.8l-.1-.2H8v-1l.3-.1.3-.1h.7a1 1 0 0 1 .6.5l.1.3a8.5 8.5 0 0 1 .3.6l1.9 4.6 2-5.2a1 1 0 0 1 1-.6.5.5 0 0 1 .5.6L13 14v2.8a.7.7 0 0 1-1.4 0Z" fill-rule="nonzero"/></svg>',help:'<svg width="24" height="24"><g fill-rule="evenodd"><path d="M12 5.5a6.5 6.5 0 0 0-6 9 6.3 6.3 0 0 0 1.4 2l1 1a6.3 6.3 0 0 0 3.6 1 6.5 6.5 0 0 0 6-9 6.3 6.3 0 0 0-1.4-2l-1-1a6.3 6.3 0 0 0-3.6-1ZM12 4a7.8 7.8 0 0 1 5.7 2.3A8 8 0 1 1 12 4Z"/><path d="M9.6 9.7a.7.7 0 0 1-.7-.8c0-1.1 1.5-1.8 3.2-1.8 1.8 0 3.2.8 3.2 2.4 0 1.4-.4 2.1-1.5 2.8-.2 0-.3.1-.3.2a2 2 0 0 0-.8.8.8.8 0 0 1-1.4-.6c.3-.7.8-1 1.3-1.5l.4-.2c.7-.4.8-.6.8-1.5 0-.5-.6-.9-1.7-.9-.5 0-1 .1-1.4.3-.2 0-.3.1-.3.2v-.2c0 .4-.4.8-.8.8Z" fill-rule="nonzero"/><circle cx="12" cy="16" r="1"/></g></svg>',"highlight-bg-color":'<svg width="24" height="24"><g fill-rule="evenodd"><path id="tox-icon-highlight-bg-color__color" d="M3 18h18v3H3z"/><path fill-rule="nonzero" d="M7.7 16.7H3l3.3-3.3-.7-.8L10.2 8l4 4.1-4 4.2c-.2.2-.6.2-.8 0l-.6-.7-1.1 1.1zm5-7.5L11 7.4l3-2.9a2 2 0 0 1 2.6 0L18 6c.7.7.7 2 0 2.7l-2.9 2.9-1.8-1.8-.5-.6"/></g></svg>',home:'<svg width="24" height="24"><path fill-rule="nonzero" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>',"horizontal-rule":'<svg width="24" height="24"><path d="M4 11h16v2H4z" fill-rule="evenodd"/></svg>',"image-options":'<svg width="24" height="24"><path d="M6 10a2 2 0 0 0-2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2 2 2 0 0 0-2-2Zm12 0a2 2 0 0 0-2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2 2 2 0 0 0-2-2Zm-6 0a2 2 0 0 0-2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2 2 2 0 0 0-2-2Z" fill-rule="nonzero"/></svg>',image:'<svg width="24" height="24"><path d="m5 15.7 3.3-3.2c.3-.3.7-.3 1 0L12 15l4.1-4c.3-.4.8-.4 1 0l2 1.9V5H5v10.7ZM5 18V19h3l2.8-2.9-2-2L5 17.9Zm14-3-2.5-2.4-6.4 6.5H19v-4ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm6 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" fill-rule="nonzero"/></svg>',indent:'<svg width="24" height="24"><path d="M7 5h12c.6 0 1 .4 1 1s-.4 1-1 1H7a1 1 0 1 1 0-2Zm5 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 0 1 0-2Zm0 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 0 1 0-2Zm-5 4h12a1 1 0 0 1 0 2H7a1 1 0 0 1 0-2Zm-2.6-3.8L6.2 12l-1.8-1.2a1 1 0 0 1 1.2-1.6l3 2a1 1 0 0 1 0 1.6l-3 2a1 1 0 1 1-1.2-1.6Z" fill-rule="evenodd"/></svg>',info:'<svg width="24" height="24"><path d="M12 4a7.8 7.8 0 0 1 5.7 2.3A8 8 0 1 1 12 4Zm-1 3v2h2V7h-2Zm3 10v-1h-1v-5h-3v1h1v4h-1v1h4Z" fill-rule="evenodd"/></svg>',"insert-character":'<svg width="24" height="24"><path d="M15 18h4l1-2v4h-6v-3.3l1.4-1a6 6 0 0 0 1.8-2.9 6.3 6.3 0 0 0-.1-4.1 5.8 5.8 0 0 0-3-3.2c-.6-.3-1.3-.5-2.1-.5a5.1 5.1 0 0 0-3.9 1.8 6.3 6.3 0 0 0-1.3 6 6.2 6.2 0 0 0 1.8 3l1.4.9V20H4v-4l1 2h4v-.5l-2-1L5.4 15A6.5 6.5 0 0 1 4 11c0-1 .2-1.9.6-2.7A7 7 0 0 1 6.3 6C7.1 5.4 8 5 9 4.5c1-.3 2-.5 3.1-.5a8.8 8.8 0 0 1 5.7 2 7 7 0 0 1 1.7 2.3 6 6 0 0 1 .2 4.8c-.2.7-.6 1.3-1 1.9a7.6 7.6 0 0 1-3.6 2.5v.5Z" fill-rule="evenodd"/></svg>',"insert-time":'<svg width="24" height="24"><g fill-rule="nonzero"><path d="M12 19a7 7 0 1 0 0-14 7 7 0 0 0 0 14Zm0 2a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"/><path d="M16 12h-3V7c0-.6-.4-1-1-1a1 1 0 0 0-1 1v7h5c.6 0 1-.4 1-1s-.4-1-1-1Z"/></g></svg>',invert:'<svg width="24" height="24"><path d="M18 19.3 16.5 18a5.8 5.8 0 0 1-3.1 1.9 6.1 6.1 0 0 1-5.5-1.6A5.8 5.8 0 0 1 6 14v-.3l.1-1.2A13.9 13.9 0 0 1 7.7 9l-3-3 .7-.8 2.8 2.9 9 8.9 1.5 1.6-.7.6Zm0-5.5v.3l-.1 1.1-.4 1-1.2-1.2a4.3 4.3 0 0 0 .2-1v-.2c0-.4 0-.8-.2-1.3l-.5-1.4a14.8 14.8 0 0 0-3-4.2L12 6a26.1 26.1 0 0 0-2.2 2.5l-1-1a20.9 20.9 0 0 1 2.9-3.3L12 4l1 .8a22.2 22.2 0 0 1 4 5.4c.6 1.2 1 2.4 1 3.6Z" fill-rule="evenodd"/></svg>',italic:'<svg width="24" height="24"><path d="m16.7 4.7-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"/></svg>',language:'<svg width="24" height="24"><path d="M12 3a9 9 0 1 1 0 18 9 9 0 0 1 0-18Zm4.3 13.3c-.5 1-1.2 2-2 2.9a7.5 7.5 0 0 0 3.2-2.1l-.2-.2a6 6 0 0 0-1-.6Zm-8.6 0c-.5.2-.9.5-1.2.8.9 1 2 1.7 3.2 2a10 10 0 0 1-2-2.8Zm3.6-.8c-.8 0-1.6.1-2.2.3.5 1 1.2 1.9 2.1 2.7Zm1.5 0v3c.9-.8 1.6-1.7 2.1-2.7-.6-.2-1.4-.3-2.1-.3Zm-6-2.7H4.5c.2 1 .5 2.1 1 3h.3l1.3-1a10 10 0 0 1-.3-2Zm12.7 0h-2.3c0 .7-.1 1.4-.3 2l1.6 1.1c.5-1 .9-2 1-3.1Zm-3.8 0h-3V14c1 0 2 .1 2.7.4.2-.5.3-1 .3-1.6Zm-4.4 0h-3l.3 1.6c.8-.3 1.7-.4 2.7-.4v-1.3Zm-5.5-5c-.7 1-1.1 2.2-1.3 3.5h2.3c0-1 .2-1.8.5-2.6l-1.5-1Zm2.9 1.4v.1c-.2.6-.4 1.3-.4 2h3V9.4c-1 0-1.8-.1-2.6-.3Zm6.6 0h-.1l-2.4.3v1.8h3l-.5-2.1Zm3-1.4-.3.1-1.3.8c.3.8.5 1.6.5 2.6h2.3a7.5 7.5 0 0 0-1.3-3.5Zm-9 0 2 .2V5.5a9 9 0 0 0-2 2.2Zm3.5-2.3V8c.6 0 1.3 0 1.9-.2a9 9 0 0 0-2-2.3Zm-3-.7h-.1c-1.1.4-2.1 1-3 1.8l1.2.7a10 10 0 0 1 1.9-2.5Zm4.4 0 .1.1a10 10 0 0 1 1.8 2.4l1.1-.7a7.5 7.5 0 0 0-3-1.8Z"/></svg>',"line-height":'<svg width="24" height="24"><path d="M21 5a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zm0 4a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zm0 4a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zm0 4a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zM7 3.6l3.7 3.7a1 1 0 0 1-1.3 1.5h-.1L8 7.3v9.2l1.3-1.3a1 1 0 0 1 1.3 0h.1c.4.4.4 1 0 1.3v.1L7 20.4l-3.7-3.7a1 1 0 0 1 1.3-1.5h.1L6 16.7V7.4L4.7 8.7a1 1 0 0 1-1.3 0h-.1a1 1 0 0 1 0-1.3v-.1L7 3.6z"/></svg>',line:'<svg width="24" height="24"><path d="m15 9-8 8H4v-3l8-8 3 3Zm1-1-3-3 1-1h1c-.2 0 0 0 0 0l2 2s0 .2 0 0v1l-1 1ZM4 18h16v2H4v-2Z" fill-rule="evenodd"/></svg>',link:'<svg width="24" height="24"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"/></svg>',"list-bull-circle":'<svg width="48" height="48"><g fill-rule="evenodd"><path d="M11 16a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm0 1a3 3 0 1 1 0-6 3 3 0 0 1 0 6ZM11 26a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm0 1a3 3 0 1 1 0-6 3 3 0 0 1 0 6ZM11 36a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm0 1a3 3 0 1 1 0-6 3 3 0 0 1 0 6Z" fill-rule="nonzero"/><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/></g></svg>',"list-bull-default":'<svg width="48" height="48"><g fill-rule="evenodd"><circle cx="11" cy="14" r="3"/><circle cx="11" cy="24" r="3"/><circle cx="11" cy="34" r="3"/><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/></g></svg>',"list-bull-square":'<svg width="48" height="48"><g fill-rule="evenodd"><path d="M8 11h6v6H8zM8 21h6v6H8zM8 31h6v6H8z"/><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/></g></svg>',"list-num-default-rtl":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M37.4 17v-4.8h-.1l-1.5 1v-1.1l1.6-1.1h1.2v6zM33.3 17.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm1.7 5.7c0-1.2 1-2 2.2-2 1.3 0 2.1.8 2.1 1.8 0 .7-.3 1.2-1.3 2.2l-1.2 1v.2h2.6v1h-4.3v-.9l2-1.9c.8-.8 1-1.1 1-1.5 0-.5-.4-.8-1-.8-.5 0-.9.3-.9.9H35zm-1.7 4.3c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm3.2 7.3v-1h.7c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7s-1 .3-1 .8H35c0-1.1 1-1.8 2.2-1.8 1.2 0 2.1.6 2.1 1.6 0 .7-.4 1.2-1 1.3v.1c.7.1 1.3.7 1.3 1.4 0 1-1 1.9-2.4 1.9-1.3 0-2.2-.8-2.3-2h1.2c0 .6.5 1 1.1 1 .6 0 1-.4 1-1 0-.5-.3-.8-1-.8h-.7zm-3.3 2.7c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7z"/></g></svg>',"list-num-default":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M10 17v-4.8l-1.5 1v-1.1l1.6-1h1.2V17h-1.2Zm3.6.1c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7Zm-5 5.7c0-1.2.8-2 2.1-2s2.1.8 2.1 1.8c0 .7-.3 1.2-1.4 2.2l-1.1 1v.2h2.6v1H8.6v-.9l2-1.9c.8-.8 1-1.1 1-1.5 0-.5-.4-.8-1-.8-.5 0-.9.3-.9.9H8.5Zm6.3 4.3c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7ZM10 34.4v-1h.7c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7s-1 .3-1 .8H8.6c0-1.1 1-1.8 2.2-1.8 1.3 0 2.1.6 2.1 1.6 0 .7-.4 1.2-1 1.3v.1c.8.1 1.3.7 1.3 1.4 0 1-1 1.9-2.4 1.9-1.3 0-2.2-.8-2.3-2h1.2c0 .6.5 1 1.1 1 .7 0 1-.4 1-1 0-.5-.3-.8-1-.8h-.7Zm4.7 2.7c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7Z"/></g></svg>',"list-num-lower-alpha-rtl":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M36.5 16c-.9 0-1.5-.5-1.5-1.3s.6-1.3 1.8-1.4h1v-.4c0-.4-.2-.6-.7-.6-.4 0-.7.1-.8.4h-1.1c0-.8.8-1.4 2-1.4S39 12 39 13V16h-1.2v-.6c-.3.4-.8.7-1.4.7Zm.4-.8c.6 0 1-.4 1-.9V14h-1c-.5.1-.7.3-.7.6 0 .4.3.6.7.6ZM33.1 16.1c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7ZM37.7 26c-.7 0-1.2-.2-1.5-.7v.7H35v-6.3h1.2v2.5c.3-.5.8-.9 1.5-.9 1.1 0 1.8 1 1.8 2.4 0 1.5-.7 2.4-1.8 2.4Zm-.5-3.6c-.6 0-1 .5-1 1.3s.4 1.4 1 1.4c.7 0 1-.6 1-1.4 0-.8-.3-1.3-1-1.3ZM33.2 26.1c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7zm6 7h-1c-.1-.5-.4-.8-1-.8s-1 .5-1 1.4c0 1 .4 1.4 1 1.4.5 0 .9-.2 1-.7h1c0 1-.8 1.7-2 1.7-1.4 0-2.2-.9-2.2-2.4s.8-2.4 2.2-2.4c1.2 0 2 .7 2 1.7zm-6.1 3c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7z"/></g></svg>',"list-num-lower-alpha":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M10.3 15.2c.5 0 1-.4 1-.9V14h-1c-.5.1-.8.3-.8.6 0 .4.3.6.8.6Zm-.4.9c-1 0-1.5-.6-1.5-1.4 0-.8.6-1.3 1.7-1.4h1.1v-.4c0-.4-.2-.6-.7-.6-.5 0-.8.1-.9.4h-1c0-.8.8-1.4 2-1.4 1.1 0 1.8.6 1.8 1.6V16h-1.1v-.6h-.1c-.2.4-.7.7-1.3.7Zm4.6 0c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Zm-3.2 10c-.6 0-1.2-.3-1.4-.8v.7H8.5v-6.3H10v2.5c.3-.5.8-.9 1.4-.9 1.2 0 1.9 1 1.9 2.4 0 1.5-.7 2.4-1.9 2.4Zm-.4-3.7c-.7 0-1 .5-1 1.3s.3 1.4 1 1.4c.6 0 1-.6 1-1.4 0-.8-.4-1.3-1-1.3Zm4 3.7c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Zm-2.2 7h-1.2c0-.5-.4-.8-.9-.8-.6 0-1 .5-1 1.4 0 1 .4 1.4 1 1.4.5 0 .8-.2 1-.7h1c0 1-.8 1.7-2 1.7-1.4 0-2.2-.9-2.2-2.4s.8-2.4 2.2-2.4c1.2 0 2 .7 2 1.7Zm1.8 3c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Z"/></g></svg>',"list-num-lower-greek-rtl":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M37.4 16c-1.2 0-2-.8-2-2.3 0-1.5.8-2.4 2-2.4.6 0 1 .4 1.3 1v-.9H40v3.2c0 .4.1.5.4.5h.2v.9h-.6c-.6 0-1-.2-1-.7h-.2c-.2.4-.7.8-1.3.8Zm.3-1c.6 0 1-.5 1-1.3s-.4-1.3-1-1.3-1 .5-1 1.3.4 1.4 1 1.4ZM33.3 16.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7ZM36 21.9c0-1.5.8-2.3 2.1-2.3 1.2 0 2 .6 2 1.6 0 .6-.3 1-.9 1.3.9.3 1.3.8 1.3 1.7 0 1.2-.7 1.9-1.8 1.9-.6 0-1.1-.3-1.4-.8v2.2H36V22Zm1.8 1.2v-1h.3c.5 0 .9-.2.9-.7 0-.5-.3-.8-.9-.8-.5 0-.8.3-.8 1v2.2c0 .8.4 1.3 1 1.3s1-.4 1-1-.4-1-1.2-1h-.3ZM33.3 26.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7ZM37.1 34.6 34.8 30h1.4l1.7 3.5 1.7-3.5h1.1l-2.2 4.6v.1c.5.8.7 1.4.7 1.8 0 .4-.2.8-.4 1-.2.2-.6.3-1 .3-.9 0-1.3-.4-1.3-1.2 0-.5.2-1 .5-1.7l.1-.2Zm.7 1a2 2 0 0 0-.4.9c0 .3.1.4.4.4.3 0 .4-.1.4-.4 0-.2-.1-.6-.4-1ZM33.3 36.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Z"/></g></svg>',"list-num-lower-greek":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M10.5 15c.7 0 1-.5 1-1.3s-.3-1.3-1-1.3c-.5 0-.9.5-.9 1.3s.4 1.4 1 1.4Zm-.3 1c-1.1 0-1.8-.8-1.8-2.3 0-1.5.7-2.4 1.8-2.4.7 0 1.1.4 1.3 1h.1v-.9h1.2v3.2c0 .4.1.5.4.5h.2v.9h-.6c-.6 0-1-.2-1.1-.7h-.1c-.2.4-.7.8-1.4.8Zm5 .1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7Zm-4.9 7v-1h.3c.6 0 1-.2 1-.7 0-.5-.4-.8-1-.8-.5 0-.8.3-.8 1v2.2c0 .8.4 1.3 1.1 1.3.6 0 1-.4 1-1s-.5-1-1.3-1h-.3ZM8.6 22c0-1.5.7-2.3 2-2.3 1.2 0 2 .6 2 1.6 0 .6-.3 1-.8 1.3.8.3 1.3.8 1.3 1.7 0 1.2-.8 1.9-1.9 1.9-.6 0-1.1-.3-1.3-.8v2.2H8.5V22Zm6.2 4.2c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7Zm-4.5 8.5L8 30h1.4l1.7 3.5 1.7-3.5h1.1l-2.2 4.6v.1c.5.8.7 1.4.7 1.8 0 .4-.1.8-.4 1-.2.2-.6.3-1 .3-.9 0-1.3-.4-1.3-1.2 0-.5.2-1 .5-1.7l.1-.2Zm.7 1a2 2 0 0 0-.4.9c0 .3.1.4.4.4.3 0 .4-.1.4-.4 0-.2-.1-.6-.4-1Zm4.5.5c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Z"/></g></svg>',"list-num-lower-roman-rtl":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M32.9 16v-1.2h-1.3V16H33Zm0 10v-1.2h-1.3V26H33Zm0 10v-1.2h-1.3V36H33Z"/><path fill-rule="nonzero" d="M36 21h-1.5v5H36zM36 31h-1.5v5H36zM39 21h-1.5v5H39zM39 31h-1.5v5H39zM42 31h-1.5v5H42zM36 11h-1.5v5H36zM36 19h-1.5v1H36zM36 29h-1.5v1H36zM39 19h-1.5v1H39zM39 29h-1.5v1H39zM42 29h-1.5v1H42zM36 9h-1.5v1H36z"/></g></svg>',"list-num-lower-roman":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M15.1 16v-1.2h1.3V16H15Zm0 10v-1.2h1.3V26H15Zm0 10v-1.2h1.3V36H15Z"/><path fill-rule="nonzero" d="M12 21h1.5v5H12zM12 31h1.5v5H12zM9 21h1.5v5H9zM9 31h1.5v5H9zM6 31h1.5v5H6zM12 11h1.5v5H12zM12 19h1.5v1H12zM12 29h1.5v1H12zM9 19h1.5v1H9zM9 29h1.5v1H9zM6 29h1.5v1H6zM12 9h1.5v1H12z"/></g></svg>',"list-num-upper-alpha-rtl":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="m39.3 17-.5-1.4h-2l-.5 1.4H35l2-6h1.6l2 6h-1.3Zm-1.6-4.7-.7 2.3h1.6l-.8-2.3ZM33.4 17c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7Zm4.7 9.9h-2.7v-6H38c1.2 0 1.9.6 1.9 1.5 0 .6-.5 1.2-1 1.3.7.1 1.3.7 1.3 1.5 0 1-.8 1.7-2 1.7Zm-1.4-5v1.5h1c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7h-1Zm0 4h1.1c.7 0 1.1-.3 1.1-.8 0-.6-.4-.9-1.1-.9h-1.1V26ZM33 27.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Zm4.9 10c-1.8 0-2.8-1.1-2.8-3.1s1-3.1 2.8-3.1c1.4 0 2.5.9 2.6 2.2h-1.3c0-.7-.6-1.1-1.3-1.1-1 0-1.6.7-1.6 2s.6 2 1.6 2c.7 0 1.2-.4 1.4-1h1.2c-.1 1.3-1.2 2.2-2.6 2.2Zm-4.5 0c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Z"/></g></svg>',"list-num-upper-alpha":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="m12.6 17-.5-1.4h-2L9.5 17H8.3l2-6H12l2 6h-1.3ZM11 12.3l-.7 2.3h1.6l-.8-2.3Zm4.7 4.8c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7ZM11.4 27H8.7v-6h2.6c1.2 0 1.9.6 1.9 1.5 0 .6-.5 1.2-1 1.3.7.1 1.3.7 1.3 1.5 0 1-.8 1.7-2 1.7ZM10 22v1.5h1c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7h-1Zm0 4H11c.7 0 1.1-.3 1.1-.8 0-.6-.4-.9-1.1-.9H10V26Zm5.4 1.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Zm-4.1 10c-1.8 0-2.8-1.1-2.8-3.1s1-3.1 2.8-3.1c1.4 0 2.5.9 2.6 2.2h-1.3c0-.7-.6-1.1-1.3-1.1-1 0-1.6.7-1.6 2s.6 2 1.6 2c.7 0 1.2-.4 1.4-1h1.2c-.1 1.3-1.2 2.2-2.6 2.2Zm4.5 0c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7Z"/></g></svg>',"list-num-upper-roman-rtl":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M31.6 17v-1.2H33V17h-1.3Zm0 10v-1.2H33V27h-1.3Zm0 10v-1.2H33V37h-1.3Z"/><path fill-rule="nonzero" d="M34.5 20H36v7h-1.5zM34.5 30H36v7h-1.5zM37.5 20H39v7h-1.5zM37.5 30H39v7h-1.5zM40.5 30H42v7h-1.5zM34.5 10H36v7h-1.5z"/></g></svg>',"list-num-upper-roman":'<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M15.1 17v-1.2h1.3V17H15Zm0 10v-1.2h1.3V27H15Zm0 10v-1.2h1.3V37H15Z"/><path fill-rule="nonzero" d="M12 20h1.5v7H12zM12 30h1.5v7H12zM9 20h1.5v7H9zM9 30h1.5v7H9zM6 30h1.5v7H6zM12 10h1.5v7H12z"/></g></svg>',lock:'<svg width="24" height="24"><path d="M16.3 11c.2 0 .3 0 .5.2l.2.6v7.4c0 .3 0 .4-.2.6l-.6.2H7.8c-.3 0-.4 0-.6-.2a.7.7 0 0 1-.2-.6v-7.4c0-.3 0-.4.2-.6l.5-.2H8V8c0-.8.3-1.5.9-2.1.6-.6 1.3-.9 2.1-.9h2c.8 0 1.5.3 2.1.9.6.6.9 1.3.9 2.1v3h.3ZM10 8v3h4V8a1 1 0 0 0-.3-.7A1 1 0 0 0 13 7h-2a1 1 0 0 0-.7.3 1 1 0 0 0-.3.7Z" fill-rule="evenodd"/></svg>',ltr:'<svg width="24" height="24"><path d="M11 5h7a1 1 0 0 1 0 2h-1v11a1 1 0 0 1-2 0V7h-2v11a1 1 0 0 1-2 0v-6c-.5 0-1 0-1.4-.3A3.4 3.4 0 0 1 7.8 10a3.3 3.3 0 0 1 0-2.8 3.4 3.4 0 0 1 1.8-1.8L11 5ZM4.4 16.2 6.2 15l-1.8-1.2a1 1 0 0 1 1.2-1.6l3 2a1 1 0 0 1 0 1.6l-3 2a1 1 0 1 1-1.2-1.6Z" fill-rule="evenodd"/></svg>',"more-drawer":'<svg width="24" height="24"><path d="M6 10a2 2 0 0 0-2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2 2 2 0 0 0-2-2Zm12 0a2 2 0 0 0-2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2 2 2 0 0 0-2-2Zm-6 0a2 2 0 0 0-2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2 2 2 0 0 0-2-2Z" fill-rule="nonzero"/></svg>',"new-document":'<svg width="24" height="24"><path d="M14.4 3H7a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h10a2 2 0 0 0 2-2V7.6L14.4 3ZM17 19H7V5h6v4h4v10Z" fill-rule="nonzero"/></svg>',"new-tab":'<svg width="24" height="24"><path d="m15 13 2-2v8H5V7h8l-2 2H7v8h8v-4Zm4-8v5.5l-2-2-5.6 5.5H10v-1.4L15.5 7l-2-2H19Z" fill-rule="evenodd"/></svg>',"non-breaking":'<svg width="24" height="24"><path d="M11 11H8a1 1 0 1 1 0-2h3V6c0-.6.4-1 1-1s1 .4 1 1v3h3c.6 0 1 .4 1 1s-.4 1-1 1h-3v3c0 .6-.4 1-1 1a1 1 0 0 1-1-1v-3Zm10 4v5H3v-5c0-.6.4-1 1-1s1 .4 1 1v3h14v-3c0-.6.4-1 1-1s1 .4 1 1Z" fill-rule="evenodd"/></svg>',notice:'<svg width="24" height="24"><path d="M15.5 4 20 8.5v7L15.5 20h-7L4 15.5v-7L8.5 4h7ZM13 17v-2h-2v2h2Zm0-4V7h-2v6h2Z" fill-rule="evenodd" clip-rule="evenodd"/></svg>',"ordered-list-rtl":'<svg width="24" height="24"><path d="M6 17h8a1 1 0 0 1 0 2H6a1 1 0 0 1 0-2Zm0-6h8a1 1 0 0 1 0 2H6a1 1 0 0 1 0-2Zm0-6h8a1 1 0 0 1 0 2H6a1 1 0 1 1 0-2Zm13-1v3.5a.5.5 0 1 1-1 0V5h-.5a.5.5 0 1 1 0-1H19Zm-1 8.8.2.2h1.3a.5.5 0 1 1 0 1h-1.6a1 1 0 0 1-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 0 0-.2-.2h-1.3a.5.5 0 0 1-.5-.5c0-.3.2-.5.5-.5h1.6c.5 0 .9.4.9 1v.1c0 .4-.3.8-.6 1l-1.2.4-.2.3Zm2 4.2v2c0 .6-.4 1-1 1h-1.5a.5.5 0 0 1 0-1h1.2a.3.3 0 1 0 0-.6h-1.3a.4.4 0 1 1 0-.8h1.3a.3.3 0 0 0 0-.6h-1.2a.5.5 0 1 1 0-1H19c.6 0 1 .4 1 1Z" fill-rule="evenodd"/></svg>',"ordered-list":'<svg width="24" height="24"><path d="M10 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 1 1 0-2ZM6 4v3.5c0 .3-.2.5-.5.5a.5.5 0 0 1-.5-.5V5h-.5a.5.5 0 0 1 0-1H6Zm-1 8.8.2.2h1.3c.3 0 .5.2.5.5s-.2.5-.5.5H4.9a1 1 0 0 1-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 0 0-.2-.2H4.5a.5.5 0 0 1-.5-.5c0-.3.2-.5.5-.5h1.6c.5 0 .9.4.9 1v.1c0 .4-.3.8-.6 1l-1.2.4-.2.3ZM7 17v2c0 .6-.4 1-1 1H4.5a.5.5 0 0 1 0-1h1.2c.2 0 .3-.1.3-.3 0-.2-.1-.3-.3-.3H4.4a.4.4 0 1 1 0-.8h1.3c.2 0 .3-.1.3-.3 0-.2-.1-.3-.3-.3H4.5a.5.5 0 1 1 0-1H6c.6 0 1 .4 1 1Z" fill-rule="evenodd"/></svg>',orientation:'<svg width="24" height="24"><path d="M7.3 6.4 1 13l6.4 6.5 6.5-6.5-6.5-6.5ZM3.7 13l3.6-3.7L11 13l-3.7 3.7-3.6-3.7ZM12 6l2.8 2.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0L9.2 5.7a.8.8 0 0 1 0-1.2L13.6.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L12 4h1a9 9 0 1 1-4.3 16.9l1.5-1.5A7 7 0 1 0 13 6h-1Z" fill-rule="nonzero"/></svg>',outdent:'<svg width="24" height="24"><path d="M7 5h12c.6 0 1 .4 1 1s-.4 1-1 1H7a1 1 0 1 1 0-2Zm5 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 0 1 0-2Zm0 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 0 1 0-2Zm-5 4h12a1 1 0 0 1 0 2H7a1 1 0 0 1 0-2Zm1.6-3.8a1 1 0 0 1-1.2 1.6l-3-2a1 1 0 0 1 0-1.6l3-2a1 1 0 0 1 1.2 1.6L6.8 12l1.8 1.2Z" fill-rule="evenodd"/></svg>',"page-break":'<svg width="24" height="24"><g fill-rule="evenodd"><path d="M5 11c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 0 1 0-2Zm3 0h1c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2Zm4 0c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 0 1 0-2Zm3 0h1c.6 0 1 .4 1 1s-.4 1-1 1h-1a1 1 0 0 1 0-2Zm4 0c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 0 1 0-2ZM7 3v5h10V3c0-.6.4-1 1-1s1 .4 1 1v7H5V3c0-.6.4-1 1-1s1 .4 1 1ZM6 22a1 1 0 0 1-1-1v-7h14v7c0 .6-.4 1-1 1a1 1 0 0 1-1-1v-5H7v5c0 .6-.4 1-1 1Z"/></g></svg>',paragraph:'<svg width="24" height="24"><path fill-rule="evenodd" d="M10 5h7a1 1 0 0 1 0 2h-1v11a1 1 0 0 1-2 0V7h-2v11a1 1 0 0 1-2 0v-6c-.5 0-1 0-1.4-.3A3.4 3.4 0 0 1 6.8 10a3.3 3.3 0 0 1 0-2.8 3.4 3.4 0 0 1 1.8-1.8L10 5Z"/></svg>',"paste-column-after":'<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2H9.2A3 3 0 0 1 12 1Zm8 7v12h-6V8h6Zm-1.5 1.5h-3v9h3v-9ZM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"/></svg>',"paste-column-before":'<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2H9.2A3 3 0 0 1 12 1Zm-2 7v12H4V8h6ZM8.5 9.5h-3v9h3v-9ZM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"/></svg>',"paste-row-after":'<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2H9.2A3 3 0 0 1 12 1Zm10 11v5H8v-5h14Zm-1.5 1.5h-11v2h11v-2ZM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"/></svg>',"paste-row-before":'<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2H9.2A3 3 0 0 1 12 1Zm10 7v5H8V8h14Zm-1.5 1.5h-11v2h11v-2ZM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"/></svg>',"paste-text":'<svg width="24" height="24"><path d="M18 9V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h3V9h9ZM9 20H6a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.2A3 3 0 0 1 12 1a3 3 0 0 1 2.8 2H18a2 2 0 0 1 2 2v4h1v12H9v-1Zm1.5-9.5v9h9v-9h-9ZM12 3a1 1 0 0 0-1 1c0 .5.4 1 1 1s1-.5 1-1-.4-1-1-1Zm0 9h6v2h-.5l-.5-1h-1v4h.8v1h-3.6v-1h.8v-4h-1l-.5 1H12v-2Z" fill-rule="nonzero"/></svg>',paste:'<svg width="24" height="24"><path d="M18 9V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h3V9h9ZM9 20H6a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.2A3 3 0 0 1 12 1a3 3 0 0 1 2.8 2H18a2 2 0 0 1 2 2v4h1v12H9v-1Zm1.5-9.5v9h9v-9h-9ZM12 3a1 1 0 0 0-1 1c0 .5.4 1 1 1s1-.5 1-1-.4-1-1-1Z" fill-rule="nonzero"/></svg>',"permanent-pen":'<svg width="24" height="24"><path d="M10.5 17.5 8 20H3v-3l3.5-3.5a2 2 0 0 1 0-3L14 3l1 1-7.3 7.3a1 1 0 0 0 0 1.4l3.6 3.6c.4.4 1 .4 1.4 0L20 9l1 1-7.6 7.6a2 2 0 0 1-2.8 0l-.1-.1Z" fill-rule="nonzero"/></svg>',plus:'<svg width="24" height="24"><path d="M12 4c.5 0 1 .4 1 .9V11h6a1 1 0 0 1 .1 2H13v6a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H11V5c0-.6.4-1 1-1Z"/></svg>',preferences:'<svg width="24" height="24"><path d="m20.1 13.5-1.9.2a5.8 5.8 0 0 1-.6 1.5l1.2 1.5c.4.4.3 1 0 1.4l-.7.7a1 1 0 0 1-1.4 0l-1.5-1.2a6.2 6.2 0 0 1-1.5.6l-.2 1.9c0 .5-.5.9-1 .9h-1a1 1 0 0 1-1-.9l-.2-1.9a5.8 5.8 0 0 1-1.5-.6l-1.5 1.2a1 1 0 0 1-1.4 0l-.7-.7a1 1 0 0 1 0-1.4l1.2-1.5a6.2 6.2 0 0 1-.6-1.5l-1.9-.2a1 1 0 0 1-.9-1v-1c0-.5.4-1 .9-1l1.9-.2a5.8 5.8 0 0 1 .6-1.5L5.2 7.3a1 1 0 0 1 0-1.4l.7-.7a1 1 0 0 1 1.4 0l1.5 1.2a6.2 6.2 0 0 1 1.5-.6l.2-1.9c0-.5.5-.9 1-.9h1c.5 0 1 .4 1 .9l.2 1.9a5.8 5.8 0 0 1 1.5.6l1.5-1.2a1 1 0 0 1 1.4 0l.7.7c.3.4.4 1 0 1.4l-1.2 1.5a6.2 6.2 0 0 1 .6 1.5l1.9.2c.5 0 .9.5.9 1v1c0 .5-.4 1-.9 1ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z" fill-rule="evenodd"/></svg>',preview:'<svg width="24" height="24"><path d="M3.5 12.5c.5.8 1.1 1.6 1.8 2.3 2 2 4.2 3.2 6.7 3.2s4.7-1.2 6.7-3.2a16.2 16.2 0 0 0 2.1-2.8 15.7 15.7 0 0 0-2.1-2.8c-2-2-4.2-3.2-6.7-3.2a9.3 9.3 0 0 0-6.7 3.2A16.2 16.2 0 0 0 3.2 12c0 .2.2.3.3.5Zm-2.4-1 .7-1.2L4 7.8C6.2 5.4 8.9 4 12 4c3 0 5.8 1.4 8.1 3.8a18.2 18.2 0 0 1 2.8 3.7v1l-.7 1.2-2.1 2.5c-2.3 2.4-5 3.8-8.1 3.8-3 0-5.8-1.4-8.1-3.8a18.2 18.2 0 0 1-2.8-3.7 1 1 0 0 1 0-1Zm12-3.3a2 2 0 1 0 2.7 2.6 4 4 0 1 1-2.6-2.6Z" fill-rule="nonzero"/></svg>',print:'<svg width="24" height="24"><path d="M18 8H6a3 3 0 0 0-3 3v6h2v3h14v-3h2v-6a3 3 0 0 0-3-3Zm-1 10H7v-4h10v4Zm.5-5c-.8 0-1.5-.7-1.5-1.5s.7-1.5 1.5-1.5 1.5.7 1.5 1.5-.7 1.5-1.5 1.5Zm.5-8H6v2h12V5Z" fill-rule="nonzero"/></svg>',quote:'<svg width="24" height="24"><path d="M7.5 17h.9c.4 0 .7-.2.9-.6L11 13V8c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v4c0 .6.4 1 1 1h2l-1.3 2.7a1 1 0 0 0 .8 1.3Zm8 0h.9c.4 0 .7-.2.9-.6L19 13V8c0-.6-.4-1-1-1h-4a1 1 0 0 0-1 1v4c0 .6.4 1 1 1h2l-1.3 2.7a1 1 0 0 0 .8 1.3Z" fill-rule="nonzero"/></svg>',redo:'<svg width="24" height="24"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"/></svg>',reload:'<svg width="24" height="24"><g fill-rule="nonzero"><path d="m5 22.1-1.2-4.7v-.2a1 1 0 0 1 1-1l5 .4a1 1 0 1 1-.2 2l-2.2-.2a7.8 7.8 0 0 0 8.4.2 7.5 7.5 0 0 0 3.5-6.4 1 1 0 1 1 2 0 9.5 9.5 0 0 1-4.5 8 9.9 9.9 0 0 1-10.2 0l.4 1.4a1 1 0 1 1-2 .5ZM13.6 7.4c0-.5.5-1 1-.9l2.8.2a8 8 0 0 0-9.5-1 7.5 7.5 0 0 0-3.6 7 1 1 0 0 1-2 0 9.5 9.5 0 0 1 4.5-8.6 10 10 0 0 1 10.9.3l-.3-1a1 1 0 0 1 2-.5l1.1 4.8a1 1 0 0 1-1 1.2l-5-.4a1 1 0 0 1-.9-1Z"/></g></svg>',"remove-formatting":'<svg width="24" height="24"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"/></svg>',remove:'<svg width="24" height="24"><path d="M16 7h3a1 1 0 0 1 0 2h-1v9a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3V9H5a1 1 0 1 1 0-2h3V6a3 3 0 0 1 3-3h2a3 3 0 0 1 3 3v1Zm-2 0V6c0-.6-.4-1-1-1h-2a1 1 0 0 0-1 1v1h4Zm2 2H8v9c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V9Zm-7 3a1 1 0 0 1 2 0v4a1 1 0 0 1-2 0v-4Zm4 0a1 1 0 0 1 2 0v4a1 1 0 0 1-2 0v-4Z" fill-rule="nonzero"/></svg>',"resize-handle":'<svg width="10" height="10"><g fill-rule="nonzero"><path d="M8.1 1.1A.5.5 0 1 1 9 2l-7 7A.5.5 0 1 1 1 8l7-7ZM8.1 5.1A.5.5 0 1 1 9 6l-3 3A.5.5 0 1 1 5 8l3-3Z"/></g></svg>',resize:'<svg width="24" height="24"><path d="M4 5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h6c.3 0 .5.1.7.3.2.2.3.4.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3H7.4L18 16.6V13c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3.3 0 .5.1.7.3.2.2.3.4.3.7v6c0 .3-.1.5-.3.7a1 1 0 0 1-.7.3h-6a1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h3.6L6 7.4V11c0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3A1 1 0 0 1 4 11V5Z" fill-rule="evenodd"/></svg>',"restore-draft":'<svg width="24" height="24"><g fill-rule="evenodd"><path d="M17 13c0 .6-.4 1-1 1h-4V8c0-.6.4-1 1-1s1 .4 1 1v4h2c.6 0 1 .4 1 1Z"/><path d="M4.7 10H9a1 1 0 0 1 0 2H3a1 1 0 0 1-1-1V5a1 1 0 1 1 2 0v3l2.5-2.4a9.2 9.2 0 0 1 10.8-1.5A9 9 0 0 1 13.4 21c-2.4.1-4.7-.7-6.5-2.2a1 1 0 1 1 1.3-1.5 7.2 7.2 0 0 0 11.6-3.7 7 7 0 0 0-3.5-7.7A7.2 7.2 0 0 0 8 7L4.7 10Z" fill-rule="nonzero"/></g></svg>',"rotate-left":'<svg width="24" height="24"><path d="M4.7 10H9a1 1 0 0 1 0 2H3a1 1 0 0 1-1-1V5a1 1 0 1 1 2 0v3l2.5-2.4a9.2 9.2 0 0 1 10.8-1.5A9 9 0 0 1 13.4 21c-2.4.1-4.7-.7-6.5-2.2a1 1 0 1 1 1.3-1.5 7.2 7.2 0 0 0 11.6-3.7 7 7 0 0 0-3.5-7.7A7.2 7.2 0 0 0 8 7L4.7 10Z" fill-rule="nonzero"/></svg>',"rotate-right":'<svg width="24" height="24"><path d="M20 8V5a1 1 0 0 1 2 0v6c0 .6-.4 1-1 1h-6a1 1 0 0 1 0-2h4.3L16 7A7.2 7.2 0 0 0 7.7 6a7 7 0 0 0 3 13.1c1.9.1 3.7-.5 5-1.7a1 1 0 0 1 1.4 1.5A9.2 9.2 0 0 1 2.2 14c-.9-3.9 1-8 4.5-9.9 3.5-1.9 8-1.3 10.8 1.5L20 8Z" fill-rule="nonzero"/></svg>',rtl:'<svg width="24" height="24"><path d="M8 5h8v2h-2v12h-2V7h-2v12H8v-7c-.5 0-1 0-1.4-.3A3.4 3.4 0 0 1 4.8 10a3.3 3.3 0 0 1 0-2.8 3.4 3.4 0 0 1 1.8-1.8L8 5Zm12 11.2a1 1 0 1 1-1 1.6l-3-2a1 1 0 0 1 0-1.6l3-2a1 1 0 1 1 1 1.6L18.4 15l1.8 1.2Z" fill-rule="evenodd"/></svg>',save:'<svg width="24" height="24"><path d="M5 16h14a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2Zm0 2v2h14v-2H5Zm10 0h2v2h-2v-2Zm-4-6.4L8.7 9.3a1 1 0 1 0-1.4 1.4l4 4c.4.4 1 .4 1.4 0l4-4a1 1 0 1 0-1.4-1.4L13 11.6V4a1 1 0 0 0-2 0v7.6Z" fill-rule="nonzero"/></svg>',search:'<svg width="24" height="24"><path d="M16 17.3a8 8 0 1 1 1.4-1.4l4.3 4.4a1 1 0 0 1-1.4 1.4l-4.4-4.3Zm-5-.3a6 6 0 1 0 0-12 6 6 0 0 0 0 12Z" fill-rule="nonzero"/></svg>',"select-all":'<svg width="24" height="24"><path d="M3 5h2V3a2 2 0 0 0-2 2Zm0 8h2v-2H3v2Zm4 8h2v-2H7v2ZM3 9h2V7H3v2Zm10-6h-2v2h2V3Zm6 0v2h2a2 2 0 0 0-2-2ZM5 21v-2H3c0 1.1.9 2 2 2Zm-2-4h2v-2H3v2ZM9 3H7v2h2V3Zm2 18h2v-2h-2v2Zm8-8h2v-2h-2v2Zm0 8a2 2 0 0 0 2-2h-2v2Zm0-12h2V7h-2v2Zm0 8h2v-2h-2v2Zm-4 4h2v-2h-2v2Zm0-16h2V3h-2v2ZM7 17h10V7H7v10Zm2-8h6v6H9V9Z" fill-rule="nonzero"/></svg>',selected:'<svg width="24" height="24"><path fill-rule="nonzero" d="M6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2Zm3.6 10.9L7 12.3a.7.7 0 0 0-1 1L9.6 17 18 8.6a.7.7 0 0 0 0-1 .7.7 0 0 0-1 0l-7.4 7.3Z"/></svg>',settings:'<svg width="24" height="24"><path d="M11 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8v.3c0 .2 0 .3-.2.5l-.6.2H7.8c-.3 0-.4 0-.6-.2a.7.7 0 0 1-.2-.6V8H5a1 1 0 1 1 0-2h2v-.3c0-.2 0-.3.2-.5l.5-.2h2.5c.3 0 .4 0 .6.2l.2.5V6ZM8 8h2V6H8v2Zm9 2.8v.2h2c.6 0 1 .4 1 1s-.4 1-1 1h-2v.3c0 .2 0 .3-.2.5l-.6.2h-2.4c-.3 0-.4 0-.6-.2a.7.7 0 0 1-.2-.6V13H5a1 1 0 0 1 0-2h8v-.3c0-.2 0-.3.2-.5l.6-.2h2.4c.3 0 .4 0 .6.2l.2.6ZM14 13h2v-2h-2v2Zm-3 2.8v.2h8c.6 0 1 .4 1 1s-.4 1-1 1h-8v.3c0 .2 0 .3-.2.5l-.6.2H7.8c-.3 0-.4 0-.6-.2a.7.7 0 0 1-.2-.6V18H5a1 1 0 0 1 0-2h2v-.3c0-.2 0-.3.2-.5l.5-.2h2.5c.3 0 .4 0 .6.2l.2.6ZM8 18h2v-2H8v2Z" fill-rule="evenodd"/></svg>',sharpen:'<svg width="24" height="24"><path d="m16 6 4 4-8 9-8-9 4-4h8Zm-4 10.2 5.5-6.2-.1-.1H12v-.3h5.1l-.2-.2H12V9h4.6l-.2-.2H12v-.3h4.1l-.2-.2H12V8h3.6l-.2-.2H8.7L6.5 10l.1.1H12v.3H6.9l.2.2H12v.3H7.3l.2.2H12v.3H7.7l.3.2h4v.3H8.2l.2.2H12v.3H8.6l.3.2H12v.3H9l.3.2H12v.3H9.5l.2.2H12v.3h-2l.2.2H12v.3h-1.6l.2.2H12v.3h-1.1l.2.2h.9v.3h-.7l.2.2h.5v.3h-.3l.3.2Z" fill-rule="evenodd"/></svg>',sourcecode:'<svg width="24" height="24"><g fill-rule="nonzero"><path d="M9.8 15.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0l-4.4-4.1a.8.8 0 0 1 0-1.2l4.4-4.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L6 12l3.8 3.7ZM14.2 15.7c-.3.3-.3.8 0 1 .4.4.9.4 1.2 0l4.4-4.1c.3-.3.3-.9 0-1.2l-4.4-4.2a.8.8 0 0 0-1.2 0c-.3.3-.3.8 0 1.1L18 12l-3.8 3.7Z"/></g></svg>',"spell-check":'<svg width="24" height="24"><path d="M6 8v3H5V5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h2c.3 0 .5.1.7.3.2.2.3.4.3.7v6H8V8H6Zm0-3v2h2V5H6Zm13 0h-3v5h3v1h-3a1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7V5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h3v1Zm-5 1.5-.1.7c-.1.2-.3.3-.6.3.3 0 .5.1.6.3l.1.7V10c0 .3-.1.5-.3.7a1 1 0 0 1-.7.3h-3V4h3c.3 0 .5.1.7.3.2.2.3.4.3.7v1.5ZM13 10V8h-2v2h2Zm0-3V5h-2v2h2Zm3 5 1 1-6.5 7L7 15.5l1.3-1 2.2 2.2L16 12Z" fill-rule="evenodd"/></svg>',"strike-through":'<svg width="24" height="24"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"/><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"/></g></svg>',subscript:'<svg width="24" height="24"><path d="m10.4 10 4.6 4.6-1.4 1.4L9 11.4 4.4 16 3 14.6 7.6 10 3 5.4 4.4 4 9 8.6 13.6 4 15 5.4 10.4 10ZM21 19h-5v-1l1-.8 1.7-1.6c.3-.4.5-.8.5-1.2 0-.3 0-.6-.2-.7-.2-.2-.5-.3-.9-.3a2 2 0 0 0-.8.2l-.7.3-.4-1.1 1-.6 1.2-.2c.8 0 1.4.3 1.8.7.4.4.6.9.6 1.5s-.2 1.1-.5 1.6a8 8 0 0 1-1.3 1.3l-.6.6h2.6V19Z" fill-rule="nonzero"/></svg>',superscript:'<svg width="24" height="24"><path d="M15 9.4 10.4 14l4.6 4.6-1.4 1.4L9 15.4 4.4 20 3 18.6 7.6 14 3 9.4 4.4 8 9 12.6 13.6 8 15 9.4Zm5.9 1.6h-5v-1l1-.8 1.7-1.6c.3-.5.5-.9.5-1.3 0-.3 0-.5-.2-.7-.2-.2-.5-.3-.9-.3l-.8.2-.7.4-.4-1.2c.2-.2.5-.4 1-.5.3-.2.8-.2 1.2-.2.8 0 1.4.2 1.8.6.4.4.6 1 .6 1.6 0 .5-.2 1-.5 1.5l-1.3 1.4-.6.5h2.6V11Z" fill-rule="nonzero"/></svg>',"table-caption":'<svg width="24" height="24"><g fill-rule="nonzero"><rect width="12" height="2" x="3" y="4" rx="1"/><path d="M19 8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-8c0-1.1.9-2 2-2h14ZM5 15v3h6v-3H5Zm14 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></g></svg>',"table-cell-classes":'<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M13 4v9H3V6c0-1.1.9-2 2-2h8Zm-2 2H5v5h6V6Z"/><path fill-rule="nonzero" d="M13 4h6a2 2 0 0 1 2 2v7h-8v-2h6V6h-6V4Z" opacity=".2"/><path d="m18 20-2.6 1.6.7-3-2.4-2 3.1-.2 1.2-2.9 1.2 2.9 3.1.2-2.4 2 .7 3z"/><path fill-rule="nonzero" d="M3 13v5c0 1.1.9 2 2 2h8v-7h-2v5H5v-5H3Z" opacity=".2"/></g></svg>',"table-cell-properties":'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 9H5v5h6v-5Zm8 0h-6v5h6v-5Zm-8-7H5v5h6V6Z"/></svg>',"table-cell-select-all":'<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 2H5v12h14V6Z"/><path d="M13 6v5h6v2h-6v5h-2v-5H5v-2h6V6h2Z" opacity=".2"/></g></svg>',"table-cell-select-inner":'<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 2H5v12h14V6Z" opacity=".2"/><path d="M13 6v5h6v2h-6v5h-2v-5H5v-2h6V6h2Z"/></g></svg>',"table-classes":'<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v7h-8v7H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 9H5v5h6v-5Zm8-7h-6v5h6V6Zm-8 0H5v5h6V6Z"/><path d="m18 20-2.6 1.6.7-3-2.4-2 3.1-.2 1.2-2.9 1.2 2.9 3.1.2-2.4 2 .7 3z"/></g></svg>',"table-delete-column":'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2Zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5Z"/></svg>',"table-delete-row":'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6Zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3Z"/></svg>',"table-delete-table":'<svg width="24" height="24"><g fill-rule="nonzero"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14ZM5 6v12h14V6H5Z"/><path d="m14.4 8.6 1.1 1-2.4 2.4 2.4 2.4-1.1 1.1-2.4-2.4-2.4 2.4-1-1.1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></g></svg>',"table-insert-column-after":'<svg width="24" height="24"><path fill-rule="nonzero" d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15ZM9 13H5v5h4v-5Zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1ZM9 6H5v5h4V6Z"/></svg>',"table-insert-column-before":'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15Zm0 9h-4v5h4v-5ZM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1Zm11-2h-4v5h4V6Z"/></svg>',"table-insert-row-above":'<svg width="24" height="24"><path fill-rule="nonzero" d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2Zm5 10H5v4h6v-4Zm8 0h-6v4h6v-4ZM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1Z"/></svg>',"table-insert-row-after":'<svg width="24" height="24"><path fill-rule="nonzero" d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1Zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18ZM11 6H5v4h6V6Zm8 0h-6v4h6V6Z"/></svg>',"table-left-header":'<svg width="24" height="24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',"table-merge-cells":'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14ZM5 15.5V18h3v-2.5H5Zm14-5h-9V18h9v-7.5ZM19 6h-4v2.5h4V6ZM8 6H5v2.5h3V6Zm5 0h-3v2.5h3V6Zm-8 7.5h3v-3H5v3Z"/></svg>',"table-row-numbering-rtl":'<svg width="24" height="24"><path d="M6 4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H6Zm0 12h8v3H6v-3Zm11 0c.6 0 1 .4 1 1v1a1 1 0 0 1-2 0v-1c0-.6.4-1 1-1ZM6 11h8v3H6v-3Zm11 0c.6 0 1 .4 1 1v1a1 1 0 0 1-2 0v-1c0-.6.4-1 1-1ZM6 6h8v3H6V6Zm11 0c.6 0 1 .4 1 1v1a1 1 0 1 1-2 0V7c0-.6.4-1 1-1Z"/></svg>',"table-row-numbering":'<svg width="24" height="24"><path d="M18 4a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h12Zm0 12h-8v3h8v-3ZM7 16a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-1c0-.6-.4-1-1-1Zm11-5h-8v3h8v-3ZM7 11a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-1c0-.6-.4-1-1-1Zm11-5h-8v3h8V6ZM7 6a1 1 0 0 0-1 1v1a1 1 0 1 0 2 0V7c0-.6-.4-1-1-1Z"/></svg>',"table-row-properties":'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14ZM5 15v3h6v-3H5Zm14 0h-6v3h6v-3Zm0-9h-6v3h6V6ZM5 9h6V6H5v3Z"/></svg>',"table-split-cells":'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14ZM8 15.5H5V18h3v-2.5Zm11-5h-9V18h9v-7.5Zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2Zm-8.5-1H5v3h3v-3ZM19 6h-4v2.5h4V6ZM8 6H5v2.5h3V6Zm5 0h-3v2.5h3V6Z"/></svg>',"table-top-header":'<svg width="24" height="24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',table:'<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14ZM5 14v4h6v-4H5Zm14 0h-6v4h6v-4Zm0-6h-6v4h6V8ZM5 12h6V8H5v4Z"/></svg>',template:'<svg width="24" height="24"><path d="M19 19v-1H5v1h14ZM9 16v-4a5 5 0 1 1 6 0v4h4a2 2 0 0 1 2 2v3H3v-3c0-1.1.9-2 2-2h4Zm4 0v-5l.8-.6a3 3 0 1 0-3.6 0l.8.6v5h2Z" fill-rule="nonzero"/></svg>',"temporary-placeholder":'<svg width="24" height="24"><g fill-rule="evenodd"><path d="M9 7.6V6h2.5V4.5a.5.5 0 1 1 1 0V6H15v1.6a8 8 0 1 1-6 0Zm-2.6 5.3a.5.5 0 0 0 .3.6c.3 0 .6 0 .6-.3l.1-.2a5 5 0 0 1 3.3-2.8c.3-.1.4-.4.4-.6-.1-.3-.4-.5-.6-.4a6 6 0 0 0-4.1 3.7Z"/><circle cx="14" cy="4" r="1"/><circle cx="12" cy="2" r="1"/><circle cx="10" cy="4" r="1"/></g></svg>',"text-color":'<svg width="24" height="24"><g fill-rule="evenodd"><path id="tox-icon-text-color__color" d="M3 18h18v3H3z"/><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"/></g></svg>',toc:'<svg width="24" height="24"><path d="M5 5c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 1 1 0-2Zm3 0h11c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 1 1 0-2Zm-3 8c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 0 1 0-2Zm3 0h11c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2Zm0-4c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 1 1 0-2Zm3 0h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm-3 8c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 0 1 0-2Zm3 0h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',translate:'<svg width="24" height="24"><path d="m12.7 14.3-.3.7-.4.7-2.2-2.2-3.1 3c-.3.4-.8.4-1 0a.7.7 0 0 1 0-1l3.1-3A12.4 12.4 0 0 1 6.7 9H8a10.1 10.1 0 0 0 1.7 2.4c.5-.5 1-1.1 1.4-1.8l.9-2H4.7a.7.7 0 1 1 0-1.5h4.4v-.7c0-.4.3-.8.7-.8.4 0 .7.4.7.8v.7H15c.4 0 .8.3.8.7 0 .4-.4.8-.8.8h-1.4a12.3 12.3 0 0 1-1 2.4 13.5 13.5 0 0 1-1.7 2.3l1.9 1.8Zm4.3-3 2.7 7.3a.5.5 0 0 1-.4.7 1 1 0 0 1-1-.7l-.6-1.5h-3.4l-.6 1.5a1 1 0 0 1-1 .7.5.5 0 0 1-.4-.7l2.7-7.4a1 1 0 0 1 2 0Zm-2.2 4.4h2.4L16 12.5l-1.2 3.2Z" fill-rule="evenodd"/></svg>',typography:'<svg width="24" height="24"><path fill-rule="evenodd" clip-rule="evenodd" d="M17 5a1 1 0 1 1 0 2h-4v11a1 1 0 1 1-2 0V7H7a1 1 0 0 1 0-2h10Z"/><path d="m17.5 14 .8-1.7 1.7-.8-1.7-.8-.8-1.7-.8 1.7-1.7.8 1.7.8.8 1.7ZM7 14l1 2 2 1-2 1-1 2-1-2-2-1 2-1 1-2Z"/></svg>',underline:'<svg width="24" height="24"><path d="M16 5c.6 0 1 .4 1 1v5.5a4 4 0 0 1-.4 1.8l-1 1.4a5.3 5.3 0 0 1-5.5 1 5 5 0 0 1-1.6-1c-.5-.4-.8-.9-1.1-1.4a4 4 0 0 1-.4-1.8V6c0-.6.4-1 1-1s1 .4 1 1v5.5c0 .3 0 .6.2 1l.6.7a3.3 3.3 0 0 0 2.2.8 3.4 3.4 0 0 0 2.2-.8c.3-.2.4-.5.6-.8l.2-.9V6c0-.6.4-1 1-1ZM8 17h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',undo:'<svg width="24" height="24"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"/></svg>',unlink:'<svg width="24" height="24"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2.1-2a2 2 0 1 0-2.7-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2ZM7.6 6.3a.8.8 0 0 1-1 1.1L3.3 4.2a.7.7 0 1 1 1-1l3.2 3.1ZM5.1 8.6a.8.8 0 0 1 0 1.5H3a.8.8 0 0 1 0-1.5H5Zm5-3.5a.8.8 0 0 1-1.5 0V3a.8.8 0 0 1 1.5 0V5Zm6 11.8a.8.8 0 0 1 1-1l3.2 3.2a.8.8 0 0 1-1 1L16 17Zm-2.2 2a.8.8 0 0 1 1.5 0V21a.8.8 0 0 1-1.5 0V19Zm5-3.5a.7.7 0 1 1 0-1.5H21a.8.8 0 0 1 0 1.5H19Z" fill-rule="nonzero"/></svg>',unlock:'<svg width="24" height="24"><path d="M16 5c.8 0 1.5.3 2.1.9.6.6.9 1.3.9 2.1v3h-2V8a1 1 0 0 0-.3-.7A1 1 0 0 0 16 7h-2a1 1 0 0 0-.7.3 1 1 0 0 0-.3.7v3h.3c.2 0 .3 0 .5.2l.2.6v7.4c0 .3 0 .4-.2.6l-.6.2H4.8c-.3 0-.4 0-.6-.2a.7.7 0 0 1-.2-.6v-7.4c0-.3 0-.4.2-.6l.5-.2H11V8c0-.8.3-1.5.9-2.1.6-.6 1.3-.9 2.1-.9h2Z" fill-rule="evenodd"/></svg>',"unordered-list":'<svg width="24" height="24"><path d="M11 5h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2ZM4.5 6c0-.4.1-.8.4-1 .3-.4.7-.5 1.1-.5.4 0 .8.1 1 .4.4.3.5.7.5 1.1 0 .4-.1.8-.4 1-.3.4-.7.5-1.1.5-.4 0-.8-.1-1-.4-.4-.3-.5-.7-.5-1.1Zm0 6c0-.4.1-.8.4-1 .3-.4.7-.5 1.1-.5.4 0 .8.1 1 .4.4.3.5.7.5 1.1 0 .4-.1.8-.4 1-.3.4-.7.5-1.1.5-.4 0-.8-.1-1-.4-.4-.3-.5-.7-.5-1.1Zm0 6c0-.4.1-.8.4-1 .3-.4.7-.5 1.1-.5.4 0 .8.1 1 .4.4.3.5.7.5 1.1 0 .4-.1.8-.4 1-.3.4-.7.5-1.1.5-.4 0-.8-.1-1-.4-.4-.3-.5-.7-.5-1.1Z" fill-rule="evenodd"/></svg>',unselected:'<svg width="24" height="24"><path fill-rule="nonzero" d="M6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2Zm0 1a1 1 0 0 0-1 1v12c0 .6.4 1 1 1h12c.6 0 1-.4 1-1V6c0-.6-.4-1-1-1H6Z"/></svg>',upload:'<svg width="24" height="24"><path d="M18 19v-2a1 1 0 0 1 2 0v3c0 .6-.4 1-1 1H5a1 1 0 0 1-1-1v-3a1 1 0 0 1 2 0v2h12ZM11 6.4 8.7 8.7a1 1 0 0 1-1.4-1.4l4-4a1 1 0 0 1 1.4 0l4 4a1 1 0 1 1-1.4 1.4L13 6.4V16a1 1 0 0 1-2 0V6.4Z" fill-rule="nonzero"/></svg>',user:'<svg width="24" height="24"><path d="M12 24a12 12 0 1 1 0-24 12 12 0 0 1 0 24Zm-8.7-5.3a11 11 0 0 0 17.4 0C19.4 16.3 14.6 15 12 15c-2.6 0-7.4 1.3-8.7 3.7ZM12 13c2.2 0 4-2 4-4.5S14.2 4 12 4 8 6 8 8.5 9.8 13 12 13Z" fill-rule="nonzero"/></svg>',"vertical-align":'<svg width="24" height="24"><g fill-rule="nonzero"><rect width="18" height="2" x="3" y="11" rx="1"/><path d="M12 2c.6 0 1 .4 1 1v4l2-1.3a1 1 0 0 1 1.2 1.5l-.1.1-4.1 3-4-3a1 1 0 0 1 1-1.7l2 1.5V3c0-.6.4-1 1-1zm0 11.8 4 2.9a1 1 0 0 1-1 1.7l-2-1.5V21c0 .5-.4 1-.9 1H12a1 1 0 0 1-1-1v-4l-2 1.3a1 1 0 0 1-1.2-.1l-.1-.1a1 1 0 0 1 .1-1.3l.1-.1 4.1-3z"/></g></svg>',visualblocks:'<svg width="24" height="24"><path d="M9 19v2H7v-2h2Zm-4 0v2a2 2 0 0 1-2-2h2Zm8 0v2h-2v-2h2Zm8 0a2 2 0 0 1-2 2v-2h2Zm-4 0v2h-2v-2h2ZM15 7a1 1 0 0 1 0 2v7a1 1 0 0 1-2 0V9h-1v7a1 1 0 0 1-2 0v-4a2.5 2.5 0 0 1-.2-5H15ZM5 15v2H3v-2h2Zm16 0v2h-2v-2h2ZM5 11v2H3v-2h2Zm16 0v2h-2v-2h2ZM5 7v2H3V7h2Zm16 0v2h-2V7h2ZM5 3v2H3c0-1.1.9-2 2-2Zm8 0v2h-2V3h2Zm6 0a2 2 0 0 1 2 2h-2V3ZM9 3v2H7V3h2Zm8 0v2h-2V3h2Z" fill-rule="evenodd"/></svg>',visualchars:'<svg width="24" height="24"><path d="M10 5h7a1 1 0 0 1 0 2h-1v11a1 1 0 0 1-2 0V7h-2v11a1 1 0 0 1-2 0v-6c-.5 0-1 0-1.4-.3A3.4 3.4 0 0 1 6.8 10a3.3 3.3 0 0 1 0-2.8 3.4 3.4 0 0 1 1.8-1.8L10 5Z" fill-rule="evenodd"/></svg>',warning:'<svg width="24" height="24"><path d="M19.8 18.3c.2.5.3.9 0 1.2-.1.3-.5.5-1 .5H5.2c-.5 0-.9-.2-1-.5-.3-.3-.2-.7 0-1.2L11 4.7l.5-.5.5-.2c.2 0 .3 0 .5.2.2 0 .3.3.5.5l6.8 13.6ZM12 18c.3 0 .5-.1.7-.3.2-.2.3-.4.3-.7a1 1 0 0 0-.3-.7 1 1 0 0 0-.7-.3 1 1 0 0 0-.7.3 1 1 0 0 0-.3.7c0 .3.1.5.3.7.2.2.4.3.7.3Zm.7-3 .3-4a1 1 0 0 0-.3-.7 1 1 0 0 0-.7-.3 1 1 0 0 0-.7.3 1 1 0 0 0-.3.7l.3 4h1.4Z" fill-rule="evenodd"/></svg>',"zoom-in":'<svg width="24" height="24"><path d="M16 17.3a8 8 0 1 1 1.4-1.4l4.3 4.4a1 1 0 0 1-1.4 1.4l-4.4-4.3Zm-5-.3a6 6 0 1 0 0-12 6 6 0 0 0 0 12Zm-1-9a1 1 0 0 1 2 0v6a1 1 0 0 1-2 0V8Zm-2 4a1 1 0 0 1 0-2h6a1 1 0 0 1 0 2H8Z" fill-rule="nonzero"/></svg>',"zoom-out":'<svg width="24" height="24"><path d="M16 17.3a8 8 0 1 1 1.4-1.4l4.3 4.4a1 1 0 0 1-1.4 1.4l-4.4-4.3Zm-5-.3a6 6 0 1 0 0-12 6 6 0 0 0 0 12Zm-3-5a1 1 0 0 1 0-2h6a1 1 0 0 1 0 2H8Z" fill-rule="nonzero"/></svg>'}});
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.ModelManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(s=n.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var o,n,r,s})(t)===e,o=e=>t=>typeof t===e,n=e=>t=>e===t,r=t("string"),s=t("object"),l=t("array"),a=n(null),c=o("boolean"),i=n(void 0),m=e=>!(e=>null==e)(e),d=o("function"),u=o("number"),f=()=>{},g=e=>()=>e,h=e=>e,p=(e,t)=>e===t;function w(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const b=e=>t=>!e(t),v=e=>e(),y=g(!1),x=g(!0);class C{constructor(e,t){this.tag=e,this.value=t}static some(e){return new C(!0,e)}static none(){return C.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?C.some(e(this.value)):C.none()}bind(e){return this.tag?e(this.value):C.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:C.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return m(e)?C.some(e):C.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}C.singletonNone=new C(!1);const S=Array.prototype.slice,T=Array.prototype.indexOf,R=Array.prototype.push,D=(e,t)=>{return o=e,n=t,T.call(o,n)>-1;var o,n},O=(e,t)=>{for(let o=0,n=e.length;o<n;o++)if(t(e[o],o))return!0;return!1},k=(e,t)=>{const o=[];for(let n=0;n<e;n++)o.push(t(n));return o},E=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r<o;r++){const o=e[r];n[r]=t(o,r)}return n},N=(e,t)=>{for(let o=0,n=e.length;o<n;o++)t(e[o],o)},B=(e,t)=>{const o=[],n=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];(t(s,r)?o:n).push(s)}return{pass:o,fail:n}},z=(e,t)=>{const o=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t(r,n)&&o.push(r)}return o},A=(e,t,o)=>(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),W=(e,t,o)=>(N(e,((e,n)=>{o=t(o,e,n)})),o),L=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n<r;n++){const r=e[n];if(t(r,n))return C.some(r);if(o(r,n))break}return C.none()})(e,t,y),_=(e,t)=>{for(let o=0,n=e.length;o<n;o++)if(t(e[o],o))return C.some(o);return C.none()},M=e=>{const t=[];for(let o=0,n=e.length;o<n;++o){if(!l(e[o]))throw new Error("Arr.flatten item "+o+" was not an array, input: "+e);R.apply(t,e[o])}return t},j=(e,t)=>M(E(e,t)),I=(e,t)=>{for(let o=0,n=e.length;o<n;++o)if(!0!==t(e[o],o))return!1;return!0},P=(e,t)=>{const o={};for(let n=0,r=e.length;n<r;n++){const r=e[n];o[String(r)]=t(r,n)}return o},F=(e,t)=>t>=0&&t<e.length?C.some(e[t]):C.none(),H=e=>F(e,0),q=e=>F(e,e.length-1),V=(e,t)=>{for(let o=0;o<e.length;o++){const n=t(e[o],o);if(n.isSome())return n}return C.none()},$=Object.keys,U=Object.hasOwnProperty,G=(e,t)=>{const o=$(e);for(let n=0,r=o.length;n<r;n++){const r=o[n];t(e[r],r)}},K=(e,t)=>Y(e,((e,o)=>({k:o,v:t(e,o)}))),Y=(e,t)=>{const o={};return G(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},J=(e,t)=>{const o=[];return G(e,((e,n)=>{o.push(t(e,n))})),o},Q=e=>J(e,h),X=(e,t)=>U.call(e,t);"undefined"!=typeof window?window:Function("return this;")();const Z=e=>e.dom.nodeName.toLowerCase(),ee=e=>e.dom.nodeType,te=e=>t=>ee(t)===e,oe=e=>8===ee(e)||"#comment"===Z(e),ne=te(1),re=te(3),se=te(9),le=te(11),ae=e=>t=>ne(t)&&Z(t)===e,ce=(e,t,o)=>{if(!(r(o)||c(o)||u(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},ie=(e,t,o)=>{ce(e.dom,t,o)},me=(e,t)=>{const o=e.dom;G(t,((e,t)=>{ce(o,t,e)}))},de=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},ue=(e,t)=>C.from(de(e,t)),fe=(e,t)=>{e.dom.removeAttribute(t)},ge=e=>W(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),he=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},pe={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return he(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return he(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return he(o)},fromDom:he,fromPoint:(e,t,o)=>C.from(e.dom.elementFromPoint(t,o)).map(he)},we=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},be=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,ve=(e,t)=>{const o=void 0===t?document:t.dom;return be(o)?C.none():C.from(o.querySelector(e)).map(pe.fromDom)},ye=(e,t)=>e.dom===t.dom,xe=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},Ce=we,Se=e=>pe.fromDom(e.dom.ownerDocument),Te=e=>se(e)?e:Se(e),Re=e=>C.from(e.dom.parentNode).map(pe.fromDom),De=(e,t)=>{const o=d(t)?t:y;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=pe.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},Oe=e=>C.from(e.dom.previousSibling).map(pe.fromDom),ke=e=>C.from(e.dom.nextSibling).map(pe.fromDom),Ee=e=>E(e.dom.childNodes,pe.fromDom),Ne=(e,t)=>{const o=e.dom.childNodes;return C.from(o[t]).map(pe.fromDom)},Be=(e,t)=>{Re(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},ze=(e,t)=>{ke(e).fold((()=>{Re(e).each((e=>{We(e,t)}))}),(e=>{Be(e,t)}))},Ae=(e,t)=>{const o=(e=>Ne(e,0))(e);o.fold((()=>{We(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},We=(e,t)=>{e.dom.appendChild(t.dom)},Le=(e,t)=>{Be(e,t),We(t,e)},_e=(e,t)=>{N(t,((o,n)=>{const r=0===n?e:t[n-1];ze(r,o)}))},Me=(e,t)=>{N(t,(t=>{We(e,t)}))},je=e=>{e.dom.textContent="",N(Ee(e),(e=>{Ie(e)}))},Ie=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Pe=e=>{const t=Ee(e);t.length>0&&_e(e,t),Ie(e)},Fe=(e,t)=>pe.fromDom(e.dom.cloneNode(t)),He=e=>Fe(e,!1),qe=e=>Fe(e,!0),Ve=(e,t)=>{const o=pe.fromTag(t),n=ge(e);return me(o,n),o},$e=["tfoot","thead","tbody","colgroup"],Ue=(e,t,o)=>({element:e,rowspan:t,colspan:o}),Ge=(e,t,o)=>({element:e,cells:t,section:o}),Ke=(e,t,o)=>({element:e,isNew:t,isLocked:o}),Ye=(e,t,o,n)=>({element:e,cells:t,section:o,isNew:n}),Je=d(Element.prototype.attachShadow)&&d(Node.prototype.getRootNode),Qe=g(Je),Xe=Je?e=>pe.fromDom(e.dom.getRootNode()):Te,Ze=e=>pe.fromDom(e.dom.host),et=e=>{const t=re(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=Xe(e);return le(o=t)&&m(o.dom.host)?C.some(t):C.none();var o})(pe.fromDom(t)).fold((()=>o.body.contains(t)),(n=et,r=Ze,e=>n(r(e))));var n,r},tt=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return pe.fromDom(t)},ot=(e,t)=>{let o=[];return N(Ee(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(ot(e,t))})),o},nt=(e,t,o)=>((e,o,n)=>z(De(e,n),(e=>we(e,t))))(e,0,o),rt=(e,t)=>((e,o)=>z(Ee(e),(e=>we(e,t))))(e),st=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return be(o)?[]:E(o.querySelectorAll(e),pe.fromDom)})(t,e);var lt=(e,t,o,n,r)=>e(o,n)?C.some(o):d(r)&&r(o)?C.none():t(o,n,r);const at=(e,t,o)=>{let n=e.dom;const r=d(o)?o:y;for(;n.parentNode;){n=n.parentNode;const e=pe.fromDom(n);if(t(e))return C.some(e);if(r(e))break}return C.none()},ct=(e,t,o)=>at(e,(e=>we(e,t)),o),it=(e,t)=>((e,o)=>L(e.dom.childNodes,(e=>{return o=pe.fromDom(e),we(o,t);var o})).map(pe.fromDom))(e),mt=(e,t)=>ve(t,e),dt=(e,t,o)=>lt(((e,t)=>we(e,t)),ct,e,t,o),ut=(e,t,o=p)=>e.exists((e=>o(e,t))),ft=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(o);return t},gt=(e,t)=>e?C.some(t):C.none(),ht=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,pt=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!i(n)||r+t.length<=n)},wt=(e,t)=>ht(e,t,0),bt=(e,t)=>ht(e,t,e.length-t.length),vt=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),yt=e=>e.length>0,xt=e=>void 0!==e.style&&d(e.style.getPropertyValue),Ct=(e,t,o)=>{if(!r(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);xt(e)&&e.style.setProperty(t,o)},St=(e,t,o)=>{const n=e.dom;Ct(n,t,o)},Tt=(e,t)=>{const o=e.dom;G(t,((e,t)=>{Ct(o,t,e)}))},Rt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||et(e)?n:Dt(o,t)},Dt=(e,t)=>xt(e)?e.style.getPropertyValue(t):"",Ot=(e,t)=>{const o=e.dom,n=Dt(o,t);return C.from(n).filter((e=>e.length>0))},kt=(e,t)=>{((e,t)=>{xt(e)&&e.style.removeProperty(t)})(e.dom,t),ut(ue(e,"style").map(vt),"")&&fe(e,"style")},Et=(e,t,o=0)=>ue(e,t).map((e=>parseInt(e,10))).getOr(o),Nt=(e,t)=>Et(e,t,1),Bt=e=>ae("col")(e)?Et(e,"span",1)>1:Nt(e,"colspan")>1,zt=e=>Nt(e,"rowspan")>1,At=(e,t)=>parseInt(Rt(e,t),10),Wt=g(10),Lt=g(10),_t=(e,t)=>Mt(e,t,x),Mt=(e,t,o)=>j(Ee(e),(e=>we(e,t)?o(e)?[e]:[]:Mt(e,t,o))),jt=(e,t)=>((e,t,o=y)=>o(t)?C.none():D(e,Z(t))?C.some(t):ct(t,e.join(","),(e=>we(e,"table")||o(e))))(["td","th"],e,t),It=e=>_t(e,"th,td"),Pt=e=>we(e,"colgroup")?rt(e,"col"):j(qt(e),(e=>rt(e,"col"))),Ft=(e,t)=>dt(e,"table",t),Ht=e=>_t(e,"tr"),qt=e=>Ft(e).fold(g([]),(e=>rt(e,"colgroup"))),Vt=(e,t)=>E(e,(e=>{if("colgroup"===Z(e)){const t=E(Pt(e),(e=>{const t=Et(e,"span",1);return Ue(e,1,t)}));return Ge(e,t,"colgroup")}{const o=E(It(e),(e=>{const t=Et(e,"rowspan",1),o=Et(e,"colspan",1);return Ue(e,t,o)}));return Ge(e,o,t(e))}})),$t=e=>Re(e).map((e=>{const t=Z(e);return(e=>D($e,e))(t)?t:"tbody"})).getOr("tbody"),Ut=e=>{const t=Ht(e),o=[...qt(e),...t];return Vt(o,$t)},Gt=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},Kt=()=>Yt(0,0),Yt=(e,t)=>({major:e,minor:t}),Jt={nu:Yt,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?Kt():((e,t)=>{const o=((e,t)=>{for(let o=0;o<e.length;o++){const n=e[o];if(n.test(t))return n}})(e,t);if(!o)return{major:0,minor:0};const n=e=>Number(t.replace(o,"$"+e));return Yt(n(1),n(2))})(e,o)},unknown:Kt},Qt=(e,t)=>{const o=String(t).toLowerCase();return L(e,(e=>e.search(o)))},Xt=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Zt=e=>t=>pt(t,e),eo=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>pt(e,"edge/")&&pt(e,"chrome")&&pt(e,"safari")&&pt(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Xt],search:e=>pt(e,"chrome")&&!pt(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>pt(e,"msie")||pt(e,"trident")},{name:"Opera",versionRegexes:[Xt,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Zt("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Zt("firefox")},{name:"Safari",versionRegexes:[Xt,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(pt(e,"safari")||pt(e,"mobile/"))&&pt(e,"applewebkit")}],to=[{name:"Windows",search:Zt("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>pt(e,"iphone")||pt(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Zt("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:Zt("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Zt("linux"),versionRegexes:[]},{name:"Solaris",search:Zt("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Zt("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:Zt("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],oo={browsers:g(eo),oses:g(to)},no="Edge",ro="Chromium",so="Opera",lo="Firefox",ao="Safari",co=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(no),isChromium:n(ro),isIE:n("IE"),isOpera:n(so),isFirefox:n(lo),isSafari:n(ao)}},io=()=>co({current:void 0,version:Jt.unknown()}),mo=co,uo=(g(no),g(ro),g("IE"),g(so),g(lo),g(ao),"Windows"),fo="Android",go="Linux",ho="macOS",po="Solaris",wo="FreeBSD",bo="ChromeOS",vo=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(uo),isiOS:n("iOS"),isAndroid:n(fo),isMacOS:n(ho),isLinux:n(go),isSolaris:n(po),isFreeBSD:n(wo),isChromeOS:n(bo)}},yo=()=>vo({current:void 0,version:Jt.unknown()}),xo=vo,Co=(g(uo),g("iOS"),g(fo),g(go),g(ho),g(po),g(wo),g(bo),e=>window.matchMedia(e).matches);let So=Gt((()=>((e,t,o)=>{const n=oo.browsers(),r=oo.oses(),s=t.bind((e=>((e,t)=>V(t.brands,(t=>{const o=t.brand.toLowerCase();return L(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:Jt.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>Qt(e,t).map((e=>{const o=Jt.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(io,mo),l=((e,t)=>Qt(e,t).map((e=>{const o=Jt.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(yo,xo),a=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,l=e.isiOS()||e.isAndroid(),a=l||n("(pointer:coarse)"),c=r||!s&&l&&n("(min-device-width:768px)"),i=s||l&&!c,m=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),d=!i&&!c&&!m;return{isiPad:g(r),isiPhone:g(s),isTablet:g(c),isPhone:g(i),isTouch:g(a),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:g(m),isDesktop:g(d)}})(l,s,e,o);return{browser:s,os:l,deviceType:a}})(navigator.userAgent,C.from(navigator.userAgentData),Co)));const To=()=>So(),Ro=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Rt(o,e);return parseFloat(t)||0}return n},n=(e,t)=>W(t,((t,o)=>{const n=Rt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!u(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;xt(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Do=(e,t,o)=>((e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?C.none():C.some(t)})(e).getOr(t))(Rt(e,t),o),Oo=Ro("width",(e=>e.dom.offsetWidth)),ko=e=>Oo.get(e),Eo=e=>Oo.getOuter(e),No=e=>((e,t)=>{const o=e.dom,n=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?n:((e,t,o,n)=>t-Do(e,"padding-left",0)-Do(e,"padding-right",0)-Do(e,"border-left-width",0)-Do(e,"border-right-width",0))(e,n)})(e,"content-box"),Bo=(e,t,o)=>{const n=e.cells,r=n.slice(0,t),s=n.slice(t),l=r.concat(o).concat(s);return Wo(e,l)},zo=(e,t,o)=>Bo(e,t,[o]),Ao=(e,t,o)=>{e.cells[t]=o},Wo=(e,t)=>Ye(e.element,t,e.section,e.isNew),Lo=(e,t)=>e.cells[t],_o=(e,t)=>Lo(e,t).element,Mo=e=>e.cells.length,jo=e=>{const t=B(e,(e=>"colgroup"===e.section));return{rows:t.fail,cols:t.pass}},Io=(e,t,o)=>{const n=E(e.cells,o);return Ye(t(e.element),n,e.section,!0)},Po="data-snooker-locked-cols",Fo=e=>ue(e,Po).bind((e=>C.from(e.match(/\d+/g)))).map((e=>P(e,x))),Ho=e=>{const t=W(jo(e).rows,((e,t)=>(N(t.cells,((t,o)=>{t.isLocked&&(e[o]=!0)})),e)),{}),o=J(t,((e,t)=>parseInt(t,10)));return((e,t)=>{const o=S.call(e,0);return o.sort(void 0),o})(o)},qo=(e,t)=>e+","+t,Vo=(e,t)=>{const o=j(e.all,(e=>e.cells));return z(o,t)},$o=e=>{const t={},o=[],n=H(e).map((e=>e.element)).bind(Ft).bind(Fo).getOr({});let r=0,s=0,l=0;const{pass:a,fail:c}=B(e,(e=>"colgroup"===e.section));N(c,(e=>{const a=[];N(e.cells,(e=>{let o=0;for(;void 0!==t[qo(l,o)];)o++;const r=((e,t)=>X(e,t)&&void 0!==e[t]&&null!==e[t])(n,o.toString()),c=((e,t,o,n,r,s)=>({element:e,rowspan:t,colspan:o,row:n,column:r,isLocked:s}))(e.element,e.rowspan,e.colspan,l,o,r);for(let n=0;n<e.colspan;n++)for(let r=0;r<e.rowspan;r++){const e=o+n,a=qo(l+r,e);t[a]=c,s=Math.max(s,e+1)}a.push(c)})),r++,o.push(Ge(e.element,a,e.section)),l++}));const{columns:i,colgroups:m}=q(a).map((e=>{const t=(e=>{const t={};let o=0;return N(e.cells,(e=>{const n=e.colspan;k(n,(r=>{const s=o+r;t[s]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,n,s)})),o+=n})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,Q(t));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),d=((e,t)=>({rows:e,columns:t}))(r,s);return{grid:d,access:t,all:o,columns:i,colgroups:m}},Uo=e=>{const t=Ut(e);return $o(t)},Go=$o,Ko=(e,t,o)=>C.from(e.access[qo(t,o)]),Yo=(e,t,o)=>{const n=Vo(e,(e=>o(t,e.element)));return n.length>0?C.some(n[0]):C.none()},Jo=Vo,Qo=e=>j(e.all,(e=>e.cells)),Xo=e=>Q(e.columns),Zo=e=>$(e.columns).length>0,en=(e,t)=>C.from(e.columns[t]),tn=(e,t=x)=>{const o=e.grid,n=k(o.columns,h),r=k(o.rows,h);return E(n,(o=>on((()=>j(r,(t=>Ko(e,t,o).filter((e=>e.column===o)).toArray()))),(e=>1===e.colspan&&t(e.element)),(()=>Ko(e,0,o)))))},on=(e,t,o)=>{const n=e();return L(n,t).orThunk((()=>C.from(n[0]).orThunk(o))).map((e=>e.element))},nn=e=>{const t=e.grid,o=k(t.rows,h),n=k(t.columns,h);return E(o,(t=>on((()=>j(n,(o=>Ko(e,t,o).filter((e=>e.row===t)).fold(g([]),(e=>[e]))))),(e=>1===e.rowspan),(()=>Ko(e,t,0)))))},rn=(e,t)=>o=>"rtl"===sn(o)?t:e,sn=e=>"rtl"===Rt(e,"direction")?"rtl":"ltr",ln=Ro("height",(e=>{const t=e.dom;return et(e)?t.getBoundingClientRect().height:t.offsetHeight})),an=e=>ln.get(e),cn=e=>ln.getOuter(e),mn=(e,t)=>({left:e,top:t,translate:(o,n)=>mn(e+o,t+n)}),dn=mn,un=(e,t)=>void 0!==e?e:void 0!==t?t:0,fn=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return dn(o.offsetLeft,o.offsetTop);const s=un(null==n?void 0:n.pageYOffset,r.scrollTop),l=un(null==n?void 0:n.pageXOffset,r.scrollLeft),a=un(r.clientTop,o.clientTop),c=un(r.clientLeft,o.clientLeft);return gn(e).translate(l-c,s-a)},gn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?dn(o.offsetLeft,o.offsetTop):et(e)?(e=>{const t=e.getBoundingClientRect();return dn(t.left,t.top)})(t):dn(0,0)},hn=(e,t)=>({row:e,y:t}),pn=(e,t)=>({col:e,x:t}),wn=e=>fn(e).left+Eo(e),bn=e=>fn(e).left,vn=(e,t)=>pn(e,bn(t)),yn=(e,t)=>pn(e,wn(t)),xn=e=>fn(e).top,Cn=(e,t)=>hn(e,xn(t)),Sn=(e,t)=>hn(e,xn(t)+cn(t)),Tn=(e,t,o)=>{if(0===o.length)return[];const n=E(o.slice(1),((t,o)=>t.map((t=>e(o,t))))),r=o[o.length-1].map((e=>t(o.length-1,e)));return n.concat([r])},Rn={delta:h,positions:e=>Tn(Cn,Sn,e),edge:xn},Dn=rn({delta:h,edge:bn,positions:e=>Tn(vn,yn,e)},{delta:e=>-e,edge:wn,positions:e=>Tn(yn,vn,e)}),On={delta:(e,t)=>Dn(t).delta(e,t),positions:(e,t)=>Dn(t).positions(e,t),edge:e=>Dn(e).edge(e)},kn={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:[""]},En=(()=>{const e="[0-9]+",t="[eE][+-]?[0-9]+",o=e=>`(?:${e})?`,n=["Infinity","[0-9]+\\."+o(e)+o(t),"\\.[0-9]+"+o(t),e+o(t)].join("|");return new RegExp(`^([+-]?(?:${n}))(.*)$`)})(),Nn=/(\d+(\.\d+)?)%/,Bn=/(\d+(\.\d+)?)px|em/,zn=ae("col"),An=(e,t,o)=>{const n=(r=e,C.from(r.dom.parentElement).map(pe.fromDom)).getOrThunk((()=>tt(Se(e))));var r;return t(e)/o(n)*100},Wn=(e,t)=>{St(e,"width",t+"px")},Ln=(e,t)=>{St(e,"width",t+"%")},_n=(e,t)=>{St(e,"height",t+"px")},Mn=e=>{const t=(e=>{return Do(t=e,"height",t.dom.offsetHeight)+"px";var t})(e);return t?((e,t,o,n)=>{const r=parseFloat(e);return bt(e,"%")&&"table"!==Z(t)?((e,t,o,n)=>{const r=Ft(e).map((e=>{const n=o(e);return Math.floor(t/100*n)})).getOr(t);return n(e,r),r})(t,r,o,n):r})(t,e,an,_n):an(e)},jn=(e,t)=>Ot(e,t).orThunk((()=>ue(e,t).map((e=>e+"px")))),In=e=>jn(e,"width"),Pn=e=>An(e,ko,No),Fn=e=>{return zn(e)?ko(e):Do(t=e,"width",t.dom.offsetWidth);var t},Hn=e=>((e,t,o)=>o(e)/Nt(e,"rowspan"))(e,0,Mn),qn=(e,t,o)=>{St(e,"width",t+o)},Vn=e=>An(e,ko,No)+"%",$n=g(Nn),Un=ae("col"),Gn=e=>In(e).getOrThunk((()=>Fn(e)+"px")),Kn=e=>{return(t=e,jn(t,"height")).getOrThunk((()=>Hn(e)+"px"));var t},Yn=(e,t,o,n,r,s)=>e.filter(n).fold((()=>s(((e,t)=>{if(t<0||t>=e.length-1)return C.none();const o=e[t].fold((()=>{const o=(e=>{const t=S.call(e,0);return t.reverse(),t})(e.slice(0,t));return V(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:0}))),n=e[t+1].fold((()=>{const o=e.slice(t+1);return V(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:1})));return o.bind((e=>n.map((t=>{const o=t.delta+e.delta;return Math.abs(t.value-e.value)/o}))))})(o,t))),(e=>r(e))),Jn=(e,t,o,n)=>{const r=tn(e),s=Zo(e)?(e=>E(Xo(e),(e=>C.from(e.element))))(e):r,l=[C.some(On.edge(t))].concat(E(On.positions(r,t),(e=>e.map((e=>e.x))))),a=b(Bt);return E(s,((e,t)=>Yn(e,t,l,a,(e=>{if((e=>{const t=To().browser,o=t.isChromium()||t.isFirefox();return!Un(e)||o})(e))return o(e);{const e=null!=(s=r[t])?h(s):C.none();return Yn(e,t,l,a,(e=>n(C.some(ko(e)))),n)}var s}),n)))},Qn=e=>e.map((e=>e+"px")).getOr(""),Xn=(e,t,o)=>Jn(e,t,Fn,(e=>e.getOrThunk(o.minCellWidth))),Zn=(e,t,o,n,r)=>{const s=nn(e),l=[C.some(o.edge(t))].concat(E(o.positions(s,t),(e=>e.map((e=>e.y)))));return E(s,((e,t)=>Yn(e,t,l,b(zt),n,r)))},er=(e,t)=>()=>et(e)?t(e):parseFloat(Ot(e,"width").getOr("0")),tr=e=>{const t=er(e,(e=>parseFloat(Vn(e)))),o=er(e,ko);return{width:t,pixelWidth:o,getWidths:(t,o)=>((e,t,o)=>Jn(e,t,Pn,(e=>e.fold((()=>o.minCellWidth()),(e=>e/o.pixelWidth()*100)))))(t,e,o),getCellDelta:e=>e/o()*100,singleColumnWidth:(e,t)=>[100-e],minCellWidth:()=>Wt()/o()*100,setElementWidth:Ln,adjustTableWidth:o=>{const n=t();Ln(e,n+o/100*n)},isRelative:!0,label:"percent"}},or=e=>{const t=er(e,ko);return{width:t,pixelWidth:t,getWidths:(t,o)=>Xn(t,e,o),getCellDelta:h,singleColumnWidth:(e,t)=>[Math.max(Wt(),e+t)-e],minCellWidth:Wt,setElementWidth:Wn,adjustTableWidth:o=>{const n=t()+o;Wn(e,n)},isRelative:!1,label:"pixel"}},nr=e=>In(e).fold((()=>(e=>{const t=er(e,ko),o=g(0);return{width:t,pixelWidth:t,getWidths:(t,o)=>Xn(t,e,o),getCellDelta:o,singleColumnWidth:g([0]),minCellWidth:o,setElementWidth:f,adjustTableWidth:f,isRelative:!0,label:"none"}})(e)),(t=>((e,t)=>null!==$n().exec(t)?tr(e):or(e))(e,t))),rr=or,sr=tr,lr=(e,t,o)=>{const n=e[o].element,r=pe.fromTag("td");We(r,pe.fromTag("br")),(t?We:Ae)(n,r)},ar=((e,t)=>{const o=t=>e(t)?C.from(t.dom.nodeValue):C.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return o(t).getOr("")},getOption:o,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(re),cr=e=>ar.get(e),ir=e=>ar.getOption(e),mr=(e,t)=>ar.set(e,t),dr=e=>"img"===Z(e)?1:ir(e).fold((()=>Ee(e).length),(e=>e.length)),ur=["img","br"],fr=e=>ir(e).filter((e=>0!==e.trim().length||e.indexOf("\xa0")>-1)).isSome()||D(ur,Z(e)),gr=e=>((e,t)=>{const o=e=>{for(let n=0;n<e.childNodes.length;n++){const r=pe.fromDom(e.childNodes[n]);if(t(r))return C.some(r);const s=o(e.childNodes[n]);if(s.isSome())return s}return C.none()};return o(e.dom)})(e,fr),hr=e=>pr(e,fr),pr=(e,t)=>{const o=e=>{const n=Ee(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return C.some(r);const s=o(r);if(s.isSome())return s}return C.none()};return o(e)},wr={scope:["row","col"]},br=e=>()=>{const t=pe.fromTag("td",e.dom);return We(t,pe.fromTag("br",e.dom)),t},vr=e=>()=>pe.fromTag("col",e.dom),yr=e=>()=>pe.fromTag("colgroup",e.dom),xr=e=>()=>pe.fromTag("tr",e.dom),Cr=(e,t,o)=>{const n=((e,t)=>{const o=Ve(e,t),n=Ee(qe(e));return Me(o,n),o})(e,t);return G(o,((e,t)=>{null===e?fe(n,t):ie(n,t,e)})),n},Sr=e=>e,Tr=(e,t,o)=>{const n=(e,t)=>{((e,t)=>{const o=e.dom,n=t.dom;xt(o)&&xt(n)&&(n.style.cssText=o.style.cssText)})(e.element,t),kt(t,"height"),1!==e.colspan&&kt(t,"width")};return{col:o=>{const r=pe.fromTag(Z(o.element),t.dom);return n(o,r),e(o.element,r),r},colgroup:yr(t),row:xr(t),cell:r=>{const s=pe.fromTag(Z(r.element),t.dom),l=o.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),a=l.length>0?((e,t,o)=>gr(e).map((n=>{const r=o.join(","),s=nt(n,r,(t=>ye(t,e)));return A(s,((e,t)=>{const o=He(t);return fe(o,"contenteditable"),We(e,o),o}),t)})).getOr(t))(r.element,s,l):s;return We(a,pe.fromTag("br")),n(r,s),((e,t)=>{G(wr,((o,n)=>ue(e,n).filter((e=>D(o,e))).each((e=>ie(t,n,e)))))})(r.element,s),e(r.element,s),s},replace:Cr,colGap:vr(t),gap:br(t)}},Rr=e=>({col:vr(e),colgroup:yr(e),row:xr(e),cell:br(e),replace:Sr,colGap:vr(e),gap:br(e)}),Dr=e=>pe.fromDom(e.getBody()),Or=e=>t=>ye(t,Dr(e)),kr=e=>{fe(e,"data-mce-style");const t=e=>fe(e,"data-mce-style");N(It(e),t),N(Pt(e),t),N(Ht(e),t)},Er=e=>pe.fromDom(e.selection.getStart()),Nr=e=>e.getBoundingClientRect().width,Br=e=>e.getBoundingClientRect().height,zr=(e,t)=>{const o=t.column,n=t.column+t.colspan-1,r=t.row,s=t.row+t.rowspan-1;return o<=e.finishCol&&n>=e.startCol&&r<=e.finishRow&&s>=e.startRow},Ar=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,Wr=(e,t,o)=>{const n=Yo(e,t,ye),r=Yo(e,o,ye);return n.bind((e=>r.map((t=>{return o=e,n=t,{startRow:Math.min(o.row,n.row),startCol:Math.min(o.column,n.column),finishRow:Math.max(o.row+o.rowspan-1,n.row+n.rowspan-1),finishCol:Math.max(o.column+o.colspan-1,n.column+n.colspan-1)};var o,n}))))},Lr=(e,t,o)=>Wr(e,t,o).map((t=>{const o=Jo(e,w(zr,t));return E(o,(e=>e.element))})),_r=(e,t)=>Yo(e,t,((e,t)=>xe(t,e))).map((e=>e.element)),Mr=(e,t,o)=>{const n=Ir(e);return Lr(n,t,o)},jr=(e,t,o,n,r)=>{const s=Ir(e),l=ye(e,o)?C.some(t):_r(s,t),a=ye(e,r)?C.some(n):_r(s,n);return l.bind((e=>a.bind((t=>Lr(s,e,t)))))},Ir=Uo;var Pr=["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"],Fr=()=>({up:g({selector:ct,closest:dt,predicate:at,all:De}),down:g({selector:st,predicate:ot}),styles:g({get:Rt,getRaw:Ot,set:St,remove:kt}),attrs:g({get:de,set:ie,remove:fe,copyTo:(e,t)=>{const o=ge(e);me(t,o)}}),insert:g({before:Be,after:ze,afterAll:_e,append:We,appendAll:Me,prepend:Ae,wrap:Le}),remove:g({unwrap:Pe,remove:Ie}),create:g({nu:pe.fromTag,clone:e=>pe.fromDom(e.dom.cloneNode(!1)),text:pe.fromText}),query:g({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:Oe,nextSibling:ke}),property:g({children:Ee,name:Z,parent:Re,document:e=>Te(e).dom,isText:re,isComment:oe,isElement:ne,isSpecial:e=>{const t=Z(e);return D(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>ne(e)?ue(e,"lang"):C.none(),getText:cr,setText:mr,isBoundary:e=>!!ne(e)&&("body"===Z(e)||D(Pr,Z(e))),isEmptyTag:e=>!!ne(e)&&D(["br","img","hr","input"],Z(e)),isNonEditable:e=>ne(e)&&"false"===de(e,"contenteditable")}),eq:ye,is:Ce});const Hr=(e,t,o,n)=>{const r=t(e,o);return A(n,((o,n)=>{const r=t(e,n);return qr(e,o,r)}),r)},qr=(e,t,o)=>t.bind((t=>o.filter(w(e.eq,t)))),Vr=Fr(),$r=(e,t)=>((e,t,o)=>o.length>0?((e,t,o,n)=>n(e,t,o[0],o.slice(1)))(e,t,o,Hr):C.none())(Vr,((t,o)=>e(o)),t),Ur=e=>ct(e,"table"),Gr=(e,t,o)=>{const n=e=>t=>void 0!==o&&o(t)||ye(t,e);return ye(e,t)?C.some({boxes:C.some([e]),start:e,finish:t}):Ur(e).bind((r=>Ur(t).bind((s=>{if(ye(r,s))return C.some({boxes:Mr(r,e,t),start:e,finish:t});if(xe(r,s)){const o=nt(t,"td,th",n(r)),l=o.length>0?o[o.length-1]:t;return C.some({boxes:jr(r,e,r,t,s),start:e,finish:l})}if(xe(s,r)){const o=nt(e,"td,th",n(s)),l=o.length>0?o[o.length-1]:e;return C.some({boxes:jr(s,e,r,t,s),start:e,finish:l})}return((e,t,o)=>((e,t,o,n=y)=>{const r=[t].concat(e.up().all(t)),s=[o].concat(e.up().all(o)),l=e=>_(e,n).fold((()=>e),(t=>e.slice(0,t+1))),a=l(r),c=l(s),i=L(a,(t=>O(c,((e,t)=>w(e.eq,t))(e,t))));return{firstpath:a,secondpath:c,shared:i}})(Vr,e,t,void 0))(e,t).shared.bind((l=>dt(l,"table",o).bind((o=>{const l=nt(t,"td,th",n(o)),a=l.length>0?l[l.length-1]:t,c=nt(e,"td,th",n(o)),i=c.length>0?c[c.length-1]:e;return C.some({boxes:jr(o,e,r,t,s),start:i,finish:a})}))))}))))},Kr=(e,t)=>{const o=st(e,t);return o.length>0?C.some(o):C.none()},Yr=(e,t,o)=>mt(e,t).bind((t=>mt(e,o).bind((e=>$r(Ur,[t,e]).map((o=>({first:t,last:e,table:o}))))))),Jr=(e,t,o,n,r)=>((e,t)=>L(e,(e=>we(e,t))))(e,r).bind((e=>((e,t,o)=>Ft(e).bind((n=>((e,t,o,n)=>Yo(e,t,ye).bind((t=>{const r=o>0?t.row+t.rowspan-1:t.row,s=n>0?t.column+t.colspan-1:t.column;return Ko(e,r+o,s+n).map((e=>e.element))})))(Ir(n),e,t,o))))(e,t,o).bind((e=>((e,t)=>ct(e,"table").bind((o=>mt(o,t).bind((t=>Gr(t,e).bind((e=>e.boxes.map((t=>({boxes:t,start:e.start,finish:e.finish}))))))))))(e,n))))),Qr=(e,t)=>Kr(e,t),Xr=(e,t,o)=>Yr(e,t,o).bind((t=>{const o=t=>ye(e,t),n="thead,tfoot,tbody,table",r=ct(t.first,n,o),s=ct(t.last,n,o);return r.bind((e=>s.bind((o=>ye(e,o)?((e,t,o)=>((e,t,o)=>Wr(e,t,o).bind((t=>((e,t)=>{let o=!0;const n=w(Ar,t);for(let r=t.startRow;r<=t.finishRow;r++)for(let s=t.startCol;s<=t.finishCol;s++)o=o&&Ko(e,r,s).exists(n);return o?C.some(t):C.none()})(e,t))))(Ir(e),t,o))(t.table,t.first,t.last):C.none()))))})),Zr=h,es=e=>{const t=(e,t)=>ue(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&I(e,(e=>t(e,"rowspan")||t(e,"colspan")))?C.some(e):C.none()},ts=(e,t,o)=>t.length<=1?C.none():Xr(e,o.firstSelectedSelector,o.lastSelectedSelector).map((e=>({bounds:e,cells:t}))),os={selected:"data-mce-selected",selectedSelector:"td[data-mce-selected],th[data-mce-selected]",firstSelected:"data-mce-first-selected",firstSelectedSelector:"td[data-mce-first-selected],th[data-mce-first-selected]",lastSelected:"data-mce-last-selected",lastSelectedSelector:"td[data-mce-last-selected],th[data-mce-last-selected]"},ns=(e,t,o)=>({element:o,mergable:ts(t,e,os),unmergable:es(e),selection:Zr(e)}),rs=e=>(t,o)=>{const n=Z(t),r="col"===n||"colgroup"===n?Ft(s=t).bind((e=>Qr(e,os.firstSelectedSelector))).fold(g(s),(e=>e[0])):t;var s;return dt(r,e,o)},ss=rs("th,td,caption"),ls=rs("th,td"),as=e=>{return t=e.model.table.getSelectedCells(),E(t,pe.fromDom);var t},cs=(e,t)=>{e.on("BeforeGetContent",(t=>{const o=o=>{t.preventDefault(),(e=>Ft(e[0]).map((e=>{const t=((e,t)=>{const o=e=>we(e.element,t),n=qe(e),r=Ut(n),s=nr(e),l=Go(r),a=((e,t)=>{const o=e.grid.columns;let n=e.grid.rows,r=o,s=0,l=0;const a=[],c=[];return G(e.access,(e=>{if(a.push(e),t(e)){c.push(e);const t=e.row,o=t+e.rowspan-1,a=e.column,i=a+e.colspan-1;t<n?n=t:o>s&&(s=o),a<r?r=a:i>l&&(l=i)}})),((e,t,o,n,r,s)=>({minRow:e,minCol:t,maxRow:o,maxCol:n,allCells:r,selectedCells:s}))(n,r,s,l,a,c)})(l,o),c="th:not("+t+"),td:not("+t+")",i=Mt(n,"th,td",(e=>we(e,c)));N(i,Ie),((e,t,o,n)=>{const r=z(e,(e=>"colgroup"!==e.section)),s=t.grid.columns,l=t.grid.rows;for(let e=0;e<l;e++){let l=!1;for(let a=0;a<s;a++)e<o.minRow||e>o.maxRow||a<o.minCol||a>o.maxCol||(Ko(t,e,a).filter(n).isNone()?lr(r,l,e):l=!0)}})(r,l,a,o);const m=((e,t,o,n)=>{if(0===n.minCol&&t.grid.columns===n.maxCol+1)return 0;const r=Xn(t,e,o),s=W(r,((e,t)=>e+t),0),l=W(r.slice(n.minCol,n.maxCol+1),((e,t)=>e+t),0),a=l/s*o.pixelWidth()-o.pixelWidth();return o.getCellDelta(a)})(e,Uo(e),s,a);return((e,t,o,n)=>{G(o.columns,(e=>{(e.column<t.minCol||e.column>t.maxCol)&&Ie(e.element)}));const r=z(_t(e,"tr"),(e=>0===e.dom.childElementCount));N(r,Ie),t.minCol!==t.maxCol&&t.minRow!==t.maxRow||N(_t(e,"th,td"),(e=>{fe(e,"rowspan"),fe(e,"colspan")})),fe(e,Po),fe(e,"data-snooker-col-series"),nr(e).adjustTableWidth(n)})(n,a,l,m),n})(e,"[data-mce-selected]");return kr(t),[t]})))(o).each((o=>{t.content="text"===t.format?(e=>E(e,(e=>e.dom.innerText)).join(""))(o):((e,t)=>E(t,(t=>e.selection.serializer.serialize(t.dom,{}))).join(""))(e,o)}))};if(!0===t.selection){const t=(e=>z(as(e),(e=>we(e,os.selectedSelector))))(e);t.length>=1&&o(t)}})),e.on("BeforeSetContent",(o=>{if(!0===o.selection&&!0===o.paste){const n=as(e);H(n).each((n=>{Ft(n).each((r=>{const s=z(((e,t)=>{const o=document.createElement("div");return o.innerHTML=e,Ee(pe.fromDom(o))})(o.content),(e=>"meta"!==Z(e))),l=ae("table");if(1===s.length&&l(s[0])){o.preventDefault();const l=pe.fromDom(e.getDoc()),a=Rr(l),c=((e,t,o)=>({element:e,clipboard:t,generators:o}))(n,s[0],a);t.pasteCells(r,c).each((()=>{e.focus()}))}}))}))}}))},is=(e,t)=>({element:e,offset:t}),ms=(e,t,o)=>e.property().isText(t)&&0===e.property().getText(t).trim().length||e.property().isComment(t)?o(t).bind((t=>ms(e,t,o).orThunk((()=>C.some(t))))):C.none(),ds=(e,t)=>e.property().isText(t)?e.property().getText(t).length:e.property().children(t).length,us=(e,t)=>{const o=ms(e,t,e.query().prevSibling).getOr(t);if(e.property().isText(o))return is(o,ds(e,o));const n=e.property().children(o);return n.length>0?us(e,n[n.length-1]):is(o,ds(e,o))},fs=us,gs=Fr(),hs=(e,t)=>{if(!Bt(e)){const o=(e=>In(e).bind((e=>{return t=e,o=["fixed","relative","empty"],C.from(En.exec(t)).bind((e=>{const t=Number(e[1]),n=e[2];return((e,t)=>O(t,(t=>O(kn[t],(t=>e===t)))))(n,o)?C.some({value:t,unit:n}):C.none()}));var t,o})))(e);o.each((o=>{const n=o.value/2;qn(e,n,o.unit),qn(t,n,o.unit)}))}},ps=e=>E(e,g(0)),ws=(e,t,o,n,r)=>r(e.slice(0,t)).concat(n).concat(r(e.slice(o))),bs=e=>(t,o,n,r)=>{if(e(n)){const e=Math.max(r,t[o]-Math.abs(n)),s=Math.abs(e-t[o]);return n>=0?s:-s}return n},vs=bs((e=>e<0)),ys=bs(x),xs=()=>{const e=(e,t,o,n)=>{const r=(100+o)/100,s=Math.max(n,(e[t]+o)/r);return E(e,((e,o)=>(o===t?s:e/r)-e))},t=(t,o,n,r,s,l)=>l?e(t,o,r,s):((e,t,o,n,r)=>{const s=vs(e,t,n,r);return ws(e,t,o+1,[s,0],ps)})(t,o,n,r,s);return{resizeTable:(e,t)=>e(t),clampTableDelta:vs,calcLeftEdgeDeltas:t,calcMiddleDeltas:(e,o,n,r,s,l,a)=>t(e,n,r,s,l,a),calcRightEdgeDeltas:(t,o,n,r,s,l)=>{if(l)return e(t,n,r,s);{const e=vs(t,n,r,s);return ps(t.slice(0,n)).concat([e])}},calcRedestributedWidths:(e,t,o,n)=>{if(n){const n=(t+o)/t,r=E(e,(e=>e/n));return{delta:100*n-100,newSizes:r}}return{delta:o,newSizes:e}}}},Cs=()=>{const e=(e,t,o,n,r)=>{const s=ys(e,n>=0?o:t,n,r);return ws(e,t,o+1,[s,-s],ps)};return{resizeTable:(e,t,o)=>{o&&e(t)},clampTableDelta:(e,t,o,n,r)=>{if(r){if(o>=0)return o;{const t=W(e,((e,t)=>e+t-n),0);return Math.max(-t,o)}}return vs(e,t,o,n)},calcLeftEdgeDeltas:e,calcMiddleDeltas:(t,o,n,r,s,l)=>e(t,n,r,s,l),calcRightEdgeDeltas:(e,t,o,n,r,s)=>{if(s)return ps(e);{const t=n/e.length;return E(e,g(t))}},calcRedestributedWidths:(e,t,o,n)=>({delta:0,newSizes:e})}},Ss=e=>Uo(e).grid,Ts=ae("th"),Rs=e=>I(e,(e=>Ts(e.element))),Ds=(e,t)=>e&&t?"sectionCells":e?"section":"cells",Os=e=>{const t="thead"===e.section,o=ut(ks(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:Ds(t,o)}:{type:"body"}},ks=e=>{const t=z(e,(e=>Ts(e.element)));return 0===t.length?C.some("td"):t.length===e.length?C.some("th"):C.none()},Es=(e,t,o)=>Ke(o(e.element,t),!0,e.isLocked),Ns=(e,t)=>e.section!==t?Ye(e.element,e.cells,t,e.isNew):e,Bs=()=>({transformRow:Ns,transformCell:(e,t,o)=>{const n=o(e.element,t),r="td"!==Z(n)?((e,t)=>{const o=Ve(e,"td");ze(e,o);const n=Ee(e);return Me(o,n),Ie(e),o})(n):n;return Ke(r,e.isNew,e.isLocked)}}),zs=()=>({transformRow:Ns,transformCell:Es}),As=()=>({transformRow:(e,t)=>Ns(e,"thead"===t?"tbody":t),transformCell:Es}),Ws=Bs,Ls=zs,_s=As,Ms=()=>({transformRow:h,transformCell:Es}),js=e=>dt(e,"[contenteditable]"),Is=(e,t=!1)=>et(e)?e.dom.isContentEditable:js(e).fold(g(t),(e=>"true"===Ps(e))),Ps=e=>e.dom.contentEditable,Fs=(e,t,o,n)=>{o===n?fe(e,t):ie(e,t,o)},Hs=(e,t,o)=>{q(rt(e,t)).fold((()=>Ae(e,o)),(e=>ze(e,o)))},qs=(e,t)=>{const o=[],n=[],r=e=>E(e,(e=>{e.isNew&&o.push(e.element);const t=e.element;return je(t),N(e.cells,(e=>{e.isNew&&n.push(e.element),Fs(e.element,"colspan",e.colspan,1),Fs(e.element,"rowspan",e.rowspan,1),We(t,e.element)})),t})),s=e=>j(e,(e=>E(e.cells,(e=>(Fs(e.element,"span",e.colspan,1),e.element))))),l=(t,o)=>{const n=((e,t)=>{const o=it(e,t).getOrThunk((()=>{const o=pe.fromTag(t,Se(e).dom);return"thead"===t?Hs(e,"caption,colgroup",o):"colgroup"===t?Hs(e,"caption",o):We(e,o),o}));return je(o),o})(e,o),l=("colgroup"===o?s:r)(t);Me(n,l)},a=(t,o)=>{t.length>0?l(t,o):(t=>{it(e,t).each(Ie)})(o)},c=[],i=[],m=[],d=[];return N(t,(e=>{switch(e.section){case"thead":c.push(e);break;case"tbody":i.push(e);break;case"tfoot":m.push(e);break;case"colgroup":d.push(e)}})),a(d,"colgroup"),a(c,"thead"),a(i,"tbody"),a(m,"tfoot"),{newRows:o,newCells:n}},Vs=(e,t)=>{if(0===e.length)return 0;const o=e[0];return _(e,(e=>!t(o.element,e.element))).getOr(e.length)},$s=(e,t)=>{const o=E(e,(e=>E(e.cells,y)));return E(e,((n,r)=>{const s=j(n.cells,((n,s)=>{if(!1===o[r][s]){const m=((e,t,o,n)=>{const r=((e,t)=>e[t])(e,t),s="colgroup"===r.section,l=Vs(r.cells.slice(o),n),a=s?1:Vs(((e,t)=>E(e,(e=>Lo(e,t))))(e.slice(t),o),n);return{colspan:l,rowspan:a}})(e,r,s,t);return((e,t,n,r)=>{for(let s=e;s<e+n;s++)for(let e=t;e<t+r;e++)o[s][e]=!0})(r,s,m.rowspan,m.colspan),[(l=n.element,a=m.rowspan,c=m.colspan,i=n.isNew,{element:l,rowspan:a,colspan:c,isNew:i})]}return[];var l,a,c,i}));return((e,t,o,n)=>({element:e,cells:t,section:o,isNew:n}))(n.element,s,n.section,n.isNew)}))},Us=(e,t,o)=>{const n=[];N(e.colgroups,(r=>{const s=[];for(let n=0;n<e.grid.columns;n++){const r=en(e,n).map((e=>Ke(e.element,o,!1))).getOrThunk((()=>Ke(t.colGap(),!0,!1)));s.push(r)}n.push(Ye(r.element,s,"colgroup",o))}));for(let r=0;r<e.grid.rows;r++){const s=[];for(let n=0;n<e.grid.columns;n++){const l=Ko(e,r,n).map((e=>Ke(e.element,o,e.isLocked))).getOrThunk((()=>Ke(t.gap(),!0,!1)));s.push(l)}const l=e.all[r],a=Ye(l.element,s,l.section,o);n.push(a)}return n},Gs=e=>$s(e,ye),Ks=(e,t)=>V(e.all,(e=>L(e.cells,(e=>ye(t,e.element))))),Ys=(e,t,o)=>{const n=E(t.selection,(t=>jt(t).bind((t=>Ks(e,t))).filter(o))),r=ft(n);return gt(r.length>0,r)},Js=(e,t,o,n,r)=>(s,l,a,c)=>{const i=Uo(s),m=C.from(null==c?void 0:c.section).getOrThunk(Ms);return t(i,l).map((t=>{const o=((e,t)=>Us(e,t,!1))(i,a),n=e(o,t,ye,r(a),m),s=Ho(n.grid);return{info:t,grid:Gs(n.grid),cursor:n.cursor,lockedColumns:s}})).bind((e=>{const t=qs(s,e.grid),r=C.from(null==c?void 0:c.sizing).getOrThunk((()=>nr(s))),l=C.from(null==c?void 0:c.resize).getOrThunk(Cs);return o(s,e.grid,e.info,{sizing:r,resize:l,section:m}),n(s),fe(s,Po),e.lockedColumns.length>0&&ie(s,Po,e.lockedColumns.join(",")),C.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})}))},Qs=(e,t)=>Ys(e,t,x).map((e=>({cells:e,generators:t.generators,clipboard:t.clipboard}))),Xs=(e,t)=>Ys(e,t,x),Zs=(e,t)=>Ys(e,t,(e=>!e.isLocked)),el=(e,t)=>I(t,(t=>((e,t)=>Ks(e,t).exists((e=>!e.isLocked)))(e,t))),tl=(e,t,o,n)=>{const r=jo(e).rows;let s=!0;for(let e=0;e<r.length;e++)for(let l=0;l<Mo(r[0]);l++){const a=r[e],c=Lo(a,l),i=o(c.element,t);i&&!s?Ao(a,l,Ke(n(),!0,c.isLocked)):i&&(s=!1)}return e},ol=e=>{const t=t=>t(e),o=g(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:x,isError:y,map:t=>rl.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>C.some(e)};return r},nl=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:y,isError:x,map:t,mapError:t=>rl.error(t(e)),bind:t,exists:y,forall:x,getOr:h,or:h,getOrThunk:v,orThunk:v,getOrDie:(n=String(e),()=>{throw new Error(n)}),each:f,toOptional:C.none};var n;return o},rl={value:ol,error:nl,fromOption:(e,t)=>e.fold((()=>nl(t)),ol)},sl=(e,t)=>({rowDelta:0,colDelta:Mo(e[0])-Mo(t[0])}),ll=(e,t)=>({rowDelta:e.length-t.length,colDelta:0}),al=(e,t,o,n)=>{const r="colgroup"===t.section?o.col:o.cell;return k(e,(e=>Ke(r(),!0,n(e))))},cl=(e,t,o,n)=>{const r=e[e.length-1];return e.concat(k(t,(()=>{const e="colgroup"===r.section?o.colgroup:o.row,t=Io(r,e,h),s=al(t.cells.length,t,o,(e=>X(n,e.toString())));return Wo(t,s)})))},il=(e,t,o,n)=>E(e,(e=>{const r=al(t,e,o,y);return Bo(e,n,r)})),ml=(e,t,o)=>{const n=t.colDelta<0?il:h,r=t.rowDelta<0?cl:h,s=Ho(e),l=Mo(e[0]),a=O(s,(e=>e===l-1)),c=n(e,Math.abs(t.colDelta),o,a?l-1:l),i=Ho(c);return r(c,Math.abs(t.rowDelta),o,P(i,x))},dl=(e,t,o,n)=>{const r=w(n,Lo(e[t],o).element),s=e[t];return e.length>1&&Mo(s)>1&&(o>0&&r(_o(s,o-1))||o<s.cells.length-1&&r(_o(s,o+1))||t>0&&r(_o(e[t-1],o))||t<e.length-1&&r(_o(e[t+1],o)))},ul=(e,t,o)=>z(o,(o=>o>=e.column&&o<=Mo(t[0])+e.column)),fl=(e,t,o,n,r)=>{((e,t,o,n)=>{t>0&&t<e[0].cells.length&&N(e,(e=>{const r=e.cells[t-1];let s=0;const l=n();for(;e.cells.length>t+s&&o(r.element,e.cells[t+s].element);)Ao(e,t+s,Ke(l,!0,e.cells[t+s].isLocked)),s++}))})(t,e,r,n.cell);const s=ll(o,t),l=ml(o,s,n),a=ll(t,l),c=ml(t,a,n);return E(c,((t,o)=>Bo(t,e,l[o].cells)))},gl=(e,t,o,n,r)=>{((e,t,o,n)=>{const r=jo(e).rows;if(t>0&&t<r.length){const e=((e,t)=>W(e,((e,o)=>O(e,(e=>t(e.element,o.element)))?e:e.concat([o])),[]))(r[t-1].cells,o);N(e,(e=>{let s=C.none();for(let l=t;l<r.length;l++)for(let t=0;t<Mo(r[0]);t++){const a=r[l],c=Lo(a,t);o(c.element,e.element)&&(s.isNone()&&(s=C.some(n())),s.each((e=>{Ao(a,t,Ke(e,!0,c.isLocked))})))}}))}})(t,e,r,n.cell);const s=Ho(t),l=sl(t,o),a={...l,colDelta:l.colDelta-s.length},c=ml(t,a,n),{cols:i,rows:m}=jo(c),d=Ho(c),u=sl(o,t),f={...u,colDelta:u.colDelta+d.length},g=(p=n,w=d,E(o,(e=>W(w,((t,o)=>{const n=al(1,e,p,x)[0];return zo(t,o,n)}),e)))),h=ml(g,f,n);var p,w;return[...i,...m.slice(0,e),...h,...m.slice(e,m.length)]},hl=(e,t,o,n,r)=>{const{rows:s,cols:l}=jo(e),a=s.slice(0,t),c=s.slice(t);return[...l,...a,((e,t,o,n)=>Io(e,(e=>n(e,o)),t))(s[o],((e,o)=>t>0&&t<s.length&&n(_o(s[t-1],o),_o(s[t],o))?Lo(s[t],o):Ke(r(e.element,n),!0,e.isLocked)),n,r),...c]},pl=(e,t,o,n,r)=>E(e,(e=>{const s=t>0&&t<Mo(e)&&n(_o(e,t-1),_o(e,t)),l=((e,t,o,n,r,s,l)=>{if("colgroup"!==o&&n)return Lo(e,t);{const t=Lo(e,r);return Ke(l(t.element,s),!0,!1)}})(e,t,e.section,s,o,n,r);return zo(e,t,l)})),wl=(e,t,o,n)=>((e,t,o,n)=>void 0!==_o(e[t],o)&&t>0&&n(_o(e[t-1],o),_o(e[t],o)))(e,t,o,n)||((e,t,o)=>t>0&&o(_o(e,t-1),_o(e,t)))(e[t],o,n),bl=(e,t,o,n)=>{const r=e=>(e=>"row"===e?zt(t):Bt(t))(e)?`${e}group`:e;return e?Ts(t)?r(o):null:n&&Ts(t)?r("row"===o?"col":"row"):null},vl=(e,t,o)=>Ke(o(e.element,t),!0,e.isLocked),yl=(e,t,o,n,r,s,l)=>E(e,((e,a)=>((e,c)=>{const i=e.cells,m=E(i,((e,c)=>{if((e=>O(t,(t=>o(e.element,t.element))))(e)){const t=l(e,a,c)?r(e,o,n):e;return s(t,a,c).each((e=>{var o,n;o=t.element,n={scope:C.from(e)},G(n,((e,t)=>{e.fold((()=>{fe(o,t)}),(e=>{ce(o.dom,t,e)}))}))})),t}return e}));return Ye(e.element,m,e.section,e.isNew)})(e))),xl=(e,t,o)=>j(e,((n,r)=>wl(e,r,t,o)?[]:[Lo(n,t)])),Cl=(e,t,o,n,r)=>{const s=jo(e).rows,l=j(t,(e=>xl(s,e,n))),a=E(s,(e=>Rs(e.cells))),c=((e,t)=>I(t,h)&&Rs(e)?x:(e,o,n)=>!("th"===Z(e.element)&&t[o]))(l,a),i=((e,t)=>(o,n)=>C.some(bl(e,o.element,"row",t[n])))(o,a);return yl(e,l,n,r,vl,i,c)},Sl=(e,t,o,n)=>{const r=jo(e).rows,s=E(t,(e=>Lo(r[e.row],e.column)));return yl(e,s,o,n,vl,C.none,x)},Tl=e=>{if(!l(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return N(e,((n,r)=>{const s=$(n);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],c=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!l(c))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==c.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+c.length+" ("+c+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=$(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!I(t,(e=>D(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o},Rl={...Tl([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}])},Dl=(e,t,o)=>{let n=0;for(let r=e;r<t;r++)n+=void 0!==o[r]?o[r]:0;return n},Ol=(e,t)=>{const o=Qo(e);return E(o,(e=>{const o=Dl(e.row,e.row+e.rowspan,t);return{element:e.element,height:o,rowspan:e.rowspan}}))},kl=(e,t,o)=>{const n=((e,t)=>Zo(e)?((e,t)=>{const o=Xo(e);return E(o,((e,o)=>({element:e.element,width:t[o],colspan:e.colspan})))})(e,t):((e,t)=>{const o=Qo(e);return E(o,(e=>{const o=Dl(e.column,e.column+e.colspan,t);return{element:e.element,width:o,colspan:e.colspan}}))})(e,t))(e,t);N(n,(e=>{o.setElementWidth(e.element,e.width)}))},El=(e,t,o,n,r)=>{const s=Uo(e),l=r.getCellDelta(t),a=r.getWidths(s,r),c=o===s.grid.columns-1,i=n.clampTableDelta(a,o,l,r.minCellWidth(),c),m=((e,t,o,n,r)=>{const s=e.slice(0),l=((e,t)=>0===e.length?Rl.none():1===e.length?Rl.only(0):0===t?Rl.left(0,1):t===e.length-1?Rl.right(t-1,t):t>0&&t<e.length-1?Rl.middle(t-1,t,t+1):Rl.none())(e,t),a=g(E(s,g(0)));return l.fold(a,(e=>n.singleColumnWidth(s[e],o)),((e,t)=>r.calcLeftEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)),((e,t,l)=>r.calcMiddleDeltas(s,e,t,l,o,n.minCellWidth(),n.isRelative)),((e,t)=>r.calcRightEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)))})(a,o,i,r,n),d=E(m,((e,t)=>e+a[t]));kl(s,d,r),n.resizeTable(r.adjustTableWidth,i,c)},Nl=e=>W(e,((e,t)=>O(e,(e=>e.column===t.column))?e:e.concat([t])),[]).sort(((e,t)=>e.column-t.column)),Bl=ae("col"),zl=ae("colgroup"),Al=e=>"tr"===Z(e)||zl(e),Wl=e=>({element:e,colspan:Et(e,"colspan",1),rowspan:Et(e,"rowspan",1)}),Ll=e=>ue(e,"scope").map((e=>e.substr(0,3))),_l=(e,t=Wl)=>{const o=o=>{if(Al(o))return zl((r={element:o}).element)?e.colgroup(r):e.row(r);{const r=o,s=(t=>Bl(t.element)?e.col(t):e.cell(t))(t(r));return n=C.some({item:r,replacement:s}),s}var r};let n=C.none();return{getOrInit:(e,t)=>n.fold((()=>o(e)),(n=>t(e,n.item)?n.replacement:o(e)))}},Ml=e=>t=>{const o=[],n=n=>{const r="td"===e?{scope:null}:{},s=t.replace(n,e,r);return o.push({item:n,sub:s}),s};return{replaceOrInit:(e,t)=>{if(Al(e)||Bl(e))return e;{const r=e;return((e,t)=>L(o,(o=>t(o.item,e))))(r,t).fold((()=>n(r)),(o=>t(e,o.item)?o.sub:n(r)))}}}},jl=e=>({unmerge:t=>{const o=Ll(t);return o.each((e=>ie(t,"scope",e))),()=>{const n=e.cell({element:t,colspan:1,rowspan:1});return kt(n,"width"),kt(t,"width"),o.each((e=>ie(n,"scope",e))),n}},merge:e=>(kt(e[0],"width"),(()=>{const t=ft(E(e,Ll));if(0===t.length)return C.none();{const e=t[0],o=["row","col"];return O(t,(t=>t!==e&&D(o,t)))?C.none():C.from(e)}})().fold((()=>fe(e[0],"scope")),(t=>ie(e[0],"scope",t+"group"))),g(e[0]))}),Il=["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"],Pl=Fr(),Fl=e=>((e,t)=>{const o=e.property().name(t);return D(Il,o)})(Pl,e),Hl=e=>((e,t)=>{const o=e.property().name(t);return D(["ol","ul"],o)})(Pl,e),ql=e=>{const t=ae("br"),o=e=>hr(e).bind((o=>{const n=ke(o).map((e=>!!Fl(e)||!!((e,t)=>D(["br","img","hr","input"],e.property().name(t)))(Pl,e)&&"img"!==Z(e))).getOr(!1);return Re(o).map((r=>{return!0===n||("li"===Z(s=r)||at(s,Hl).isSome())||t(o)||Fl(r)&&!ye(e,r)?[]:[pe.fromTag("br")];var s}))})).getOr([]),n=(()=>{const n=j(e,(e=>{const n=Ee(e);return(e=>I(e,(e=>t(e)||re(e)&&0===cr(e).trim().length)))(n)?[]:n.concat(o(e))}));return 0===n.length?[pe.fromTag("br")]:n})();je(e[0]),Me(e[0],n)},Vl=e=>Is(e,!0),$l=e=>{0===It(e).length&&Ie(e)},Ul=(e,t)=>({grid:e,cursor:t}),Gl=(e,t,o)=>{const n=((e,t,o)=>{var n,r;const s=jo(e).rows;return C.from(null===(r=null===(n=s[t])||void 0===n?void 0:n.cells[o])||void 0===r?void 0:r.element).filter(Vl).orThunk((()=>(e=>V(e,(e=>V(e.cells,(e=>{const t=e.element;return gt(Vl(t),t)})))))(s)))})(e,t,o);return Ul(e,n)},Kl=e=>W(e,((e,t)=>O(e,(e=>e.row===t.row))?e:e.concat([t])),[]).sort(((e,t)=>e.row-t.row)),Yl=(e,t)=>(o,n,r,s,l)=>{const a=Kl(n),c=E(a,(e=>e.row)),i=((e,t,o,n,r,s,l)=>{const{cols:a,rows:c}=jo(e),i=c[t[0]],m=j(t,(e=>((e,t,o)=>{const n=e[t];return j(n.cells,((n,r)=>wl(e,t,r,o)?[]:[n]))})(c,e,r))),d=E(i.cells,((e,t)=>Rs(xl(c,t,r)))),u=[...c];N(t,(e=>{u[e]=l.transformRow(c[e],o)}));const f=[...a,...u],g=((e,t)=>I(t,h)&&Rs(e.cells)?x:(e,o,n)=>!("th"===Z(e.element)&&t[n]))(i,d),p=((e,t)=>(o,n,r)=>C.some(bl(e,o.element,"col",t[r])))(n,d);return yl(f,m,r,s,l.transformCell,p,g)})(o,c,e,t,r,s.replaceOrInit,l);return Gl(i,n[0].row,n[0].column)},Jl=Yl("thead",!0),Ql=Yl("tbody",!1),Xl=Yl("tfoot",!1),Zl=(e,t,o)=>{const n=((e,t)=>Vt(e,(()=>t)))(e,o.section),r=Go(n);return Us(r,t,!0)},ea=(e,t,o,n)=>((e,t,o,n)=>{const r=Go(t),s=n.getWidths(r,n);kl(r,s,n)})(0,t,0,n.sizing),ta=(e,t,o,n)=>((e,t,o,n,r)=>{const s=Go(t),l=n.getWidths(s,n),a=n.pixelWidth(),{newSizes:c,delta:i}=r.calcRedestributedWidths(l,a,o.pixelDelta,n.isRelative);kl(s,c,n),n.adjustTableWidth(i)})(0,t,o,n.sizing,n.resize),oa=(e,t)=>O(t,(e=>0===e.column&&e.isLocked)),na=(e,t)=>O(t,(t=>t.column+t.colspan>=e.grid.columns&&t.isLocked)),ra=(e,t)=>{const o=tn(e),n=Nl(t);return W(n,((e,t)=>e+o[t.column].map(Eo).getOr(0)),0)},sa=e=>(t,o)=>Xs(t,o).filter((o=>!(e?oa:na)(t,o))).map((e=>({details:e,pixelDelta:ra(t,e)}))),la=e=>(t,o)=>Qs(t,o).filter((o=>!(e?oa:na)(t,o.cells))),aa=Ml("th"),ca=Ml("td"),ia=Js(((e,t,o,n)=>{const r=t[0].row,s=Kl(t),l=A(s,((e,t)=>({grid:hl(e.grid,r,t.row+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return Gl(l,r,t[0].column)}),Xs,f,f,_l),ma=Js(((e,t,o,n)=>{const r=Kl(t),s=r[r.length-1],l=s.row+s.rowspan,a=A(r,((e,t)=>hl(e,l,t.row,o,n.getOrInit)),e);return Gl(a,l,t[0].column)}),Xs,f,f,_l),da=Js(((e,t,o,n)=>{const r=t.details,s=Nl(r),l=s[0].column,a=A(s,((e,t)=>({grid:pl(e.grid,l,t.column+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return Gl(a,r[0].row,l)}),sa(!0),ta,f,_l),ua=Js(((e,t,o,n)=>{const r=t.details,s=r[r.length-1],l=s.column+s.colspan,a=Nl(r),c=A(a,((e,t)=>pl(e,l,t.column,o,n.getOrInit)),e);return Gl(c,r[0].row,l)}),sa(!1),ta,f,_l),fa=Js(((e,t,o,n)=>{const r=Nl(t.details),s=((e,t)=>j(e,(e=>{const o=e.cells,n=A(t,((e,t)=>t>=0&&t<e.length?e.slice(0,t).concat(e.slice(t+1)):e),o);return n.length>0?[Ye(e.element,n,e.section,e.isNew)]:[]})))(e,E(r,(e=>e.column))),l=s.length>0?s[0].cells.length-1:0;return Gl(s,r[0].row,Math.min(r[0].column,l))}),((e,t)=>Zs(e,t).map((t=>({details:t,pixelDelta:-ra(e,t)})))),ta,$l,_l),ga=Js(((e,t,o,n)=>{const r=Kl(t),s=((e,t,o)=>{const{rows:n,cols:r}=jo(e);return[...r,...n.slice(0,t),...n.slice(o+1)]})(e,r[0].row,r[r.length-1].row),l=s.length>0?s.length-1:0;return Gl(s,Math.min(t[0].row,l),t[0].column)}),Xs,f,$l,_l),ha=Js(((e,t,o,n)=>{const r=Nl(t),s=E(r,(e=>e.column)),l=Cl(e,s,!0,o,n.replaceOrInit);return Gl(l,t[0].row,t[0].column)}),Zs,f,f,aa),pa=Js(((e,t,o,n)=>{const r=Nl(t),s=E(r,(e=>e.column)),l=Cl(e,s,!1,o,n.replaceOrInit);return Gl(l,t[0].row,t[0].column)}),Zs,f,f,ca),wa=Js(Jl,Zs,f,f,aa),ba=Js(Ql,Zs,f,f,ca),va=Js(Xl,Zs,f,f,ca),ya=Js(((e,t,o,n)=>{const r=Sl(e,t,o,n.replaceOrInit);return Gl(r,t[0].row,t[0].column)}),Zs,f,f,aa),xa=Js(((e,t,o,n)=>{const r=Sl(e,t,o,n.replaceOrInit);return Gl(r,t[0].row,t[0].column)}),Zs,f,f,ca),Ca=Js(((e,t,o,n)=>{const r=t.cells;ql(r);const s=((e,t,o,n)=>{const r=jo(e).rows;if(0===r.length)return e;for(let e=t.startRow;e<=t.finishRow;e++)for(let o=t.startCol;o<=t.finishCol;o++){const t=r[e],s=Lo(t,o).isLocked;Ao(t,o,Ke(n(),!1,s))}return e})(e,t.bounds,0,n.merge(r));return Ul(s,C.from(r[0]))}),((e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>el(e,t.cells)))),ea,f,jl),Sa=Js(((e,t,o,n)=>{const r=A(t,((e,t)=>tl(e,t,o,n.unmerge(t))),e);return Ul(r,C.from(t[0]))}),((e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>el(e,t)))),ea,f,jl),Ta=Js(((e,t,o,n)=>{const r=((e,t)=>{const o=Uo(e);return Us(o,t,!0)})(t.clipboard,t.generators);var s,l;return((e,t,o,n,r)=>{const s=Ho(t),l=((e,t,o)=>{const n=Mo(t[0]),r=jo(t).cols.length+e.row,s=k(n-e.column,(t=>t+e.column));return{row:r,column:L(s,(e=>I(o,(t=>t!==e)))).getOr(n-1)}})(e,t,s),a=jo(o).rows,c=ul(l,a,s),i=((e,t,o)=>{if(e.row>=t.length||e.column>Mo(t[0]))return rl.error("invalid start address out of table bounds, row: "+e.row+", column: "+e.column);const n=t.slice(e.row),r=n[0].cells.slice(e.column),s=Mo(o[0]),l=o.length;return rl.value({rowDelta:n.length-l,colDelta:r.length-s})})(l,t,a);return i.map((e=>{const o={...e,colDelta:e.colDelta-c.length},s=ml(t,o,n),i=Ho(s),m=ul(l,a,i);return((e,t,o,n,r,s)=>{const l=e.row,a=e.column,c=l+o.length,i=a+Mo(o[0])+s.length,m=P(s,x);for(let e=l;e<c;e++){let s=0;for(let c=a;c<i;c++){if(m[c]){s++;continue}dl(t,e,c,r)&&tl(t,_o(t[e],c),r,n.cell);const i=c-a-s,d=Lo(o[e-l],i),u=d.element,f=n.replace(u);Ao(t[e],c,Ke(f,!0,d.isLocked))}}return t})(l,s,a,n,r,m)}))})((s=t.row,l=t.column,{row:s,column:l}),e,r,t.generators,o).fold((()=>Ul(e,C.some(t.element))),(e=>Gl(e,t.row,t.column)))}),((e,t)=>jt(t.element).bind((o=>Ks(e,o).map((e=>({...e,generators:t.generators,clipboard:t.clipboard})))))),ea,f,_l),Ra=Js(((e,t,o,n)=>{const r=jo(e).rows,s=t.cells[0].column,l=r[t.cells[0].row],a=Zl(t.clipboard,t.generators,l),c=fl(s,e,a,t.generators,o);return Gl(c,t.cells[0].row,t.cells[0].column)}),la(!0),f,f,_l),Da=Js(((e,t,o,n)=>{const r=jo(e).rows,s=t.cells[t.cells.length-1].column+t.cells[t.cells.length-1].colspan,l=r[t.cells[0].row],a=Zl(t.clipboard,t.generators,l),c=fl(s,e,a,t.generators,o);return Gl(c,t.cells[0].row,t.cells[0].column)}),la(!1),f,f,_l),Oa=Js(((e,t,o,n)=>{const r=jo(e).rows,s=t.cells[0].row,l=r[s],a=Zl(t.clipboard,t.generators,l),c=gl(s,e,a,t.generators,o);return Gl(c,t.cells[0].row,t.cells[0].column)}),Qs,f,f,_l),ka=Js(((e,t,o,n)=>{const r=jo(e).rows,s=t.cells[t.cells.length-1].row+t.cells[t.cells.length-1].rowspan,l=r[t.cells[0].row],a=Zl(t.clipboard,t.generators,l),c=gl(s,e,a,t.generators,o);return Gl(c,t.cells[0].row,t.cells[0].column)}),Qs,f,f,_l),Ea=(e,t)=>{const o=Uo(e);return Xs(o,t).bind((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=M(E(o.all,(e=>z(e.cells,(e=>e.column>=n&&e.column<r)))));return ks(s)})).getOr("")},Na=(e,t)=>{const o=Uo(e);return Xs(o,t).bind(ks).getOr("")},Ba=(e,t)=>{const o=Uo(e);return Xs(o,t).bind((e=>{const t=e[e.length-1],n=e[0].row,r=t.row+t.rowspan;return(e=>{const t=E(e,(e=>Os(e).type)),o=D(t,"header"),n=D(t,"footer");if(o||n){const e=D(t,"body");return!o||e||n?o||e||!n?C.none():C.some("footer"):C.some("header")}return C.some("body")})(o.all.slice(n,r))})).getOr("")},za=(e,t)=>e.dispatch("NewRow",{node:t}),Aa=(e,t)=>e.dispatch("NewCell",{node:t}),Wa=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},La={structure:!1,style:!0},_a={structure:!0,style:!1},Ma={structure:!0,style:!0},ja=e=>t=>t.options.get(e),Ia="100%",Pa=e=>{var t;const o=e.dom,n=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return No(pe.fromDom(n))+"px"},Fa=e=>C.from(e.options.get("table_clone_elements")),Ha=ja("table_header_type"),qa=ja("table_column_resizing"),Va=e=>"preservetable"===qa(e),$a=e=>"resizetable"===qa(e),Ua=ja("table_sizing_mode"),Ga=e=>"relative"===Ua(e),Ka=e=>"fixed"===Ua(e),Ya=e=>"responsive"===Ua(e),Ja=ja("table_resize_bars"),Qa=ja("table_style_by_css"),Xa=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>Ya(e)||Qa(e)?t:Ka(e)?{...t,width:Pa(e)}:{...t,width:Ia})(e,o)},Za=ja("table_use_colgroups"),ec=(e,t)=>Ga(e)?sr(t):Ka(e)?rr(t):nr(t),tc=(e,t,o)=>{const n=e=>"table"===Z(Dr(e)),r=Fa(e),s=$a(e)?f:hs,l=t=>{switch(Ha(e)){case"section":return Ws();case"sectionCells":return Ls();case"cells":return _s();default:return((e,t)=>{var o;switch((o=Uo(e),V(o.all,(e=>{const t=Os(e);return"header"===t.type?C.from(t.subType):C.none()}))).getOr(t)){case"section":return Bs();case"sectionCells":return zs();case"cells":return As()}})(t,"section")}},a=(n,s,a,c)=>(i,m,d=!1)=>{kr(i);const u=pe.fromDom(e.getDoc()),f=Tr(a,u,r),g={sizing:ec(e,i),resize:$a(e)?xs():Cs(),section:l(i)};return s(i)?n(i,m,f,g).bind((n=>{t.refresh(i.dom),N(n.newRows,(t=>{za(e,t.dom)})),N(n.newCells,(t=>{Aa(e,t.dom)}));const r=((t,n)=>n.cursor.fold((()=>{const n=It(t);return H(n).filter(et).map((n=>{o.clearSelectedCells(t.dom);const r=e.dom.createRng();return r.selectNode(n.dom),e.selection.setRng(r),ie(n,"data-mce-selected","1"),r}))}),(n=>{const r=fs(gs,n),s=e.dom.createRng();return s.setStart(r.element.dom,r.offset),s.setEnd(r.element.dom,r.offset),e.selection.setRng(s),o.clearSelectedCells(t.dom),C.some(s)})))(i,n);return et(i)&&(kr(i),d||Wa(e,i.dom,c)),r.map((e=>({rng:e,effect:c})))})):C.none()},c=a(ga,(t=>!n(e)||Ss(t).rows>1),f,_a),i=a(fa,(t=>!n(e)||Ss(t).columns>1),f,_a);return{deleteRow:c,deleteColumn:i,insertRowsBefore:a(ia,x,f,_a),insertRowsAfter:a(ma,x,f,_a),insertColumnsBefore:a(da,x,s,_a),insertColumnsAfter:a(ua,x,s,_a),mergeCells:a(Ca,x,f,_a),unmergeCells:a(Sa,x,f,_a),pasteColsBefore:a(Ra,x,f,_a),pasteColsAfter:a(Da,x,f,_a),pasteRowsBefore:a(Oa,x,f,_a),pasteRowsAfter:a(ka,x,f,_a),pasteCells:a(Ta,x,f,Ma),makeCellsHeader:a(ya,x,f,_a),unmakeCellsHeader:a(xa,x,f,_a),makeColumnsHeader:a(ha,x,f,_a),unmakeColumnsHeader:a(pa,x,f,_a),makeRowsHeader:a(wa,x,f,_a),makeRowsBody:a(ba,x,f,_a),makeRowsFooter:a(va,x,f,_a),getTableRowType:Ba,getTableCellType:Na,getTableColType:Ea}},oc=(e,t,o)=>{const n=Et(e,t,1);1===o||n<=1?fe(e,t):ie(e,t,Math.min(o,n))},nc=(e,t)=>o=>{const n=o.column+o.colspan-1,r=o.column;return n>=e&&r<t},rc=Tl([{invalid:["raw"]},{pixels:["value"]},{percent:["value"]}]),sc=(e,t,o)=>{const n=o.substring(0,o.length-e.length),r=parseFloat(n);return n===r.toString()?t(r):rc.invalid(o)},lc={...rc,from:e=>bt(e,"%")?sc("%",rc.percent,e):bt(e,"px")?sc("px",rc.pixels,e):rc.invalid(e)},ac=(e,t,o)=>{const n=lc.from(o),r=I(e,(e=>"0px"===e))?((e,t)=>{const o=e.fold((()=>g("")),(e=>g(e/t+"px")),(()=>g(100/t+"%")));return k(t,o)})(n,e.length):((e,t,o)=>e.fold((()=>t),(e=>((e,t,o)=>{const n=o/t;return E(e,(e=>lc.from(e).fold((()=>e),(e=>e*n+"px"),(e=>e/100*o+"px"))))})(t,o,e)),(e=>((e,t)=>E(e,(e=>lc.from(e).fold((()=>e),(e=>e/t*100+"%"),(e=>e+"%")))))(t,o))))(n,e,t);return mc(r)},cc=(e,t)=>0===e.length?t:A(e,((e,t)=>lc.from(t).fold(g(0),h,h)+e),0),ic=(e,t)=>lc.from(e).fold(g(e),(e=>e+t+"px"),(e=>e+t+"%")),mc=e=>{if(0===e.length)return e;const t=A(e,((e,t)=>{const o=lc.from(t).fold((()=>({value:t,remainder:0})),(e=>((e,t)=>{const o=Math.floor(e);return{value:o+"px",remainder:e-o}})(e)),(e=>({value:e+"%",remainder:0})));return{output:[o.value].concat(e.output),remainder:e.remainder+o.remainder}}),{output:[],remainder:0}),o=t.output;return o.slice(0,o.length-1).concat([ic(o[o.length-1],Math.round(t.remainder))])},dc=lc.from,uc=e=>dc(e).fold(g("px"),g("px"),g("%")),fc=(e,t,o)=>{const n=Uo(e),r=n.all,s=Qo(n),l=Xo(n);t.each((t=>{const o=uc(t),r=ko(e),a=((e,t)=>Jn(e,t,Gn,Qn))(n,e),c=ac(a,r,t);Zo(n)?((e,t,o)=>{N(t,((t,n)=>{const r=cc([e[n]],Wt());St(t.element,"width",r+o)}))})(c,l,o):((e,t,o)=>{N(t,(t=>{const n=e.slice(t.column,t.colspan+t.column),r=cc(n,Wt());St(t.element,"width",r+o)}))})(c,s,o),St(e,"width",t)})),o.each((t=>{const o=uc(t),l=an(e),a=((e,t,o)=>Zn(e,t,o,Kn,Qn))(n,e,Rn);((e,t,o,n)=>{N(o,(t=>{const o=e.slice(t.row,t.rowspan+t.row),r=cc(o,Lt());St(t.element,"height",r+n)})),N(t,((t,o)=>{St(t.element,"height",e[o])}))})(ac(a,l,t),r,s,o),St(e,"height",t)}))},gc=e=>In(e).exists((e=>Nn.test(e))),hc=e=>In(e).exists((e=>Bn.test(e))),pc=e=>In(e).isNone(),wc=e=>{fe(e,"width")},bc=e=>{const t=Vn(e);fc(e,C.some(t),C.none()),wc(e)},vc=e=>{const t=(e=>ko(e)+"px")(e);fc(e,C.some(t),C.none()),wc(e)},yc=e=>{kt(e,"width");const t=Pt(e),o=t.length>0?t:It(e);N(o,(e=>{kt(e,"width"),wc(e)})),wc(e)},xc={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},colGroups:!1},Cc=(e,t,o,n)=>k(e,(e=>((e,t,o,n)=>{const r=pe.fromTag("tr");for(let s=0;s<e;s++){const e=pe.fromTag(n<t||s<o?"th":"td");s<o&&ie(e,"scope","row"),n<t&&ie(e,"scope","col"),We(e,pe.fromTag("br")),We(r,e)}return r})(t,o,n,e))),Sc=(e,t)=>{e.selection.select(t.dom,!0),e.selection.collapse(!0)},Tc=(e,t,o,n,s)=>{const l=(e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>Ya(e)||!Qa(e)?t:Ka(e)?{...t,width:Pa(e)}:{...t,width:Ia})(e,o)})(e),a={styles:l,attributes:Xa(e),colGroups:Za(e)};return e.undoManager.ignore((()=>{const r=((e,t,o,n,r,s=xc)=>{const l=pe.fromTag("table"),a="cells"!==r;Tt(l,s.styles),me(l,s.attributes),s.colGroups&&We(l,(e=>{const t=pe.fromTag("colgroup");return k(e,(()=>We(t,pe.fromTag("col")))),t})(t));const c=Math.min(e,o);if(a&&o>0){const e=pe.fromTag("thead");We(l,e);const s=Cc(o,t,"sectionCells"===r?c:0,n);Me(e,s)}const i=pe.fromTag("tbody");We(l,i);const m=Cc(a?e-c:e,t,a?0:o,n);return Me(i,m),l})(o,t,s,n,Ha(e),a);ie(r,"data-mce-id","__mce");const l=(e=>{const t=pe.fromTag("div"),o=pe.fromDom(e.dom.cloneNode(!0));return We(t,o),(e=>e.dom.innerHTML)(t)})(r);e.insertContent(l),e.addVisual()})),mt(Dr(e),'table[data-mce-id="__mce"]').map((t=>(Ka(e)?vc(t):Ya(e)?yc(t):(Ga(e)||(e=>r(e)&&-1!==e.indexOf("%"))(l.width))&&bc(t),kr(t),fe(t,"data-mce-id"),((e,t)=>{N(st(t,"tr"),(t=>{za(e,t.dom),N(st(t,"th,td"),(t=>{Aa(e,t.dom)}))}))})(e,t),((e,t)=>{mt(t,"td,th").each(w(Sc,e))})(e,t),t.dom))).getOrNull()};var Rc=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const Dc="x-tinymce/dom-table-",Oc=Dc+"rows",kc=Dc+"columns",Ec=e=>{const t=Rc.FakeClipboardItem(e);Rc.write([t])},Nc=e=>{var t;const o=null!==(t=Rc.read())&&void 0!==t?t:[];return V(o,(t=>C.from(t.getType(e))))},Bc=e=>{Nc(e).isSome()&&Rc.clear()},zc=e=>{e.fold(Wc,(e=>Ec({[Oc]:e})))},Ac=()=>Nc(Oc),Wc=()=>Bc(Oc),Lc=e=>{e.fold(Mc,(e=>Ec({[kc]:e})))},_c=()=>Nc(kc),Mc=()=>Bc(kc),jc=e=>ss(Er(e),Or(e)),Ic=(e,t)=>{const o=Or(e),n=e=>Ft(e,o),l=t=>(e=>ls(Er(e),Or(e)))(e).bind((e=>n(e).map((o=>t(o,e))))),a=t=>{e.focus()},c=(t,o=!1)=>l(((n,r)=>{const s=ns(as(e),n,r);t(n,s,o).each(a)})),i=()=>l(((t,o)=>((e,t,o)=>{const n=Uo(e);return Xs(n,t).bind((e=>{const t=Us(n,o,!1),r=jo(t).rows.slice(e[0].row,e[e.length-1].row+e[e.length-1].rowspan),s=j(r,(e=>{const t=z(e.cells,(e=>!e.isLocked));return t.length>0?[{...e,cells:t}]:[]})),l=Gs(s);return gt(l.length>0,l)})).map((e=>E(e,(e=>{const t=He(e.element);return N(e.cells,(e=>{const o=qe(e.element);Fs(o,"colspan",e.colspan,1),Fs(o,"rowspan",e.rowspan,1),We(t,o)})),t}))))})(t,ns(as(e),t,o),Tr(f,pe.fromDom(e.getDoc()),C.none())))),m=()=>l(((t,o)=>((e,t)=>{const o=Uo(e);return Zs(o,t).map((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=((e,t,o)=>{if(Zo(e)){const n=z(Xo(e),nc(t,o)),r=E(n,(e=>{const n=qe(e.element);return oc(n,"span",o-t),n})),s=pe.fromTag("colgroup");return Me(s,r),[s]}return[]})(o,n,r),l=((e,t,o)=>E(e.all,(e=>{const n=z(e.cells,nc(t,o)),r=E(n,(e=>{const n=qe(e.element);return oc(n,"colspan",o-t),n})),s=pe.fromTag("tr");return Me(s,r),s})))(o,n,r);return[...s,...l]}))})(t,ns(as(e),t,o)))),d=(t,o)=>o().each((o=>{const n=E(o,(e=>qe(e)));l(((o,r)=>{const s=Rr(pe.fromDom(e.getDoc())),l=((e,t,o,n)=>({selection:Zr(e),clipboard:o,generators:n}))(as(e),0,n,s);t(o,l).each(a)}))})),g=e=>(t,o)=>((e,t)=>X(e,t)?C.from(e.type):C.none())(o,"type").each((t=>{c(e(t),o.no_events)}));G({mceTableSplitCells:()=>c(t.unmergeCells),mceTableMergeCells:()=>c(t.mergeCells),mceTableInsertRowBefore:()=>c(t.insertRowsBefore),mceTableInsertRowAfter:()=>c(t.insertRowsAfter),mceTableInsertColBefore:()=>c(t.insertColumnsBefore),mceTableInsertColAfter:()=>c(t.insertColumnsAfter),mceTableDeleteCol:()=>c(t.deleteColumn),mceTableDeleteRow:()=>c(t.deleteRow),mceTableCutCol:()=>m().each((e=>{Lc(e),c(t.deleteColumn)})),mceTableCutRow:()=>i().each((e=>{zc(e),c(t.deleteRow)})),mceTableCopyCol:()=>m().each((e=>Lc(e))),mceTableCopyRow:()=>i().each((e=>zc(e))),mceTablePasteColBefore:()=>d(t.pasteColsBefore,_c),mceTablePasteColAfter:()=>d(t.pasteColsAfter,_c),mceTablePasteRowBefore:()=>d(t.pasteRowsBefore,Ac),mceTablePasteRowAfter:()=>d(t.pasteRowsAfter,Ac),mceTableDelete:()=>jc(e).each((t=>{Ft(t,o).filter(b(o)).each((t=>{const o=pe.fromText("");if(ze(t,o),Ie(t),e.dom.isEmpty(e.getBody()))e.setContent(""),e.selection.setCursorLocation();else{const t=e.dom.createRng();t.setStart(o.dom,0),t.setEnd(o.dom,0),e.selection.setRng(t),e.nodeChanged()}}))})),mceTableCellToggleClass:(t,o)=>{l((t=>{const n=as(e),r=I(n,(t=>e.formatter.match("tablecellclass",{value:o},t.dom))),s=r?e.formatter.remove:e.formatter.apply;N(n,(e=>s("tablecellclass",{value:o},e.dom))),Wa(e,t.dom,La)}))},mceTableToggleClass:(t,o)=>{l((t=>{e.formatter.toggle("tableclass",{value:o},t.dom),Wa(e,t.dom,La)}))},mceTableToggleCaption:()=>{jc(e).each((t=>{Ft(t,o).each((o=>{it(o,"caption").fold((()=>{const t=pe.fromTag("caption");We(t,pe.fromText("Caption")),((e,t,o)=>{Ne(e,0).fold((()=>{We(e,t)}),(e=>{Be(e,t)}))})(o,t),e.selection.setCursorLocation(t.dom,0)}),(n=>{ae("caption")(t)&&ve("td",o).each((t=>e.selection.setCursorLocation(t.dom,0))),Ie(n)})),Wa(e,o.dom,_a)}))}))},mceTableSizingMode:(t,n)=>(t=>jc(e).each((n=>{Ya(e)||Ka(e)||Ga(e)||Ft(n,o).each((o=>{"relative"!==t||gc(o)?"fixed"!==t||hc(o)?"responsive"!==t||pc(o)||yc(o):vc(o):bc(o),kr(o),Wa(e,o.dom,_a)}))})))(n),mceTableCellType:g((e=>"th"===e?t.makeCellsHeader:t.unmakeCellsHeader)),mceTableColType:g((e=>"th"===e?t.makeColumnsHeader:t.unmakeColumnsHeader)),mceTableRowType:g((e=>{switch(e){case"header":return t.makeRowsHeader;case"footer":return t.makeRowsFooter;default:return t.makeRowsBody}}))},((t,o)=>e.addCommand(o,t))),e.addCommand("mceInsertTable",((t,o)=>{((e,t,o,n={})=>{const r=e=>u(e)&&e>0;if(r(t)&&r(o)){const r=n.headerRows||0,s=n.headerColumns||0;return Tc(e,o,t,s,r)}console.error("Invalid values for mceInsertTable - rows and columns values are required to insert a table.")})(e,o.rows,o.columns,o.options)})),e.addCommand("mceTableApplyCellStyle",((t,o)=>{const l=e=>"tablecell"+e.toLowerCase().replace("-","");if(!s(o))return;const a=as(e);if(0===a.length)return;const c=((e,t)=>{const o={};return((e,t,o,n)=>{G(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(e=>(t,o)=>{e[o]=t})(o),f),o})(o,((t,o)=>e.formatter.has(l(o))&&r(t)));(e=>{for(const t in e)if(U.call(e,t))return!1;return!0})(c)||(G(c,((t,o)=>{const n=l(o);N(a,(o=>{""===t?e.formatter.remove(n,{value:null},o.dom,!0):e.formatter.apply(n,{value:t},o.dom)}))})),n(a[0]).each((t=>Wa(e,t.dom,La))))}))},Pc=Tl([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Fc={before:Pc.before,on:Pc.on,after:Pc.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(h,h,h)},Hc=(e,t)=>({selection:e,kill:t}),qc=(e,t)=>{const o=e.document.createRange();return o.selectNode(t.dom),o},Vc=(e,t)=>{const o=e.document.createRange();return $c(o,t),o},$c=(e,t)=>e.selectNodeContents(t.dom),Uc=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Gc=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},Kc=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),Yc=Tl([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Jc=(e,t,o)=>t(pe.fromDom(o.startContainer),o.startOffset,pe.fromDom(o.endContainer),o.endOffset),Qc=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:g(e),rtl:C.none}),relative:(t,o)=>({ltr:Gt((()=>Uc(e,t,o))),rtl:Gt((()=>C.some(Uc(e,o,t))))}),exact:(t,o,n,r)=>({ltr:Gt((()=>Gc(e,t,o,n,r))),rtl:Gt((()=>C.some(Gc(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();return o.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>Yc.rtl(pe.fromDom(e.endContainer),e.endOffset,pe.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>Jc(0,Yc.ltr,o))):Jc(0,Yc.ltr,o)})(0,o)},Xc=(e,t)=>Qc(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});Yc.ltr,Yc.rtl;const Zc=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),ei=(e,t,o,n)=>({start:Fc.on(e,t),finish:Fc.on(o,n)}),ti=(e,t)=>{const o=Xc(e,t);return Zc(pe.fromDom(o.startContainer),o.startOffset,pe.fromDom(o.endContainer),o.endOffset)},oi=ei,ni=(e,t,o,n,r)=>ye(o,n)?C.none():Gr(o,n,t).bind((t=>{const n=t.boxes.getOr([]);return n.length>1?(r(e,n,t.start,t.finish),C.some(Hc(C.some(oi(o,0,o,dr(o))),!0))):C.none()})),ri=(e,t)=>({item:e,mode:t}),si=(e,t,o,n=li)=>e.property().parent(t).map((e=>ri(e,n))),li=(e,t,o,n=ai)=>o.sibling(e,t).map((e=>ri(e,n))),ai=(e,t,o,n=ai)=>{const r=e.property().children(t);return o.first(r).map((e=>ri(e,n)))},ci=[{current:si,next:li,fallback:C.none()},{current:li,next:ai,fallback:C.some(si)},{current:ai,next:ai,fallback:C.some(li)}],ii=(e,t,o,n,r=ci)=>L(r,(e=>e.current===o)).bind((o=>o.current(e,t,n,o.next).orThunk((()=>o.fallback.bind((o=>ii(e,t,o,n))))))),mi=(e,t,o,n,r,s)=>ii(e,t,n,r).bind((t=>s(t.item)?C.none():o(t.item)?C.some(t.item):mi(e,t.item,o,t.mode,r,s))),di=e=>t=>0===e.property().children(t).length,ui=(e,t,o,n)=>mi(e,t,o,li,{sibling:(e,t)=>e.query().prevSibling(t),first:e=>e.length>0?C.some(e[e.length-1]):C.none()},n),fi=(e,t,o,n)=>mi(e,t,o,li,{sibling:(e,t)=>e.query().nextSibling(t),first:e=>e.length>0?C.some(e[0]):C.none()},n),gi=Fr(),hi=(e,t)=>((e,t,o)=>ui(e,t,di(e),o))(gi,e,t),pi=(e,t)=>((e,t,o)=>fi(e,t,di(e),o))(gi,e,t),wi=Tl([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),bi=e=>dt(e,"tr"),vi={...wi,verify:(e,t,o,n,r,s,l)=>dt(n,"td,th",l).bind((o=>dt(t,"td,th",l).map((t=>ye(o,t)?ye(n,o)&&dr(o)===r?s(t):wi.none("in same cell"):$r(bi,[o,t]).fold((()=>((e,t,o)=>{const n=e.getRect(t),r=e.getRect(o);return r.right>n.left&&r.left<n.right})(e,t,o)?wi.success():s(t)),(e=>s(t))))))).getOr(wi.none("default")),cata:(e,t,o,n,r)=>e.fold(t,o,n,r)},yi=ae("br"),xi=(e,t,o)=>t(e,o).bind((e=>re(e)&&0===cr(e).trim().length?xi(e,t,o):C.some(e))),Ci=(e,t,o,n)=>((e,t)=>Ne(e,t).filter(yi).orThunk((()=>Ne(e,t-1).filter(yi))))(t,o).bind((t=>n.traverse(t).fold((()=>xi(t,n.gather,e).map(n.relative)),(e=>(e=>Re(e).bind((t=>{const o=Ee(t);return((e,t)=>_(e,w(ye,t)))(o,e).map((n=>((e,t,o,n)=>({parent:e,children:t,element:o,index:n}))(t,o,e,n)))})))(e).map((e=>Fc.on(e.parent,e.index))))))),Si=(e,t)=>({left:e.left,top:e.top+t,right:e.right,bottom:e.bottom+t}),Ti=(e,t)=>({left:e.left,top:e.top-t,right:e.right,bottom:e.bottom-t}),Ri=(e,t,o)=>({left:e.left+t,top:e.top+o,right:e.right+t,bottom:e.bottom+o}),Di=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom}),Oi=(e,t)=>C.some(e.getRect(t)),ki=(e,t,o)=>ne(t)?Oi(e,t).map(Di):re(t)?((e,t,o)=>o>=0&&o<dr(t)?e.getRangedRect(t,o,t,o+1):o>0?e.getRangedRect(t,o-1,t,o):C.none())(e,t,o).map(Di):C.none(),Ei=(e,t)=>ne(t)?Oi(e,t).map(Di):re(t)?e.getRangedRect(t,0,t,dr(t)).map(Di):C.none(),Ni=Tl([{none:[]},{retry:["caret"]}]),Bi=(e,t,o)=>{return(n=t,r=Fl,lt(((e,t)=>t(e)),at,n,r,undefined)).fold(y,(t=>Ei(e,t).exists((e=>((e,t)=>e.left<t.left||Math.abs(t.right-e.left)<1||e.left>t.right)(o,e)))));var n,r},zi={point:e=>e.bottom,adjuster:(e,t,o,n,r)=>{const s=Si(r,5);return Math.abs(o.bottom-n.bottom)<1||o.top>r.bottom?Ni.retry(s):o.top===r.bottom?Ni.retry(Si(r,1)):Bi(e,t,r)?Ni.retry(Ri(s,5,0)):Ni.none()},move:Si,gather:pi},Ai=(e,t,o,n,r)=>0===r?C.some(n):((e,t,o)=>e.elementFromPoint(t,o).filter((e=>"table"===Z(e))).isSome())(e,n.left,t.point(n))?((e,t,o,n,r)=>Ai(e,t,o,t.move(n,5),r))(e,t,o,n,r-1):e.situsFromPoint(n.left,t.point(n)).bind((s=>s.start.fold(C.none,(s=>Ei(e,s).bind((l=>t.adjuster(e,s,l,o,n).fold(C.none,(n=>Ai(e,t,o,n,r-1))))).orThunk((()=>C.some(n)))),C.none))),Wi=(e,t,o)=>{const n=e.move(o,5),r=Ai(t,e,o,n,100).getOr(n);return((e,t,o)=>e.point(t)>o.getInnerHeight()?C.some(e.point(t)-o.getInnerHeight()):e.point(t)<0?C.some(-e.point(t)):C.none())(e,r,t).fold((()=>t.situsFromPoint(r.left,e.point(r))),(o=>(t.scrollBy(0,o),t.situsFromPoint(r.left,e.point(r)-o))))},Li={tryUp:w(Wi,{point:e=>e.top,adjuster:(e,t,o,n,r)=>{const s=Ti(r,5);return Math.abs(o.top-n.top)<1||o.bottom<r.top?Ni.retry(s):o.bottom===r.top?Ni.retry(Ti(r,1)):Bi(e,t,r)?Ni.retry(Ri(s,5,0)):Ni.none()},move:Ti,gather:hi}),tryDown:w(Wi,zi),getJumpSize:g(5)},_i=(e,t,o)=>e.getSelection().bind((n=>((e,t,o,n)=>{const r=yi(t)?((e,t,o)=>o.traverse(t).orThunk((()=>xi(t,o.gather,e))).map(o.relative))(e,t,n):Ci(e,t,o,n);return r.map((e=>({start:e,finish:e})))})(t,n.finish,n.foffset,o).fold((()=>C.some(is(n.finish,n.foffset))),(r=>{const s=e.fromSitus(r);return l=vi.verify(e,n.finish,n.foffset,s.finish,s.foffset,o.failure,t),vi.cata(l,(e=>C.none()),(()=>C.none()),(e=>C.some(is(e,0))),(e=>C.some(is(e,dr(e)))));var l})))),Mi=(e,t,o,n,r,s)=>0===s?C.none():Pi(e,t,o,n,r).bind((l=>{const a=e.fromSitus(l),c=vi.verify(e,o,n,a.finish,a.foffset,r.failure,t);return vi.cata(c,(()=>C.none()),(()=>C.some(l)),(l=>ye(o,l)&&0===n?ji(e,o,n,Ti,r):Mi(e,t,l,0,r,s-1)),(l=>ye(o,l)&&n===dr(l)?ji(e,o,n,Si,r):Mi(e,t,l,dr(l),r,s-1)))})),ji=(e,t,o,n,r)=>ki(e,t,o).bind((t=>Ii(e,r,n(t,Li.getJumpSize())))),Ii=(e,t,o)=>{const n=To().browser;return n.isChromium()||n.isSafari()||n.isFirefox()?t.retry(e,o):C.none()},Pi=(e,t,o,n,r)=>ki(e,o,n).bind((t=>Ii(e,r,t))),Fi=(e,t,o,n,r)=>dt(n,"td,th",t).bind((n=>dt(n,"table",t).bind((s=>((e,t)=>at(e,(e=>Re(e).exists((e=>ye(e,t)))),void 0).isSome())(r,s)?((e,t,o)=>_i(e,t,o).bind((n=>Mi(e,t,n.element,n.offset,o,20).map(e.fromSitus))))(e,t,o).bind((e=>dt(e.finish,"td,th",t).map((t=>({start:n,finish:t,range:e}))))):C.none())))),Hi=(e,t,o,n,r,s)=>s(n,t).orThunk((()=>Fi(e,t,o,n,r).map((e=>{const t=e.range;return Hc(C.some(oi(t.start,t.soffset,t.finish,t.foffset)),!0)})))),qi=(e,t)=>dt(e,"tr",t).bind((e=>dt(e,"table",t).bind((o=>{const n=st(o,"tr");return ye(e,n[0])?((e,t,o)=>ui(gi,e,(e=>hr(e).isSome()),o))(o,0,t).map((e=>{const t=dr(e);return Hc(C.some(oi(e,t,e,t)),!0)})):C.none()})))),Vi=(e,t)=>dt(e,"tr",t).bind((e=>dt(e,"table",t).bind((o=>{const n=st(o,"tr");return ye(e,n[n.length-1])?((e,t,o)=>fi(gi,e,(e=>gr(e).isSome()),o))(o,0,t).map((e=>Hc(C.some(oi(e,0,e,0)),!0))):C.none()})))),$i=(e,t,o,n,r,s,l)=>Fi(e,o,n,r,s).bind((e=>ni(t,o,e.start,e.finish,l))),Ui=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Gi=()=>{const e=(e=>{const t=Ui(C.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(C.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(C.some(e))}}})(f);return{...e,on:t=>e.get().each(t)}},Ki=(e,t)=>dt(e,"td,th",t),Yi={traverse:ke,gather:pi,relative:Fc.before,retry:Li.tryDown,failure:vi.failedDown},Ji={traverse:Oe,gather:hi,relative:Fc.before,retry:Li.tryUp,failure:vi.failedUp},Qi=e=>t=>t===e,Xi=Qi(38),Zi=Qi(40),em=e=>e>=37&&e<=40,tm={isBackward:Qi(37),isForward:Qi(39)},om={isBackward:Qi(39),isForward:Qi(37)},nm=Tl([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),rm={domRange:nm.domRange,relative:nm.relative,exact:nm.exact,exactFromRange:e=>nm.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>pe.fromDom(e.startContainer),relative:(e,t)=>Fc.getStart(e),exact:(e,t,o,n)=>e}))(e);return pe.fromDom(Te(t).dom.defaultView)},range:Zc},sm=document.caretPositionFromPoint?(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return C.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),C.some(o)}))}:document.caretRangeFromPoint?(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))}:C.none,lm=(e,t)=>{const o=Z(e);return"input"===o?Fc.after(e):D(["br","img"],o)?0===t?Fc.before(e):Fc.after(e):Fc.on(e,t)},am=e=>C.from(e.getSelection()),cm=(e,t)=>{am(e).each((e=>{e.removeAllRanges(),e.addRange(t)}))},im=(e,t,o,n,r)=>{const s=Gc(e,t,o,n,r);cm(e,s)},mm=(e,t)=>Qc(e,t).match({ltr:(t,o,n,r)=>{im(e,t,o,n,r)},rtl:(t,o,n,r)=>{am(e).each((s=>{if(s.setBaseAndExtent)s.setBaseAndExtent(t.dom,o,n.dom,r);else if(s.extend)try{((e,t,o,n,r,s)=>{t.collapse(o.dom,n),t.extend(r.dom,s)})(0,s,t,o,n,r)}catch(s){im(e,n,r,t,o)}else im(e,n,r,t,o)}))}}),dm=(e,t,o,n,r)=>{const s=((e,t,o,n)=>{const r=lm(e,t),s=lm(o,n);return rm.relative(r,s)})(t,o,n,r);mm(e,s)},um=(e,t,o)=>{const n=((e,t)=>{const o=e.fold(Fc.before,lm,Fc.after),n=t.fold(Fc.before,lm,Fc.after);return rm.relative(o,n)})(t,o);mm(e,n)},fm=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return C.some(Zc(pe.fromDom(t.startContainer),t.startOffset,pe.fromDom(o.endContainer),o.endOffset))}return C.none()},gm=e=>{if(null===e.anchorNode||null===e.focusNode)return fm(e);{const t=pe.fromDom(e.anchorNode),o=pe.fromDom(e.focusNode);return((e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Se(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=ye(e,o)&&t===n;return r.collapsed&&!s})(t,e.anchorOffset,o,e.focusOffset)?C.some(Zc(t,e.anchorOffset,o,e.focusOffset)):fm(e)}},hm=(e,t,o=!0)=>{const n=(o?Vc:qc)(e,t);cm(e,n)},pm=e=>(e=>am(e).filter((e=>e.rangeCount>0)).bind(gm))(e).map((e=>rm.exact(e.start,e.soffset,e.finish,e.foffset))),wm=e=>({elementFromPoint:(t,o)=>pe.fromPoint(pe.fromDom(e.document),t,o),getRect:e=>e.dom.getBoundingClientRect(),getRangedRect:(t,o,n,r)=>{const s=rm.exact(t,o,n,r);return((e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?C.some(o).map(Kc):C.none()})(Xc(e,t)))(e,s)},getSelection:()=>pm(e).map((t=>ti(e,t))),fromSitus:t=>{const o=rm.relative(t.start,t.finish);return ti(e,o)},situsFromPoint:(t,o)=>((e,t,o)=>((e,t,o)=>{const n=pe.fromDom(e.document);return sm(n,t,o).map((e=>Zc(pe.fromDom(e.startContainer),e.startOffset,pe.fromDom(e.endContainer),e.endOffset)))})(e,t,o))(e,t,o).map((e=>ei(e.start,e.soffset,e.finish,e.foffset))),clearSelection:()=>{(e=>{am(e).each((e=>e.removeAllRanges()))})(e)},collapseSelection:(t=!1)=>{pm(e).each((o=>o.fold((e=>e.collapse(t)),((o,n)=>{const r=t?o:n;um(e,r,r)}),((o,n,r,s)=>{const l=t?o:r,a=t?n:s;dm(e,l,a,l,a)}))))},setSelection:t=>{dm(e,t.start,t.soffset,t.finish,t.foffset)},setRelativeSelection:(t,o)=>{um(e,t,o)},selectNode:t=>{hm(e,t,!1)},selectContents:t=>{hm(e,t)},getInnerHeight:()=>e.innerHeight,getScrollY:()=>(e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return dn(o,n)})(pe.fromDom(e.document)).top,scrollBy:(t,o)=>{((e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollBy(e,t)})(t,o,pe.fromDom(e.document))}}),bm=(e,t)=>({rows:e,cols:t}),vm=e=>void 0!==e.dom.classList,ym=(e,t)=>((e,t,o)=>{const n=((e,t)=>{const o=de(e,t);return void 0===o||""===o?[]:o.split(" ")})(e,t).concat([o]);return ie(e,t,n.join(" ")),!0})(e,"class",t),xm=(e,t)=>{vm(e)?e.dom.classList.add(t):ym(e,t)},Cm=(e,t)=>vm(e)&&e.dom.classList.contains(t),Sm=()=>({tag:"none"}),Tm=e=>({tag:"multiple",elements:e}),Rm=e=>({tag:"single",element:e}),Dm=e=>{const t=pe.fromDom((e=>{if(Qe()&&m(e.target)){const t=pe.fromDom(e.target);if(ne(t)&&m(t.dom.shadowRoot)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return H(t)}}return C.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=(s=n,l=o,(...e)=>s(l.apply(null,e)));var s,l;return((e,t,o,n,r,s,l)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:l}))(t,e.clientX,e.clientY,o,n,r,e)},Om=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},km=x,Em=(e,t,o)=>((e,t,o,n)=>((e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(Dm(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:w(Om,e,t,s,r)}})(e,t,o,n,!1))(e,t,km,o),Nm=Dm,Bm=e=>!Cm(pe.fromDom(e.target),"ephox-snooker-resizer-bar"),zm=(e,t)=>{const o=(r=os.selectedSelector,{get:()=>Qr(pe.fromDom(e.getBody()),r).fold((()=>ls(Er(e),Or(e)).fold(Sm,Rm)),Tm)}),n=((e,t,o)=>{const n=t=>{fe(t,e.selected),fe(t,e.firstSelected),fe(t,e.lastSelected)},r=t=>{ie(t,e.selected,"1")},s=e=>{l(e),o()},l=t=>{const o=st(t,`${e.selectedSelector},${e.firstSelectedSelector},${e.lastSelectedSelector}`);N(o,n)};return{clearBeforeUpdate:l,clear:s,selectRange:(o,n,l,a)=>{s(o),N(n,r),ie(l,e.firstSelected,"1"),ie(a,e.lastSelected,"1"),t(n,l,a)},selectedSelector:e.selectedSelector,firstSelectedSelector:e.firstSelectedSelector,lastSelectedSelector:e.lastSelectedSelector}})(os,((t,o,n)=>{Ft(o).each((r=>{const s=Fa(e),l=Tr(f,pe.fromDom(e.getDoc()),s),a=((e,t,o)=>{const n=Uo(e);return Xs(n,t).map((e=>{const t=Us(n,o,!1),{rows:r}=jo(t),s=((e,t)=>{const o=e.slice(0,t[t.length-1].row+1),n=Gs(o);return j(n,(e=>{const o=e.cells.slice(0,t[t.length-1].column+1);return E(o,(e=>e.element))}))})(r,e),l=((e,t)=>{const o=e.slice(t[0].row+t[0].rowspan-1,e.length),n=Gs(o);return j(n,(e=>{const o=e.cells.slice(t[0].column+t[0].colspan-1,e.cells.length);return E(o,(e=>e.element))}))})(r,e);return{upOrLeftCells:s,downOrRightCells:l}}))})(r,{selection:as(e)},l);((e,t,o,n,r)=>{e.dispatch("TableSelectionChange",{cells:t,start:o,finish:n,otherCells:r})})(e,t,o,n,a)}))}),(()=>(e=>{e.dispatch("TableSelectionClear")})(e)));var r;return e.on("init",(o=>{const r=e.getWin(),s=Dr(e),l=Or(e),a=((e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Gi(),s=r.clear,l=s=>{r.on((r=>{n.clearBeforeUpdate(t),Ki(s.target,o).each((l=>{Gr(r,l,o).each((o=>{const r=o.boxes.getOr([]);if(1===r.length){const o=r[0],l="false"===Ps(o),a=ut(js(s.target),o,ye);l&&a&&(n.selectRange(t,r,o,o),e.selectContents(o))}else r.length>1&&(n.selectRange(t,r,o.start,o.finish),e.selectContents(l))}))}))}))};return{clearstate:s,mousedown:e=>{n.clear(t),Ki(e.target,o).each(r.set)},mouseover:e=>{l(e)},mouseup:e=>{l(e),s()}}})(wm(e),t,o,n);return{clearstate:r.clearstate,mousedown:r.mousedown,mouseover:r.mouseover,mouseup:r.mouseup}})(r,s,l,n),c=((e,t,o,n)=>{const r=wm(e),s=()=>(n.clear(t),C.none());return{keydown:(e,l,a,c,i,m)=>{const d=e.raw,u=d.which,f=!0===d.shiftKey,g=Kr(t,n.selectedSelector).fold((()=>(em(u)&&!f&&n.clearBeforeUpdate(t),Zi(u)&&f?w($i,r,t,o,Yi,c,l,n.selectRange):Xi(u)&&f?w($i,r,t,o,Ji,c,l,n.selectRange):Zi(u)?w(Hi,r,o,Yi,c,l,Vi):Xi(u)?w(Hi,r,o,Ji,c,l,qi):C.none)),(e=>{const o=o=>()=>{const s=V(o,(o=>((e,t,o,n,r)=>Jr(n,e,t,r.firstSelectedSelector,r.lastSelectedSelector).map((e=>(r.clearBeforeUpdate(o),r.selectRange(o,e.boxes,e.start,e.finish),e.boxes))))(o.rows,o.cols,t,e,n)));return s.fold((()=>Yr(t,n.firstSelectedSelector,n.lastSelectedSelector).map((e=>{const o=Zi(u)||m.isForward(u)?Fc.after:Fc.before;return r.setRelativeSelection(Fc.on(e.first,0),o(e.table)),n.clear(t),Hc(C.none(),!0)}))),(e=>C.some(Hc(C.none(),!0))))};return Zi(u)&&f?o([bm(1,0)]):Xi(u)&&f?o([bm(-1,0)]):m.isBackward(u)&&f?o([bm(0,-1),bm(-1,0)]):m.isForward(u)&&f?o([bm(0,1),bm(1,0)]):em(u)&&!f?s:C.none}));return g()},keyup:(e,r,s,l,a)=>Kr(t,n.selectedSelector).fold((()=>{const c=e.raw,i=c.which;return!0===c.shiftKey&&em(i)?((e,t,o,n,r,s,l)=>ye(o,r)&&n===s?C.none():dt(o,"td,th",t).bind((o=>dt(r,"td,th",t).bind((n=>ni(e,t,o,n,l))))))(t,o,r,s,l,a,n.selectRange):C.none()}),C.none)}})(r,s,l,n),i=((e,t,o,n)=>{const r=wm(e);return(e,s)=>{n.clearBeforeUpdate(t),Gr(e,s,o).each((e=>{const o=e.boxes.getOr([]);n.selectRange(t,o,e.start,e.finish),r.selectContents(s),r.collapseSelection()}))}})(r,s,l,n);e.on("TableSelectorChange",(e=>i(e.start,e.finish)));const m=(t,o)=>{(e=>!0===e.raw.shiftKey)(t)&&(o.kill&&t.kill(),o.selection.each((t=>{const o=rm.relative(t.start,t.finish),n=Xc(r,o);e.selection.setRng(n)})))},d=e=>0===e.button,u=(()=>{const e=Ui(pe.fromDom(s)),t=Ui(0);return{touchEnd:o=>{const n=pe.fromDom(o.target);if(ae("td")(n)||ae("th")(n)){const r=e.get(),s=t.get();ye(r,n)&&o.timeStamp-s<300&&(o.preventDefault(),i(n,n))}e.set(n),t.set(o.timeStamp)}}})();e.on("dragstart",(e=>{a.clearstate()})),e.on("mousedown",(e=>{d(e)&&Bm(e)&&a.mousedown(Nm(e))})),e.on("mouseover",(e=>{var t;void 0!==(t=e).buttons&&0==(1&t.buttons)||!Bm(e)||a.mouseover(Nm(e))})),e.on("mouseup",(e=>{d(e)&&Bm(e)&&a.mouseup(Nm(e))})),e.on("touchend",u.touchEnd),e.on("keyup",(t=>{const o=Nm(t);if(o.raw.shiftKey&&em(o.raw.which)){const t=e.selection.getRng(),n=pe.fromDom(t.startContainer),r=pe.fromDom(t.endContainer);c.keyup(o,n,t.startOffset,r,t.endOffset).each((e=>{m(o,e)}))}})),e.on("keydown",(o=>{const n=Nm(o);t.hide();const r=e.selection.getRng(),s=pe.fromDom(r.startContainer),l=pe.fromDom(r.endContainer),a=rn(tm,om)(pe.fromDom(e.selection.getStart()));c.keydown(n,s,r.startOffset,l,r.endOffset,a).each((e=>{m(n,e)})),t.show()})),e.on("NodeChange",(()=>{const t=e.selection,o=pe.fromDom(t.getStart()),r=pe.fromDom(t.getEnd());$r(Ft,[o,r]).fold((()=>n.clear(s)),f)}))})),e.on("PreInit",(()=>{e.serializer.addTempAttr(os.firstSelected),e.serializer.addTempAttr(os.lastSelected)})),{getSelectedCells:()=>((e,t,o,n)=>{switch(e.tag){case"none":return t();case"single":return(e=>[e.dom])(e.element);case"multiple":return(e=>E(e,(e=>e.dom)))(e.elements)}})(o.get(),g([])),clearSelectedCells:e=>n.clear(pe.fromDom(e))}},Am=e=>{let t=[];return{bind:e=>{if(void 0===e)throw new Error("Event bind error: undefined handler");t.push(e)},unbind:e=>{t=z(t,(t=>t!==e))},trigger:(...o)=>{const n={};N(e,((e,t)=>{n[e]=o[t]})),N(t,(e=>{e(n)}))}}},Wm=e=>({registry:K(e,(e=>({bind:e.bind,unbind:e.unbind}))),trigger:K(e,(e=>e.trigger))}),Lm=e=>e.slice(0).sort(),_m=(e,t)=>{const o=z(t,(t=>!D(e,t)));o.length>0&&(e=>{throw new Error("Unsupported keys for object: "+Lm(e).join(", "))})(o)},Mm=e=>((e,t)=>((e,t,o)=>{if(0===t.length)throw new Error("You must specify at least one required field.");return((e,t)=>{if(!l(t))throw new Error("The required fields must be an array. Was: "+t+".");N(t,(t=>{if(!r(t))throw new Error("The value "+t+" in the "+e+" fields was not a string.")}))})("required",t),(e=>{const t=Lm(e);L(t,((e,o)=>o<t.length-1&&e===t[o+1])).each((e=>{throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+t.join(", ")+"].")}))})(t),n=>{const r=$(n);I(t,(e=>D(r,e)))||((e,t)=>{throw new Error("All required keys ("+Lm(e).join(", ")+") were not specified. Specified keys were: "+Lm(t).join(", ")+".")})(t,r),e(t,r);const s=z(t,(e=>!o.validate(n[e],e)));return s.length>0&&((e,t)=>{throw new Error("All values need to be of type: "+t+". Keys ("+Lm(e).join(", ")+") were not.")})(s,o.label),n}})(e,t,{validate:d,label:"function"}))(_m,e),jm=Mm(["compare","extract","mutate","sink"]),Im=Mm(["element","start","stop","destroy"]),Pm=Mm(["forceDrop","drop","move","delayDrop"]),Fm=()=>{const e=(()=>{const e=Wm({move:Am(["info"])});return{onEvent:f,reset:f,events:e.registry}})(),t=(()=>{let e=C.none();const t=Wm({move:Am(["info"])});return{onEvent:(o,n)=>{n.extract(o).each((o=>{const r=((t,o)=>{const n=e.map((e=>t.compare(e,o)));return e=C.some(o),n})(n,o);r.each((e=>{t.trigger.move(e)}))}))},reset:()=>{e=C.none()},events:t.registry}})();let o=e;return{on:()=>{o.reset(),o=t},off:()=>{o.reset(),o=e},isOn:()=>o===t,onEvent:(e,t)=>{o.onEvent(e,t)},events:t.events}},Hm=e=>{const t=e.replace(/\./g,"-");return{resolve:e=>t+"-"+e}},qm=Hm("ephox-dragster").resolve;var Vm=jm({compare:(e,t)=>dn(t.left-e.left,t.top-e.top),extract:e=>C.some(dn(e.x,e.y)),sink:(e,t)=>{const o=(e=>{const t={layerClass:qm("blocker"),...e},o=pe.fromTag("div");return ie(o,"role","presentation"),Tt(o,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),xm(o,qm("blocker")),xm(o,t.layerClass),{element:g(o),destroy:()=>{Ie(o)}}})(t),n=Em(o.element(),"mousedown",e.forceDrop),r=Em(o.element(),"mouseup",e.drop),s=Em(o.element(),"mousemove",e.move),l=Em(o.element(),"mouseout",e.delayDrop);return Im({element:o.element,start:e=>{We(e,o.element())},stop:()=>{Ie(o.element())},destroy:()=>{o.destroy(),r.unbind(),s.unbind(),l.unbind(),n.unbind()}})},mutate:(e,t)=>{e.mutate(t.left,t.top)}});const $m=Hm("ephox-snooker").resolve,Um=$m("resizer-bar"),Gm=$m("resizer-rows"),Km=$m("resizer-cols"),Ym=e=>{const t=st(e.parent(),"."+Um);N(t,Ie)},Jm=(e,t,o)=>{const n=e.origin();N(t,(t=>{t.each((t=>{const r=o(n,t);xm(r,Um),We(e.parent(),r)}))}))},Qm=(e,t,o,n,r)=>{const s=fn(o),l=t.isResizable,a=n.length>0?Rn.positions(n,o):[],c=a.length>0?((e,t)=>j(e.all,((e,o)=>t(e.element)?[o]:[])))(e,l):[];((e,t,o,n)=>{Jm(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=pe.fromTag("div");return Tt(s,{position:"absolute",left:t+"px",top:o-3.5+"px",height:"7px",width:n+"px"}),me(s,{"data-row":e,role:"presentation"}),s})(t.row,o.left-e.left,t.y-e.top,n);return xm(r,Gm),r}))})(t,z(a,((e,t)=>O(c,(e=>t===e)))),s,Eo(o));const i=r.length>0?On.positions(r,o):[],m=i.length>0?((e,t)=>{const o=[];return k(e.grid.columns,(n=>{en(e,n).map((e=>e.element)).forall(t)&&o.push(n)})),z(o,(o=>{const n=Jo(e,(e=>e.column===o));return I(n,(e=>t(e.element)))}))})(e,l):[];((e,t,o,n)=>{Jm(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=pe.fromTag("div");return Tt(s,{position:"absolute",left:t-3.5+"px",top:o+"px",height:r+"px",width:"7px"}),me(s,{"data-column":e,role:"presentation"}),s})(t.col,t.x-e.left,o.top-e.top,0,n);return xm(r,Km),r}))})(t,z(i,((e,t)=>O(m,(e=>t===e)))),s,cn(o))},Xm=(e,t)=>{if(Ym(e),e.isResizable(t)){const o=Uo(t),n=nn(o),r=tn(o);Qm(o,e,t,n,r)}},Zm=(e,t)=>{const o=st(e.parent(),"."+Um);N(o,t)},ed=e=>{Zm(e,(e=>{St(e,"display","none")}))},td=e=>{Zm(e,(e=>{St(e,"display","block")}))},od=$m("resizer-bar-dragging"),nd=e=>{const t=(()=>{const e=Wm({drag:Am(["xDelta","yDelta","target"])});let t=C.none();const o=(()=>{const e=Wm({drag:Am(["xDelta","yDelta"])});return{mutate:(t,o)=>{e.trigger.drag(t,o)},events:e.registry}})();return o.events.drag.bind((o=>{t.each((t=>{e.trigger.drag(o.xDelta,o.yDelta,t)}))})),{assign:e=>{t=C.some(e)},get:()=>t,mutate:o.mutate,events:e.registry}})(),o=((e,t={})=>{var o;return((e,t,o)=>{let n=!1;const r=Wm({start:Am([]),stop:Am([])}),s=Fm(),l=()=>{m.stop(),s.isOn()&&(s.off(),r.trigger.stop())},c=((e,t)=>{let o=null;const n=()=>{a(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...t)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,t)}),200)}}})(l);s.events.move.bind((o=>{t.mutate(e,o.info)}));const i=e=>(...t)=>{n&&e.apply(null,t)},m=t.sink(Pm({forceDrop:l,drop:i(l),move:i((e=>{c.cancel(),s.onEvent(e,t)})),delayDrop:i(c.throttle)}),o);return{element:m.element,go:e=>{m.start(e),s.on(),r.trigger.start()},on:()=>{n=!0},off:()=>{n=!1},destroy:()=>{m.destroy()},events:r.registry}})(e,null!==(o=t.mode)&&void 0!==o?o:Vm,t)})(t,{});let n=C.none();const r=(e,t)=>C.from(de(e,t));t.events.drag.bind((e=>{r(e.target,"data-row").each((t=>{const o=At(e.target,"top");St(e.target,"top",o+e.yDelta+"px")})),r(e.target,"data-column").each((t=>{const o=At(e.target,"left");St(e.target,"left",o+e.xDelta+"px")}))}));const s=(e,t)=>At(e,t)-Et(e,"data-initial-"+t,0);o.events.stop.bind((()=>{t.get().each((t=>{n.each((o=>{r(t,"data-row").each((e=>{const n=s(t,"top");fe(t,"data-initial-top"),d.trigger.adjustHeight(o,n,parseInt(e,10))})),r(t,"data-column").each((e=>{const n=s(t,"left");fe(t,"data-initial-left"),d.trigger.adjustWidth(o,n,parseInt(e,10))})),Xm(e,o)}))}))}));const l=(n,r)=>{d.trigger.startAdjust(),t.assign(n),ie(n,"data-initial-"+r,At(n,r)),xm(n,od),St(n,"opacity","0.2"),o.go(e.parent())},c=Em(e.parent(),"mousedown",(e=>{var t;t=e.target,Cm(t,Gm)&&l(e.target,"top"),(e=>Cm(e,Km))(e.target)&&l(e.target,"left")})),i=t=>ye(t,e.view()),m=Em(e.view(),"mouseover",(t=>{var o;(o=t.target,dt(o,"table",i).filter(Is)).fold((()=>{et(t.target)&&Ym(e)}),(t=>{n=C.some(t),Xm(e,t)}))})),d=Wm({adjustHeight:Am(["table","delta","row"]),adjustWidth:Am(["table","delta","column"]),startAdjust:Am([])});return{destroy:()=>{c.unbind(),m.unbind(),o.destroy(),Ym(e)},refresh:t=>{Xm(e,t)},on:o.on,off:o.off,hideBars:w(ed,e),showBars:w(td,e),events:d.registry}},rd=(e,t,o)=>{const n=Rn,r=On,s=nd(e),l=Wm({beforeResize:Am(["table","type"]),afterResize:Am(["table","type"]),startDrag:Am([])});return s.events.adjustHeight.bind((e=>{const t=e.table;l.trigger.beforeResize(t,"row");((e,t,o,n)=>{const r=Uo(e),s=((e,t,o)=>Zn(e,t,o,Hn,(e=>e.getOrThunk(Lt))))(r,e,n),l=E(s,((e,n)=>o===n?Math.max(t+e,Lt()):e)),a=Ol(r,l),c=((e,t)=>E(e.all,((e,o)=>({element:e.element,height:t[o]}))))(r,l);N(c,(e=>{_n(e.element,e.height)})),N(a,(e=>{_n(e.element,e.height)}));const i=A(l,((e,t)=>e+t),0);_n(e,i)})(t,n.delta(e.delta,t),e.row,n),l.trigger.afterResize(t,"row")})),s.events.startAdjust.bind((e=>{l.trigger.startDrag()})),s.events.adjustWidth.bind((e=>{const n=e.table;l.trigger.beforeResize(n,"col");const s=r.delta(e.delta,n),a=o(n);El(n,s,e.column,t,a),l.trigger.afterResize(n,"col")})),{on:s.on,off:s.off,refreshBars:s.refresh,hideBars:s.hideBars,showBars:s.showBars,destroy:s.destroy,events:l.registry}},sd=e=>m(e)&&"TABLE"===e.nodeName,ld="bar-",ad=e=>"false"!==de(e,"data-mce-resize"),cd=e=>{const t=Gi(),o=Gi(),n=Gi();let r,s;const l=t=>ec(e,t),a=()=>Va(e)?Cs():xs();return e.on("init",(()=>{const r=((e,t)=>e.inline?((e,t,o)=>({parent:g(t),view:g(e),origin:g(dn(0,0)),isResizable:o}))(pe.fromDom(e.getBody()),(()=>{const e=pe.fromTag("div");return Tt(e,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),We(tt(pe.fromDom(document)),e),e})(),t):((e,t)=>{const o=se(e)?(e=>pe.fromDom(Te(e).dom.documentElement))(e):e;return{parent:g(o),view:g(e),origin:g(dn(0,0)),isResizable:t}})(pe.fromDom(e.getDoc()),t))(e,ad);if(n.set(r),(e=>{const t=e.options.get("object_resizing");return D(t.split(","),"table")})(e)&&Ja(e)){const n=a(),s=rd(r,n,l);s.on(),s.events.startDrag.bind((o=>{t.set(e.selection.getRng())})),s.events.beforeResize.bind((t=>{const o=t.table.dom;((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(e,o,Nr(o),Br(o),ld+t.type)})),s.events.afterResize.bind((o=>{const n=o.table,r=n.dom;kr(n),t.on((t=>{e.selection.setRng(t),e.focus()})),((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(e,r,Nr(r),Br(r),ld+o.type),e.undoManager.add()})),o.set(s)}})),e.on("ObjectResizeStart",(t=>{const o=t.target;if(sd(o)){const n=pe.fromDom(o);N(e.dom.select(".mce-clonedresizable"),(t=>{e.dom.addClass(t,"mce-"+qa(e)+"-columns")})),!hc(n)&&Ka(e)?vc(n):!gc(n)&&Ga(e)&&bc(n),pc(n)&&wt(t.origin,ld)&&bc(n),r=t.width,s=Ya(e)?"":((e,t)=>{const o=e.dom.getStyle(t,"width")||e.dom.getAttrib(t,"width");return C.from(o).filter(yt)})(e,o).getOr("")}})),e.on("ObjectResized",(t=>{const o=t.target;if(sd(o)){const n=pe.fromDom(o),c=t.origin;wt(c,"corner-")&&((t,o,n)=>{const c=bt(o,"e");if(""===s&&bc(t),n!==r&&""!==s){St(t,"width",s);const o=a(),i=l(t),m=Va(e)||c?(e=>Ss(e).columns)(t)-1:0;El(t,n-r,m,o,i)}else if((e=>/^(\d+(\.\d+)?)%$/.test(e))(s)){const e=parseFloat(s.replace("%",""));St(t,"width",n*e/r+"%")}(e=>/^(\d+(\.\d+)?)px$/.test(e))(s)&&(e=>{const t=Uo(e);Zo(t)||N(It(e),(e=>{const t=Rt(e,"width");St(e,"width",t),fe(e,"width")}))})(t)})(n,c,t.width),kr(n),Wa(e,n.dom,La)}})),e.on("SwitchMode",(()=>{o.on((t=>{e.mode.isReadOnly()?t.hideBars():t.showBars()}))})),e.on("remove",(()=>{o.on((e=>{e.destroy()})),n.on((t=>{((e,t)=>{e.inline&&Ie(t.parent())})(e,t)}))})),{refresh:e=>{o.on((t=>t.refreshBars(pe.fromDom(e))))},hide:()=>{o.on((e=>e.hideBars()))},show:()=>{o.on((e=>e.showBars()))}}},id=e=>{(e=>{const t=e.options.register;t("table_clone_elements",{processor:"string[]"}),t("table_use_colgroups",{processor:"boolean",default:!0}),t("table_header_type",{processor:e=>{const t=D(["section","cells","sectionCells","auto"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: section, cells, sectionCells or auto."}},default:"section"}),t("table_sizing_mode",{processor:"string",default:"auto"}),t("table_default_attributes",{processor:"object",default:{border:"1"}}),t("table_default_styles",{processor:"object",default:{"border-collapse":"collapse"}}),t("table_column_resizing",{processor:e=>{const t=D(["preservetable","resizetable"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be preservetable, or resizetable."}},default:"preservetable"}),t("table_resize_bars",{processor:"boolean",default:!0}),t("table_style_by_css",{processor:"boolean",default:!0})})(e);const t=cd(e),o=zm(e,t),n=tc(e,t,o);return Ic(e,n),((e,t)=>{const o=Or(e),n=t=>ls(Er(e)).bind((n=>Ft(n,o).map((o=>{const r=ns(as(e),o,n);return t(o,r)})))).getOr("");G({mceTableRowType:()=>n(t.getTableRowType),mceTableCellType:()=>n(t.getTableCellType),mceTableColType:()=>n(t.getTableColType)},((t,o)=>e.addQueryValueHandler(o,t)))})(e,n),cs(e,n),{getSelectedCells:o.getSelectedCells,clearSelectedCells:o.clearSelectedCells}};e.add("dom",(e=>({table:id(e)})))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";const e=Object.getPrototypeOf,t=(e,t,o)=>{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},o=e=>o=>(e=>{const o=typeof e;return null===e?"null":"object"===o&&Array.isArray(e)?"array":"object"===o&&t(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":o})(o)===e,n=e=>t=>typeof t===e,r=e=>t=>e===t,s=o("string"),a=o("object"),i=o=>((o,n)=>a(o)&&t(o,n,((t,o)=>e(t)===o)))(o,Object),l=o("array"),c=r(null),d=n("boolean"),u=r(void 0),m=e=>null==e,g=e=>!m(e),p=n("function"),h=n("number"),f=(e,t)=>{if(l(e)){for(let o=0,n=e.length;o<n;++o)if(!t(e[o]))return!1;return!0}return!1},b=()=>{},v=(e,t)=>(...o)=>e(t.apply(null,o)),y=e=>()=>e,x=e=>e,w=(e,t)=>e===t;function S(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const k=e=>t=>!e(t),C=e=>()=>{throw new Error(e)},O=e=>e(),_=y(!1),T=y(!0);var E=tinymce.util.Tools.resolve("tinymce.ThemeManager");class M{constructor(e,t){this.tag=e,this.value=t}static some(e){return new M(!0,e)}static none(){return M.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?M.some(e(this.value)):M.none()}bind(e){return this.tag?e(this.value):M.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:M.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return g(e)?M.some(e):M.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}M.singletonNone=new M(!1);const A=Array.prototype.slice,D=Array.prototype.indexOf,B=Array.prototype.push,F=(e,t)=>D.call(e,t),I=(e,t)=>{const o=F(e,t);return-1===o?M.none():M.some(o)},R=(e,t)=>F(e,t)>-1,N=(e,t)=>{for(let o=0,n=e.length;o<n;o++)if(t(e[o],o))return!0;return!1},V=(e,t)=>{const o=[];for(let n=0;n<e;n++)o.push(t(n));return o},H=(e,t)=>{const o=[];for(let n=0;n<e.length;n+=t){const r=A.call(e,n,n+t);o.push(r)}return o},z=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r<o;r++){const o=e[r];n[r]=t(o,r)}return n},L=(e,t)=>{for(let o=0,n=e.length;o<n;o++)t(e[o],o)},P=(e,t)=>{const o=[],n=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];(t(s,r)?o:n).push(s)}return{pass:o,fail:n}},U=(e,t)=>{const o=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t(r,n)&&o.push(r)}return o},W=(e,t,o)=>(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),j=(e,t,o)=>(L(e,((e,n)=>{o=t(o,e,n)})),o),G=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n<r;n++){const r=e[n];if(t(r,n))return M.some(r);if(o(r,n))break}return M.none()})(e,t,_),$=(e,t)=>{for(let o=0,n=e.length;o<n;o++)if(t(e[o],o))return M.some(o);return M.none()},q=e=>{const t=[];for(let o=0,n=e.length;o<n;++o){if(!l(e[o]))throw new Error("Arr.flatten item "+o+" was not an array, input: "+e);B.apply(t,e[o])}return t},X=(e,t)=>q(z(e,t)),K=(e,t)=>{for(let o=0,n=e.length;o<n;++o)if(!0!==t(e[o],o))return!1;return!0},Y=e=>{const t=A.call(e,0);return t.reverse(),t},J=(e,t)=>U(e,(e=>!R(t,e))),Z=(e,t)=>{const o={};for(let n=0,r=e.length;n<r;n++){const r=e[n];o[String(r)]=t(r,n)}return o},Q=e=>[e],ee=(e,t)=>{const o=A.call(e,0);return o.sort(t),o},te=(e,t)=>t>=0&&t<e.length?M.some(e[t]):M.none(),oe=e=>te(e,0),ne=e=>te(e,e.length-1),re=p(Array.from)?Array.from:e=>A.call(e),se=(e,t)=>{for(let o=0;o<e.length;o++){const n=t(e[o],o);if(n.isSome())return n}return M.none()},ae=Object.keys,ie=Object.hasOwnProperty,le=(e,t)=>{const o=ae(e);for(let n=0,r=o.length;n<r;n++){const r=o[n];t(e[r],r)}},ce=(e,t)=>de(e,((e,o)=>({k:o,v:t(e,o)}))),de=(e,t)=>{const o={};return le(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},ue=e=>(t,o)=>{e[o]=t},me=(e,t,o,n)=>{le(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},ge=(e,t)=>{const o={};return me(e,t,ue(o),b),o},pe=(e,t)=>{const o=[];return le(e,((e,n)=>{o.push(t(e,n))})),o},he=(e,t)=>{const o=ae(e);for(let n=0,r=o.length;n<r;n++){const r=o[n],s=e[r];if(t(s,r,e))return M.some(s)}return M.none()},fe=e=>pe(e,x),be=(e,t)=>ve(e,t)?M.from(e[t]):M.none(),ve=(e,t)=>ie.call(e,t),ye=(e,t)=>ve(e,t)&&void 0!==e[t]&&null!==e[t],xe=(e,t,o=w)=>e.exists((e=>o(e,t))),we=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(o);return t},Se=(e,t,o)=>e.isSome()&&t.isSome()?M.some(o(e.getOrDie(),t.getOrDie())):M.none(),ke=(e,t)=>e?M.some(t):M.none(),Ce=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Oe=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!u(n)||r+t.length<=n)},_e=(e,t)=>Ce(e,t,e.length-t.length),Te=(Co=/^\s+|\s+$/g,e=>e.replace(Co,"")),Ee=e=>e.length>0,Me=e=>void 0!==e.style&&p(e.style.getPropertyValue),Ae=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},De=(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Ae(o.childNodes[0])},Be=(e,t)=>{const o=(t||document).createElement(e);return Ae(o)},Fe=(e,t)=>{const o=(t||document).createTextNode(e);return Ae(o)},Ie=Ae,Re="undefined"!=typeof window?window:Function("return this;")(),Ne=(e,t)=>((e,t)=>{let o=null!=t?t:Re;for(let t=0;t<e.length&&null!=o;++t)o=o[e[t]];return o})(e.split("."),t),Ve=Object.getPrototypeOf,He=e=>{const t=Ne("ownerDocument.defaultView",e);return a(e)&&((e=>((e,t)=>{const o=((e,t)=>Ne(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o})("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(Ve(e).constructor.name))},ze=e=>e.dom.nodeName.toLowerCase(),Le=e=>t=>(e=>e.dom.nodeType)(t)===e,Pe=Le(1),Ue=Le(3),We=Le(9),je=Le(11),Ge=e=>t=>Pe(t)&&ze(t)===e,$e=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},qe=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Xe=(e,t)=>e.dom===t.dom,Ke=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},Ye=e=>Ie(e.dom.ownerDocument),Je=e=>We(e)?e:Ye(e),Ze=e=>Ie(Je(e).dom.documentElement),Qe=e=>Ie(Je(e).dom.defaultView),et=e=>M.from(e.dom.parentNode).map(Ie),tt=e=>M.from(e.dom.parentElement).map(Ie),ot=e=>M.from(e.dom.offsetParent).map(Ie),nt=e=>z(e.dom.childNodes,Ie),rt=(e,t)=>{const o=e.dom.childNodes;return M.from(o[t]).map(Ie)},st=(e,t)=>({element:e,offset:t}),at=(e,t)=>{const o=nt(e);return o.length>0&&t<o.length?st(o[t],0):st(e,t)},it=e=>je(e)&&g(e.dom.host),lt=p(Element.prototype.attachShadow)&&p(Node.prototype.getRootNode),ct=y(lt),dt=lt?e=>Ie(e.dom.getRootNode()):Je,ut=e=>it(e)?e:Ie(Je(e).dom.body),mt=e=>{const t=dt(e);return it(t)?M.some(t):M.none()},gt=e=>Ie(e.dom.host),pt=e=>{const t=Ue(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return mt(Ie(t)).fold((()=>o.body.contains(t)),(n=pt,r=gt,e=>n(r(e))));var n,r},ht=()=>ft(Ie(document)),ft=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Ie(t)},bt=(e,t,o)=>{if(!(s(o)||d(o)||h(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},vt=(e,t,o)=>{bt(e.dom,t,o)},yt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{bt(o,t,e)}))},xt=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},wt=(e,t)=>M.from(xt(e,t)),St=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},kt=(e,t)=>{e.dom.removeAttribute(t)},Ct=(e,t,o)=>{if(!s(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Me(e)&&e.style.setProperty(t,o)},Ot=(e,t)=>{Me(e)&&e.style.removeProperty(t)},_t=(e,t,o)=>{const n=e.dom;Ct(n,t,o)},Tt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{Ct(o,t,e)}))},Et=(e,t)=>{const o=e.dom;le(t,((e,t)=>{e.fold((()=>{Ot(o,t)}),(e=>{Ct(o,t,e)}))}))},Mt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||pt(e)?n:At(o,t)},At=(e,t)=>Me(e)?e.style.getPropertyValue(t):"",Dt=(e,t)=>{const o=e.dom,n=At(o,t);return M.from(n).filter((e=>e.length>0))},Bt=e=>{const t={},o=e.dom;if(Me(o))for(let e=0;e<o.style.length;e++){const n=o.style.item(e);t[n]=o.style[n]}return t},Ft=(e,t,o)=>{const n=Be(e);return _t(n,t,o),Dt(n,t).isSome()},It=(e,t)=>{const o=e.dom;Ot(o,t),xe(wt(e,"style").map(Te),"")&&kt(e,"style")},Rt=e=>e.dom.offsetWidth,Nt=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Mt(o,e);return parseFloat(t)||0}return n},n=(e,t)=>j(t,((t,o)=>{const n=Mt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!h(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Me(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Vt=Nt("height",(e=>{const t=e.dom;return pt(e)?t.getBoundingClientRect().height:t.offsetHeight})),Ht=e=>Vt.get(e),zt=e=>Vt.getOuter(e),Lt=(e,t)=>({left:e,top:t,translate:(o,n)=>Lt(e+o,t+n)}),Pt=Lt,Ut=(e,t)=>void 0!==e?e:void 0!==t?t:0,Wt=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return Pt(o.offsetLeft,o.offsetTop);const s=Ut(null==n?void 0:n.pageYOffset,r.scrollTop),a=Ut(null==n?void 0:n.pageXOffset,r.scrollLeft),i=Ut(r.clientTop,o.clientTop),l=Ut(r.clientLeft,o.clientLeft);return jt(e).translate(a-l,s-i)},jt=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?Pt(o.offsetLeft,o.offsetTop):pt(e)?(e=>{const t=e.getBoundingClientRect();return Pt(t.left,t.top)})(t):Pt(0,0)},Gt=Nt("width",(e=>e.dom.offsetWidth)),$t=e=>Gt.get(e),qt=e=>Gt.getOuter(e),Xt=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},Kt=()=>Yt(0,0),Yt=(e,t)=>({major:e,minor:t}),Jt={nu:Yt,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?Kt():((e,t)=>{const o=((e,t)=>{for(let o=0;o<e.length;o++){const n=e[o];if(n.test(t))return n}})(e,t);if(!o)return{major:0,minor:0};const n=e=>Number(t.replace(o,"$"+e));return Yt(n(1),n(2))})(e,o)},unknown:Kt},Zt=(e,t)=>{const o=String(t).toLowerCase();return G(e,(e=>e.search(o)))},Qt=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,eo=e=>t=>Oe(t,e),to=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Oe(e,"edge/")&&Oe(e,"chrome")&&Oe(e,"safari")&&Oe(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Qt],search:e=>Oe(e,"chrome")&&!Oe(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Oe(e,"msie")||Oe(e,"trident")},{name:"Opera",versionRegexes:[Qt,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:eo("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:eo("firefox")},{name:"Safari",versionRegexes:[Qt,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Oe(e,"safari")||Oe(e,"mobile/"))&&Oe(e,"applewebkit")}],oo=[{name:"Windows",search:eo("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Oe(e,"iphone")||Oe(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:eo("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:eo("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:eo("linux"),versionRegexes:[]},{name:"Solaris",search:eo("sunos"),versionRegexes:[]},{name:"FreeBSD",search:eo("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:eo("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],no={browsers:y(to),oses:y(oo)},ro="Edge",so="Chromium",ao="Opera",io="Firefox",lo="Safari",co=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(ro),isChromium:n(so),isIE:n("IE"),isOpera:n(ao),isFirefox:n(io),isSafari:n(lo)}},uo=()=>co({current:void 0,version:Jt.unknown()}),mo=co,go=(y(ro),y(so),y("IE"),y(ao),y(io),y(lo),"Windows"),po="Android",ho="Linux",fo="macOS",bo="Solaris",vo="FreeBSD",yo="ChromeOS",xo=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(go),isiOS:n("iOS"),isAndroid:n(po),isMacOS:n(fo),isLinux:n(ho),isSolaris:n(bo),isFreeBSD:n(vo),isChromeOS:n(yo)}},wo=()=>xo({current:void 0,version:Jt.unknown()}),So=xo,ko=(y(go),y("iOS"),y(po),y(ho),y(fo),y(bo),y(vo),y(yo),e=>window.matchMedia(e).matches);var Co;let Oo=Xt((()=>((e,t,o)=>{const n=no.browsers(),r=no.oses(),s=t.bind((e=>((e,t)=>se(t.brands,(t=>{const o=t.brand.toLowerCase();return G(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:Jt.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>Zt(e,t).map((e=>{const o=Jt.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(uo,mo),a=((e,t)=>Zt(e,t).map((e=>{const o=Jt.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(wo,So),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),u=!c&&!l&&!d;return{isiPad:y(r),isiPhone:y(s),isTablet:y(l),isPhone:y(c),isTouch:y(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:y(d),isDesktop:y(u)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}})(navigator.userAgent,M.from(navigator.userAgentData),ko)));const _o=()=>Oo(),To=e=>{const t=Ie((e=>{if(ct()&&g(e.target)){const t=Ie(e.target);if(Pe(t)&&(e=>g(e.dom.shadowRoot))(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return oe(t)}}return M.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=v(n,o);return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},Eo=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(To(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:S(Mo,e,t,s,r)}},Mo=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Ao=(e,t)=>{et(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Do=(e,t)=>{const o=(e=>M.from(e.dom.nextSibling).map(Ie))(e);o.fold((()=>{et(e).each((e=>{Fo(e,t)}))}),(e=>{Ao(e,t)}))},Bo=(e,t)=>{const o=(e=>rt(e,0))(e);o.fold((()=>{Fo(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Fo=(e,t)=>{e.dom.appendChild(t.dom)},Io=(e,t)=>{L(t,(t=>{Fo(e,t)}))},Ro=e=>{e.dom.textContent="",L(nt(e),(e=>{No(e)}))},No=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Vo=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return Pt(o,n)},Ho=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},zo=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Lo=e=>{const t=void 0===e?window:e,o=t.document,n=Vo(Ie(o));return(e=>{const t=void 0===e?window:e;return _o().browser.isFirefox()?M.none():M.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return zo(n.left,n.top,o,r)}),(e=>zo(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},Po=()=>Ie(document),Uo=(e,t)=>e.view(t).fold(y([]),(t=>{const o=e.owner(t),n=Uo(e,o);return[t].concat(n)}));var Wo=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?M.none():M.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(Ie)},owner:e=>Ye(e)});const jo=e=>{const t=Po(),o=Vo(t),n=((e,t)=>{const o=t.owner(e),n=Uo(t,o);return M.some(n)})(e,Wo);return n.fold(S(Wt,e),(t=>{const n=jt(e),r=W(t,((e,t)=>{const o=jt(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return Pt(r.left+n.left+o.left,r.top+n.top+o.top)}))},Go=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),$o=e=>{const t=Wt(e),o=qt(e),n=zt(e);return Go(t.left,t.top,o,n)},qo=e=>{const t=jo(e),o=qt(e),n=zt(e);return Go(t.left,t.top,o,n)},Xo=()=>Lo(window),Ko=e=>{const t=t=>t(e),o=y(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:T,isError:_,map:t=>Jo.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>M.some(e)};return r},Yo=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:_,isError:T,map:t,mapError:t=>Jo.error(t(e)),bind:t,exists:_,forall:T,getOr:x,or:x,getOrThunk:O,orThunk:O,getOrDie:C(String(e)),each:b,toOptional:M.none};return o},Jo={value:Ko,error:Yo,fromOption:(e,t)=>e.fold((()=>Yo(t)),Ko)};var Zo;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(Zo||(Zo={}));const Qo=(e,t,o)=>e.stype===Zo.Error?t(e.serror):o(e.svalue),en=e=>({stype:Zo.Value,svalue:e}),tn=e=>({stype:Zo.Error,serror:e}),on=en,nn=tn,rn=Qo,sn=(e,t,o,n)=>({tag:"field",key:e,newKey:t,presence:o,prop:n}),an=(e,t,o)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return o(e.newKey,e.instantiator)}},ln=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const o={};for(let n=0;n<t.length;n++){const r=t[n];for(const t in r)ve(r,t)&&(o[t]=e(o[t],r[t]))}return o},cn=ln(((e,t)=>i(e)&&i(t)?cn(e,t):t)),dn=ln(((e,t)=>t)),un=e=>({tag:"defaultedThunk",process:e}),mn=e=>un(y(e)),gn=e=>({tag:"mergeWithThunk",process:e}),pn=e=>{const t=(e=>{const t=[],o=[];return L(e,(e=>{Qo(e,(e=>o.push(e)),(e=>t.push(e)))})),{values:t,errors:o}})(e);return t.errors.length>0?(o=t.errors,v(nn,q)(o)):on(t.values);var o},hn=e=>a(e)&&ae(e).length>100?" removed due to size":JSON.stringify(e,null,2),fn=(e,t)=>nn([{path:e,getErrorInfo:t}]),bn=e=>({extract:(t,o)=>{return n=e(o),r=e=>((e,t)=>fn(e,y(t)))(t,e),n.stype===Zo.Error?r(n.serror):n;var n,r},toString:y("val")}),vn=bn(on),yn=(e,t,o,n)=>n(be(e,t).getOrThunk((()=>o(e)))),xn=(e,t,o,n,r)=>{const s=e=>r.extract(t.concat([n]),e),a=e=>e.fold((()=>on(M.none())),(e=>{const o=r.extract(t.concat([n]),e);return s=o,a=M.some,s.stype===Zo.Value?{stype:Zo.Value,svalue:a(s.svalue)}:s;var s,a}));switch(e.tag){case"required":return((e,t,o,n)=>be(t,o).fold((()=>((e,t,o)=>fn(e,(()=>'Could not find valid *required* value for "'+t+'" in '+hn(o))))(e,o,t)),n))(t,o,n,s);case"defaultedThunk":return yn(o,n,e.process,s);case"option":return((e,t,o)=>o(be(e,t)))(o,n,a);case"defaultedOptionThunk":return((e,t,o,n)=>n(be(e,t).map((t=>!0===t?o(e):t))))(o,n,e.process,a);case"mergeWithThunk":return yn(o,n,y({}),(t=>{const n=cn(e.process(o),t);return s(n)}))}},wn=e=>({extract:(t,o)=>e().extract(t,o),toString:()=>e().toString()}),Sn=e=>ae(ge(e,g)),kn=e=>{const t=Cn(e),o=W(e,((e,t)=>an(t,(t=>cn(e,{[t]:!0})),y(e))),{});return{extract:(e,n)=>{const r=d(n)?[]:Sn(n),s=U(r,(e=>!ye(o,e)));return 0===s.length?t.extract(e,n):((e,t)=>fn(e,(()=>"There are unsupported fields: ["+t.join(", ")+"] specified")))(e,s)},toString:t.toString}},Cn=e=>({extract:(t,o)=>((e,t,o)=>{const n={},r=[];for(const s of o)an(s,((o,s,a,i)=>{const l=xn(a,e,t,o,i);rn(l,(e=>{r.push(...e)}),(e=>{n[s]=e}))}),((e,o)=>{n[e]=o(t)}));return r.length>0?nn(r):on(n)})(t,o,e),toString:()=>{const t=z(e,(e=>an(e,((e,t,o,n)=>e+" -> "+n.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),On=e=>({extract:(t,o)=>{const n=z(o,((o,n)=>e.extract(t.concat(["["+n+"]"]),o)));return pn(n)},toString:()=>"array("+e.toString()+")"}),_n=(e,t)=>{const o=void 0!==t?t:x;return{extract:(t,n)=>{const r=[];for(const s of e){const e=s.extract(t,n);if(e.stype===Zo.Value)return{stype:Zo.Value,svalue:o(e.svalue)};r.push(e)}return pn(r)},toString:()=>"oneOf("+z(e,(e=>e.toString())).join(", ")+")"}},Tn=(e,t)=>({extract:(o,n)=>{const r=ae(n),s=((t,o)=>On(bn(e)).extract(t,o))(o,r);return i=e=>{const r=z(e,(e=>sn(e,e,{tag:"required",process:{}},t)));return Cn(r).extract(o,n)},(a=s).stype===Zo.Value?i(a.svalue):a;var a,i},toString:()=>"setOf("+t.toString()+")"}),En=v(On,Cn),Mn=y(vn),An=(e,t)=>bn((o=>{const n=typeof o;return e(o)?on(o):nn(`Expected type: ${t} but got: ${n}`)})),Dn=An(h,"number"),Bn=An(s,"string"),Fn=An(d,"boolean"),In=An(p,"function"),Rn=e=>{if(Object(e)!==e)return!0;switch({}.toString.call(e).slice(8,-1)){case"Boolean":case"Number":case"String":case"Date":case"RegExp":case"Blob":case"FileList":case"ImageData":case"ImageBitmap":case"ArrayBuffer":return!0;case"Array":case"Object":return Object.keys(e).every((t=>Rn(e[t])));default:return!1}},Nn=bn((e=>Rn(e)?on(e):nn("Expected value to be acceptable for sending via postMessage"))),Vn=(e,t)=>({extract:(o,n)=>be(n,e).fold((()=>((e,t)=>fn(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(o,e)),(e=>((e,t,o,n)=>be(o,n).fold((()=>((e,t,o)=>fn(e,(()=>'The chosen schema: "'+o+'" did not exist in branches: '+hn(t))))(e,o,n)),(o=>o.extract(e.concat(["branch: "+n]),t))))(o,n,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+ae(t)}),Hn=e=>bn((t=>e(t).fold(nn,on))),zn=(e,t)=>Tn((t=>e(t).fold(tn,en)),t),Ln=(e,t,o)=>{return n=((e,t,o)=>((e,t)=>e.stype===Zo.Error?{stype:Zo.Error,serror:t(e.serror)}:e)(t.extract([e],o),(e=>({input:o,errors:e}))))(e,t,o),Qo(n,Jo.error,Jo.value);var n},Pn=e=>e.fold((e=>{throw new Error(Wn(e))}),x),Un=(e,t,o)=>Pn(Ln(e,t,o)),Wn=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:y("... (only showing first ten failures)")}]):e;return z(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+hn(e.input),jn=(e,t)=>Vn(e,ce(t,Cn)),Gn=sn,$n=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),qn=e=>Hn((t=>R(e,t)?Jo.value(t):Jo.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`))),Xn=e=>Gn(e,e,{tag:"required",process:{}},Mn()),Kn=(e,t)=>Gn(e,e,{tag:"required",process:{}},t),Yn=e=>Kn(e,Dn),Jn=e=>Kn(e,Bn),Zn=(e,t)=>Gn(e,e,{tag:"required",process:{}},qn(t)),Qn=e=>Kn(e,In),er=(e,t)=>Gn(e,e,{tag:"required",process:{}},Cn(t)),tr=(e,t)=>Gn(e,e,{tag:"required",process:{}},En(t)),or=(e,t)=>Gn(e,e,{tag:"required",process:{}},On(t)),nr=e=>Gn(e,e,{tag:"option",process:{}},Mn()),rr=(e,t)=>Gn(e,e,{tag:"option",process:{}},t),sr=e=>rr(e,Dn),ar=e=>rr(e,Bn),ir=(e,t)=>rr(e,qn(t)),lr=e=>rr(e,In),cr=(e,t)=>rr(e,On(t)),dr=(e,t)=>rr(e,Cn(t)),ur=(e,t)=>Gn(e,e,mn(t),Mn()),mr=(e,t,o)=>Gn(e,e,mn(t),o),gr=(e,t)=>mr(e,t,Dn),pr=(e,t)=>mr(e,t,Bn),hr=(e,t,o)=>mr(e,t,qn(o)),fr=(e,t)=>mr(e,t,Fn),br=(e,t)=>mr(e,t,In),vr=(e,t,o)=>mr(e,t,On(o)),yr=(e,t,o)=>mr(e,t,Cn(o)),xr=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},wr=e=>{if(!l(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return L(e,((n,r)=>{const s=ae(n);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!l(i))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=ae(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!K(t,(e=>R(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o};wr([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Sr=(e,t)=>((e,t)=>({[e]:t}))(e,t),kr=e=>(e=>{const t={};return L(e,(e=>{t[e.key]=e.value})),t})(e),Cr=e=>p(e)?e:_,Or=(e,t,o)=>{let n=e.dom;const r=Cr(o);for(;n.parentNode;){n=n.parentNode;const e=Ie(n),o=t(e);if(o.isSome())return o;if(r(e))break}return M.none()},_r=(e,t,o)=>{const n=t(e),r=Cr(o);return n.orThunk((()=>r(e)?M.none():Or(e,t,r)))},Tr=(e,t)=>Xe(e.element,t.event.target),Er={can:T,abort:_,run:b},Mr=e=>{if(!ye(e,"can")&&!ye(e,"abort")&&!ye(e,"run"))throw new Error("EventHandler defined by: "+JSON.stringify(e,null,2)+" does not have can, abort, or run!");return{...Er,...e}},Ar=y,Dr=Ar("touchstart"),Br=Ar("touchmove"),Fr=Ar("touchend"),Ir=Ar("touchcancel"),Rr=Ar("mousedown"),Nr=Ar("mousemove"),Vr=Ar("mouseout"),Hr=Ar("mouseup"),zr=Ar("mouseover"),Lr=Ar("focusin"),Pr=Ar("focusout"),Ur=Ar("keydown"),Wr=Ar("keyup"),jr=Ar("input"),Gr=Ar("change"),$r=Ar("click"),qr=Ar("transitioncancel"),Xr=Ar("transitionend"),Kr=Ar("transitionstart"),Yr=Ar("selectstart"),Jr=e=>y("alloy."+e),Zr={tap:Jr("tap")},Qr=Jr("focus"),es=Jr("blur.post"),ts=Jr("paste.post"),os=Jr("receive"),ns=Jr("execute"),rs=Jr("focus.item"),ss=Zr.tap,as=Jr("longpress"),is=Jr("sandbox.close"),ls=Jr("typeahead.cancel"),cs=Jr("system.init"),ds=Jr("system.touchmove"),us=Jr("system.touchend"),ms=Jr("system.scroll"),gs=Jr("system.resize"),ps=Jr("system.attached"),hs=Jr("system.detached"),fs=Jr("system.dismissRequested"),bs=Jr("system.repositionRequested"),vs=Jr("focusmanager.shifted"),ys=Jr("slotcontainer.visibility"),xs=Jr("change.tab"),ws=Jr("dismiss.tab"),Ss=Jr("highlight"),ks=Jr("dehighlight"),Cs=(e,t)=>{Es(e,e.element,t,{})},Os=(e,t,o)=>{Es(e,e.element,t,o)},_s=e=>{Cs(e,ns())},Ts=(e,t,o)=>{Es(e,t,o,{})},Es=(e,t,o,n)=>{const r={target:t,...n};e.getSystem().triggerEvent(o,t,r)},Ms=(e,t,o,n)=>{e.getSystem().triggerEvent(o,t,n.event)},As=e=>kr(e),Ds=(e,t)=>({key:e,value:Mr({abort:t})}),Bs=e=>({key:e,value:Mr({run:(e,t)=>{t.event.prevent()}})}),Fs=(e,t)=>({key:e,value:Mr({run:t})}),Is=(e,t,o)=>({key:e,value:Mr({run:(e,n)=>{t.apply(void 0,[e,n].concat(o))}})}),Rs=e=>t=>({key:e,value:Mr({run:(e,o)=>{Tr(e,o)&&t(e,o)}})}),Ns=(e,t,o)=>((e,t)=>Fs(e,((o,n)=>{o.getSystem().getByUid(t).each((t=>{Ms(t,t.element,e,n)}))})))(e,t.partUids[o]),Vs=(e,t)=>Fs(e,((e,o)=>{const n=o.event,r=e.getSystem().getByDom(n.target).getOrThunk((()=>_r(n.target,(t=>e.getSystem().getByDom(t).toOptional()),_).getOr(e)));t(e,r,o)})),Hs=e=>Fs(e,((e,t)=>{t.cut()})),zs=e=>Fs(e,((e,t)=>{t.stop()})),Ls=(e,t)=>Rs(e)(t),Ps=Rs(ps()),Us=Rs(hs()),Ws=Rs(cs()),js=(Ys=ns(),e=>Fs(Ys,e)),Gs=e=>e.dom.innerHTML,$s=(e,t)=>{const o=Ye(e).dom,n=Ie(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,nt(Ie(o))})(t,o);Io(n,r),Ro(e),Fo(e,n)},qs=e=>it(e)?"#shadow-root":(e=>{const t=Be("div"),o=Ie(e.dom.cloneNode(!0));return Fo(t,o),Gs(t)})((e=>((e,t)=>Ie(e.dom.cloneNode(!1)))(e))(e)),Xs=e=>qs(e),Ks=As([((e,t)=>({key:e,value:Mr({can:(e,t)=>{const o=t.event,n=o.originator,r=o.target;return!((e,t,o)=>Xe(t,e.element)&&!Xe(t,o))(e,n,r)||(console.warn(Qr()+" did not get interpreted by the desired target. \nOriginator: "+Xs(n)+"\nTarget: "+Xs(r)+"\nCheck the "+Qr()+" event handlers"),!1)}})}))(Qr())]);var Ys,Js=Object.freeze({__proto__:null,events:Ks});let Zs=0;const Qs=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return Zs++,e+"_"+o+Zs+String(t)},ea=y("alloy-id-"),ta=y("data-alloy-id"),oa=ea(),na=ta(),ra=(e,t)=>{Object.defineProperty(e.dom,na,{value:t,writable:!0})},sa=e=>{const t=Pe(e)?e.dom[na]:null;return M.from(t)},aa=e=>Qs(e),ia=x,la=e=>{const t=t=>`The component must be in a context to execute: ${t}`+(e?"\n"+Xs(e().element)+" is not in context.":""),o=e=>()=>{throw new Error(t(e))},n=e=>()=>{console.warn(t(e))};return{debugInfo:y("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),build:o("build"),buildOrPatch:o("buildOrPatch"),addToWorld:o("addToWorld"),removeFromWorld:o("removeFromWorld"),addToGui:o("addToGui"),removeFromGui:o("removeFromGui"),getByUid:o("getByUid"),getByDom:o("getByDom"),isConnected:_}},ca=la(),da=e=>z(e,(e=>_e(e,"/*")?e.substring(0,e.length-"/*".length):e)),ua=(e,t)=>{const o=e.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:da(s)}),e},ma=Qs("alloy-premade"),ga=e=>(Object.defineProperty(e.element.dom,ma,{value:e.uid,writable:!0}),Sr(ma,e)),pa=e=>be(e,ma),ha=e=>((e,t)=>{const o=t.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:"OVERRIDE",parameters:da(s.slice(1))}),e})(((t,...o)=>e(t.getApis(),t,...o)),e),fa={init:()=>ba({readState:y("No State required")})},ba=e=>e,va=(e,t)=>{const o={};return le(e,((e,n)=>{le(e,((e,r)=>{const s=be(o,r).getOr([]);o[r]=s.concat([t(n,e)])}))})),o},ya=e=>({classes:u(e.classes)?[]:e.classes,attributes:u(e.attributes)?{}:e.attributes,styles:u(e.styles)?{}:e.styles}),xa=e=>e.cHandler,wa=(e,t)=>({name:e,handler:t}),Sa=(e,t)=>{const o={};return L(e,(e=>{o[e.name()]=e.handlers(t)})),o},ka=(e,t,o)=>{const n=t[o];return n?((e,t,o,n)=>{try{const t=ee(o,((t,o)=>{const r=t.name,s=o.name,a=n.indexOf(r),i=n.indexOf(s);if(-1===a)throw new Error("The ordering for "+e+" does not have an entry for "+r+".\nOrder specified: "+JSON.stringify(n,null,2));if(-1===i)throw new Error("The ordering for "+e+" does not have an entry for "+s+".\nOrder specified: "+JSON.stringify(n,null,2));return a<i?-1:i<a?1:0}));return Jo.value(t)}catch(e){return Jo.error([e])}})("Event: "+o,0,e,n).map((e=>(e=>{const t=((e,t)=>(...t)=>j(e,((e,o)=>e&&(e=>e.can)(o).apply(void 0,t)),!0))(e),o=((e,t)=>(...t)=>j(e,((e,o)=>e||(e=>e.abort)(o).apply(void 0,t)),!1))(e);return{can:t,abort:o,run:(...t)=>{L(e,(e=>{e.run.apply(void 0,t)}))}}})(z(e,(e=>e.handler))))):((e,t)=>Jo.error(["The event ("+e+') has more than one behaviour that listens to it.\nWhen this occurs, you must specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that can trigger it are: '+JSON.stringify(z(t,(e=>e.name)),null,2)]))(o,e)},Ca=(e,t)=>((e,t)=>{const o=(e=>{const t=[],o=[];return L(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})(e);return o.errors.length>0?(n=o.errors,Jo.error(q(n))):((e,t)=>0===e.length?Jo.value(t):Jo.value(cn(t,dn.apply(void 0,e))))(o.values,t);var n})(pe(e,((e,o)=>(1===e.length?Jo.value(e[0].handler):ka(e,t,o)).map((n=>{const r=(e=>{const t=(e=>p(e)?{can:T,abort:_,run:e}:e)(e);return(e,o,...n)=>{const r=[e,o].concat(n);t.abort.apply(void 0,r)?o.stop():t.can.apply(void 0,r)&&t.run.apply(void 0,r)}})(n),s=e.length>1?U(t[o],(t=>N(e,(e=>e.name===t)))).join(" > "):e[0].name;return Sr(o,((e,t)=>({handler:e,purpose:t}))(r,s))})))),{}),Oa="alloy.base.behaviour",_a=Cn([Gn("dom","dom",{tag:"required",process:{}},Cn([Xn("tag"),ur("styles",{}),ur("classes",[]),ur("attributes",{}),nr("value"),nr("innerHtml")])),Xn("components"),Xn("uid"),ur("events",{}),ur("apis",{}),Gn("eventOrder","eventOrder",(Ja={[ns()]:["disabling",Oa,"toggling","typeaheadevents"],[Qr()]:[Oa,"focusing","keying"],[cs()]:[Oa,"disabling","toggling","representing"],[jr()]:[Oa,"representing","streaming","invalidating"],[hs()]:[Oa,"representing","item-events","tooltipping"],[Rr()]:["focusing",Oa,"item-type-events"],[Dr()]:["focusing",Oa,"item-type-events"],[zr()]:["item-type-events","tooltipping"],[os()]:["receiving","reflecting","tooltipping"]},gn(y(Ja))),Mn()),nr("domModification")]),Ta=e=>e.events,Ea=(e,t)=>{const o=xt(e,t);return void 0===o||""===o?[]:o.split(" ")},Ma=e=>void 0!==e.dom.classList,Aa=e=>Ea(e,"class"),Da=(e,t)=>{Ma(e)?e.dom.classList.add(t):((e,t)=>{((e,t,o)=>{const n=Ea(e,t).concat([o]);vt(e,t,n.join(" "))})(e,"class",t)})(e,t)},Ba=(e,t)=>{Ma(e)?e.dom.classList.remove(t):((e,t)=>{((e,t,o)=>{const n=U(Ea(e,t),(e=>e!==o));n.length>0?vt(e,t,n.join(" ")):kt(e,t)})(e,"class",t)})(e,t),(e=>{0===(Ma(e)?e.dom.classList:Aa(e)).length&&kt(e,"class")})(e)},Fa=(e,t)=>Ma(e)&&e.dom.classList.contains(t),Ia=(e,t)=>{L(t,(t=>{Da(e,t)}))},Ra=(e,t)=>{L(t,(t=>{Ba(e,t)}))},Na=e=>e.dom.value,Va=(e,t)=>{if(void 0===t)throw new Error("Value.set was undefined");e.dom.value=t},Ha=(e,t,o)=>{o.fold((()=>Fo(e,t)),(e=>{Xe(e,t)||(Ao(e,t),No(e))}))},za=(e,t,o)=>{const n=z(t,o),r=nt(e);return L(r.slice(n.length),No),n},La=(e,t,o,n)=>{const r=rt(e,t),s=n(o,r),a=((e,t,o)=>rt(e,t).map((e=>{if(o.exists((t=>!Xe(t,e)))){const t=o.map(ze).getOr("span"),n=Be(t);return Ao(e,n),n}return e})))(e,t,r);return Ha(e,s.element,a),s},Pa=(e,t)=>{const o=ae(e),n=ae(t);return{toRemove:J(n,o),toSet:((e,o)=>{const n={},r={};return me(e,((e,o)=>!ve(t,o)||e!==t[o]),ue(n),ue(r)),{t:n,f:r}})(e).t}},Ua=(e,t)=>{const{class:o,style:n,...r}=(e=>j(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))(t),{toSet:s,toRemove:a}=Pa(e.attributes,r),i=Bt(t),{toSet:l,toRemove:c}=Pa(e.styles,i),d=(e=>Ma(e)?(e=>{const t=e.dom.classList,o=new Array(t.length);for(let e=0;e<t.length;e++){const n=t.item(e);null!==n&&(o[e]=n)}return o})(e):Aa(e))(t),u=J(d,e.classes),m=J(e.classes,d);return L(a,(e=>kt(t,e))),yt(t,s),Ia(t,m),Ra(t,u),L(c,(e=>It(t,e))),Tt(t,l),e.innerHtml.fold((()=>{const o=e.domChildren;((e,t)=>{za(e,t,((t,o)=>{const n=rt(e,o);return Ha(e,t,n),t}))})(t,o)}),(e=>{$s(t,e)})),(()=>{const o=t,n=e.value.getOrUndefined();n!==Na(o)&&Va(o,null!=n?n:"")})(),t},Wa=e=>{const t=(e=>{const t=be(e,"behaviours").getOr({});return X(ae(t),(e=>{const o=t[e];return g(o)?[o.me]:[]}))})(e);return((e,t)=>((e,t)=>{const o=z(t,(e=>dr(e.name(),[Xn("config"),ur("state",fa)]))),n=Ln("component.behaviours",Cn(o),e.behaviours).fold((t=>{throw new Error(Wn(t)+"\nComplete spec:\n"+JSON.stringify(e,null,2))}),x);return{list:t,data:ce(n,(e=>{const t=e.map((e=>({config:e.config,state:e.state.init(e.config)})));return y(t)}))}})(e,t))(e,t)},ja=(e,t)=>{const o=()=>m,n=xr(ca),r=Pn((e=>Ln("custom.definition",_a,e))(e)),s=Wa(e),a=(e=>e.list)(s),i=(e=>e.data)(s),l=((e,t,o)=>{const n={...(r=e).dom,uid:r.uid,domChildren:z(r.components,(e=>e.element))};var r;const s=(e=>e.domModification.fold((()=>ya({})),ya))(e),a={"alloy.base.modification":s},i=t.length>0?((e,t,o,n)=>{const r={...t};L(o,(t=>{r[t.name()]=t.exhibit(e,n)}));const s=va(r,((e,t)=>({name:e,modification:t}))),a=e=>W(e,((e,t)=>({...t.modification,...e})),{}),i=W(s.classes,((e,t)=>t.modification.concat(e)),[]),l=a(s.attributes),c=a(s.styles);return ya({classes:i,attributes:l,styles:c})})(o,a,t,n):s;return l=n,c=i,{...l,attributes:{...l.attributes,...c.attributes},styles:{...l.styles,...c.styles},classes:l.classes.concat(c.classes)};var l,c})(r,a,i),c=((e,t)=>{const o=t.filter((t=>ze(t)===e.tag&&!(e=>e.innerHtml.isSome()&&e.domChildren.length>0)(e)&&!(e=>ve(e.dom,ma))(t))).bind((t=>((e,t)=>{try{const o=Ua(e,t);return M.some(o)}catch(e){return M.none()}})(e,t))).getOrThunk((()=>(e=>{const t=Be(e.tag);yt(t,e.attributes),Ia(t,e.classes),Tt(t,e.styles),e.innerHtml.each((e=>$s(t,e)));const o=e.domChildren;return Io(t,o),e.value.each((e=>{Va(t,e)})),t})(e)));return ra(o,e.uid),o})(l,t),d=((e,t,o)=>{const n={"alloy.base.behaviour":Ta(e)};return((e,t,o,n)=>{const r=((e,t,o)=>{const n={...o,...Sa(t,e)};return va(n,wa)})(e,o,n);return Ca(r,t)})(o,e.eventOrder,t,n).getOrDie()})(r,a,i),u=xr(r.components),m={uid:e.uid,getSystem:n.get,config:t=>{const o=i;return(p(o[t.name()])?o[t.name()]:()=>{throw new Error("Could not find "+t.name()+" in "+JSON.stringify(e,null,2))})()},hasConfigured:e=>p(i[e.name()]),spec:e,readState:e=>i[e]().map((e=>e.state.readState())).getOr("not enabled"),getApis:()=>r.apis,connect:e=>{n.set(e)},disconnect:()=>{n.set(la(o))},element:c,syncComponents:()=>{const e=nt(c),t=X(e,(e=>n.get().getByDom(e).fold((()=>[]),Q)));u.set(t)},components:u.get,events:d};return m},Ga=e=>{const t=Fe(e);return $a({element:t})},$a=e=>{const t=Un("external.component",kn([Xn("element"),nr("uid")]),e),o=xr(la()),n=t.uid.getOrThunk((()=>aa("external")));ra(t.element,n);const r={uid:n,getSystem:o.get,config:M.none,hasConfigured:_,connect:e=>{o.set(e)},disconnect:()=>{o.set(la((()=>r)))},getApis:()=>({}),element:t.element,spec:e,readState:y("No state"),syncComponents:b,components:y([]),events:{}};return ga(r)},qa=aa,Xa=(e,t)=>pa(e).getOrThunk((()=>((e,t)=>{const{events:o,...n}=ia(e),r=((e,t)=>{const o=be(e,"components").getOr([]);return t.fold((()=>z(o,Ka)),(e=>z(o,((t,o)=>Xa(t,rt(e,o))))))})(n,t),s={...n,events:{...Js,...o},components:r};return Jo.value(ja(s,t))})((e=>ve(e,"uid"))(e)?e:{uid:qa(""),...e},t).getOrDie())),Ka=e=>Xa(e,M.none()),Ya=ga;var Ja,Za=(e,t,o,n,r)=>e(o,n)?M.some(o):p(r)&&r(o)?M.none():t(o,n,r);const Qa=(e,t,o)=>{let n=e.dom;const r=p(o)?o:_;for(;n.parentNode;){n=n.parentNode;const e=Ie(n);if(t(e))return M.some(e);if(r(e))break}return M.none()},ei=(e,t,o)=>Za(((e,t)=>t(e)),Qa,e,t,o),ti=(e,t,o)=>ei(e,t,o).isSome(),oi=(e,t,o)=>Qa(e,(e=>$e(e,t)),o),ni=(e,t)=>((e,o)=>G(e.dom.childNodes,(e=>{return o=Ie(e),$e(o,t);var o})).map(Ie))(e),ri=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return qe(o)?M.none():M.from(o.querySelector(e)).map(Ie)})(t,e),si=(e,t,o)=>Za(((e,t)=>$e(e,t)),oi,e,t,o),ai="aria-controls",ii=()=>{const e=Qs(ai);return{id:e,link:t=>{vt(t,ai,e)},unlink:e=>{kt(e,ai)}}},li=(e,t)=>ti(t,(t=>Xe(t,e.element)),_)||((e,t)=>(e=>ei(e,(e=>{if(!Pe(e))return!1;const t=xt(e,"id");return void 0!==t&&t.indexOf(ai)>-1})).bind((e=>{const t=xt(e,"id"),o=dt(e);return ri(o,`[${ai}="${t}"]`)})))(t).exists((t=>li(e,t))))(e,t);var ci;!function(e){e[e.STOP=0]="STOP",e[e.NORMAL=1]="NORMAL",e[e.LOGGING=2]="LOGGING"}(ci||(ci={}));const di=xr({}),ui=["alloy/data/Fields","alloy/debugging/Debugging"],mi=(e,t,o)=>((e,t,o)=>{switch(be(di.get(),e).orThunk((()=>{const t=ae(di.get());return se(t,(t=>e.indexOf(t)>-1?M.some(di.get()[t]):M.none()))})).getOr(ci.NORMAL)){case ci.NORMAL:return o(gi());case ci.LOGGING:{const n=((e,t)=>{const o=[],n=(new Date).getTime();return{logEventCut:(e,t,n)=>{o.push({outcome:"cut",target:t,purpose:n})},logEventStopped:(e,t,n)=>{o.push({outcome:"stopped",target:t,purpose:n})},logNoParent:(e,t,n)=>{o.push({outcome:"no-parent",target:t,purpose:n})},logEventNoHandlers:(e,t)=>{o.push({outcome:"no-handlers-left",target:t})},logEventResponse:(e,t,n)=>{o.push({outcome:"response",purpose:n,target:t})},write:()=>{const r=(new Date).getTime();R(["mousemove","mouseover","mouseout",cs()],e)||console.log(e,{event:e,time:r-n,target:t.dom,sequence:z(o,(e=>R(["cut","stopped","response"],e.outcome)?"{"+e.purpose+"} "+e.outcome+" at ("+Xs(e.target)+")":e.outcome))})}}})(e,t),r=o(n);return n.write(),r}case ci.STOP:return!0}})(e,t,o),gi=y({logEventCut:b,logEventStopped:b,logNoParent:b,logEventNoHandlers:b,logEventResponse:b,write:b}),pi=y([Xn("menu"),Xn("selectedMenu")]),hi=y([Xn("item"),Xn("selectedItem")]);y(Cn(hi().concat(pi())));const fi=y(Cn(hi())),bi=er("initSize",[Xn("numColumns"),Xn("numRows")]),vi=()=>er("markers",[Xn("backgroundMenu")].concat(pi()).concat(hi())),yi=e=>er("markers",z(e,Xn)),xi=(e,t,o)=>((()=>{const e=new Error;if(void 0!==e.stack){const t=e.stack.split("\n");G(t,(e=>e.indexOf("alloy")>0&&!N(ui,(t=>e.indexOf(t)>-1)))).getOr("unknown")}})(),Gn(t,t,o,Hn((e=>Jo.value(((...t)=>e.apply(void 0,t))))))),wi=e=>xi(0,e,mn(b)),Si=e=>xi(0,e,mn(M.none)),ki=e=>xi(0,e,{tag:"required",process:{}}),Ci=e=>xi(0,e,{tag:"required",process:{}}),Oi=(e,t)=>$n(e,y(t)),_i=e=>$n(e,x),Ti=y(bi),Ei=(e,t,o,n,r,s,a,i=!1)=>({x:e,y:t,bubble:o,direction:n,placement:r,restriction:s,label:`${a}-${r}`,alwaysFit:i}),Mi=wr([{southeast:[]},{southwest:[]},{northeast:[]},{northwest:[]},{south:[]},{north:[]},{east:[]},{west:[]}]),Ai=Mi.southeast,Di=Mi.southwest,Bi=Mi.northeast,Fi=Mi.northwest,Ii=Mi.south,Ri=Mi.north,Ni=Mi.east,Vi=Mi.west,Hi=(e,t,o,n)=>{const r=e+t;return r>n?o:r<o?n:r},zi=(e,t,o)=>Math.min(Math.max(e,t),o),Li=(e,t)=>Z(["left","right","top","bottom"],(o=>be(t,o).map((t=>((e,t)=>{switch(t){case 1:return e.x;case 0:return e.x+e.width;case 2:return e.y;case 3:return e.y+e.height}})(e,t))))),Pi="layout",Ui=e=>e.x,Wi=(e,t)=>e.x+e.width/2-t.width/2,ji=(e,t)=>e.x+e.width-t.width,Gi=(e,t)=>e.y-t.height,$i=e=>e.y+e.height,qi=(e,t)=>e.y+e.height/2-t.height/2,Xi=(e,t,o)=>Ei(Ui(e),$i(e),o.southeast(),Ai(),"southeast",Li(e,{left:1,top:3}),Pi),Ki=(e,t,o)=>Ei(ji(e,t),$i(e),o.southwest(),Di(),"southwest",Li(e,{right:0,top:3}),Pi),Yi=(e,t,o)=>Ei(Ui(e),Gi(e,t),o.northeast(),Bi(),"northeast",Li(e,{left:1,bottom:2}),Pi),Ji=(e,t,o)=>Ei(ji(e,t),Gi(e,t),o.northwest(),Fi(),"northwest",Li(e,{right:0,bottom:2}),Pi),Zi=(e,t,o)=>Ei(Wi(e,t),Gi(e,t),o.north(),Ri(),"north",Li(e,{bottom:2}),Pi),Qi=(e,t,o)=>Ei(Wi(e,t),$i(e),o.south(),Ii(),"south",Li(e,{top:3}),Pi),el=(e,t,o)=>Ei((e=>e.x+e.width)(e),qi(e,t),o.east(),Ni(),"east",Li(e,{left:0}),Pi),tl=(e,t,o)=>Ei(((e,t)=>e.x-t.width)(e,t),qi(e,t),o.west(),Vi(),"west",Li(e,{right:1}),Pi),ol=()=>[Xi,Ki,Yi,Ji,Qi,Zi,el,tl],nl=()=>[Ki,Xi,Ji,Yi,Qi,Zi,el,tl],rl=()=>[Yi,Ji,Xi,Ki,Zi,Qi],sl=()=>[Ji,Yi,Ki,Xi,Zi,Qi],al=()=>[Xi,Ki,Yi,Ji,Qi,Zi],il=()=>[Ki,Xi,Ji,Yi,Qi,Zi];var ll=Object.freeze({__proto__:null,events:e=>As([Fs(os(),((t,o)=>{const n=e.channels,r=ae(n),s=o,a=((e,t)=>t.universal?e:U(e,(e=>R(t.channels,e))))(r,s);L(a,(e=>{const o=n[e],r=o.schema,a=Un("channel["+e+"] data\nReceiver: "+Xs(t.element),r,s.data);o.onReceive(t,a)}))}))])}),cl=[Kn("channels",zn(Jo.value,kn([ki("onReceive"),ur("schema",Mn())])))];const dl=(e,t,o)=>Ws(((n,r)=>{o(n,e,t)})),ul=e=>({key:e,value:void 0}),ml=(e,t,o,n,r,s,a)=>{const i=e=>ye(e,o)?e[o]():M.none(),l=ce(r,((e,t)=>((e,t,o)=>((e,t,o)=>{const n=o.toString(),r=n.indexOf(")")+1,s=n.indexOf("("),a=n.substring(s+1,r-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:da(a.slice(0,1).concat(a.slice(3)))}),e})(((n,...r)=>{const s=[n].concat(r);return n.config({name:y(e)}).fold((()=>{throw new Error("We could not find any behaviour configuration for: "+e+". Using API: "+o)}),(e=>{const o=Array.prototype.slice.call(s,1);return t.apply(void 0,[n,e.config,e.state].concat(o))}))}),o,t))(o,e,t))),c={...ce(s,((e,t)=>ua(e,t))),...l,revoke:S(ul,o),config:t=>{const n=Un(o+"-config",e,t);return{key:o,value:{config:n,me:c,configAsRaw:Xt((()=>Un(o+"-config",e,t))),initialConfig:t,state:a}}},schema:y(t),exhibit:(e,t)=>Se(i(e),be(n,"exhibit"),((e,o)=>o(t,e.config,e.state))).getOrThunk((()=>ya({}))),name:y(o),handlers:e=>i(e).map((e=>be(n,"events").getOr((()=>({})))(e.config,e.state))).getOr({})};return c},gl=e=>kr(e),pl=kn([Xn("fields"),Xn("name"),ur("active",{}),ur("apis",{}),ur("state",fa),ur("extra",{})]),hl=e=>{const t=Un("Creating behaviour: "+e.name,pl,e);return((e,t,o,n,r,s)=>{const a=kn(e),i=dr(t,[("config",l=e,rr("config",kn(l)))]);var l;return ml(a,i,t,o,n,r,s)})(t.fields,t.name,t.active,t.apis,t.extra,t.state)},fl=kn([Xn("branchKey"),Xn("branches"),Xn("name"),ur("active",{}),ur("apis",{}),ur("state",fa),ur("extra",{})]),bl=e=>{const t=Un("Creating behaviour: "+e.name,fl,e);return((e,t,o,n,r,s)=>{const a=e,i=dr(t,[rr("config",e)]);return ml(a,i,t,o,n,r,s)})(jn(t.branchKey,t.branches),t.name,t.active,t.apis,t.extra,t.state)},vl=y(void 0),yl=hl({fields:cl,name:"receiving",active:ll});var xl=Object.freeze({__proto__:null,exhibit:(e,t)=>ya({classes:[],styles:t.useFixed()?{}:{position:"relative"}})});const wl=e=>e.dom.focus(),Sl=e=>{const t=dt(e).dom;return e.dom===t.activeElement},kl=(e=Po())=>M.from(e.dom.activeElement).map(Ie),Cl=e=>kl(dt(e)).filter((t=>e.dom.contains(t.dom))),Ol=(e,t)=>{const o=dt(t),n=kl(o).bind((e=>{const o=t=>Xe(e,t);return o(t)?M.some(t):((e,t)=>{const o=e=>{for(let n=0;n<e.childNodes.length;n++){const r=Ie(e.childNodes[n]);if(t(r))return M.some(r);const s=o(e.childNodes[n]);if(s.isSome())return s}return M.none()};return o(e.dom)})(t,o)})),r=e(t);return n.each((e=>{kl(o).filter((t=>Xe(t,e))).fold((()=>{wl(e)}),b)})),r},_l=(e,t,o,n,r)=>{const s=e=>e+"px";return{position:e,left:t.map(s),top:o.map(s),right:n.map(s),bottom:r.map(s)}},Tl=(e,t)=>{Et(e,(e=>({...e,position:M.some(e.position)}))(t))},El=wr([{none:[]},{relative:["x","y","width","height"]},{fixed:["x","y","width","height"]}]),Ml=(e,t,o,n,r,s)=>{const a=t.rect,i=a.x-o,l=a.y-n,c=r-(i+a.width),d=s-(l+a.height),u=M.some(i),m=M.some(l),g=M.some(c),p=M.some(d),h=M.none();return t.direction.fold((()=>_l(e,u,m,h,h)),(()=>_l(e,h,m,g,h)),(()=>_l(e,u,h,h,p)),(()=>_l(e,h,h,g,p)),(()=>_l(e,u,m,h,h)),(()=>_l(e,u,h,h,p)),(()=>_l(e,u,m,h,h)),(()=>_l(e,h,m,g,h)))},Al=(e,t)=>e.fold((()=>{const e=t.rect;return _l("absolute",M.some(e.x),M.some(e.y),M.none(),M.none())}),((e,o,n,r)=>Ml("absolute",t,e,o,n,r)),((e,o,n,r)=>Ml("fixed",t,e,o,n,r))),Dl=(e,t)=>{const o=S(jo,t),n=e.fold(o,o,(()=>{const e=Vo();return jo(t).translate(-e.left,-e.top)})),r=qt(t),s=zt(t);return Go(n.left,n.top,r,s)},Bl=(e,t)=>t.fold((()=>e.fold(Xo,Xo,Go)),(t=>e.fold(t,t,(()=>{const o=t(),n=Fl(e,o.x,o.y);return Go(n.left,n.top,o.width,o.height)})))),Fl=(e,t,o)=>{const n=Pt(t,o);return e.fold(y(n),y(n),(()=>{const e=Vo();return n.translate(-e.left,-e.top)}))};El.none;const Il=El.relative,Rl=El.fixed,Nl="data-alloy-placement",Vl=e=>wt(e,Nl),Hl=wr([{fit:["reposition"]},{nofit:["reposition","visibleW","visibleH","isVisible"]}]),zl=(e,t,o,n)=>{const r=e.bubble,s=r.offset,a=((e,t,o)=>{const n=(n,r)=>t[n].map((t=>{const s="top"===n||"bottom"===n,a=s?o.top:o.left,i=("left"===n||"top"===n?Math.max:Math.min)(t,r)+a;return s?zi(i,e.y,e.bottom):zi(i,e.x,e.right)})).getOr(r),r=n("left",e.x),s=n("top",e.y),a=n("right",e.right),i=n("bottom",e.bottom);return Go(r,s,a-r,i-s)})(n,e.restriction,s),i=e.x+s.left,l=e.y+s.top,c=Go(i,l,t,o),{originInBounds:d,sizeInBounds:u,visibleW:m,visibleH:g}=((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,right:l,bottom:c,width:d,height:u}=e;return{originInBounds:a>=o&&a<=r&&i>=n&&i<=s,sizeInBounds:l<=r&&l>=o&&c<=s&&c>=n,visibleW:Math.min(d,a>=o?r-a:l-o),visibleH:Math.min(u,i>=n?s-i:c-n)}})(c,a),p=d&&u,h=p?c:((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,width:l,height:c}=e,d=Math.max(o,r-l),u=Math.max(n,s-c),m=zi(a,o,d),g=zi(i,n,u),p=Math.min(m+l,r)-m,h=Math.min(g+c,s)-g;return Go(m,g,p,h)})(c,a),f=h.width>0&&h.height>0,{maxWidth:b,maxHeight:v}=((e,t,o)=>{const n=y(t.bottom-o.y),r=y(o.bottom-t.y),s=((e,t,o,n)=>e.fold(t,t,n,n,t,n,o,o))(e,r,r,n),a=y(t.right-o.x),i=y(o.right-t.x),l=((e,t,o,n)=>e.fold(t,n,t,n,o,o,t,n))(e,i,i,a);return{maxWidth:l,maxHeight:s}})(e.direction,h,n),x={rect:h,maxHeight:v,maxWidth:b,direction:e.direction,placement:e.placement,classes:{on:r.classesOn,off:r.classesOff},layout:e.label,testY:l};return p||e.alwaysFit?Hl.fit(x):Hl.nofit(x,m,g,f)},Ll=e=>{const t=xr(M.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(M.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(M.some(e))}}},Pl=()=>Ll((e=>e.unbind())),Ul=()=>{const e=Ll(b);return{...e,on:t=>e.get().each(t)}},Wl=T,jl=(e,t,o)=>((e,t,o,n)=>Eo(e,t,o,n,!1))(e,t,Wl,o),Gl=(e,t,o)=>((e,t,o,n)=>Eo(e,t,o,n,!0))(e,t,Wl,o),$l=To,ql=["top","bottom","right","left"],Xl="data-alloy-transition-timer",Kl=(e,t,o,n,r,a)=>{const i=((e,t,o)=>o.exists((o=>{const n=e.mode;return"all"===n||o[n]!==t[n]})))(n,r,a);if(i||((e,t)=>((e,t)=>K(t,(t=>Fa(e,t))))(e,t.classes))(e,n)){_t(e,"position",o.position);const a=Dl(t,e),l=Al(t,{...r,rect:a}),c=Z(ql,(e=>l[e]));((e,t)=>{const o=e=>parseFloat(e).toFixed(3);return he(t,((t,n)=>!((e,t,o=w)=>Se(e,t,o).getOr(e.isNone()&&t.isNone()))(e[n].map(o),t.map(o)))).isSome()})(o,c)&&(Et(e,c),i&&((e,t)=>{Ia(e,t.classes),wt(e,Xl).each((t=>{clearTimeout(parseInt(t,10)),kt(e,Xl)})),((e,t)=>{const o=Pl(),n=Pl();let r;const a=t=>{var o;const n=null!==(o=t.raw.pseudoElement)&&void 0!==o?o:"";return Xe(t.target,e)&&!Ee(n)&&R(ql,t.raw.propertyName)},i=s=>{if(m(s)||a(s)){o.clear(),n.clear();const a=null==s?void 0:s.raw.type;(m(a)||a===Xr())&&(clearTimeout(r),kt(e,Xl),Ra(e,t.classes))}},l=jl(e,Kr(),(t=>{a(t)&&(l.unbind(),o.set(jl(e,Xr(),i)),n.set(jl(e,qr(),i)))})),c=(e=>{const t=t=>{const o=Mt(e,t).split(/\s*,\s*/);return U(o,Ee)},o=e=>{if(s(e)&&/^[\d.]+/.test(e)){const t=parseFloat(e);return _e(e,"ms")?t:1e3*t}return 0},n=t("transition-delay"),r=t("transition-duration");return j(r,((e,t,r)=>{const s=o(n[r])+o(t);return Math.max(e,s)}),0)})(e);requestAnimationFrame((()=>{r=setTimeout(i,c+17),vt(e,Xl,r)}))})(e,t)})(e,n),Rt(e))}else Ra(e,n.classes)},Yl=(e,t)=>{((e,t)=>{const o=Vt.max(e,t,["margin-top","border-top-width","padding-top","padding-bottom","border-bottom-width","margin-bottom"]);_t(e,"max-height",o+"px")})(e,Math.floor(t))},Jl=y(((e,t)=>{Yl(e,t),Tt(e,{"overflow-x":"hidden","overflow-y":"auto"})})),Zl=y(((e,t)=>{Yl(e,t)})),Ql=(e,t,o)=>void 0===e[t]?o:e[t],ec=(e,t,o,n)=>{const r=((e,t,o,n)=>{It(t,"max-height"),It(t,"max-width");const r={width:qt(s=t),height:zt(s)};var s;return((e,t,o,n,r,s)=>{const a=n.width,i=n.height,l=(t,l,c,d,u)=>{const m=t(o,n,r,e,s),g=zl(m,a,i,s);return g.fold(y(g),((e,t,o,n)=>(u===n?o>d||t>c:!u&&n)?g:Hl.nofit(l,c,d,u)))};return j(t,((e,t)=>{const o=S(l,t);return e.fold(y(e),o)}),Hl.nofit({rect:o,maxHeight:n.height,maxWidth:n.width,direction:Ai(),placement:"southeast",classes:{on:[],off:[]},layout:"none",testY:o.y},-1,-1,!1)).fold(x,x)})(t,n.preference,e,r,o,n.bounds)})(e,t,o,n);return((e,t,o)=>{const n=Al(o.origin,t);o.transition.each((r=>{Kl(e,o.origin,n,r,t,o.lastPlacement)})),Tl(e,n)})(t,r,n),((e,t)=>{((e,t)=>{vt(e,Nl,t)})(e,t.placement)})(t,r),((e,t)=>{const o=t.classes;Ra(e,o.off),Ia(e,o.on)})(t,r),((e,t,o)=>{(0,o.maxHeightFunction)(e,t.maxHeight)})(t,r,n),((e,t,o)=>{(0,o.maxWidthFunction)(e,t.maxWidth)})(t,r,n),{layout:r.layout,placement:r.placement}},tc=["valignCentre","alignLeft","alignRight","alignCentre","top","bottom","left","right","inset"],oc=(e,t,o,n=1)=>{const r=e*n,s=t*n,a=e=>be(o,e).getOr([]),i=(e,t,o)=>{const n=J(tc,o);return{offset:Pt(e,t),classesOn:X(o,a),classesOff:X(n,a)}};return{southeast:()=>i(-e,t,["top","alignLeft"]),southwest:()=>i(e,t,["top","alignRight"]),south:()=>i(-e/2,t,["top","alignCentre"]),northeast:()=>i(-e,-t,["bottom","alignLeft"]),northwest:()=>i(e,-t,["bottom","alignRight"]),north:()=>i(-e/2,-t,["bottom","alignCentre"]),east:()=>i(e,-t/2,["valignCentre","left"]),west:()=>i(-e,-t/2,["valignCentre","right"]),insetNortheast:()=>i(r,s,["top","alignLeft","inset"]),insetNorthwest:()=>i(-r,s,["top","alignRight","inset"]),insetNorth:()=>i(-r/2,s,["top","alignCentre","inset"]),insetSoutheast:()=>i(r,-s,["bottom","alignLeft","inset"]),insetSouthwest:()=>i(-r,-s,["bottom","alignRight","inset"]),insetSouth:()=>i(-r/2,-s,["bottom","alignCentre","inset"]),insetEast:()=>i(-r,-s/2,["valignCentre","right","inset"]),insetWest:()=>i(r,-s/2,["valignCentre","left","inset"])}},nc=()=>oc(0,0,{}),rc=x,sc=(e,t)=>o=>"rtl"===ac(o)?t:e,ac=e=>"rtl"===Mt(e,"direction")?"rtl":"ltr";var ic;!function(e){e.TopToBottom="toptobottom",e.BottomToTop="bottomtotop"}(ic||(ic={}));const lc="data-alloy-vertical-dir",cc=e=>ti(e,(e=>Pe(e)&&xt(e,"data-alloy-vertical-dir")===ic.BottomToTop)),dc=()=>dr("layouts",[Xn("onLtr"),Xn("onRtl"),nr("onBottomLtr"),nr("onBottomRtl")]),uc=(e,t,o,n,r,s,a)=>{const i=a.map(cc).getOr(!1),l=t.layouts.map((t=>t.onLtr(e))),c=t.layouts.map((t=>t.onRtl(e))),d=i?t.layouts.bind((t=>t.onBottomLtr.map((t=>t(e))))).or(l).getOr(r):l.getOr(o),u=i?t.layouts.bind((t=>t.onBottomRtl.map((t=>t(e))))).or(c).getOr(s):c.getOr(n);return sc(d,u)(e)};var mc=[Xn("hotspot"),nr("bubble"),ur("overrides",{}),dc(),Oi("placement",((e,t,o)=>{const n=t.hotspot,r=Dl(o,n.element),s=uc(e.element,t,al(),il(),rl(),sl(),M.some(t.hotspot.element));return M.some(rc({anchorBox:r,bubble:t.bubble.getOr(nc()),overrides:t.overrides,layouts:s,placer:M.none()}))}))],gc=[Xn("x"),Xn("y"),ur("height",0),ur("width",0),ur("bubble",nc()),ur("overrides",{}),dc(),Oi("placement",((e,t,o)=>{const n=Fl(o,t.x,t.y),r=Go(n.left,n.top,t.width,t.height),s=uc(e.element,t,ol(),nl(),ol(),nl(),M.none());return M.some(rc({anchorBox:r,bubble:t.bubble,overrides:t.overrides,layouts:s,placer:M.none()}))}))];const pc=wr([{screen:["point"]},{absolute:["point","scrollLeft","scrollTop"]}]),hc=e=>e.fold(x,((e,t,o)=>e.translate(-t,-o))),fc=e=>e.fold(x,x),bc=e=>j(e,((e,t)=>e.translate(t.left,t.top)),Pt(0,0)),vc=e=>{const t=z(e,fc);return bc(t)},yc=pc.screen,xc=pc.absolute,wc=(e,t,o)=>{const n=Ye(e.element),r=Vo(n),s=((e,t,o)=>{const n=Qe(o.root).dom;return M.from(n.frameElement).map(Ie).filter((t=>{const o=Ye(t),n=Ye(e.element);return Xe(o,n)})).map(Wt)})(e,0,o).getOr(r);return xc(s,r.left,r.top)},Sc=(e,t,o,n)=>{const r=yc(Pt(e,t));return M.some(((e,t,o)=>({point:e,width:t,height:o}))(r,o,n))},kc=(e,t,o,n,r)=>e.map((e=>{const s=[t,e.point],a=(i=()=>vc(s),l=()=>vc(s),c=()=>(e=>{const t=z(e,hc);return bc(t)})(s),n.fold(i,l,c));var i,l,c;const d=(p=a.left,h=a.top,f=e.width,b=e.height,{x:p,y:h,width:f,height:b}),u=o.showAbove?rl():al(),m=o.showAbove?sl():il(),g=uc(r,o,u,m,u,m,M.none());var p,h,f,b;return rc({anchorBox:d,bubble:o.bubble.getOr(nc()),overrides:o.overrides,layouts:g,placer:M.none()})}));var Cc=[Xn("node"),Xn("root"),nr("bubble"),dc(),ur("overrides",{}),ur("showAbove",!1),Oi("placement",((e,t,o)=>{const n=wc(e,0,t);return t.node.filter(pt).bind((r=>{const s=r.dom.getBoundingClientRect(),a=Sc(s.left,s.top,s.width,s.height),i=t.node.getOr(e.element);return kc(a,n,t,o,i)}))}))];const Oc=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),_c=wr([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Tc=(_c.before,_c.on,_c.after,e=>e.fold(x,x,x)),Ec=wr([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Mc={domRange:Ec.domRange,relative:Ec.relative,exact:Ec.exact,exactFromRange:e=>Ec.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Ie(e.startContainer),relative:(e,t)=>Tc(e),exact:(e,t,o,n)=>e}))(e);return Qe(t)},range:Oc},Ac=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Dc=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},Bc=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),Fc=wr([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Ic=(e,t,o)=>t(Ie(o.startContainer),o.startOffset,Ie(o.endContainer),o.endOffset),Rc=(e,t)=>((e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:y(e),rtl:M.none}),relative:(t,o)=>({ltr:Xt((()=>Ac(e,t,o))),rtl:Xt((()=>M.some(Ac(e,o,t))))}),exact:(t,o,n,r)=>({ltr:Xt((()=>Dc(e,t,o,n,r))),rtl:Xt((()=>M.some(Dc(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();return o.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>Fc.rtl(Ie(e.endContainer),e.endOffset,Ie(e.startContainer),e.startOffset))).getOrThunk((()=>Ic(0,Fc.ltr,o))):Ic(0,Fc.ltr,o)})(0,o)})(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});Fc.ltr,Fc.rtl;const Nc=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return qe(o)?[]:z(o.querySelectorAll(e),Ie)})(t,e),Vc=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return M.some(Oc(Ie(t.startContainer),t.startOffset,Ie(o.endContainer),o.endOffset))}return M.none()},Hc=e=>{if(null===e.anchorNode||null===e.focusNode)return Vc(e);{const t=Ie(e.anchorNode),o=Ie(e.focusNode);return((e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Ye(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=Xe(e,o)&&t===n;return r.collapsed&&!s})(t,e.anchorOffset,o,e.focusOffset)?M.some(Oc(t,e.anchorOffset,o,e.focusOffset)):Vc(e)}},zc=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?M.some(o).map(Bc):M.none()})(Rc(e,t)),Lc=((e,t)=>{const o=t=>e(t)?M.from(t.dom.nodeValue):M.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return o(t).getOr("")},getOption:o,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(Ue),Pc=(e,t)=>({element:e,offset:t}),Uc=(e,t)=>Ue(e)?Pc(e,t):((e,t)=>{const o=nt(e);if(0===o.length)return Pc(e,t);if(t<o.length)return Pc(o[t],0);{const e=o[o.length-1],t=Ue(e)?(e=>Lc.get(e))(e).length:nt(e).length;return Pc(e,t)}})(e,t),Wc=(e,t)=>t.getSelection.getOrThunk((()=>()=>(e=>(e=>M.from(e.getSelection()))(e).filter((e=>e.rangeCount>0)).bind(Hc))(e)))().map((e=>{const t=Uc(e.start,e.soffset),o=Uc(e.finish,e.foffset);return Mc.range(t.element,t.offset,o.element,o.offset)}));var jc=[nr("getSelection"),Xn("root"),nr("bubble"),dc(),ur("overrides",{}),ur("showAbove",!1),Oi("placement",((e,t,o)=>{const n=Qe(t.root).dom,r=wc(e,0,t),s=Wc(n,t).bind((e=>{const t=((e,t)=>(e=>{const t=e.getBoundingClientRect();return t.width>0||t.height>0?M.some(t).map(Bc):M.none()})(Rc(e,t)))(n,Mc.exactFromRange(e)).orThunk((()=>{const t=Fe("\ufeff");Ao(e.start,t);const o=zc(n,Mc.exact(t,0,t,1));return No(t),o}));return t.bind((e=>Sc(e.left,e.top,e.width,e.height)))})),a=Wc(n,t).bind((e=>Pe(e.start)?M.some(e.start):tt(e.start))).getOr(e.element);return kc(s,r,t,o,a)}))];const Gc="link-layout",$c=e=>e.x+e.width,qc=(e,t)=>e.x-t.width,Xc=(e,t)=>e.y-t.height+e.height,Kc=e=>e.y,Yc=(e,t,o)=>Ei($c(e),Kc(e),o.southeast(),Ai(),"southeast",Li(e,{left:0,top:2}),Gc),Jc=(e,t,o)=>Ei(qc(e,t),Kc(e),o.southwest(),Di(),"southwest",Li(e,{right:1,top:2}),Gc),Zc=(e,t,o)=>Ei($c(e),Xc(e,t),o.northeast(),Bi(),"northeast",Li(e,{left:0,bottom:3}),Gc),Qc=(e,t,o)=>Ei(qc(e,t),Xc(e,t),o.northwest(),Fi(),"northwest",Li(e,{right:1,bottom:3}),Gc),ed=()=>[Yc,Jc,Zc,Qc],td=()=>[Jc,Yc,Qc,Zc];var od=[Xn("item"),dc(),ur("overrides",{}),Oi("placement",((e,t,o)=>{const n=Dl(o,t.item.element),r=uc(e.element,t,ed(),td(),ed(),td(),M.none());return M.some(rc({anchorBox:n,bubble:nc(),overrides:t.overrides,layouts:r,placer:M.none()}))}))],nd=jn("type",{selection:jc,node:Cc,hotspot:mc,submenu:od,makeshift:gc});const rd=[or("classes",Bn),hr("mode","all",["all","layout","placement"])],sd=[ur("useFixed",_),nr("getBounds")],ad=[Kn("anchor",nd),dr("transition",rd)],id=(e,t,o,n,r,s,a)=>((e,t,o,n,r,s,a,i)=>{const l=Ql(a,"maxHeightFunction",Jl()),c=Ql(a,"maxWidthFunction",b),d=e.anchorBox,u=e.origin,m={bounds:Bl(u,s),origin:u,preference:n,maxHeightFunction:l,maxWidthFunction:c,lastPlacement:r,transition:i};return ec(d,t,o,m)})(((e,t)=>((e,t)=>({anchorBox:e,origin:t}))(e,t))(o.anchorBox,t),r.element,o.bubble,o.layouts,s,n,o.overrides,a),ld=(e,t,o,n,r,s)=>{const a=s.map($o);return cd(e,t,o,n,r,a)},cd=(e,t,o,n,r,s)=>{const a=Un("placement.info",Cn(ad),r),i=a.anchor,l=n.element,c=o.get(n.uid);Ol((()=>{_t(l,"position","fixed");const r=Dt(l,"visibility");_t(l,"visibility","hidden");const d=t.useFixed()?(()=>{const e=document.documentElement;return Rl(0,0,e.clientWidth,e.clientHeight)})():(e=>{const t=Wt(e.element),o=e.element.dom.getBoundingClientRect();return Il(t.left,t.top,o.width,o.height)})(e),u=i.placement,m=s.map(y).or(t.getBounds);u(e,i,d).each((t=>{const r=t.placer.getOr(id)(e,d,t,m,n,c,a.transition);o.set(n.uid,r)})),r.fold((()=>{It(l,"visibility")}),(e=>{_t(l,"visibility",e)})),Dt(l,"left").isNone()&&Dt(l,"top").isNone()&&Dt(l,"right").isNone()&&Dt(l,"bottom").isNone()&&xe(Dt(l,"position"),"fixed")&&It(l,"position")}),l)};var dd=Object.freeze({__proto__:null,position:(e,t,o,n,r)=>{ld(e,t,o,n,r,M.none())},positionWithin:ld,positionWithinBounds:cd,getMode:(e,t,o)=>t.useFixed()?"fixed":"absolute",reset:(e,t,o,n)=>{const r=n.element;L(["position","left","right","top","bottom"],(e=>It(r,e))),(e=>{kt(e,Nl)})(r),o.clear(n.uid)}});const ud=hl({fields:sd,name:"positioning",active:xl,apis:dd,state:Object.freeze({__proto__:null,init:()=>{let e={};return ba({readState:()=>e,clear:t=>{g(t)?delete e[t]:e={}},set:(t,o)=>{e[t]=o},get:t=>be(e,t)})}})}),md=e=>e.getSystem().isConnected(),gd=e=>{Cs(e,hs());const t=e.components();L(t,gd)},pd=e=>{const t=e.components();L(t,pd),Cs(e,ps())},hd=(e,t)=>{e.getSystem().addToWorld(t),pt(e.element)&&pd(t)},fd=e=>{gd(e),e.getSystem().removeFromWorld(e)},bd=(e,t)=>{Fo(e.element,t.element)},vd=(e,t)=>{yd(e,t,Fo)},yd=(e,t,o)=>{e.getSystem().addToWorld(t),o(e.element,t.element),pt(e.element)&&pd(t),e.syncComponents()},xd=e=>{gd(e),No(e.element),e.getSystem().removeFromWorld(e)},wd=e=>{const t=et(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()));xd(e),t.each((e=>{e.syncComponents()}))},Sd=e=>{const t=e.components();L(t,xd),Ro(e.element),e.syncComponents()},kd=(e,t)=>{Cd(e,t,Fo)},Cd=(e,t,o)=>{o(e,t.element);const n=nt(t.element);L(n,(e=>{t.getByDom(e).each(pd)}))},Od=e=>{const t=nt(e.element);L(t,(t=>{e.getByDom(t).each(gd)})),No(e.element)},_d=(e,t,o,n)=>{o.get().each((t=>{Sd(e)}));const r=t.getAttachPoint(e);vd(r,e);const s=e.getSystem().build(n);return vd(e,s),o.set(s),s},Td=(e,t,o,n)=>{const r=_d(e,t,o,n);return t.onOpen(e,r),r},Ed=(e,t,o)=>{o.get().each((n=>{Sd(e),wd(e),t.onClose(e,n),o.clear()}))},Md=(e,t,o)=>o.isOpen(),Ad=(e,t,o)=>{const n=t.getAttachPoint(e);_t(e.element,"position",ud.getMode(n)),((e,t,o,n)=>{Dt(e.element,t).fold((()=>{kt(e.element,o)}),(t=>{vt(e.element,o,t)})),_t(e.element,t,"hidden")})(e,"visibility",t.cloakVisibilityAttr)},Dd=(e,t,o)=>{(e=>N(["top","left","right","bottom"],(t=>Dt(e,t).isSome())))(e.element)||It(e.element,"position"),((e,t,o)=>{wt(e.element,o).fold((()=>It(e.element,t)),(o=>_t(e.element,t,o)))})(e,"visibility",t.cloakVisibilityAttr)};var Bd=Object.freeze({__proto__:null,cloak:Ad,decloak:Dd,open:Td,openWhileCloaked:(e,t,o,n,r)=>{Ad(e,t),Td(e,t,o,n),r(),Dd(e,t)},close:Ed,isOpen:Md,isPartOf:(e,t,o,n)=>Md(0,0,o)&&o.get().exists((o=>t.isPartOf(e,o,n))),getState:(e,t,o)=>o.get(),setContent:(e,t,o,n)=>o.get().map((()=>_d(e,t,o,n)))}),Fd=Object.freeze({__proto__:null,events:(e,t)=>As([Fs(is(),((o,n)=>{Ed(o,e,t)}))])}),Id=[wi("onOpen"),wi("onClose"),Xn("isPartOf"),Xn("getAttachPoint"),ur("cloakVisibilityAttr","data-precloak-visibility")],Rd=Object.freeze({__proto__:null,init:()=>{const e=Ul(),t=y("not-implemented");return ba({readState:t,isOpen:e.isSet,clear:e.clear,set:e.set,get:e.get})}});const Nd=hl({fields:Id,name:"sandboxing",active:Fd,apis:Bd,state:Rd}),Vd=y("dismiss.popups"),Hd=y("reposition.popups"),zd=y("mouse.released"),Ld=kn([ur("isExtraPart",_),dr("fireEventInstead",[ur("event",fs())])]),Pd=e=>{const t=Un("Dismissal",Ld,e);return{[Vd()]:{schema:kn([Xn("target")]),onReceive:(e,o)=>{Nd.isOpen(e)&&(Nd.isPartOf(e,o.target)||t.isExtraPart(e,o.target)||t.fireEventInstead.fold((()=>Nd.close(e)),(t=>Cs(e,t.event))))}}}},Ud=kn([dr("fireEventInstead",[ur("event",bs())]),Qn("doReposition")]),Wd=e=>{const t=Un("Reposition",Ud,e);return{[Hd()]:{onReceive:e=>{Nd.isOpen(e)&&t.fireEventInstead.fold((()=>t.doReposition(e)),(t=>Cs(e,t.event)))}}}},jd=(e,t,o)=>{t.store.manager.onLoad(e,t,o)},Gd=(e,t,o)=>{t.store.manager.onUnload(e,t,o)};var $d=Object.freeze({__proto__:null,onLoad:jd,onUnload:Gd,setValue:(e,t,o,n)=>{t.store.manager.setValue(e,t,o,n)},getValue:(e,t,o)=>t.store.manager.getValue(e,t,o),getState:(e,t,o)=>o}),qd=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.resetOnDom?[Ps(((o,n)=>{jd(o,e,t)})),Us(((o,n)=>{Gd(o,e,t)}))]:[dl(e,t,jd)];return As(o)}});const Xd=()=>{const e=xr(null);return ba({set:e.set,get:e.get,isNotSet:()=>null===e.get(),clear:()=>{e.set(null)},readState:()=>({mode:"memory",value:e.get()})})},Kd=()=>{const e=xr({}),t=xr({});return ba({readState:()=>({mode:"dataset",dataByValue:e.get(),dataByText:t.get()}),lookup:o=>be(e.get(),o).orThunk((()=>be(t.get(),o))),update:o=>{const n=e.get(),r=t.get(),s={},a={};L(o,(e=>{s[e.value]=e,be(e,"meta").each((t=>{be(t,"text").each((t=>{a[t]=e}))}))})),e.set({...n,...s}),t.set({...r,...a})},clear:()=>{e.set({}),t.set({})}})};var Yd=Object.freeze({__proto__:null,memory:Xd,dataset:Kd,manual:()=>ba({readState:b}),init:e=>e.store.manager.state(e)});const Jd=(e,t,o,n)=>{const r=t.store;o.update([n]),r.setValue(e,n),t.onSetValue(e,n)};var Zd=[nr("initialValue"),Xn("getFallbackEntry"),Xn("getDataKey"),Xn("setValue"),Oi("manager",{setValue:Jd,getValue:(e,t,o)=>{const n=t.store,r=n.getDataKey(e);return o.lookup(r).getOrThunk((()=>n.getFallbackEntry(r)))},onLoad:(e,t,o)=>{t.store.initialValue.each((n=>{Jd(e,t,o,n)}))},onUnload:(e,t,o)=>{o.clear()},state:Kd})],Qd=[Xn("getValue"),ur("setValue",b),nr("initialValue"),Oi("manager",{setValue:(e,t,o,n)=>{t.store.setValue(e,n),t.onSetValue(e,n)},getValue:(e,t,o)=>t.store.getValue(e),onLoad:(e,t,o)=>{t.store.initialValue.each((o=>{t.store.setValue(e,o)}))},onUnload:b,state:fa.init})],eu=[nr("initialValue"),Oi("manager",{setValue:(e,t,o,n)=>{o.set(n),t.onSetValue(e,n)},getValue:(e,t,o)=>o.get(),onLoad:(e,t,o)=>{t.store.initialValue.each((e=>{o.isNotSet()&&o.set(e)}))},onUnload:(e,t,o)=>{o.clear()},state:Xd})],tu=[mr("store",{mode:"memory"},jn("mode",{memory:eu,manual:Qd,dataset:Zd})),wi("onSetValue"),ur("resetOnDom",!1)];const ou=hl({fields:tu,name:"representing",active:qd,apis:$d,extra:{setValueFrom:(e,t)=>{const o=ou.getValue(t);ou.setValue(e,o)}},state:Yd}),nu=(e,t)=>yr(e,{},z(t,(t=>{return o=t.name(),n="Cannot configure "+t.name()+" for "+e,Gn(o,o,{tag:"option",process:{}},bn((e=>nn("The field: "+o+" is forbidden. "+n))));var o,n})).concat([$n("dump",x)])),ru=e=>e.dump,su=(e,t)=>({...gl(t),...e.dump}),au=nu,iu=su,lu="placeholder",cu=wr([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),du=e=>ve(e,"uiType"),uu=(e,t,o,n)=>((e,t,o,n)=>du(o)&&o.uiType===lu?((e,t,o,n)=>e.exists((e=>e!==o.owner))?cu.single(!0,y(o)):be(n,o.name).fold((()=>{throw new Error("Unknown placeholder component: "+o.name+"\nKnown: ["+ae(n)+"]\nNamespace: "+e.getOr("none")+"\nSpec: "+JSON.stringify(o,null,2))}),(e=>e.replace())))(e,0,o,n):cu.single(!1,y(o)))(e,0,o,n).fold(((r,s)=>{const a=du(o)?s(t,o.config,o.validated):s(t),i=be(a,"components").getOr([]),l=X(i,(o=>uu(e,t,o,n)));return[{...a,components:l}]}),((e,n)=>{if(du(o)){const e=n(t,o.config,o.validated);return o.validated.preprocess.getOr(x)(e)}return n(t)})),mu=cu.single,gu=cu.multiple,pu=y(lu),hu=wr([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),fu=ur("factory",{sketch:x}),bu=ur("schema",[]),vu=Xn("name"),yu=Gn("pname","pname",un((e=>"<alloy."+Qs(e.name)+">")),Mn()),xu=$n("schema",(()=>[nr("preprocess")])),wu=ur("defaults",y({})),Su=ur("overrides",y({})),ku=Cn([fu,bu,vu,yu,wu,Su]),Cu=Cn([fu,bu,vu,wu,Su]),Ou=Cn([fu,bu,vu,yu,wu,Su]),_u=Cn([fu,xu,vu,Xn("unit"),yu,wu,Su]),Tu=e=>e.fold(M.some,M.none,M.some,M.some),Eu=e=>{const t=e=>e.name;return e.fold(t,t,t,t)},Mu=(e,t)=>o=>{const n=Un("Converting part type",t,o);return e(n)},Au=Mu(hu.required,ku),Du=Mu(hu.external,Cu),Bu=Mu(hu.optional,Ou),Fu=Mu(hu.group,_u),Iu=y("entirety");var Ru=Object.freeze({__proto__:null,required:Au,external:Du,optional:Bu,group:Fu,asNamedPart:Tu,name:Eu,asCommon:e=>e.fold(x,x,x,x),original:Iu});const Nu=(e,t,o,n)=>cn(t.defaults(e,o,n),o,{uid:e.partUids[t.name]},t.overrides(e,o,n)),Vu=(e,t)=>{const o={};return L(t,(t=>{Tu(t).each((t=>{const n=Hu(e,t.pname);o[t.name]=o=>{const r=Un("Part: "+t.name+" in "+e,Cn(t.schema),o);return{...n,config:o,validated:r}}}))})),o},Hu=(e,t)=>({uiType:pu(),owner:e,name:t}),zu=(e,t,o)=>({uiType:pu(),owner:e,name:t,config:o,validated:{}}),Lu=e=>X(e,(e=>e.fold(M.none,M.some,M.none,M.none).map((e=>er(e.name,e.schema.concat([_i(Iu())])))).toArray())),Pu=e=>z(e,Eu),Uu=(e,t,o)=>((e,t,o)=>{const n={},r={};return L(o,(e=>{e.fold((e=>{n[e.pname]=mu(!0,((t,o,n)=>e.factory.sketch(Nu(t,e,o,n))))}),(e=>{const o=t.parts[e.name];r[e.name]=y(e.factory.sketch(Nu(t,e,o[Iu()]),o))}),(e=>{n[e.pname]=mu(!1,((t,o,n)=>e.factory.sketch(Nu(t,e,o,n))))}),(e=>{n[e.pname]=gu(!0,((t,o,n)=>{const r=t[e.name];return z(r,(o=>e.factory.sketch(cn(e.defaults(t,o,n),o,e.overrides(t,o)))))}))}))})),{internals:y(n),externals:y(r)}})(0,t,o),Wu=(e,t,o)=>((e,t,o,n)=>{const r=ce(n,((e,t)=>((e,t)=>{let o=!1;return{name:y(e),required:()=>t.fold(((e,t)=>e),((e,t)=>e)),used:()=>o,replace:()=>{if(o)throw new Error("Trying to use the same placeholder more than once: "+e);return o=!0,t}}})(t,e))),s=((e,t,o,n)=>X(o,(o=>uu(e,t,o,n))))(e,t,o,r);return le(r,(o=>{if(!1===o.used()&&o.required())throw new Error("Placeholder: "+o.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+JSON.stringify(t.components,null,2))})),s})(M.some(e),t,t.components,o),ju=(e,t,o)=>{const n=t.partUids[o];return e.getSystem().getByUid(n).toOptional()},Gu=(e,t,o)=>ju(e,t,o).getOrDie("Could not find part: "+o),$u=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return L(o,(e=>{n[e]=y(s.getByUid(r[e]))})),n},qu=(e,t)=>{const o=e.getSystem();return ce(t.partUids,((e,t)=>y(o.getByUid(e))))},Xu=e=>ae(e.partUids),Ku=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return L(o,(e=>{n[e]=y(s.getByUid(r[e]).getOrDie())})),n},Yu=(e,t)=>{const o=Pu(t);return kr(z(o,(t=>({key:t,value:e+"-"+t}))))},Ju=e=>Gn("partUids","partUids",gn((t=>Yu(t.uid,e))),Mn());var Zu=Object.freeze({__proto__:null,generate:Vu,generateOne:zu,schemas:Lu,names:Pu,substitutes:Uu,components:Wu,defaultUids:Yu,defaultUidsSchema:Ju,getAllParts:qu,getAllPartNames:Xu,getPart:ju,getPartOrDie:Gu,getParts:$u,getPartsOrDie:Ku});const Qu=(e,t,o,n,r)=>{const s=((e,t)=>(e.length>0?[er("parts",e)]:[]).concat([Xn("uid"),ur("dom",{}),ur("components",[]),_i("originalSpec"),ur("debug.sketcher",{})]).concat(t))(n,r);return Un(e+" [SpecSchema]",kn(s.concat(t)),o)},em=(e,t,o,n,r)=>{const s=tm(r),a=Lu(o),i=Ju(o),l=Qu(e,t,s,a,[i]),c=Uu(0,l,o);return n(l,Wu(e,l,c.internals()),s,c.externals())},tm=e=>(e=>ve(e,"uid"))(e)?e:{...e,uid:aa("uid")},om=kn([Xn("name"),Xn("factory"),Xn("configFields"),ur("apis",{}),ur("extraApis",{})]),nm=kn([Xn("name"),Xn("factory"),Xn("configFields"),Xn("partFields"),ur("apis",{}),ur("extraApis",{})]),rm=e=>{const t=Un("Sketcher for "+e.name,om,e),o=ce(t.apis,ha),n=ce(t.extraApis,((e,t)=>ua(e,t)));return{name:t.name,configFields:t.configFields,sketch:e=>((e,t,o,n)=>{const r=tm(n);return o(Qu(e,t,r,[],[]),r)})(t.name,t.configFields,t.factory,e),...o,...n}},sm=e=>{const t=Un("Sketcher for "+e.name,nm,e),o=Vu(t.name,t.partFields),n=ce(t.apis,ha),r=ce(t.extraApis,((e,t)=>ua(e,t)));return{name:t.name,partFields:t.partFields,configFields:t.configFields,sketch:e=>em(t.name,t.configFields,t.partFields,t.factory,e),parts:o,...n,...r}},am=e=>Ge("input")(e)&&"radio"!==xt(e,"type")||Ge("textarea")(e);var im=Object.freeze({__proto__:null,getCurrent:(e,t,o)=>t.find(e)});const lm=[Xn("find")],cm=hl({fields:lm,name:"composing",apis:im}),dm=["input","button","textarea","select"],um=(e,t,o)=>{(t.disabled()?bm:vm)(e,t)},mm=(e,t)=>!0===t.useNative&&R(dm,ze(e.element)),gm=e=>{vt(e.element,"disabled","disabled")},pm=e=>{kt(e.element,"disabled")},hm=e=>{vt(e.element,"aria-disabled","true")},fm=e=>{vt(e.element,"aria-disabled","false")},bm=(e,t,o)=>{t.disableClass.each((t=>{Da(e.element,t)})),(mm(e,t)?gm:hm)(e),t.onDisabled(e)},vm=(e,t,o)=>{t.disableClass.each((t=>{Ba(e.element,t)})),(mm(e,t)?pm:fm)(e),t.onEnabled(e)},ym=(e,t)=>mm(e,t)?(e=>St(e.element,"disabled"))(e):(e=>"true"===xt(e.element,"aria-disabled"))(e);var xm=Object.freeze({__proto__:null,enable:vm,disable:bm,isDisabled:ym,onLoad:um,set:(e,t,o,n)=>{(n?bm:vm)(e,t)}}),wm=Object.freeze({__proto__:null,exhibit:(e,t)=>ya({classes:t.disabled()?t.disableClass.toArray():[]}),events:(e,t)=>As([Ds(ns(),((t,o)=>ym(t,e))),dl(e,t,um)])}),Sm=[br("disabled",_),ur("useNative",!0),nr("disableClass"),wi("onDisabled"),wi("onEnabled")];const km=hl({fields:Sm,name:"disabling",active:wm,apis:xm}),Cm=(e,t,o,n)=>{const r=Nc(e.element,"."+t.highlightClass);L(r,(o=>{N(n,(e=>Xe(e.element,o)))||(Ba(o,t.highlightClass),e.getSystem().getByDom(o).each((o=>{t.onDehighlight(e,o),Cs(o,ks())})))}))},Om=(e,t,o,n)=>{Cm(e,t,0,[n]),_m(e,t,o,n)||(Da(n.element,t.highlightClass),t.onHighlight(e,n),Cs(n,Ss()))},_m=(e,t,o,n)=>Fa(n.element,t.highlightClass),Tm=(e,t,o)=>ri(e.element,"."+t.itemClass).bind((t=>e.getSystem().getByDom(t).toOptional())),Em=(e,t,o)=>{const n=Nc(e.element,"."+t.itemClass);return(n.length>0?M.some(n[n.length-1]):M.none()).bind((t=>e.getSystem().getByDom(t).toOptional()))},Mm=(e,t,o,n)=>{const r=Nc(e.element,"."+t.itemClass);return $(r,(e=>Fa(e,t.highlightClass))).bind((t=>{const o=Hi(t,n,0,r.length-1);return e.getSystem().getByDom(r[o]).toOptional()}))},Am=(e,t,o)=>{const n=Nc(e.element,"."+t.itemClass);return we(z(n,(t=>e.getSystem().getByDom(t).toOptional())))};var Dm=Object.freeze({__proto__:null,dehighlightAll:(e,t,o)=>Cm(e,t,0,[]),dehighlight:(e,t,o,n)=>{_m(e,t,o,n)&&(Ba(n.element,t.highlightClass),t.onDehighlight(e,n),Cs(n,ks()))},highlight:Om,highlightFirst:(e,t,o)=>{Tm(e,t).each((n=>{Om(e,t,o,n)}))},highlightLast:(e,t,o)=>{Em(e,t).each((n=>{Om(e,t,o,n)}))},highlightAt:(e,t,o,n)=>{((e,t,o,n)=>{const r=Nc(e.element,"."+t.itemClass);return M.from(r[n]).fold((()=>Jo.error(new Error("No element found with index "+n))),e.getSystem().getByDom)})(e,t,0,n).fold((e=>{throw e}),(n=>{Om(e,t,o,n)}))},highlightBy:(e,t,o,n)=>{const r=Am(e,t);G(r,n).each((n=>{Om(e,t,o,n)}))},isHighlighted:_m,getHighlighted:(e,t,o)=>ri(e.element,"."+t.highlightClass).bind((t=>e.getSystem().getByDom(t).toOptional())),getFirst:Tm,getLast:Em,getPrevious:(e,t,o)=>Mm(e,t,0,-1),getNext:(e,t,o)=>Mm(e,t,0,1),getCandidates:Am}),Bm=[Xn("highlightClass"),Xn("itemClass"),wi("onHighlight"),wi("onDehighlight")];const Fm=hl({fields:Bm,name:"highlighting",apis:Dm}),Im=[8],Rm=[9],Nm=[13],Vm=[27],Hm=[32],zm=[37],Lm=[38],Pm=[39],Um=[40],Wm=(e,t,o)=>{const n=Y(e.slice(0,t)),r=Y(e.slice(t+1));return G(n.concat(r),o)},jm=(e,t,o)=>{const n=Y(e.slice(0,t));return G(n,o)},Gm=(e,t,o)=>{const n=e.slice(0,t),r=e.slice(t+1);return G(r.concat(n),o)},$m=(e,t,o)=>{const n=e.slice(t+1);return G(n,o)},qm=e=>t=>{const o=t.raw;return R(e,o.which)},Xm=e=>t=>K(e,(e=>e(t))),Km=e=>!0===e.raw.shiftKey,Ym=e=>!0===e.raw.ctrlKey,Jm=k(Km),Zm=(e,t)=>({matches:e,classification:t}),Qm=(e,t,o)=>{t.exists((e=>o.exists((t=>Xe(t,e)))))||Os(e,vs(),{prevFocus:t,newFocus:o})},eg=()=>{const e=e=>Cl(e.element);return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().triggerFocus(o,t.element);const r=e(t);Qm(t,n,r)}}},tg=()=>{const e=e=>Fm.getHighlighted(e).map((e=>e.element));return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().getByDom(o).fold(b,(e=>{Fm.highlight(t,e)}));const r=e(t);Qm(t,n,r)}}};var og;!function(e){e.OnFocusMode="onFocus",e.OnEnterOrSpaceMode="onEnterOrSpace",e.OnApiMode="onApi"}(og||(og={}));const ng=(e,t,o,n,r)=>{const s=(e,t,o,n,r)=>{return(s=o(e,t,n,r),a=t.event,G(s,(e=>e.matches(a))).map((e=>e.classification))).bind((o=>o(e,t,n,r)));var s,a},a={schema:()=>e.concat([ur("focusManager",eg()),mr("focusInside","onFocus",Hn((e=>R(["onFocus","onEnterOrSpace","onApi"],e)?Jo.value(e):Jo.error("Invalid value for focusInside")))),Oi("handler",a),Oi("state",t),Oi("sendFocusIn",r)]),processKey:s,toEvents:(e,t)=>{const a=e.focusInside!==og.OnFocusMode?M.none():r(e).map((o=>Fs(Qr(),((n,r)=>{o(n,e,t),r.stop()})))),i=[Fs(Ur(),((n,a)=>{s(n,a,o,e,t).fold((()=>{((o,n)=>{const s=qm(Hm.concat(Nm))(n.event);e.focusInside===og.OnEnterOrSpaceMode&&s&&Tr(o,n)&&r(e).each((r=>{r(o,e,t),n.stop()}))})(n,a)}),(e=>{a.stop()}))})),Fs(Wr(),((o,r)=>{s(o,r,n,e,t).each((e=>{r.stop()}))}))];return As(a.toArray().concat(i))}};return a},rg=e=>{const t=[nr("onEscape"),nr("onEnter"),ur("selector",'[data-alloy-tabstop="true"]:not(:disabled)'),ur("firstTabstop",0),ur("useTabstopAt",T),nr("visibilitySelector")].concat([e]),o=(e,t)=>{const o=e.visibilitySelector.bind((e=>si(t,e))).getOr(t);return Ht(o)>0},n=(e,t,n)=>{((e,t)=>{const n=Nc(e.element,t.selector),r=U(n,(e=>o(t,e)));return M.from(r[t.firstTabstop])})(e,t).each((o=>{t.focusManager.set(e,o)}))},r=(e,t,n,r)=>{const s=Nc(e.element,n.selector);return((e,t)=>t.focusManager.get(e).bind((e=>si(e,t.selector))))(e,n).bind((t=>$(s,S(Xe,t)).bind((t=>((e,t,n,r,s)=>s(t,n,(e=>((e,t)=>o(e,t)&&e.useTabstopAt(t))(r,e))).fold((()=>r.cyclic?M.some(!0):M.none()),(t=>(r.focusManager.set(e,t),M.some(!0)))))(e,s,t,n,r)))))},s=y([Zm(Xm([Km,qm(Rm)]),((e,t,o)=>{const n=o.cyclic?Wm:jm;return r(e,0,o,n)})),Zm(qm(Rm),((e,t,o)=>{const n=o.cyclic?Gm:$m;return r(e,0,o,n)})),Zm(Xm([Jm,qm(Nm)]),((e,t,o)=>o.onEnter.bind((o=>o(e,t)))))]),a=y([Zm(qm(Vm),((e,t,o)=>o.onEscape.bind((o=>o(e,t)))))]);return ng(t,fa.init,s,a,(()=>M.some(n)))};var sg=rg($n("cyclic",_)),ag=rg($n("cyclic",T));const ig=(e,t,o)=>am(o)&&qm(Hm)(t.event)?M.none():((e,t,o)=>(Ts(e,o,ns()),M.some(!0)))(e,0,o),lg=(e,t)=>M.some(!0),cg=[ur("execute",ig),ur("useSpace",!1),ur("useEnter",!0),ur("useControlEnter",!1),ur("useDown",!1)],dg=(e,t,o)=>o.execute(e,t,e.element);var ug=ng(cg,fa.init,((e,t,o,n)=>{const r=o.useSpace&&!am(e.element)?Hm:[],s=o.useEnter?Nm:[],a=o.useDown?Um:[],i=r.concat(s).concat(a);return[Zm(qm(i),dg)].concat(o.useControlEnter?[Zm(Xm([Ym,qm(Nm)]),dg)]:[])}),((e,t,o,n)=>o.useSpace&&!am(e.element)?[Zm(qm(Hm),lg)]:[]),(()=>M.none()));const mg=()=>{const e=Ul();return ba({readState:()=>e.get().map((e=>({numRows:String(e.numRows),numColumns:String(e.numColumns)}))).getOr({numRows:"?",numColumns:"?"}),setGridSize:(t,o)=>{e.set({numRows:t,numColumns:o})},getNumRows:()=>e.get().map((e=>e.numRows)),getNumColumns:()=>e.get().map((e=>e.numColumns))})};var gg=Object.freeze({__proto__:null,flatgrid:mg,init:e=>e.state(e)});const pg=e=>(t,o,n,r)=>{const s=e(t.element);return vg(s,t,o,n,r)},hg=(e,t)=>{const o=sc(e,t);return pg(o)},fg=(e,t)=>{const o=sc(t,e);return pg(o)},bg=e=>(t,o,n,r)=>vg(e,t,o,n,r),vg=(e,t,o,n,r)=>n.focusManager.get(t).bind((o=>e(t.element,o,n,r))).map((e=>(n.focusManager.set(t,e),!0))),yg=bg,xg=bg,wg=bg,Sg=e=>!(e=>e.offsetWidth<=0&&e.offsetHeight<=0)(e.dom),kg=(e,t,o)=>{const n=Nc(e,o);return((e,o)=>$(e,(e=>Xe(e,t))).map((t=>({index:t,candidates:e}))))(U(n,Sg))},Cg=(e,t)=>$(e,(e=>Xe(t,e))),Og=(e,t,o,n)=>n(Math.floor(t/o),t%o).bind((t=>{const n=t.row*o+t.column;return n>=0&&n<e.length?M.some(e[n]):M.none()})),_g=(e,t,o,n,r)=>Og(e,t,n,((t,s)=>{const a=t===o-1?e.length-t*n:n,i=Hi(s,r,0,a-1);return M.some({row:t,column:i})})),Tg=(e,t,o,n,r)=>Og(e,t,n,((t,s)=>{const a=Hi(t,r,0,o-1),i=a===o-1?e.length-a*n:n,l=zi(s,0,i-1);return M.some({row:a,column:l})})),Eg=[Xn("selector"),ur("execute",ig),Si("onEscape"),ur("captureTab",!1),Ti()],Mg=(e,t,o)=>{ri(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},Ag=e=>(t,o,n,r)=>kg(t,o,n.selector).bind((t=>e(t.candidates,t.index,r.getNumRows().getOr(n.initSize.numRows),r.getNumColumns().getOr(n.initSize.numColumns)))),Dg=(e,t,o)=>o.captureTab?M.some(!0):M.none(),Bg=Ag(((e,t,o,n)=>_g(e,t,o,n,-1))),Fg=Ag(((e,t,o,n)=>_g(e,t,o,n,1))),Ig=Ag(((e,t,o,n)=>Tg(e,t,o,n,-1))),Rg=Ag(((e,t,o,n)=>Tg(e,t,o,n,1))),Ng=y([Zm(qm(zm),hg(Bg,Fg)),Zm(qm(Pm),fg(Bg,Fg)),Zm(qm(Lm),yg(Ig)),Zm(qm(Um),xg(Rg)),Zm(Xm([Km,qm(Rm)]),Dg),Zm(Xm([Jm,qm(Rm)]),Dg),Zm(qm(Hm.concat(Nm)),((e,t,o,n)=>((e,t)=>t.focusManager.get(e).bind((e=>si(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n)))))]),Vg=y([Zm(qm(Vm),((e,t,o)=>o.onEscape(e,t))),Zm(qm(Hm),lg)]);var Hg=ng(Eg,mg,Ng,Vg,(()=>M.some(Mg)));const zg=(e,t,o,n)=>{const r=(e,t,o)=>{const s=Hi(t,n,0,o.length-1);return s===e?M.none():(a=o[s],"button"===ze(a)&&"disabled"===xt(a,"disabled")?r(e,s,o):M.from(o[s]));var a};return kg(e,o,t).bind((e=>{const t=e.index,o=e.candidates;return r(t,t,o)}))},Lg=[Xn("selector"),ur("getInitial",M.none),ur("execute",ig),Si("onEscape"),ur("executeOnMove",!1),ur("allowVertical",!0)],Pg=(e,t,o)=>((e,t)=>t.focusManager.get(e).bind((e=>si(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n))),Ug=(e,t,o)=>{t.getInitial(e).orThunk((()=>ri(e.element,t.selector))).each((o=>{t.focusManager.set(e,o)}))},Wg=(e,t,o)=>zg(e,o.selector,t,-1),jg=(e,t,o)=>zg(e,o.selector,t,1),Gg=e=>(t,o,n,r)=>e(t,o,n,r).bind((()=>n.executeOnMove?Pg(t,o,n):M.some(!0))),$g=y([Zm(qm(Hm),lg),Zm(qm(Vm),((e,t,o)=>o.onEscape(e,t)))]);var qg=ng(Lg,fa.init,((e,t,o,n)=>{const r=zm.concat(o.allowVertical?Lm:[]),s=Pm.concat(o.allowVertical?Um:[]);return[Zm(qm(r),Gg(hg(Wg,jg))),Zm(qm(s),Gg(fg(Wg,jg))),Zm(qm(Nm),Pg),Zm(qm(Hm),Pg)]}),$g,(()=>M.some(Ug)));const Xg=(e,t,o)=>M.from(e[t]).bind((e=>M.from(e[o]).map((e=>({rowIndex:t,columnIndex:o,cell:e}))))),Kg=(e,t,o,n)=>{const r=e[t].length,s=Hi(o,n,0,r-1);return Xg(e,t,s)},Yg=(e,t,o,n)=>{const r=Hi(o,n,0,e.length-1),s=e[r].length,a=zi(t,0,s-1);return Xg(e,r,a)},Jg=(e,t,o,n)=>{const r=e[t].length,s=zi(o+n,0,r-1);return Xg(e,t,s)},Zg=(e,t,o,n)=>{const r=zi(o+n,0,e.length-1),s=e[r].length,a=zi(t,0,s-1);return Xg(e,r,a)},Qg=[er("selectors",[Xn("row"),Xn("cell")]),ur("cycles",!0),ur("previousSelector",M.none),ur("execute",ig)],ep=(e,t,o)=>{t.previousSelector(e).orThunk((()=>{const o=t.selectors;return ri(e.element,o.cell)})).each((o=>{t.focusManager.set(e,o)}))},tp=(e,t)=>(o,n,r)=>{const s=r.cycles?e:t;return si(n,r.selectors.row).bind((e=>{const t=Nc(e,r.selectors.cell);return Cg(t,n).bind((t=>{const n=Nc(o,r.selectors.row);return Cg(n,e).bind((e=>{const o=((e,t)=>z(e,(e=>Nc(e,t.selectors.cell))))(n,r);return s(o,e,t).map((e=>e.cell))}))}))}))},op=tp(((e,t,o)=>Kg(e,t,o,-1)),((e,t,o)=>Jg(e,t,o,-1))),np=tp(((e,t,o)=>Kg(e,t,o,1)),((e,t,o)=>Jg(e,t,o,1))),rp=tp(((e,t,o)=>Yg(e,o,t,-1)),((e,t,o)=>Zg(e,o,t,-1))),sp=tp(((e,t,o)=>Yg(e,o,t,1)),((e,t,o)=>Zg(e,o,t,1))),ap=y([Zm(qm(zm),hg(op,np)),Zm(qm(Pm),fg(op,np)),Zm(qm(Lm),yg(rp)),Zm(qm(Um),xg(sp)),Zm(qm(Hm.concat(Nm)),((e,t,o)=>Cl(e.element).bind((n=>o.execute(e,t,n)))))]),ip=y([Zm(qm(Hm),lg)]);var lp=ng(Qg,fa.init,ap,ip,(()=>M.some(ep)));const cp=[Xn("selector"),ur("execute",ig),ur("moveOnTab",!1)],dp=(e,t,o)=>o.focusManager.get(e).bind((n=>o.execute(e,t,n))),up=(e,t,o)=>{ri(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},mp=(e,t,o)=>zg(e,o.selector,t,-1),gp=(e,t,o)=>zg(e,o.selector,t,1),pp=y([Zm(qm(Lm),wg(mp)),Zm(qm(Um),wg(gp)),Zm(Xm([Km,qm(Rm)]),((e,t,o,n)=>o.moveOnTab?wg(mp)(e,t,o,n):M.none())),Zm(Xm([Jm,qm(Rm)]),((e,t,o,n)=>o.moveOnTab?wg(gp)(e,t,o,n):M.none())),Zm(qm(Nm),dp),Zm(qm(Hm),dp)]),hp=y([Zm(qm(Hm),lg)]);var fp=ng(cp,fa.init,pp,hp,(()=>M.some(up)));const bp=[Si("onSpace"),Si("onEnter"),Si("onShiftEnter"),Si("onLeft"),Si("onRight"),Si("onTab"),Si("onShiftTab"),Si("onUp"),Si("onDown"),Si("onEscape"),ur("stopSpaceKeyup",!1),nr("focusIn")];var vp=ng(bp,fa.init,((e,t,o)=>[Zm(qm(Hm),o.onSpace),Zm(Xm([Jm,qm(Nm)]),o.onEnter),Zm(Xm([Km,qm(Nm)]),o.onShiftEnter),Zm(Xm([Km,qm(Rm)]),o.onShiftTab),Zm(Xm([Jm,qm(Rm)]),o.onTab),Zm(qm(Lm),o.onUp),Zm(qm(Um),o.onDown),Zm(qm(zm),o.onLeft),Zm(qm(Pm),o.onRight),Zm(qm(Hm),o.onSpace)]),((e,t,o)=>[...o.stopSpaceKeyup?[Zm(qm(Hm),lg)]:[],Zm(qm(Vm),o.onEscape)]),(e=>e.focusIn));const yp=sg.schema(),xp=ag.schema(),wp=qg.schema(),Sp=Hg.schema(),kp=lp.schema(),Cp=ug.schema(),Op=fp.schema(),_p=vp.schema(),Tp=bl({branchKey:"mode",branches:Object.freeze({__proto__:null,acyclic:yp,cyclic:xp,flow:wp,flatgrid:Sp,matrix:kp,execution:Cp,menu:Op,special:_p}),name:"keying",active:{events:(e,t)=>e.handler.toEvents(e,t)},apis:{focusIn:(e,t,o)=>{t.sendFocusIn(t).fold((()=>{e.getSystem().triggerFocus(e.element,e.element)}),(n=>{n(e,t,o)}))},setGridSize:(e,t,o,n,r)=>{(e=>ye(e,"setGridSize"))(o)?o.setGridSize(n,r):console.error("Layout does not support setGridSize")}},state:gg}),Ep=(e,t)=>{Ol((()=>{((e,t,o)=>{const n=e.components();(e=>{L(e.components(),(e=>No(e.element))),Ro(e.element),e.syncComponents()})(e);const r=o(t),s=J(n,r);L(s,(t=>{gd(t),e.getSystem().removeFromWorld(t)})),L(r,(t=>{md(t)?bd(e,t):(e.getSystem().addToWorld(t),bd(e,t),pt(e.element)&&pd(t))})),e.syncComponents()})(e,t,(()=>z(t,e.getSystem().build)))}),e.element)},Mp=(e,t)=>{Ol((()=>{((o,n,r)=>{const s=o.components(),a=X(n,(e=>pa(e).toArray()));L(s,(e=>{R(a,e)||fd(e)}));const i=((e,t,o)=>za(e,t,((t,n)=>La(e,n,t,o))))(e.element,t,e.getSystem().buildOrPatch),l=J(s,i);L(l,(e=>{md(e)&&fd(e)})),L(i,(e=>{md(e)||hd(o,e)})),o.syncComponents()})(e,t)}),e.element)},Ap=(e,t,o,n)=>{fd(t);const r=La(e.element,o,n,e.getSystem().buildOrPatch);hd(e,r),e.syncComponents()},Dp=(e,t,o)=>{const n=e.getSystem().build(o);yd(e,n,t)},Bp=(e,t,o,n)=>{wd(t),Dp(e,((e,t)=>((e,t,o)=>{rt(e,o).fold((()=>{Fo(e,t)}),(e=>{Ao(e,t)}))})(e,t,o)),n)},Fp=(e,t)=>e.components(),Ip=(e,t,o,n,r)=>{const s=Fp(e);return M.from(s[n]).map((o=>(r.fold((()=>wd(o)),(r=>{(t.reuseDom?Ap:Bp)(e,o,n,r)})),o)))};var Rp=Object.freeze({__proto__:null,append:(e,t,o,n)=>{Dp(e,Fo,n)},prepend:(e,t,o,n)=>{Dp(e,Bo,n)},remove:(e,t,o,n)=>{const r=Fp(e),s=G(r,(e=>Xe(n.element,e.element)));s.each(wd)},replaceAt:Ip,replaceBy:(e,t,o,n,r)=>{const s=Fp(e);return $(s,n).bind((o=>Ip(e,t,0,o,r)))},set:(e,t,o,n)=>(t.reuseDom?Mp:Ep)(e,n),contents:Fp});const Np=hl({fields:[fr("reuseDom",!0)],name:"replacing",apis:Rp}),Vp=(e,t)=>{const o=((e,t)=>{const o=As(t);return hl({fields:[Xn("enabled")],name:e,active:{events:y(o)}})})(e,t);return{key:e,value:{config:{},me:o,configAsRaw:y({}),initialConfig:{},state:fa}}},Hp=(e,t)=>{t.ignore||(wl(e.element),t.onFocus(e))};var zp=Object.freeze({__proto__:null,focus:Hp,blur:(e,t)=>{t.ignore||(e=>{e.dom.blur()})(e.element)},isFocused:e=>Sl(e.element)}),Lp=Object.freeze({__proto__:null,exhibit:(e,t)=>{const o=t.ignore?{}:{attributes:{tabindex:"-1"}};return ya(o)},events:e=>As([Fs(Qr(),((t,o)=>{Hp(t,e),o.stop()}))].concat(e.stopMousedown?[Fs(Rr(),((e,t)=>{t.event.prevent()}))]:[]))}),Pp=[wi("onFocus"),ur("stopMousedown",!1),ur("ignore",!1)];const Up=hl({fields:Pp,name:"focusing",active:Lp,apis:zp}),Wp=(e,t,o,n)=>{const r=o.get();o.set(n),((e,t,o)=>{t.toggleClass.each((t=>{o.get()?Da(e.element,t):Ba(e.element,t)}))})(e,t,o),((e,t,o)=>{const n=t.aria;n.update(e,n,o.get())})(e,t,o),r!==n&&t.onToggled(e,n)},jp=(e,t,o)=>{Wp(e,t,o,!o.get())},Gp=(e,t,o)=>{Wp(e,t,o,t.selected)};var $p=Object.freeze({__proto__:null,onLoad:Gp,toggle:jp,isOn:(e,t,o)=>o.get(),on:(e,t,o)=>{Wp(e,t,o,!0)},off:(e,t,o)=>{Wp(e,t,o,!1)},set:Wp}),qp=Object.freeze({__proto__:null,exhibit:()=>ya({}),events:(e,t)=>{const o=(n=e,r=t,s=jp,js((e=>{s(e,n,r)})));var n,r,s;const a=dl(e,t,Gp);return As(q([e.toggleOnExecute?[o]:[],[a]]))}});const Xp=(e,t,o)=>{vt(e.element,"aria-expanded",o)};var Kp=[ur("selected",!1),nr("toggleClass"),ur("toggleOnExecute",!0),wi("onToggled"),mr("aria",{mode:"none"},jn("mode",{pressed:[ur("syncWithExpanded",!1),Oi("update",((e,t,o)=>{vt(e.element,"aria-pressed",o),t.syncWithExpanded&&Xp(e,0,o)}))],checked:[Oi("update",((e,t,o)=>{vt(e.element,"aria-checked",o)}))],expanded:[Oi("update",Xp)],selected:[Oi("update",((e,t,o)=>{vt(e.element,"aria-selected",o)}))],none:[Oi("update",b)]}))];const Yp=hl({fields:Kp,name:"toggling",active:qp,apis:$p,state:(!1,{init:()=>{const e=xr(false);return{get:()=>e.get(),set:t=>e.set(t),clear:()=>e.set(false),readState:()=>e.get()}}})});const Jp=()=>{const e=(e,t)=>{t.stop(),_s(e)};return[Fs($r(),e),Fs(ss(),e),Hs(Dr()),Hs(Rr())]},Zp=e=>As(q([e.map((e=>js(((t,o)=>{e(t),o.stop()})))).toArray(),Jp()])),Qp="alloy.item-hover",eh="alloy.item-focus",th="alloy.item-toggled",oh=e=>{(Cl(e.element).isNone()||Up.isFocused(e))&&(Up.isFocused(e)||Up.focus(e),Os(e,Qp,{item:e}))},nh=e=>{Os(e,eh,{item:e})},rh=y(Qp),sh=y(eh),ah=y(th),ih=e=>e.toggling.map((e=>e.exclusive?"menuitemradio":"menuitemcheckbox")).getOr("menuitem"),lh=[Xn("data"),Xn("components"),Xn("dom"),ur("hasSubmenu",!1),nr("toggling"),au("itemBehaviours",[Yp,Up,Tp,ou]),ur("ignoreFocus",!1),ur("domModification",{}),Oi("builder",(e=>({dom:e.dom,domModification:{...e.domModification,attributes:{role:ih(e),...e.domModification.attributes,"aria-haspopup":e.hasSubmenu,...e.hasSubmenu?{"aria-expanded":!1}:{}}},behaviours:iu(e.itemBehaviours,[e.toggling.fold(Yp.revoke,(e=>Yp.config((e=>({aria:{mode:"checked"},...ge(e,((e,t)=>"exclusive"!==t)),onToggled:(t,o)=>{p(e.onToggled)&&e.onToggled(t,o),((e,t)=>{Os(e,th,{item:e,state:t})})(t,o)}}))(e)))),Up.config({ignore:e.ignoreFocus,stopMousedown:e.ignoreFocus,onFocus:e=>{nh(e)}}),Tp.config({mode:"execution"}),ou.config({store:{mode:"memory",initialValue:e.data}}),Vp("item-type-events",[...Jp(),Fs(zr(),oh),Fs(rs(),Up.focus)])]),components:e.components,eventOrder:e.eventOrder}))),ur("eventOrder",{})],ch=[Xn("dom"),Xn("components"),Oi("builder",(e=>({dom:e.dom,components:e.components,events:As([zs(rs())])})))],dh=y("item-widget"),uh=y([Au({name:"widget",overrides:e=>({behaviours:gl([ou.config({store:{mode:"manual",getValue:t=>e.data,setValue:b}})])})})]),mh=[Xn("uid"),Xn("data"),Xn("components"),Xn("dom"),ur("autofocus",!1),ur("ignoreFocus",!1),au("widgetBehaviours",[ou,Up,Tp]),ur("domModification",{}),Ju(uh()),Oi("builder",(e=>{const t=Uu(dh(),e,uh()),o=Wu(dh(),e,t.internals()),n=t=>ju(t,e,"widget").map((e=>(Tp.focusIn(e),e))),r=(t,o)=>am(o.event.target)?M.none():e.autofocus?(o.setSource(t.element),M.none()):M.none();return{dom:e.dom,components:o,domModification:e.domModification,events:As([js(((e,t)=>{n(e).each((e=>{t.stop()}))})),Fs(zr(),oh),Fs(rs(),((t,o)=>{e.autofocus?n(t):Up.focus(t)}))]),behaviours:iu(e.widgetBehaviours,[ou.config({store:{mode:"memory",initialValue:e.data}}),Up.config({ignore:e.ignoreFocus,onFocus:e=>{nh(e)}}),Tp.config({mode:"special",focusIn:e.autofocus?e=>{n(e)}:vl(),onLeft:r,onRight:r,onEscape:(t,o)=>Up.isFocused(t)||e.autofocus?e.autofocus?(o.setSource(t.element),M.none()):M.none():(Up.focus(t),M.some(!0))})])}}))],gh=jn("type",{widget:mh,item:lh,separator:ch}),ph=y([Fu({factory:{sketch:e=>{const t=Un("menu.spec item",gh,e);return t.builder(t)}},name:"items",unit:"item",defaults:(e,t)=>ve(t,"uid")?t:{...t,uid:aa("item")},overrides:(e,t)=>({type:t.type,ignoreFocus:e.fakeFocus,domModification:{classes:[e.markers.item]}})})]),hh=y([Xn("value"),Xn("items"),Xn("dom"),Xn("components"),ur("eventOrder",{}),nu("menuBehaviours",[Fm,ou,cm,Tp]),mr("movement",{mode:"menu",moveOnTab:!0},jn("mode",{grid:[Ti(),Oi("config",((e,t)=>({mode:"flatgrid",selector:"."+e.markers.item,initSize:{numColumns:t.initSize.numColumns,numRows:t.initSize.numRows},focusManager:e.focusManager})))],matrix:[Oi("config",((e,t)=>({mode:"matrix",selectors:{row:t.rowSelector,cell:"."+e.markers.item},previousSelector:t.previousSelector,focusManager:e.focusManager}))),Xn("rowSelector"),ur("previousSelector",M.none)],menu:[ur("moveOnTab",!0),Oi("config",((e,t)=>({mode:"menu",selector:"."+e.markers.item,moveOnTab:t.moveOnTab,focusManager:e.focusManager})))]})),Kn("markers",fi()),ur("fakeFocus",!1),ur("focusManager",eg()),wi("onHighlight"),wi("onDehighlight")]),fh=y("alloy.menu-focus"),bh=sm({name:"Menu",configFields:hh(),partFields:ph(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,markers:e.markers,behaviours:su(e.menuBehaviours,[Fm.config({highlightClass:e.markers.selectedItem,itemClass:e.markers.item,onHighlight:e.onHighlight,onDehighlight:e.onDehighlight}),ou.config({store:{mode:"memory",initialValue:e.value}}),cm.config({find:M.some}),Tp.config(e.movement.config(e,e.movement))]),events:As([Fs(sh(),((e,t)=>{const o=t.event;e.getSystem().getByDom(o.target).each((o=>{Fm.highlight(e,o),t.stop(),Os(e,fh(),{menu:e,item:o})}))})),Fs(rh(),((e,t)=>{const o=t.event.item;Fm.highlight(e,o)})),Fs(ah(),((e,t)=>{const{item:o,state:n}=t.event;n&&"menuitemradio"===xt(o.element,"role")&&((e,t)=>{const o=Nc(e.element,'[role="menuitemradio"][aria-checked="true"]');L(o,(o=>{Xe(o,t.element)||e.getSystem().getByDom(o).each((e=>{Yp.off(e)}))}))})(e,o)}))]),components:t,eventOrder:e.eventOrder,domModification:{attributes:{role:"menu"}}})}),vh=(e,t,o,n)=>be(o,n).bind((n=>be(e,n).bind((n=>{const r=vh(e,t,o,n);return M.some([n].concat(r))})))).getOr([]),yh=e=>"prepared"===e.type?M.some(e.menu):M.none(),xh=()=>{const e=xr({}),t=xr({}),o=xr({}),n=Ul(),r=xr({}),s=e=>a(e).bind(yh),a=e=>be(t.get(),e),i=t=>be(e.get(),t);return{setMenuBuilt:(e,o)=>{t.set({...t.get(),[e]:{type:"prepared",menu:o}})},setContents:(s,a,i,l)=>{n.set(s),e.set(i),t.set(a),r.set(l);const c=((e,t)=>{const o={};le(e,((e,t)=>{L(e,(e=>{o[e]=t}))}));const n=t,r=de(t,((e,t)=>({k:e,v:t}))),s=ce(r,((e,t)=>[t].concat(vh(o,n,r,t))));return ce(o,(e=>be(s,e).getOr([e])))})(l,i);o.set(c)},expand:t=>be(e.get(),t).map((e=>{const n=be(o.get(),t).getOr([]);return[e].concat(n)})),refresh:e=>be(o.get(),e),collapse:e=>be(o.get(),e).bind((e=>e.length>1?M.some(e.slice(1)):M.none())),lookupMenu:a,lookupItem:i,otherMenus:e=>{const t=r.get();return J(ae(t),e)},getPrimary:()=>n.get().bind(s),getMenus:()=>t.get(),clear:()=>{e.set({}),t.set({}),o.set({}),n.clear()},isClear:()=>n.get().isNone(),getTriggeringPath:(t,r)=>{const a=U(i(t).toArray(),(e=>s(e).isSome()));return be(o.get(),t).bind((t=>{const o=Y(a.concat(t));return(e=>{const t=[];for(let o=0;o<e.length;o++){const n=e[o];if(!n.isSome())return M.none();t.push(n.getOrDie())}return M.some(t)})(X(o,((t,a)=>((t,o,n)=>s(t).bind((r=>(t=>he(e.get(),((e,o)=>e===t)))(t).bind((e=>o(e).map((e=>({triggeredMenu:r,triggeringItem:e,triggeringPath:n}))))))))(t,r,o.slice(0,a+1)).fold((()=>xe(n.get(),t)?[]:[M.none()]),(e=>[M.some(e)])))))}))}}},wh=yh,Sh=Qs("tiered-menu-item-highlight"),kh=Qs("tiered-menu-item-dehighlight");var Ch;!function(e){e[e.HighlightMenuAndItem=0]="HighlightMenuAndItem",e[e.HighlightJustMenu=1]="HighlightJustMenu",e[e.HighlightNone=2]="HighlightNone"}(Ch||(Ch={}));const Oh=y("collapse-item"),_h=rm({name:"TieredMenu",configFields:[Ci("onExecute"),Ci("onEscape"),ki("onOpenMenu"),ki("onOpenSubmenu"),wi("onRepositionMenu"),wi("onCollapseMenu"),ur("highlightOnOpen",Ch.HighlightMenuAndItem),er("data",[Xn("primary"),Xn("menus"),Xn("expansions")]),ur("fakeFocus",!1),wi("onHighlightItem"),wi("onDehighlightItem"),wi("onHover"),vi(),Xn("dom"),ur("navigateOnHover",!0),ur("stayInDom",!1),nu("tmenuBehaviours",[Tp,Fm,cm,Np]),ur("eventOrder",{})],apis:{collapseMenu:(e,t)=>{e.collapseMenu(t)},highlightPrimary:(e,t)=>{e.highlightPrimary(t)},repositionMenus:(e,t)=>{e.repositionMenus(t)}},factory:(e,t)=>{const o=Ul(),n=xh(),r=e=>ou.getValue(e).value,s=t=>ce(e.data.menus,((e,t)=>X(e.items,(e=>"separator"===e.type?[]:[e.data.value])))),a=Fm.highlight,i=(t,o)=>{a(t,o),Fm.getHighlighted(o).orThunk((()=>Fm.getFirst(o))).each((n=>{e.fakeFocus?Fm.highlight(o,n):Ts(t,n.element,rs())}))},l=(e,t)=>we(z(t,(t=>e.lookupMenu(t).bind((e=>"prepared"===e.type?M.some(e.menu):M.none()))))),c=(t,o,n)=>{const r=l(o,o.otherMenus(n));L(r,(o=>{Ra(o.element,[e.markers.backgroundMenu]),e.stayInDom||Np.remove(t,o)}))},d=(t,n)=>{const s=(t=>o.get().getOrThunk((()=>{const n={},s=Nc(t.element,`.${e.markers.item}`),a=U(s,(e=>"true"===xt(e,"aria-haspopup")));return L(a,(e=>{t.getSystem().getByDom(e).each((e=>{const t=r(e);n[t]=e}))})),o.set(n),n})))(t);le(s,((e,t)=>{const o=R(n,t);vt(e.element,"aria-expanded",o)}))},u=(t,o,n)=>M.from(n[0]).bind((r=>o.lookupMenu(r).bind((r=>{if("notbuilt"===r.type)return M.none();{const s=r.menu,a=l(o,n.slice(1));return L(a,(t=>{Da(t.element,e.markers.backgroundMenu)})),pt(s.element)||Np.append(t,Ya(s)),Ra(s.element,[e.markers.backgroundMenu]),i(t,s),c(t,o,n),M.some(s)}}))));let m;!function(e){e[e.HighlightSubmenu=0]="HighlightSubmenu",e[e.HighlightParent=1]="HighlightParent"}(m||(m={}));const g=(t,o,s=m.HighlightSubmenu)=>{if(o.hasConfigured(km)&&km.isDisabled(o))return M.some(o);{const a=r(o);return n.expand(a).bind((r=>(d(t,r),M.from(r[0]).bind((a=>n.lookupMenu(a).bind((i=>{const l=((e,t,o)=>{if("notbuilt"===o.type){const r=e.getSystem().build(o.nbMenu());return n.setMenuBuilt(t,r),r}return o.menu})(t,a,i);return pt(l.element)||Np.append(t,Ya(l)),e.onOpenSubmenu(t,o,l,Y(r)),s===m.HighlightSubmenu?(Fm.highlightFirst(l),u(t,n,r)):(Fm.dehighlightAll(l),M.some(o))})))))))}},p=(t,o)=>{const s=r(o);return n.collapse(s).bind((r=>(d(t,r),u(t,n,r).map((n=>(e.onCollapseMenu(t,o,n),n))))))},h=t=>(o,n)=>si(n.getSource(),`.${e.markers.item}`).bind((e=>o.getSystem().getByDom(e).toOptional().bind((e=>t(o,e).map(T))))),f=As([Fs(fh(),((e,t)=>{const o=t.event.item;n.lookupItem(r(o)).each((()=>{const o=t.event.menu;Fm.highlight(e,o);const s=r(t.event.item);n.refresh(s).each((t=>c(e,n,t)))}))})),js(((t,o)=>{const n=o.event.target;t.getSystem().getByDom(n).each((o=>{0===r(o).indexOf("collapse-item")&&p(t,o),g(t,o,m.HighlightSubmenu).fold((()=>{e.onExecute(t,o)}),b)}))})),Ps(((t,o)=>{(t=>{const o=((t,o,n)=>ce(n,((n,r)=>{const s=()=>bh.sketch({...n,value:r,markers:e.markers,fakeFocus:e.fakeFocus,onHighlight:(e,t)=>{Os(e,Sh,{menuComp:e,itemComp:t})},onDehighlight:(e,t)=>{Os(e,kh,{menuComp:e,itemComp:t})},focusManager:e.fakeFocus?tg():eg()});return r===o?{type:"prepared",menu:t.getSystem().build(s())}:{type:"notbuilt",nbMenu:s}})))(t,e.data.primary,e.data.menus),r=s();return n.setContents(e.data.primary,o,e.data.expansions,r),n.getPrimary()})(t).each((o=>{Np.append(t,Ya(o)),e.onOpenMenu(t,o),e.highlightOnOpen===Ch.HighlightMenuAndItem?i(t,o):e.highlightOnOpen===Ch.HighlightJustMenu&&a(t,o)}))})),Fs(Sh,((t,o)=>{e.onHighlightItem(t,o.event.menuComp,o.event.itemComp)})),Fs(kh,((t,o)=>{e.onDehighlightItem(t,o.event.menuComp,o.event.itemComp)})),...e.navigateOnHover?[Fs(rh(),((t,o)=>{const s=o.event.item;((e,t)=>{const o=r(t);n.refresh(o).bind((t=>(d(e,t),u(e,n,t))))})(t,s),g(t,s,m.HighlightParent),e.onHover(t,s)}))]:[]]),v=e=>Fm.getHighlighted(e).bind(Fm.getHighlighted),y={collapseMenu:e=>{v(e).each((t=>{p(e,t)}))},highlightPrimary:e=>{n.getPrimary().each((t=>{i(e,t)}))},repositionMenus:t=>{const o=n.getPrimary().bind((e=>v(t).bind((e=>{const t=r(e),o=fe(n.getMenus()),s=we(z(o,wh));return n.getTriggeringPath(t,(e=>((e,t,o)=>se(t,(e=>{if(!e.getSystem().isConnected())return M.none();const t=Fm.getCandidates(e);return G(t,(e=>r(e)===o))})))(0,s,e)))})).map((t=>({primary:e,triggeringPath:t})))));o.fold((()=>{(e=>M.from(e.components()[0]).filter((e=>"menu"===xt(e.element,"role"))))(t).each((o=>{e.onRepositionMenu(t,o,[])}))}),(({primary:o,triggeringPath:n})=>{e.onRepositionMenu(t,o,n)}))}};return{uid:e.uid,dom:e.dom,markers:e.markers,behaviours:su(e.tmenuBehaviours,[Tp.config({mode:"special",onRight:h(((e,t)=>am(t.element)?M.none():g(e,t,m.HighlightSubmenu))),onLeft:h(((e,t)=>am(t.element)?M.none():p(e,t))),onEscape:h(((t,o)=>p(t,o).orThunk((()=>e.onEscape(t,o).map((()=>t)))))),focusIn:(e,t)=>{n.getPrimary().each((t=>{Ts(e,t.element,rs())}))}}),Fm.config({highlightClass:e.markers.selectedMenu,itemClass:e.markers.menu}),cm.config({find:e=>Fm.getHighlighted(e)}),Np.config({})]),eventOrder:e.eventOrder,apis:y,events:f}},extraApis:{tieredData:(e,t,o)=>({primary:e,menus:t,expansions:o}),singleData:(e,t)=>({primary:e,menus:Sr(e,t),expansions:{}}),collapseItem:e=>({value:Qs(Oh()),meta:{text:e}})}}),Th=rm({name:"InlineView",configFields:[Xn("lazySink"),wi("onShow"),wi("onHide"),lr("onEscape"),nu("inlineBehaviours",[Nd,ou,yl]),dr("fireDismissalEventInstead",[ur("event",fs())]),dr("fireRepositionEventInstead",[ur("event",bs())]),ur("getRelated",M.none),ur("isExtraPart",_),ur("eventOrder",M.none)],factory:(e,t)=>{const o=(e,t,o,r)=>{n(e,t,o,(()=>r.map((e=>$o(e)))))},n=(t,o,n,r)=>{const s=e.lazySink(t).getOrDie();Nd.openWhileCloaked(t,o,(()=>ud.positionWithinBounds(s,t,n,r()))),ou.setValue(t,M.some({mode:"position",config:n,getBounds:r}))},r=(t,o,n,r)=>{const s=((e,t,o,n,r)=>{const s=()=>e.lazySink(t),a="horizontal"===n.type?{layouts:{onLtr:()=>al(),onRtl:()=>il()}}:{},i=e=>(e=>2===e.length)(e)?a:{};return _h.sketch({dom:{tag:"div"},data:n.data,markers:n.menu.markers,highlightOnOpen:n.menu.highlightOnOpen,fakeFocus:n.menu.fakeFocus,onEscape:()=>(Nd.close(t),e.onEscape.map((e=>e(t))),M.some(!0)),onExecute:()=>M.some(!0),onOpenMenu:(e,t)=>{ud.positionWithinBounds(s().getOrDie(),t,o,r())},onOpenSubmenu:(e,t,o,n)=>{const r=s().getOrDie();ud.position(r,o,{anchor:{type:"submenu",item:t,...i(n)}})},onRepositionMenu:(e,t,n)=>{const a=s().getOrDie();ud.positionWithinBounds(a,t,o,r()),L(n,(e=>{const t=i(e.triggeringPath);ud.position(a,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem,...t}})}))}})})(e,t,o,n,r);Nd.open(t,s),ou.setValue(t,M.some({mode:"menu",menu:s}))},s=t=>{Nd.isOpen(t)&&ou.getValue(t).each((o=>{switch(o.mode){case"menu":Nd.getState(t).each(_h.repositionMenus);break;case"position":const n=e.lazySink(t).getOrDie();ud.positionWithinBounds(n,t,o.config,o.getBounds())}}))},a={setContent:(e,t)=>{Nd.setContent(e,t)},showAt:(e,t,n)=>{o(e,t,n,M.none())},showWithin:o,showWithinBounds:n,showMenuAt:(e,t,o)=>{r(e,t,o,M.none)},showMenuWithinBounds:r,hide:e=>{Nd.isOpen(e)&&(ou.setValue(e,M.none()),Nd.close(e))},getContent:e=>Nd.getState(e),reposition:s,isOpen:Nd.isOpen};return{uid:e.uid,dom:e.dom,behaviours:su(e.inlineBehaviours,[Nd.config({isPartOf:(t,o,n)=>li(o,n)||((t,o)=>e.getRelated(t).exists((e=>li(e,o))))(t,n),getAttachPoint:t=>e.lazySink(t).getOrDie(),onOpen:t=>{e.onShow(t)},onClose:t=>{e.onHide(t)}}),ou.config({store:{mode:"memory",initialValue:M.none()}}),yl.config({channels:{...Pd({isExtraPart:t.isExtraPart,...e.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...Wd({...e.fireRepositionEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({}),doReposition:s})}})]),eventOrder:e.eventOrder,apis:a}},apis:{showAt:(e,t,o,n)=>{e.showAt(t,o,n)},showWithin:(e,t,o,n,r)=>{e.showWithin(t,o,n,r)},showWithinBounds:(e,t,o,n,r)=>{e.showWithinBounds(t,o,n,r)},showMenuAt:(e,t,o,n)=>{e.showMenuAt(t,o,n)},showMenuWithinBounds:(e,t,o,n,r)=>{e.showMenuWithinBounds(t,o,n,r)},hide:(e,t)=>{e.hide(t)},isOpen:(e,t)=>e.isOpen(t),getContent:(e,t)=>e.getContent(t),setContent:(e,t,o)=>{e.setContent(t,o)},reposition:(e,t)=>{e.reposition(t)}}});var Eh=tinymce.util.Tools.resolve("tinymce.util.Delay");const Mh=rm({name:"Button",factory:e=>{const t=Zp(e.action),o=e.dom.tag,n=t=>be(e.dom,"attributes").bind((e=>be(e,t)));return{uid:e.uid,dom:e.dom,components:e.components,events:t,behaviours:iu(e.buttonBehaviours,[Up.config({}),Tp.config({mode:"execution",useSpace:!0,useEnter:!0})]),domModification:{attributes:"button"===o?{type:n("type").getOr("button"),...n("role").map((e=>({role:e}))).getOr({})}:{role:n("role").getOr("button")}},eventOrder:e.eventOrder}},configFields:[ur("uid",void 0),Xn("dom"),ur("components",[]),au("buttonBehaviours",[Up,Tp]),nr("action"),nr("role"),ur("eventOrder",{})]}),Ah=e=>{const t=(e=>void 0!==e.uid)(e)&&ye(e,"uid")?e.uid:aa("memento");return{get:e=>e.getSystem().getByUid(t).getOrDie(),getOpt:e=>e.getSystem().getByUid(t).toOptional(),asSpec:()=>({...e,uid:t})}};var Dh=tinymce.util.Tools.resolve("tinymce.util.I18n");const Bh={indent:!0,outdent:!0,"table-insert-column-after":!0,"table-insert-column-before":!0,"paste-column-after":!0,"paste-column-before":!0,"unordered-list":!0,"list-bull-circle":!0,"list-bull-default":!0,"list-bull-square":!0},Fh="temporary-placeholder",Ih=e=>()=>be(e,Fh).getOr("!not found!"),Rh=(e,t)=>{const o=e.toLowerCase();if(Dh.isRtl()){const e=((e,t)=>_e(e,t)?e:((e,t)=>e+"-rtl")(e))(o,"-rtl");return ve(t,e)?e:o}return o},Nh=(e,t)=>be(t,Rh(e,t)),Vh=(e,t)=>{const o=t();return Nh(e,o).getOrThunk(Ih(o))},Hh=()=>Vp("add-focusable",[Ps((e=>{ni(e.element,"svg").each((e=>vt(e,"focusable","false")))}))]),zh=(e,t,o,n)=>{var r,s;const a=(e=>!!Dh.isRtl()&&ve(Bh,e))(t)?["tox-icon--flip"]:[],i=be(o,Rh(t,o)).or(n).getOrThunk(Ih(o));return{dom:{tag:e.tag,attributes:null!==(r=e.attributes)&&void 0!==r?r:{},classes:e.classes.concat(a),innerHtml:i},behaviours:gl([...null!==(s=e.behaviours)&&void 0!==s?s:[],Hh()])}},Lh=(e,t,o,n=M.none())=>zh(t,e,o(),n),Ph={success:"checkmark",error:"warning",err:"error",warning:"warning",warn:"warning",info:"info"},Uh=rm({name:"Notification",factory:e=>{const t=Ah({dom:{tag:"p",innerHtml:e.translationProvider(e.text)},behaviours:gl([Np.config({})])}),o=e=>({dom:{tag:"div",classes:["tox-bar"],styles:{width:`${e}%`}}}),n=e=>({dom:{tag:"div",classes:["tox-text"],innerHtml:`${e}%`}}),r=Ah({dom:{tag:"div",classes:e.progress?["tox-progress-bar","tox-progress-indicator"]:["tox-progress-bar"]},components:[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(0)]},n(0)],behaviours:gl([Np.config({})])}),s={updateProgress:(e,t)=>{e.getSystem().isConnected()&&r.getOpt(e).each((e=>{Np.set(e,[{dom:{tag:"div",classes:["tox-bar-container"]},components:[o(t)]},n(t)])}))},updateText:(e,o)=>{if(e.getSystem().isConnected()){const n=t.get(e);Np.set(n,[Ga(o)])}}},a=q([e.icon.toArray(),e.level.toArray(),e.level.bind((e=>M.from(Ph[e]))).toArray()]),i=Ah(Mh.sketch({dom:{tag:"button",classes:["tox-notification__dismiss","tox-button","tox-button--naked","tox-button--icon"]},components:[Lh("close",{tag:"div",classes:["tox-icon"],attributes:{"aria-label":e.translationProvider("Close")}},e.iconProvider)],action:t=>{e.onAction(t)}})),l=((e,t,o)=>{const n=o(),r=G(e,(e=>ve(n,Rh(e,n))));return zh({tag:"div",classes:["tox-notification__icon"]},r.getOr(Fh),n,M.none())})(a,0,e.iconProvider),c=[l,{dom:{tag:"div",classes:["tox-notification__body"]},components:[t.asSpec()],behaviours:gl([Np.config({})])}];return{uid:e.uid,dom:{tag:"div",attributes:{role:"alert"},classes:e.level.map((e=>["tox-notification","tox-notification--in",`tox-notification--${e}`])).getOr(["tox-notification","tox-notification--in"])},behaviours:gl([Up.config({}),Vp("notification-events",[Fs(Lr(),(e=>{i.getOpt(e).each(Up.focus)}))])]),components:c.concat(e.progress?[r.asSpec()]:[]).concat(e.closeButton?[i.asSpec()]:[]),apis:s}},configFields:[nr("level"),Xn("progress"),nr("icon"),Xn("onAction"),Xn("text"),Xn("iconProvider"),Xn("translationProvider"),fr("closeButton",!0)],apis:{updateProgress:(e,t,o)=>{e.updateProgress(t,o)},updateText:(e,t,o)=>{e.updateText(t,o)}}});var Wh,jh,Gh=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),$h=tinymce.util.Tools.resolve("tinymce.EditorManager"),qh=tinymce.util.Tools.resolve("tinymce.Env");!function(e){e.default="wrap",e.floating="floating",e.sliding="sliding",e.scrolling="scrolling"}(Wh||(Wh={})),function(e){e.auto="auto",e.top="top",e.bottom="bottom"}(jh||(jh={}));const Xh=e=>t=>t.options.get(e),Kh=e=>t=>M.from(e(t)),Yh=e=>{const t=qh.deviceType.isPhone(),o=qh.deviceType.isTablet()||t,n=e.options.register,r=e=>s(e)||!1===e,a=e=>s(e)||h(e);n("skin",{processor:e=>s(e)||!1===e,default:"oxide"}),n("skin_url",{processor:"string"}),n("height",{processor:a,default:Math.max(e.getElement().offsetHeight,400)}),n("width",{processor:a,default:Gh.DOM.getStyle(e.getElement(),"width")}),n("min_height",{processor:"number",default:100}),n("min_width",{processor:"number"}),n("max_height",{processor:"number"}),n("max_width",{processor:"number"}),n("style_formats",{processor:"object[]"}),n("style_formats_merge",{processor:"boolean",default:!1}),n("style_formats_autohide",{processor:"boolean",default:!1}),n("line_height_formats",{processor:"string",default:"1 1.1 1.2 1.3 1.4 1.5 2"}),n("font_family_formats",{processor:"string",default:"Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats"}),n("font_size_formats",{processor:"string",default:"8pt 10pt 12pt 14pt 18pt 24pt 36pt"}),n("block_formats",{processor:"string",default:"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre"}),n("content_langs",{processor:"object[]"}),n("removed_menuitems",{processor:"string",default:""}),n("menubar",{processor:e=>s(e)||d(e),default:!t}),n("menu",{processor:"object",default:{}}),n("toolbar",{processor:e=>d(e)||s(e)||l(e)?{value:e,valid:!0}:{valid:!1,message:"Must be a boolean, string or array."},default:!0}),V(9,(e=>{n("toolbar"+(e+1),{processor:"string"})})),n("toolbar_mode",{processor:"string",default:o?"scrolling":"floating"}),n("toolbar_groups",{processor:"object",default:{}}),n("toolbar_location",{processor:"string",default:jh.auto}),n("toolbar_persist",{processor:"boolean",default:!1}),n("toolbar_sticky",{processor:"boolean",default:e.inline}),n("toolbar_sticky_offset",{processor:"number",default:0}),n("fixed_toolbar_container",{processor:"string",default:""}),n("fixed_toolbar_container_target",{processor:"object"}),n("file_picker_callback",{processor:"function"}),n("file_picker_validator_handler",{processor:"function"}),n("file_picker_types",{processor:"string"}),n("typeahead_urls",{processor:"boolean",default:!0}),n("anchor_top",{processor:r,default:"#top"}),n("anchor_bottom",{processor:r,default:"#bottom"}),n("draggable_modal",{processor:"boolean",default:!1}),n("statusbar",{processor:"boolean",default:!0}),n("elementpath",{processor:"boolean",default:!0}),n("branding",{processor:"boolean",default:!0}),n("promotion",{processor:"boolean",default:!0}),n("resize",{processor:e=>"both"===e||d(e),default:!qh.deviceType.isTouch()}),n("sidebar_show",{processor:"string"})},Jh=Xh("readonly"),Zh=Xh("height"),Qh=Xh("width"),ef=Kh(Xh("min_width")),tf=Kh(Xh("min_height")),of=Kh(Xh("max_width")),nf=Kh(Xh("max_height")),rf=Kh(Xh("style_formats")),sf=Xh("style_formats_merge"),af=Xh("style_formats_autohide"),lf=Xh("content_langs"),cf=Xh("removed_menuitems"),df=Xh("toolbar_mode"),uf=Xh("toolbar_groups"),mf=Xh("toolbar_location"),gf=Xh("fixed_toolbar_container"),pf=Xh("fixed_toolbar_container_target"),hf=Xh("toolbar_persist"),ff=Xh("toolbar_sticky_offset"),bf=Xh("menubar"),vf=Xh("toolbar"),yf=Xh("file_picker_callback"),xf=Xh("file_picker_validator_handler"),wf=Xh("file_picker_types"),Sf=Xh("typeahead_urls"),kf=Xh("anchor_top"),Cf=Xh("anchor_bottom"),Of=Xh("draggable_modal"),_f=Xh("statusbar"),Tf=Xh("elementpath"),Ef=Xh("branding"),Mf=Xh("resize"),Af=Xh("paste_as_text"),Df=Xh("sidebar_show"),Bf=Xh("promotion"),Ff=e=>!1===e.options.get("skin"),If=e=>!1!==e.options.get("menubar"),Rf=e=>{const t=e.options.get("skin_url");if(Ff(e))return t;if(t)return e.documentBaseURI.toAbsolute(t);{const t=e.options.get("skin");return $h.baseURL+"/skins/ui/"+t}},Nf=e=>e.options.get("line_height_formats").split(" "),Vf=e=>{const t=vf(e),o=s(t),n=l(t)&&t.length>0;return!zf(e)&&(n||o||!0===t)},Hf=e=>{const t=V(9,(t=>e.options.get("toolbar"+(t+1)))),o=U(t,s);return ke(o.length>0,o)},zf=e=>Hf(e).fold((()=>{const t=vf(e);return f(t,s)&&t.length>0}),T),Lf=e=>mf(e)===jh.bottom,Pf=e=>{var t;if(!e.inline)return M.none();const o=null!==(t=gf(e))&&void 0!==t?t:"";if(o.length>0)return ri(ht(),o);const n=pf(e);return g(n)?M.some(Ie(n)):M.none()},Uf=e=>e.inline&&Pf(e).isSome(),Wf=e=>Pf(e).getOrThunk((()=>ut(dt(Ie(e.getElement()))))),jf=e=>e.inline&&!If(e)&&!Vf(e)&&!zf(e),Gf=e=>(e.options.get("toolbar_sticky")||e.inline)&&!Uf(e)&&!jf(e),$f=e=>{const t=e.options.get("menu");return ce(t,(e=>({...e,items:e.items})))};var qf=Object.freeze({__proto__:null,get ToolbarMode(){return Wh},get ToolbarLocation(){return jh},register:Yh,getSkinUrl:Rf,isReadOnly:Jh,isSkinDisabled:Ff,getHeightOption:Zh,getWidthOption:Qh,getMinWidthOption:ef,getMinHeightOption:tf,getMaxWidthOption:of,getMaxHeightOption:nf,getUserStyleFormats:rf,shouldMergeStyleFormats:sf,shouldAutoHideStyleFormats:af,getLineHeightFormats:Nf,getContentLanguages:lf,getRemovedMenuItems:cf,isMenubarEnabled:If,isMultipleToolbars:zf,isToolbarEnabled:Vf,isToolbarPersist:hf,getMultipleToolbarsOption:Hf,getUiContainer:Wf,useFixedContainer:Uf,getToolbarMode:df,isDraggableModal:Of,isDistractionFree:jf,isStickyToolbar:Gf,getStickyToolbarOffset:ff,getToolbarLocation:mf,isToolbarLocationBottom:Lf,getToolbarGroups:uf,getMenus:$f,getMenubar:bf,getToolbar:vf,getFilePickerCallback:yf,getFilePickerTypes:wf,useTypeaheadUrls:Sf,getAnchorTop:kf,getAnchorBottom:Cf,getFilePickerValidatorHandler:xf,useStatusBar:_f,useElementPath:Tf,promotionEnabled:Bf,useBranding:Ef,getResize:Mf,getPasteAsText:Af,getSidebarShow:Df});const Xf="[data-mce-autocompleter]",Kf=e=>si(e,Xf);var Yf;!function(e){e[e.CLOSE_ON_EXECUTE=0]="CLOSE_ON_EXECUTE",e[e.BUBBLE_TO_SANDBOX=1]="BUBBLE_TO_SANDBOX"}(Yf||(Yf={}));var Jf=Yf;const Zf="tox-menu-nav__js",Qf="tox-collection__item",eb={normal:Zf,color:"tox-swatch"},tb="tox-collection__item--enabled",ob="tox-collection__item-icon",nb="tox-collection__item-label",rb="tox-collection__item-caret",sb="tox-collection__item--active",ab="tox-collection__item-container",ib="tox-collection__item-container--row",lb=e=>be(eb,e).getOr(Zf),cb=e=>"color"===e?"tox-swatches":"tox-menu",db=e=>({backgroundMenu:"tox-background-menu",selectedMenu:"tox-selected-menu",selectedItem:"tox-collection__item--active",hasIcons:"tox-menu--has-icons",menu:cb(e),tieredMenu:"tox-tiered-menu"}),ub=e=>{const t=db(e);return{backgroundMenu:t.backgroundMenu,selectedMenu:t.selectedMenu,menu:t.menu,selectedItem:t.selectedItem,item:lb(e)}},mb=(e,t,o)=>{const n=db(o);return{tag:"div",classes:q([[n.menu,`tox-menu-${t}-column`],e?[n.hasIcons]:[]])}},gb=[bh.parts.items({})],pb=(e,t,o)=>{const n=db(o);return{dom:{tag:"div",classes:q([[n.tieredMenu]])},markers:ub(o)}},hb=y([nr("data"),ur("inputAttributes",{}),ur("inputStyles",{}),ur("tag","input"),ur("inputClasses",[]),wi("onSetValue"),ur("styles",{}),ur("eventOrder",{}),nu("inputBehaviours",[ou,Up]),ur("selectOnFocus",!0)]),fb=e=>gl([Up.config({onFocus:e.selectOnFocus?e=>{const t=e.element,o=Na(t);t.dom.setSelectionRange(0,o.length)}:b})]),bb=e=>({...fb(e),...su(e.inputBehaviours,[ou.config({store:{mode:"manual",...e.data.map((e=>({initialValue:e}))).getOr({}),getValue:e=>Na(e.element),setValue:(e,t)=>{Na(e.element)!==t&&Va(e.element,t)}},onSetValue:e.onSetValue})])}),vb=e=>({tag:e.tag,attributes:{type:"text",...e.inputAttributes},styles:e.inputStyles,classes:e.inputClasses}),yb=rm({name:"Input",configFields:hb(),factory:(e,t)=>({uid:e.uid,dom:vb(e),components:[],behaviours:bb(e),eventOrder:e.eventOrder})}),xb=Qs("refetch-trigger-event"),wb=Qs("redirect-menu-item-interaction"),Sb=e=>ri(e.element,".tox-menu__searcher").bind((t=>e.getSystem().getByDom(t).toOptional())),kb=Sb,Cb=e=>({fetchPattern:ou.getValue(e),selectionStart:e.element.dom.selectionStart,selectionEnd:e.element.dom.selectionEnd}),Ob=e=>{const t=(e,t)=>(t.cut(),M.none()),o=(e,t)=>{const o={interactionEvent:t.event,eventType:t.event.raw.type};return Os(e,wb,o),M.some(!0)},n="searcher-events";return{dom:{tag:"div",classes:[Qf]},components:[yb.sketch({inputClasses:["tox-menu__searcher","tox-textfield"],inputAttributes:{...e.placeholder.map((t=>({placeholder:e.i18n(t)}))).getOr({}),type:"search","aria-autocomplete":"list"},inputBehaviours:gl([Vp(n,[Fs(jr(),(e=>{Cs(e,xb)})),Fs(Ur(),((e,t)=>{"Escape"===t.event.raw.key&&t.stop()}))]),Tp.config({mode:"special",onLeft:t,onRight:t,onSpace:t,onEnter:o,onEscape:o,onUp:o,onDown:o})]),eventOrder:{keydown:[n,Tp.name()]}})]}},_b="tox-collection--results__js",Tb=e=>{var t;return e.dom?{...e,dom:{...e.dom,attributes:{...null!==(t=e.dom.attributes)&&void 0!==t?t:{},id:Qs("aria-item-search-result-id"),"aria-selected":"false"}}}:e},Eb=(e,t)=>o=>{const n=H(o,t);return z(n,(t=>({dom:e,components:t})))},Mb=(e,t)=>{const o=[];let n=[];return L(e,((e,r)=>{t(e,r)?(n.length>0&&o.push(n),n=[],(ve(e.dom,"innerHtml")||e.components&&e.components.length>0)&&n.push(e)):n.push(e)})),n.length>0&&o.push(n),z(o,(e=>({dom:{tag:"div",classes:["tox-collection__group"]},components:e})))},Ab=(e,t,o)=>bh.parts.items({preprocess:n=>{const r=z(n,o);return"auto"!==e&&e>1?Eb({tag:"div",classes:["tox-collection__group"]},e)(r):Mb(r,((e,o)=>"separator"===t[o].type))}}),Db=(e,t,o=!0)=>({dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Ab(e,t,x)]}),Bb=e=>N(e,(e=>"icon"in e&&void 0!==e.icon)),Fb=e=>(console.error(Wn(e)),console.log(e),M.none()),Ib=(e,t,o,n,r)=>{const s=(a=o,{dom:{tag:"div",classes:["tox-collection","tox-collection--horizontal"]},components:[bh.parts.items({preprocess:e=>Mb(e,((e,t)=>"separator"===a[t].type))})]});var a;return{value:e,dom:s.dom,components:s.components,items:o}},Rb=(e,t,o,n,r)=>{if("color"===r.menuType){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-swatches-menu"]},components:[{dom:{tag:"div",classes:["tox-swatches"]},components:[bh.parts.items({preprocess:"auto"!==e?Eb({tag:"div",classes:["tox-swatches__row"]},e):x})]}]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType&&"auto"===n){const t=Db(n,o);return{value:e,dom:t.dom,components:t.components,items:o}}if("normal"===r.menuType||"searchable"===r.menuType){const t="searchable"!==r.menuType?Db(n,o):"search-with-field"===r.searchMode.searchMode?((e,t,o)=>{const n=Qs("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection"].concat(1===e?["tox-collection--list"]:["tox-collection--grid"])},components:[Ob({i18n:Dh.translate,placeholder:o.placeholder}),{dom:{tag:"div",classes:[...1===e?["tox-collection--list"]:["tox-collection--grid"],_b],attributes:{id:n}},components:[Ab(e,t,Tb)]}]}})(n,o,r.searchMode):((e,t,o=!0)=>{const n=Qs("aria-controls-search-results");return{dom:{tag:"div",classes:["tox-menu","tox-collection",_b].concat(1===e?["tox-collection--list"]:["tox-collection--grid"]),attributes:{id:n}},components:[Ab(e,t,Tb)]}})(n,o);return{value:e,dom:t.dom,components:t.components,items:o}}if("listpreview"===r.menuType&&"auto"!==n){const t=(e=>({dom:{tag:"div",classes:["tox-menu","tox-collection","tox-collection--toolbar","tox-collection--toolbar-lg"]},components:[bh.parts.items({preprocess:Eb({tag:"div",classes:["tox-collection__group"]},e)})]}))(n);return{value:e,dom:t.dom,components:t.components,items:o}}return{value:e,dom:mb(t,n,r.menuType),components:gb,items:o}},Nb=Jn("type"),Vb=Jn("name"),Hb=Jn("label"),zb=Jn("text"),Lb=Jn("title"),Pb=Jn("icon"),Ub=Jn("value"),Wb=Qn("fetch"),jb=Qn("getSubmenuItems"),Gb=Qn("onAction"),$b=Qn("onItemAction"),qb=br("onSetup",(()=>b)),Xb=ar("name"),Kb=ar("text"),Yb=ar("icon"),Jb=ar("tooltip"),Zb=ar("label"),Qb=ar("shortcut"),ev=lr("select"),tv=fr("active",!1),ov=fr("borderless",!1),nv=fr("enabled",!0),rv=fr("primary",!1),sv=e=>ur("columns",e),av=ur("meta",{}),iv=br("onAction",b),lv=e=>pr("type",e),cv=e=>Gn("name","name",un((()=>Qs(`${e}-name`))),Bn),dv=Cn([Nb,Kb]),uv=Cn([lv("autocompleteitem"),tv,nv,av,Ub,Kb,Yb]),mv=[nv,Jb,Yb,Kb,qb],gv=Cn([Nb,Gb].concat(mv)),pv=e=>Ln("toolbarbutton",gv,e),hv=[tv].concat(mv),fv=Cn(hv.concat([Nb,Gb])),bv=e=>Ln("ToggleButton",fv,e),vv=[br("predicate",_),hr("scope","node",["node","editor"]),hr("position","selection",["node","selection","line"])],yv=mv.concat([lv("contextformbutton"),rv,Gb,$n("original",x)]),xv=hv.concat([lv("contextformbutton"),rv,Gb,$n("original",x)]),wv=mv.concat([lv("contextformbutton")]),Sv=hv.concat([lv("contextformtogglebutton")]),kv=jn("type",{contextformbutton:yv,contextformtogglebutton:xv}),Cv=Cn([lv("contextform"),br("initValue",y("")),Zb,or("commands",kv),rr("launch",jn("type",{contextformbutton:wv,contextformtogglebutton:Sv}))].concat(vv)),Ov=Cn([lv("contexttoolbar"),Jn("items")].concat(vv)),_v=[Nb,Jn("src"),ar("alt"),vr("classes",[],Bn)],Tv=Cn(_v),Ev=[Nb,zb,Xb,vr("classes",["tox-collection__item-label"],Bn)],Mv=Cn(Ev),Av=wn((()=>Vn("type",{cardimage:Tv,cardtext:Mv,cardcontainer:Dv}))),Dv=Cn([Nb,pr("direction","horizontal"),pr("align","left"),pr("valign","middle"),or("items",Av)]),Bv=[nv,Kb,Qb,("menuitem",Gn("value","value",un((()=>Qs("menuitem-value"))),Mn())),av];const Fv=Cn([Nb,Zb,or("items",Av),qb,iv].concat(Bv)),Iv=Cn([Nb,tv,Yb].concat(Bv)),Rv=[Nb,Jn("fancytype"),iv],Nv=[ur("initData",{})].concat(Rv),Vv=[yr("initData",{},[fr("allowCustomColors",!0),pr("storageKey","default"),cr("colors",Mn())])].concat(Rv),Hv=jn("fancytype",{inserttable:Nv,colorswatch:Vv}),zv=Cn([Nb,qb,iv,Yb].concat(Bv)),Lv=Cn([Nb,jb,qb,Yb].concat(Bv)),Pv=Cn([Nb,Yb,tv,qb,Gb].concat(Bv)),Uv=(e,t,o)=>{const n=Nc(e.element,"."+o);if(n.length>0){const e=$(n,(e=>{const o=e.dom.getBoundingClientRect().top,r=n[0].dom.getBoundingClientRect().top;return Math.abs(o-r)>t})).getOr(n.length);return M.some({numColumns:e,numRows:Math.ceil(n.length/e)})}return M.none()},Wv=e=>((e,t)=>gl([Vp(e,t)]))(Qs("unnamed-events"),e),jv=Qs("tooltip.exclusive"),Gv=Qs("tooltip.show"),$v=Qs("tooltip.hide"),qv=(e,t,o)=>{e.getSystem().broadcastOn([jv],{})};var Xv=Object.freeze({__proto__:null,hideAllExclusive:qv,setComponents:(e,t,o,n)=>{o.getTooltip().each((e=>{e.getSystem().isConnected()&&Np.set(e,n)}))}}),Kv=Object.freeze({__proto__:null,events:(e,t)=>{const o=o=>{t.getTooltip().each((n=>{wd(n),e.onHide(o,n),t.clearTooltip()})),t.clearTimer()};return As(q([[Fs(Gv,(o=>{t.resetTimer((()=>{(o=>{if(!t.isShowing()){qv(o);const n=e.lazySink(o).getOrDie(),r=o.getSystem().build({dom:e.tooltipDom,components:e.tooltipComponents,events:As("normal"===e.mode?[Fs(zr(),(e=>{Cs(o,Gv)})),Fs(Vr(),(e=>{Cs(o,$v)}))]:[]),behaviours:gl([Np.config({})])});t.setTooltip(r),vd(n,r),e.onShow(o,r),ud.position(n,r,{anchor:e.anchor(o)})}})(o)}),e.delay)})),Fs($v,(n=>{t.resetTimer((()=>{o(n)}),e.delay)})),Fs(os(),((e,t)=>{const n=t;n.universal||R(n.channels,jv)&&o(e)})),Us((e=>{o(e)}))],"normal"===e.mode?[Fs(Lr(),(e=>{Cs(e,Gv)})),Fs(es(),(e=>{Cs(e,$v)})),Fs(zr(),(e=>{Cs(e,Gv)})),Fs(Vr(),(e=>{Cs(e,$v)}))]:[Fs(Ss(),((e,t)=>{Cs(e,Gv)})),Fs(ks(),(e=>{Cs(e,$v)}))]]))}}),Yv=[Xn("lazySink"),Xn("tooltipDom"),ur("exclusive",!0),ur("tooltipComponents",[]),ur("delay",300),hr("mode","normal",["normal","follow-highlight"]),ur("anchor",(e=>({type:"hotspot",hotspot:e,layouts:{onLtr:y([Qi,Zi,Xi,Yi,Ki,Ji]),onRtl:y([Qi,Zi,Xi,Yi,Ki,Ji])}}))),wi("onHide"),wi("onShow")];const Jv=hl({fields:Yv,name:"tooltipping",active:Kv,state:Object.freeze({__proto__:null,init:()=>{const e=Ul(),t=Ul(),o=()=>{e.on(clearTimeout)},n=y("not-implemented");return ba({getTooltip:t.get,isShowing:t.isSet,setTooltip:t.set,clearTooltip:t.clear,clearTimer:o,resetTimer:(t,n)=>{o(),e.set(setTimeout(t,n))},readState:n})}}),apis:Xv}),Zv="silver.readonly",Qv=Cn([("readonly",Kn("readonly",Fn))]);const ey=(e,t)=>{const o=e.mainUi.outerContainer.element,n=[e.mainUi.mothership,...e.uiMotherships];t&&L(n,(e=>{e.broadcastOn([Vd()],{target:o})})),L(n,(e=>{e.broadcastOn([Zv],{readonly:t})}))},ty=(e,t)=>{e.on("init",(()=>{e.mode.isReadOnly()&&ey(t,!0)})),e.on("SwitchMode",(()=>ey(t,e.mode.isReadOnly()))),Jh(e)&&e.mode.set("readonly")},oy=()=>yl.config({channels:{[Zv]:{schema:Qv,onReceive:(e,t)=>{km.set(e,t.readonly)}}}}),ny=e=>km.config({disabled:e}),ry=e=>km.config({disabled:e,disableClass:"tox-tbtn--disabled"}),sy=e=>km.config({disabled:e,disableClass:"tox-tbtn--disabled",useNative:!1}),ay=(e,t)=>{const o=e.getApi(t);return e=>{e(o)}},iy=(e,t)=>Ps((o=>{ay(e,o)((o=>{const n=e.onSetup(o);p(n)&&t.set(n)}))})),ly=(e,t)=>Us((o=>ay(e,o)(t.get()))),cy=(e,t)=>js(((o,n)=>{ay(e,o)(e.onAction),e.triggersSubmenu||t!==Jf.CLOSE_ON_EXECUTE||(o.getSystem().isConnected()&&Cs(o,is()),n.stop())})),dy={[ns()]:["disabling","alloy.base.behaviour","toggling","item-events"]},uy=we,my=(e,t,o,n)=>{const r=xr(b);return{type:"item",dom:t.dom,components:uy(t.optComponents),data:e.data,eventOrder:dy,hasSubmenu:e.triggersSubmenu,itemBehaviours:gl([Vp("item-events",[cy(e,o),iy(e,r),ly(e,r)]),(s=()=>!e.enabled||n.isDisabled(),km.config({disabled:s,disableClass:"tox-collection__item--state-disabled"})),oy(),Np.config({})].concat(e.itemBehaviours))};var s},gy=e=>({value:e.value,meta:{text:e.text.getOr(""),...e.meta}}),py=e=>{const t=qh.os.isMacOS()||qh.os.isiOS(),o=t?{alt:"\u2325",ctrl:"\u2303",shift:"\u21e7",meta:"\u2318",access:"\u2303\u2325"}:{meta:"Ctrl",access:"Shift+Alt"},n=e.split("+"),r=z(n,(e=>{const t=e.toLowerCase().trim();return ve(o,t)?o[t]:e}));return t?r.join(""):r.join("+")},hy=(e,t,o=[ob])=>Lh(e,{tag:"div",classes:o},t),fy=e=>({dom:{tag:"div",classes:[nb]},components:[Ga(Dh.translate(e))]}),by=(e,t)=>({dom:{tag:"div",classes:t,innerHtml:e}}),vy=(e,t)=>({dom:{tag:"div",classes:[nb]},components:[{dom:{tag:e.tag,styles:e.styles},components:[Ga(Dh.translate(t))]}]}),yy=e=>({dom:{tag:"div",classes:["tox-collection__item-accessory"]},components:[Ga(py(e))]}),xy=e=>hy("checkmark",e,["tox-collection__item-checkmark"]),wy=e=>{const t=e.map((e=>({attributes:{title:Dh.translate(e)}}))).getOr({});return{tag:"div",classes:[Zf,Qf],...t}},Sy=(e,t,o,n=M.none())=>"color"===e.presets?((e,t,o)=>{const n=e.ariaLabel,r=e.value,s=e.iconContent.map((e=>((e,t,o)=>{const n=t();return Nh(e,n).or(o).getOrThunk(Ih(n))})(e,t.icons,o)));return{dom:(()=>{const e=s.getOr(""),o=n.map((e=>({title:t.translate(e)}))).getOr({}),a={tag:"div",attributes:o,classes:["tox-swatch"]};return"custom"===r?{...a,tag:"button",classes:[...a.classes,"tox-swatches__picker-btn"],innerHtml:e}:"remove"===r?{...a,classes:[...a.classes,"tox-swatch--remove"],innerHtml:e}:g(r)?{...a,attributes:{...a.attributes,"data-mce-color":r},styles:{"background-color":r},innerHtml:e}:a})(),optComponents:[]}})(e,t,n):((e,t,o,n)=>{const r={tag:"div",classes:[ob]},s=o?e.iconContent.map((e=>Lh(e,r,t.icons,n))).orThunk((()=>M.some({dom:r}))):M.none(),a=e.checkMark,i=M.from(e.meta).fold((()=>fy),(e=>ve(e,"style")?S(vy,e.style):fy)),l=e.htmlContent.fold((()=>e.textContent.map(i)),(e=>M.some(by(e,[nb]))));return{dom:wy(e.ariaLabel),optComponents:[s,l,e.shortcutContent.map(yy),a,e.caret]}})(e,t,o,n),ky=(e,t)=>be(e,"tooltipWorker").map((e=>[Jv.config({lazySink:t.getSink,tooltipDom:{tag:"div",classes:["tox-tooltip-worker-container"]},tooltipComponents:[],anchor:e=>({type:"submenu",item:e,overrides:{maxHeightFunction:Zl}}),mode:"follow-highlight",onShow:(t,o)=>{e((e=>{Jv.setComponents(t,[$a({element:Ie(e)})])}))}})])).getOr([]),Cy=(e,t)=>{const o=(e=>Gh.DOM.encode(e))(Dh.translate(e));if(t.length>0){const e=new RegExp((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))(t),"gi");return o.replace(e,(e=>`<span class="tox-autocompleter-highlight">${e}</span>`))}return o},Oy=(e,t)=>z(e,(e=>{switch(e.type){case"cardcontainer":return((e,t)=>{const o="vertical"===e.direction?"tox-collection__item-container--column":ib,n="left"===e.align?"tox-collection__item-container--align-left":"tox-collection__item-container--align-right";return{dom:{tag:"div",classes:[ab,o,n,(()=>{switch(e.valign){case"top":return"tox-collection__item-container--valign-top";case"middle":return"tox-collection__item-container--valign-middle";case"bottom":return"tox-collection__item-container--valign-bottom"}})()]},components:t}})(e,Oy(e.items,t));case"cardimage":return((e,t,o)=>({dom:{tag:"img",classes:t,attributes:{src:e,alt:o.getOr("")}}}))(e.src,e.classes,e.alt);case"cardtext":const o=e.name.exists((e=>R(t.cardText.highlightOn,e))),n=o?M.from(t.cardText.matchText).getOr(""):"";return by(Cy(e.text,n),e.classes)}})),_y=Vu(dh(),uh()),Ty=e=>({value:e}),Ey=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,My=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Ay=e=>Ey.test(e)||My.test(e),Dy=e=>{return(t=e,((e,t)=>Ce(e,t,0))(t,"#")?((e,t)=>e.substring(t))(t,"#".length):t).toUpperCase();var t},By=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Fy=e=>{const t=By(e.red)+By(e.green)+By(e.blue);return Ty(t)},Iy=Math.min,Ry=Math.max,Ny=Math.round,Vy=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,Hy=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,zy=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),Ly=e=>{const t=parseInt(e,10);return t.toString()===e&&t>=0&&t<=255},Py=e=>{let t,o,n;const r=(e.hue||0)%360;let s=e.saturation/100,a=e.value/100;if(s=Ry(0,Iy(s,1)),a=Ry(0,Iy(a,1)),0===s)return t=o=n=Ny(255*a),zy(t,o,n,1);const i=r/60,l=a*s,c=l*(1-Math.abs(i%2-1)),d=a-l;switch(Math.floor(i)){case 0:t=l,o=c,n=0;break;case 1:t=c,o=l,n=0;break;case 2:t=0,o=l,n=c;break;case 3:t=0,o=c,n=l;break;case 4:t=c,o=0,n=l;break;case 5:t=l,o=0,n=c;break;default:t=o=n=0}return t=Ny(255*(t+d)),o=Ny(255*(o+d)),n=Ny(255*(n+d)),zy(t,o,n,1)},Uy=e=>{const t=(e=>{const t=(e=>{const t=e.value.replace(Ey,((e,t,o,n)=>t+t+o+o+n+n));return{value:t}})(e),o=My.exec(t.value);return null===o?["FFFFFF","FF","FF","FF"]:o})(e),o=parseInt(t[1],16),n=parseInt(t[2],16),r=parseInt(t[3],16);return zy(o,n,r,1)},Wy=(e,t,o,n)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(o,10),i=parseFloat(n);return zy(r,s,a,i)},jy=e=>{if("transparent"===e)return M.some(zy(0,0,0,0));const t=Vy.exec(e);if(null!==t)return M.some(Wy(t[1],t[2],t[3],"1"));const o=Hy.exec(e);return null!==o?M.some(Wy(o[1],o[2],o[3],o[4])):M.none()},Gy=e=>`rgba(${e.red},${e.green},${e.blue},${e.alpha})`,$y=zy(255,0,0,1),qy=(e,t)=>{e.dispatch("ResizeContent",t)},Xy=(e,t)=>e.dispatch("ResolveName",{name:t.nodeName.toLowerCase(),target:t});var Ky=tinymce.util.Tools.resolve("tinymce.util.LocalStorage");const Yy={},Jy=e=>be(Yy,e).getOrThunk((()=>{const t=`tinymce-custom-colors-${e}`,o=Ky.getItem(t);if(m(o)){const e=Ky.getItem("tinymce-custom-colors");Ky.setItem(t,g(e)?e:"[]")}const n=((e,t=10)=>{const o=Ky.getItem(e),n=s(o)?JSON.parse(o):[],r=t-(a=n).length<0?a.slice(0,t):a;var a;const i=e=>{r.splice(e,1)};return{add:o=>{I(r,o).each(i),r.unshift(o),r.length>t&&r.pop(),Ky.setItem(e,JSON.stringify(r))},state:()=>r.slice(0)}})(t,10);return Yy[e]=n,n})),Zy=(e,t)=>{Jy(e).add(t)},Qy=(e,t,o)=>({hue:e,saturation:t,value:o}),ex=e=>{let t=0,o=0,n=0;const r=e.red/255,s=e.green/255,a=e.blue/255,i=Math.min(r,Math.min(s,a)),l=Math.max(r,Math.max(s,a));return i===l?(n=i,Qy(0,0,100*n)):(t=r===i?3:a===i?1:5,t=60*(t-(r===i?s-a:a===i?r-s:a-r)/(l-i)),o=(l-i)/l,n=l,Qy(Math.round(t),Math.round(100*o),Math.round(100*n)))},tx=e=>Fy(Py(e)),ox=e=>{return(t=e,Ay(t)?M.some({value:Dy(t)}):M.none()).orThunk((()=>jy(e).map(Fy))).getOrThunk((()=>{const t=document.createElement("canvas");t.height=1,t.width=1;const o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),o.fillStyle="#FFFFFF",o.fillStyle=e,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data,r=n[0],s=n[1],a=n[2],i=n[3];return Fy(zy(r,s,a,i))}));var t},nx="forecolor",rx="hilitecolor",sx=e=>Math.max(5,Math.ceil(Math.sqrt(e))),ax=e=>{const t=[];for(let o=0;o<e.length;o+=2)t.push({text:e[o+1],value:"#"+ox(e[o]).value,icon:"checkmark",type:"choiceitem"});return t},ix=e=>t=>t.options.get(e),lx="#000000",cx=(e,t)=>t===nx?ix("color_cols_foreground")(e):t===rx?ix("color_cols_background")(e):ix("color_cols")(e),dx=ix("custom_colors"),ux=(e,t)=>t===nx&&e.options.isSet("color_map_foreground")?ix("color_map_foreground")(e):t===rx&&e.options.isSet("color_map_background")?ix("color_map_background")(e):ix("color_map")(e),mx=ix("color_default_foreground"),gx=ix("color_default_background"),px=(e,t)=>{const o=Mt(Ie(e.selection.getStart()),"hilitecolor"===t?"background-color":"color");return jy(o).map((e=>"#"+Fy(e).value))},hx=e=>{const t="choiceitem",o={type:t,text:"Remove color",icon:"color-swatch-remove-color",value:"remove"};return e?[o,{type:t,text:"Custom color",icon:"color-picker",value:"custom"}]:[o]},fx=(e,t,o,n)=>{"custom"===o?Sx(e)((o=>{o.each((o=>{Zy(t,o),e.execCommand("mceApplyTextcolor",t,o),n(o)}))}),px(e,t).getOr(lx)):"remove"===o?(n(""),e.execCommand("mceRemoveTextcolor",t)):(n(o),e.execCommand("mceApplyTextcolor",t,o))},bx=(e,t,o)=>e.concat((e=>z(Jy(e).state(),(e=>({type:"choiceitem",text:e,icon:"checkmark",value:e}))))(t).concat(hx(o))),vx=(e,t,o)=>n=>{n(bx(e,t,o))},yx=(e,t,o)=>{const n="forecolor"===t?"tox-icon-text-color__color":"tox-icon-highlight-bg-color__color";e.setIconFill(n,o)},xx=(e,t,o,n,r)=>{e.ui.registry.addSplitButton(t,{tooltip:n,presets:"color",icon:"forecolor"===t?"text-color":"highlight-bg-color",select:t=>{const n=px(e,o);return xe(n,t.toUpperCase())},columns:cx(e,o),fetch:vx(ux(e,o),o,dx(e)),onAction:t=>{fx(e,o,r.get(),b)},onItemAction:(n,s)=>{fx(e,o,s,(o=>{r.set(o),((e,t)=>{e.dispatch("TextColorChange",t)})(e,{name:t,color:o})}))},onSetup:o=>{yx(o,t,r.get());const n=e=>{e.name===t&&yx(o,e.name,e.color)};return e.on("TextColorChange",n),()=>{e.off("TextColorChange",n)}}})},wx=(e,t,o,n)=>{e.ui.registry.addNestedMenuItem(t,{text:n,icon:"forecolor"===t?"text-color":"highlight-bg-color",getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"colorswatch",initData:{storageKey:o},onAction:t=>{fx(e,o,t.value,b)}}]})},Sx=e=>(t,o)=>{let n=!1;const r={colorpicker:o};e.windowManager.open({title:"Color Picker",size:"normal",body:{type:"panel",items:[{type:"colorpicker",name:"colorpicker",label:"Color"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:r,onAction:(e,t)=>{"hex-valid"===t.name&&(n=t.value)},onSubmit:o=>{const r=o.getData().colorpicker;n?(t(M.from(r)),o.close()):e.windowManager.alert(e.translate(["Invalid hex color code: {0}",r]))},onClose:b,onCancel:()=>{t(M.none())}})},kx=(e,t,o,n,r,s,a,i)=>{const l=Bb(t),c=Cx(t,o,n,"color"!==r?"normal":"color",s,a,i);return Rb(e,l,c,n,{menuType:r})},Cx=(e,t,o,n,r,s,a)=>we(z(e,(i=>{return"choiceitem"===i.type?(l=i,Ln("choicemenuitem",Iv,l)).fold(Fb,(i=>M.some(((e,t,o,n,r,s,a,i=!0)=>{const l=Sy({presets:o,textContent:t?e.text:M.none(),htmlContent:M.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:t?e.shortcut:M.none(),checkMark:t?M.some(xy(a.icons)):M.none(),caret:M.none(),value:e.value},a,i);return cn(my({data:gy(e),enabled:e.enabled,getApi:e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t)}),onAction:t=>n(e.value),onSetup:e=>(e.setActive(r),b),triggersSubmenu:!1,itemBehaviours:[]},l,s,a),{toggling:{toggleClass:tb,toggleOnExecute:!1,selected:e.active,exclusive:!0}})})(i,1===o,n,t,s(i.value),r,a,Bb(e))))):M.none();var l}))),Ox=(e,t)=>{const o=ub(t);return 1===e?{mode:"menu",moveOnTab:!0}:"auto"===e?{mode:"grid",selector:"."+o.item,initSize:{numColumns:1,numRows:1}}:{mode:"matrix",rowSelector:"."+("color"===t?"tox-swatches__row":"tox-collection__group"),previousSelector:e=>"color"===t?ri(e.element,"[aria-checked=true]"):M.none()}},_x=Qs("cell-over"),Tx=Qs("cell-execute"),Ex=(e,t,o)=>{const n=o=>Os(o,Tx,{row:e,col:t}),r=(e,t)=>{t.stop(),n(e)};return Ka({dom:{tag:"div",attributes:{role:"button","aria-labelledby":o}},behaviours:gl([Vp("insert-table-picker-cell",[Fs(zr(),Up.focus),Fs(ns(),n),Fs($r(),r),Fs(ss(),r)]),Yp.config({toggleClass:"tox-insert-table-picker__selected",toggleOnExecute:!1}),Up.config({onFocus:o=>Os(o,_x,{row:e,col:t})})])})},Mx=e=>X(e,(e=>z(e,Ya))),Ax=(e,t)=>Ga(`${t}x${e}`),Dx={inserttable:e=>{const t=Qs("size-label"),o=((e,t,o)=>{const n=[];for(let t=0;t<10;t++){const o=[];for(let n=0;n<10;n++)o.push(Ex(t,n,e));n.push(o)}return n})(t),n=Ax(0,0),r=Ah({dom:{tag:"span",classes:["tox-insert-table-picker__label"],attributes:{id:t}},components:[n],behaviours:gl([Np.config({})])});return{type:"widget",data:{value:Qs("widget-id")},dom:{tag:"div",classes:["tox-fancymenuitem"]},autofocus:!0,components:[_y.widget({dom:{tag:"div",classes:["tox-insert-table-picker"]},components:Mx(o).concat(r.asSpec()),behaviours:gl([Vp("insert-table-picker",[Ps((e=>{Np.set(r.get(e),[n])})),Vs(_x,((e,t,n)=>{const{row:s,col:a}=n.event;((e,t,o,n,r)=>{for(let n=0;n<10;n++)for(let r=0;r<10;r++)Yp.set(e[n][r],n<=t&&r<=o)})(o,s,a),Np.set(r.get(e),[Ax(s+1,a+1)])})),Vs(Tx,((t,o,n)=>{const{row:r,col:s}=n.event;e.onAction({numRows:r+1,numColumns:s+1}),Cs(t,is())}))]),Tp.config({initSize:{numRows:10,numColumns:10},mode:"flatgrid",selector:'[role="button"]'})])})]}},colorswatch:(e,t)=>{const o=((e,t)=>{const o=e.initData.allowCustomColors&&t.colorinput.hasCustomColors();return e.initData.colors.fold((()=>bx(t.colorinput.getColors(e.initData.storageKey),e.initData.storageKey,o)),(e=>e.concat(hx(o))))})(e,t),n=t.colorinput.getColorCols(e.initData.storageKey),r="color",s={...kx(Qs("menu-value"),o,(t=>{e.onAction({value:t})}),n,r,Jf.CLOSE_ON_EXECUTE,_,t.shared.providers),markers:ub(r),movement:Ox(n,r)};return{type:"widget",data:{value:Qs("widget-id")},dom:{tag:"div",classes:["tox-fancymenuitem"]},autofocus:!0,components:[_y.widget(bh.sketch(s))]}}},Bx=e=>({type:"separator",dom:{tag:"div",classes:[Qf,"tox-collection__group-heading"]},components:e.text.map(Ga).toArray()});var Fx=Object.freeze({__proto__:null,getCoupled:(e,t,o,n)=>o.getOrCreate(e,t,n),getExistingCoupled:(e,t,o,n)=>o.getExisting(e,t,n)}),Ix=[Kn("others",zn(Jo.value,Mn()))],Rx=Object.freeze({__proto__:null,init:()=>{const e={},t=(t,o)=>{if(0===ae(t.others).length)throw new Error("Cannot find any known coupled components");return be(e,o)},o=y({});return ba({readState:o,getExisting:(e,o,n)=>t(o,n).orThunk((()=>(be(o.others,n).getOrDie("No information found for coupled component: "+n),M.none()))),getOrCreate:(o,n,r)=>t(n,r).getOrThunk((()=>{const t=be(n.others,r).getOrDie("No information found for coupled component: "+r)(o),s=o.getSystem().build(t);return e[r]=s,s}))})}});const Nx=hl({fields:Ix,name:"coupling",apis:Fx,state:Rx}),Vx=e=>{let t=M.none(),o=[];const n=e=>{r()?s(e):o.push(e)},r=()=>t.isSome(),s=e=>{t.each((t=>{setTimeout((()=>{e(t)}),0)}))};return e((e=>{r()||(t=M.some(e),L(o,s),o=[])})),{get:n,map:e=>Vx((t=>{n((o=>{t(e(o))}))})),isReady:r}},Hx={nu:Vx,pure:e=>Vx((t=>{t(e)}))},zx=e=>{setTimeout((()=>{throw e}),0)},Lx=e=>{const t=t=>{e().then(t,zx)};return{map:t=>Lx((()=>e().then(t))),bind:t=>Lx((()=>e().then((e=>t(e).toPromise())))),anonBind:t=>Lx((()=>e().then((()=>t.toPromise())))),toLazy:()=>Hx.nu(t),toCached:()=>{let t=null;return Lx((()=>(null===t&&(t=e()),t)))},toPromise:e,get:t}},Px=e=>Lx((()=>new Promise(e))),Ux=e=>Lx((()=>Promise.resolve(e))),Wx=y("sink"),jx=y(Bu({name:Wx(),overrides:y({dom:{tag:"div"},behaviours:gl([ud.config({useFixed:T})]),events:As([Hs(Ur()),Hs(Rr()),Hs($r())])})})),Gx=(e,t)=>{const o=e.getHotspot(t).getOr(t),n="hotspot",r=e.getAnchorOverrides();return e.layouts.fold((()=>({type:n,hotspot:o,overrides:r})),(e=>({type:n,hotspot:o,overrides:r,layouts:e})))},$x=(e,t,o,n,r,s,a)=>{const i=((e,t,o,n,r,s,a)=>{const i=((e,t,o)=>(0,e.fetch)(o).map(t))(e,t,n),l=Kx(n,e);return i.map((e=>e.bind((e=>M.from(_h.sketch({...s.menu(),uid:aa(""),data:e,highlightOnOpen:a,onOpenMenu:(e,t)=>{const n=l().getOrDie();ud.position(n,t,{anchor:o}),Nd.decloak(r)},onOpenSubmenu:(e,t,o)=>{const n=l().getOrDie();ud.position(n,o,{anchor:{type:"submenu",item:t}}),Nd.decloak(r)},onRepositionMenu:(e,t,n)=>{const r=l().getOrDie();ud.position(r,t,{anchor:o}),L(n,(e=>{ud.position(r,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem}})}))},onEscape:()=>(Up.focus(n),Nd.close(r),M.some(!0))}))))))})(e,t,Gx(e,o),o,n,r,a);return i.map((e=>(e.fold((()=>{Nd.isOpen(n)&&Nd.close(n)}),(e=>{Nd.cloak(n),Nd.open(n,e),s(n)})),n)))},qx=(e,t,o,n,r,s,a)=>(Nd.close(n),Ux(n)),Xx=(e,t,o,n,r,s)=>{const a=Nx.getCoupled(o,"sandbox");return(Nd.isOpen(a)?qx:$x)(e,t,o,a,n,r,s)},Kx=(e,t)=>e.getSystem().getByUid(t.uid+"-"+Wx()).map((e=>()=>Jo.value(e))).getOrThunk((()=>t.lazySink.fold((()=>()=>Jo.error(new Error("No internal sink is specified, nor could an external sink be found"))),(t=>()=>t(e))))),Yx=e=>{Nd.getState(e).each((e=>{_h.repositionMenus(e)}))},Jx=(e,t,o)=>{const n=ii(),r=Kx(t,e);return{dom:{tag:"div",classes:e.sandboxClasses,attributes:{id:n.id,role:"listbox"}},behaviours:iu(e.sandboxBehaviours,[ou.config({store:{mode:"memory",initialValue:t}}),Nd.config({onOpen:(r,s)=>{const a=Gx(e,t);n.link(t.element),e.matchWidth&&((e,t,o)=>{const n=cm.getCurrent(t).getOr(t),r=$t(e.element);o?_t(n.element,"min-width",r+"px"):((e,t)=>{Gt.set(e,t)})(n.element,r)})(a.hotspot,s,e.useMinWidth),e.onOpen(a,r,s),void 0!==o&&void 0!==o.onOpen&&o.onOpen(r,s)},onClose:(e,r)=>{n.unlink(t.element),void 0!==o&&void 0!==o.onClose&&o.onClose(e,r)},isPartOf:(e,o,n)=>li(o,n)||li(t,n),getAttachPoint:()=>r().getOrDie()}),cm.config({find:e=>Nd.getState(e).bind((e=>cm.getCurrent(e)))}),yl.config({channels:{...Pd({isExtraPart:_}),...Wd({doReposition:Yx})}})])}},Zx=e=>{const t=Nx.getCoupled(e,"sandbox");Yx(t)},Qx=()=>[ur("sandboxClasses",[]),au("sandboxBehaviours",[cm,yl,Nd,ou])],ew=y([Xn("dom"),Xn("fetch"),wi("onOpen"),Si("onExecute"),ur("getHotspot",M.some),ur("getAnchorOverrides",y({})),dc(),nu("dropdownBehaviours",[Yp,Nx,Tp,Up]),Xn("toggleClass"),ur("eventOrder",{}),nr("lazySink"),ur("matchWidth",!1),ur("useMinWidth",!1),nr("role")].concat(Qx())),tw=y([Du({schema:[vi(),ur("fakeFocus",!1)],name:"menu",defaults:e=>({onExecute:e.onExecute})}),jx()]),ow=sm({name:"Dropdown",configFields:ew(),partFields:tw(),factory:(e,t,o,n)=>{const r=e=>{Nd.getState(e).each((e=>{_h.highlightPrimary(e)}))},s=(t,o,r)=>Xx(e,x,t,n,o,r),a={expand:e=>{Yp.isOn(e)||s(e,b,Ch.HighlightNone).get(b)},open:e=>{Yp.isOn(e)||s(e,b,Ch.HighlightMenuAndItem).get(b)},refetch:t=>Nx.getExistingCoupled(t,"sandbox").fold((()=>s(t,b,Ch.HighlightMenuAndItem).map(b)),(o=>$x(e,x,t,o,n,b,Ch.HighlightMenuAndItem).map(b))),isOpen:Yp.isOn,close:e=>{Yp.isOn(e)&&s(e,b,Ch.HighlightMenuAndItem).get(b)},repositionMenus:e=>{Yp.isOn(e)&&Zx(e)}},i=(e,t)=>(_s(e),M.some(!0));return{uid:e.uid,dom:e.dom,components:t,behaviours:su(e.dropdownBehaviours,[Yp.config({toggleClass:e.toggleClass,aria:{mode:"expanded"}}),Nx.config({others:{sandbox:t=>Jx(e,t,{onOpen:()=>Yp.on(t),onClose:()=>Yp.off(t)})}}),Tp.config({mode:"special",onSpace:i,onEnter:i,onDown:(e,t)=>{if(ow.isOpen(e)){const t=Nx.getCoupled(e,"sandbox");r(t)}else ow.open(e);return M.some(!0)},onEscape:(e,t)=>ow.isOpen(e)?(ow.close(e),M.some(!0)):M.none()}),Up.config({})]),events:Zp(M.some((e=>{s(e,r,Ch.HighlightMenuAndItem).get(b)}))),eventOrder:{...e.eventOrder,[ns()]:["disabling","toggling","alloy.base.behaviour"]},apis:a,domModification:{attributes:{"aria-haspopup":"true",...e.role.fold((()=>({})),(e=>({role:e}))),..."button"===e.dom.tag?{type:("type",be(e.dom,"attributes").bind((e=>be(e,"type")))).getOr("button")}:{}}}}},apis:{open:(e,t)=>e.open(t),refetch:(e,t)=>e.refetch(t),expand:(e,t)=>e.expand(t),close:(e,t)=>e.close(t),isOpen:(e,t)=>e.isOpen(t),repositionMenus:(e,t)=>e.repositionMenus(t)}}),nw=(e,t,o)=>{kb(e).each((e=>{var n;((e,t)=>{wt(t.element,"id").each((t=>vt(e.element,"aria-activedescendant",t)))})(e,o),(Fa((n=t).element,_b)?M.some(n.element):ri(n.element,"."+_b)).each((t=>{wt(t,"id").each((t=>vt(e.element,"aria-controls",t)))}))})),vt(o.element,"aria-selected","true")},rw=(e,t,o)=>{vt(o.element,"aria-selected","false")},sw=e=>Nx.getExistingCoupled(e,"sandbox").bind(Sb).map(Cb).map((e=>e.fetchPattern)).getOr("");var aw;!function(e){e[e.ContentFocus=0]="ContentFocus",e[e.UiFocus=1]="UiFocus"}(aw||(aw={}));const iw=(e,t,o,n,r)=>{const s=o.shared.providers,a=e=>r?{...e,shortcut:M.none(),icon:e.text.isSome()?M.none():e.icon}:e;switch(e.type){case"menuitem":return(i=e,Ln("menuitem",zv,i)).fold(Fb,(e=>M.some(((e,t,o,n=!0)=>{const r=Sy({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:M.none(),ariaLabel:e.text,caret:M.none(),checkMark:M.none(),shortcutContent:e.shortcut},o,n);return my({data:gy(e),getApi:e=>({isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t)}),enabled:e.enabled,onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o)})(a(e),t,s,n))));case"nestedmenuitem":return(e=>Ln("nestedmenuitem",Lv,e))(e).fold(Fb,(e=>M.some(((e,t,o,n=!0,r=!1)=>{const s=r?(a=o.icons,hy("chevron-down",a,[rb])):(e=>hy("chevron-right",e,[rb]))(o.icons);var a;const i=Sy({presets:"normal",iconContent:e.icon,textContent:e.text,htmlContent:M.none(),ariaLabel:e.text,caret:M.some(s),checkMark:M.none(),shortcutContent:e.shortcut},o,n);return my({data:gy(e),getApi:e=>({isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t)}),enabled:e.enabled,onAction:b,onSetup:e.onSetup,triggersSubmenu:!0,itemBehaviours:[]},i,t,o)})(a(e),t,s,n,r))));case"togglemenuitem":return(e=>Ln("togglemenuitem",Pv,e))(e).fold(Fb,(e=>M.some(((e,t,o,n=!0)=>{const r=Sy({iconContent:e.icon,textContent:e.text,htmlContent:M.none(),ariaLabel:e.text,checkMark:M.some(xy(o.icons)),caret:M.none(),shortcutContent:e.shortcut,presets:"normal",meta:e.meta},o,n);return cn(my({data:gy(e),enabled:e.enabled,getApi:e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t)}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:[]},r,t,o),{toggling:{toggleClass:tb,toggleOnExecute:!1,selected:e.active}})})(a(e),t,s,n))));case"separator":return(e=>Ln("separatormenuitem",dv,e))(e).fold(Fb,(e=>M.some(Bx(e))));case"fancymenuitem":return(e=>Ln("fancymenuitem",Hv,e))(e).fold(Fb,(e=>((e,t)=>be(Dx,e.fancytype).map((o=>o(e,t))))(e,o)));default:return console.error("Unknown item in general menu",e),M.none()}var i},lw=(e,t,o,n,r,s,a)=>{const i=1===n,l=!i||Bb(e);return we(z(e,(e=>{switch(e.type){case"separator":return(n=e,Ln("Autocompleter.Separator",dv,n)).fold(Fb,(e=>M.some(Bx(e))));case"cardmenuitem":return(e=>Ln("cardmenuitem",Fv,e))(e).fold(Fb,(e=>M.some(((e,t,o,n)=>{const r={dom:wy(e.label),optComponents:[M.some({dom:{tag:"div",classes:[ab,ib]},components:Oy(e.items,n)})]};return my({data:gy({text:M.none(),...e}),enabled:e.enabled,getApi:e=>({isEnabled:()=>!km.isDisabled(e),setEnabled:t=>{km.set(e,!t),L(Nc(e.element,"*"),(o=>{e.getSystem().getByDom(o).each((e=>{e.hasConfigured(km)&&km.set(e,!t)}))}))}}),onAction:e.onAction,onSetup:e.onSetup,triggersSubmenu:!1,itemBehaviours:M.from(n.itemBehaviours).getOr([])},r,t,o.providers)})({...e,onAction:t=>{e.onAction(t),o(e.value,e.meta)}},r,s,{itemBehaviours:ky(e.meta,s),cardText:{matchText:t,highlightOn:a}}))));default:return(e=>Ln("Autocompleter.Item",uv,e))(e).fold(Fb,(e=>M.some(((e,t,o,n,r,s,a,i=!0)=>{const l=Sy({presets:n,textContent:M.none(),htmlContent:o?e.text.map((e=>Cy(e,t))):M.none(),ariaLabel:e.text,iconContent:e.icon,shortcutContent:M.none(),checkMark:M.none(),caret:M.none(),value:e.value},a.providers,i,e.icon);return my({data:gy(e),enabled:e.enabled,getApi:y({}),onAction:t=>r(e.value,e.meta),onSetup:y(b),triggersSubmenu:!1,itemBehaviours:ky(e.meta,a)},l,s,a.providers)})(e,t,i,"normal",o,r,s,l))))}var n})))},cw=(e,t,o,n,r,s)=>{const a=Bb(t),i=we(z(t,(e=>{const t=e=>iw(e,o,n,(e=>r?!ve(e,"text"):a)(e),r);return"nestedmenuitem"===e.type&&e.getSubmenuItems().length<=0?t({...e,enabled:!1}):t(e)}))),l=(e=>"no-search"===e.searchMode?{menuType:"normal"}:{menuType:"searchable",searchMode:e})(s);return(r?Ib:Rb)(e,a,i,1,l)},dw=e=>_h.singleData(e.value,e),uw=(e,t)=>{const o=xr(!1),n=xr(!1),r=Ka(Th.sketch({dom:{tag:"div",classes:["tox-autocompleter"]},components:[],fireDismissalEventInstead:{},inlineBehaviours:gl([Vp("dismissAutocompleter",[Fs(fs(),(()=>c()))])]),lazySink:t.getSink})),s=()=>Th.isOpen(r),a=n.get,i=()=>{s()&&Th.hide(r)},l=()=>Th.getContent(r).bind((e=>te(e.components(),0))),c=()=>e.execCommand("mceAutocompleterClose"),d=n=>{const s=(n=>{const r=se(n,(e=>M.from(e.columns))).getOr(1);return X(n,(n=>{const s=n.items;return lw(s,n.matchText,((t,r)=>{const s=e.selection.getRng();((e,t)=>Kf(Ie(t.startContainer)).map((t=>{const o=e.createRng();return o.selectNode(t.dom),o})))(e.dom,s).each((s=>{const a={hide:()=>c(),reload:t=>{i(),e.execCommand("mceAutocompleterReload",!1,{fetchOptions:t})}};o.set(!0),n.onAction(a,s,t,r),o.set(!1)}))}),r,Jf.BUBBLE_TO_SANDBOX,t,n.highlightOn)}))})(n);s.length>0?((t,o)=>{var n;(n=Ie(e.getBody()),ri(n,Xf)).each((n=>{const s=se(t,(e=>M.from(e.columns))).getOr(1);Th.showMenuAt(r,{anchor:{type:"node",root:Ie(e.getBody()),node:M.from(n)}},((e,t,o,n)=>{const r=Ox(t,n),s=ub(n);return{data:dw({...e,movement:r,menuBehaviours:Wv("auto"!==t?[]:[Ps(((e,t)=>{Uv(e,4,s.item).each((({numColumns:t,numRows:o})=>{Tp.setGridSize(e,o,t)}))}))])}),menu:{markers:ub(n),fakeFocus:o===aw.ContentFocus}}})(Rb("autocompleter-value",!0,o,s,{menuType:"normal"}),s,aw.ContentFocus,"normal"))})),l().each(Fm.highlightFirst)})(n,s):i()};e.on("AutocompleterStart",(({lookupData:e})=>{n.set(!0),o.set(!1),d(e)})),e.on("AutocompleterUpdate",(({lookupData:e})=>d(e))),e.on("AutocompleterEnd",(()=>{i(),n.set(!1),o.set(!1)}));((e,t)=>{const o=(e,t)=>{Os(e,Ur(),{raw:t})},n=()=>e.getMenu().bind(Fm.getHighlighted);t.on("keydown",(t=>{const r=t.which;e.isActive()&&(e.isMenuOpen()?13===r?(n().each(_s),t.preventDefault()):40===r?(n().fold((()=>{e.getMenu().each(Fm.highlightFirst)}),(e=>{o(e,t)})),t.preventDefault(),t.stopImmediatePropagation()):37!==r&&38!==r&&39!==r||n().each((e=>{o(e,t),t.preventDefault(),t.stopImmediatePropagation()})):13!==r&&38!==r&&40!==r||e.cancelIfNecessary())})),t.on("NodeChange",(t=>{e.isActive()&&!e.isProcessingAction()&&Kf(Ie(t.element)).isNone()&&e.cancelIfNecessary()}))})({cancelIfNecessary:c,isMenuOpen:s,isActive:a,isProcessingAction:o.get,getMenu:l},e)},mw=(e,t,o)=>si(e,t,o).isSome(),gw=(e,t)=>{let o=null;return{cancel:()=>{null!==o&&(clearTimeout(o),o=null)},schedule:(...n)=>{o=setTimeout((()=>{e.apply(null,n),o=null}),t)}}},pw=e=>{const t=e.raw;return void 0===t.touches||1!==t.touches.length?M.none():M.some(t.touches[0])},hw=(e,t)=>{const o={stopBackspace:!0,...t},n=(e=>{const t=Ul(),o=xr(!1),n=gw((t=>{e.triggerEvent(as(),t),o.set(!0)}),400),r=kr([{key:Dr(),value:e=>(pw(e).each((r=>{n.cancel();const s={x:r.clientX,y:r.clientY,target:e.target};n.schedule(e),o.set(!1),t.set(s)})),M.none())},{key:Br(),value:e=>(n.cancel(),pw(e).each((e=>{t.on((o=>{((e,t)=>{const o=Math.abs(e.clientX-t.x),n=Math.abs(e.clientY-t.y);return o>5||n>5})(e,o)&&t.clear()}))})),M.none())},{key:Fr(),value:r=>(n.cancel(),t.get().filter((e=>Xe(e.target,r.target))).map((t=>o.get()?(r.prevent(),!1):e.triggerEvent(ss(),r))))}]);return{fireIfReady:(e,t)=>be(r,t).bind((t=>t(e)))}})(o),r=z(["touchstart","touchmove","touchend","touchcancel","gesturestart","mousedown","mouseup","mouseover","mousemove","mouseout","click"].concat(["selectstart","input","contextmenu","change","transitionend","transitioncancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","keyup"]),(t=>jl(e,t,(e=>{n.fireIfReady(e,t).each((t=>{t&&e.kill()})),o.triggerEvent(t,e)&&e.kill()})))),s=Ul(),a=jl(e,"paste",(e=>{n.fireIfReady(e,"paste").each((t=>{t&&e.kill()})),o.triggerEvent("paste",e)&&e.kill(),s.set(setTimeout((()=>{o.triggerEvent(ts(),e)}),0))})),i=jl(e,"keydown",(e=>{o.triggerEvent("keydown",e)?e.kill():o.stopBackspace&&(e=>e.raw.which===Im[0]&&!R(["input","textarea"],ze(e.target))&&!mw(e.target,'[contenteditable="true"]'))(e)&&e.prevent()})),l=jl(e,"focusin",(e=>{o.triggerEvent("focusin",e)&&e.kill()})),c=Ul(),d=jl(e,"focusout",(e=>{o.triggerEvent("focusout",e)&&e.kill(),c.set(setTimeout((()=>{o.triggerEvent(es(),e)}),0))}));return{unbind:()=>{L(r,(e=>{e.unbind()})),i.unbind(),l.unbind(),d.unbind(),a.unbind(),s.on(clearTimeout),c.on(clearTimeout)}}},fw=(e,t)=>{const o=be(e,"target").getOr(t);return xr(o)},bw=wr([{stopped:[]},{resume:["element"]},{complete:[]}]),vw=(e,t,o,n,r,s)=>{const a=e(t,n),i=((e,t)=>{const o=xr(!1),n=xr(!1);return{stop:()=>{o.set(!0)},cut:()=>{n.set(!0)},isStopped:o.get,isCut:n.get,event:e,setSource:t.set,getSource:t.get}})(o,r);return a.fold((()=>(s.logEventNoHandlers(t,n),bw.complete())),(e=>{const o=e.descHandler;return xa(o)(i),i.isStopped()?(s.logEventStopped(t,e.element,o.purpose),bw.stopped()):i.isCut()?(s.logEventCut(t,e.element,o.purpose),bw.complete()):et(e.element).fold((()=>(s.logNoParent(t,e.element,o.purpose),bw.complete())),(n=>(s.logEventResponse(t,e.element,o.purpose),bw.resume(n))))}))},yw=(e,t,o,n,r,s)=>vw(e,t,o,n,r,s).fold(T,(n=>yw(e,t,o,n,r,s)),_),xw=(e,t,o,n,r)=>{const s=fw(o,n);return yw(e,t,o,n,s,r)},ww=()=>{const e=(()=>{const e={};return{registerId:(t,o,n)=>{le(n,((n,r)=>{const s=void 0!==e[r]?e[r]:{};s[o]=((e,t)=>({cHandler:S.apply(void 0,[e.handler].concat(t)),purpose:e.purpose}))(n,t),e[r]=s}))},unregisterId:t=>{le(e,((e,o)=>{ve(e,t)&&delete e[t]}))},filterByType:t=>be(e,t).map((e=>pe(e,((e,t)=>((e,t)=>({id:e,descHandler:t}))(t,e))))).getOr([]),find:(t,o,n)=>be(e,o).bind((e=>_r(n,(t=>((e,t)=>sa(t).bind((t=>be(e,t))).map((e=>((e,t)=>({element:e,descHandler:t}))(t,e))))(e,t)),t)))}})(),t={},o=o=>{sa(o.element).each((o=>{delete t[o],e.unregisterId(o)}))};return{find:(t,o,n)=>e.find(t,o,n),filter:t=>e.filterByType(t),register:n=>{const r=(e=>{const t=e.element;return sa(t).getOrThunk((()=>((e,t)=>{const o=Qs(oa+"uid-");return ra(t,o),o})(0,e.element)))})(n);ye(t,r)&&((e,n)=>{const r=t[n];if(r!==e)throw new Error('The tagId "'+n+'" is already used by: '+Xs(r.element)+"\nCannot use it for: "+Xs(e.element)+"\nThe conflicting element is"+(pt(r.element)?" ":" not ")+"already in the DOM");o(e)})(n,r);const s=[n];e.registerId(s,r,n.events),t[r]=n},unregister:o,getById:e=>be(t,e)}},Sw=rm({name:"Container",factory:e=>{const{attributes:t,...o}=e.dom;return{uid:e.uid,dom:{tag:"div",attributes:{role:"presentation",...t},...o},components:e.components,behaviours:ru(e.containerBehaviours),events:e.events,domModification:e.domModification,eventOrder:e.eventOrder}},configFields:[ur("components",[]),nu("containerBehaviours",[]),ur("events",{}),ur("domModification",{}),ur("eventOrder",{})]}),kw=e=>{const t=t=>et(e.element).fold(T,(e=>Xe(t,e))),o=ww(),n=(e,n)=>o.find(t,e,n),r=hw(e.element,{triggerEvent:(e,t)=>mi(e,t.target,(o=>((e,t,o,n)=>xw(e,t,o,o.target,n))(n,e,t,o)))}),s={debugInfo:y("real"),triggerEvent:(e,t,o)=>{mi(e,t,(r=>xw(n,e,o,t,r)))},triggerFocus:(e,t)=>{sa(e).fold((()=>{wl(e)}),(o=>{mi(Qr(),e,(o=>(((e,t,o,n,r)=>{const s=fw(o,n);vw(e,t,o,n,s,r)})(n,Qr(),{originator:t,kill:b,prevent:b,target:e},e,o),!1)))}))},triggerEscape:(e,t)=>{s.triggerEvent("keydown",e.element,t.event)},getByUid:e=>p(e),getByDom:e=>h(e),build:Ka,buildOrPatch:Xa,addToGui:e=>{l(e)},removeFromGui:e=>{c(e)},addToWorld:e=>{a(e)},removeFromWorld:e=>{i(e)},broadcast:e=>{u(e)},broadcastOn:(e,t)=>{m(e,t)},broadcastEvent:(e,t)=>{g(e,t)},isConnected:T},a=e=>{e.connect(s),Ue(e.element)||(o.register(e),L(e.components(),a),s.triggerEvent(cs(),e.element,{target:e.element}))},i=e=>{Ue(e.element)||(L(e.components(),i),o.unregister(e)),e.disconnect()},l=t=>{vd(e,t)},c=e=>{wd(e)},d=e=>{const t=o.filter(os());L(t,(t=>{const o=t.descHandler;xa(o)(e)}))},u=e=>{d({universal:!0,data:e})},m=(e,t)=>{d({universal:!1,channels:e,data:t})},g=(e,t)=>((e,t,o)=>{const n=(e=>{const t=xr(!1);return{stop:()=>{t.set(!0)},cut:b,isStopped:t.get,isCut:_,event:e,setSource:C("Cannot set source of a broadcasted event"),getSource:C("Cannot get source of a broadcasted event")}})(t);return L(e,(e=>{const t=e.descHandler;xa(t)(n)})),n.isStopped()})(o.filter(e),t),p=e=>o.getById(e).fold((()=>Jo.error(new Error('Could not find component with uid: "'+e+'" in system.'))),Jo.value),h=e=>{const t=sa(e).getOr("not found");return p(t)};return a(e),{root:e,element:e.element,destroy:()=>{r.unbind(),No(e.element)},add:l,remove:c,getByUid:p,getByDom:h,addToWorld:a,removeFromWorld:i,broadcast:u,broadcastOn:m,broadcastEvent:g}},Cw=y([ur("prefix","form-field"),nu("fieldBehaviours",[cm,ou])]),Ow=y([Bu({schema:[Xn("dom")],name:"label"}),Bu({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[Xn("text")],name:"aria-descriptor"}),Au({factory:{sketch:e=>{const t=((e,t)=>{const o={};return le(e,((e,n)=>{R(t,n)||(o[n]=e)})),o})(e,["factory"]);return e.factory.sketch(t)}},schema:[Xn("factory")],name:"field"})]),_w=sm({name:"FormField",configFields:Cw(),partFields:Ow(),factory:(e,t,o,n)=>{const r=su(e.fieldBehaviours,[cm.config({find:t=>ju(t,e,"field")}),ou.config({store:{mode:"manual",getValue:e=>cm.getCurrent(e).bind(ou.getValue),setValue:(e,t)=>{cm.getCurrent(e).each((e=>{ou.setValue(e,t)}))}}})]),s=As([Ps(((t,o)=>{const n=$u(t,e,["label","field","aria-descriptor"]);n.field().each((t=>{const o=Qs(e.prefix);n.label().each((e=>{vt(e.element,"for",o),vt(t.element,"id",o)})),n["aria-descriptor"]().each((o=>{const n=Qs(e.prefix);vt(o.element,"id",n),vt(t.element,"aria-describedby",n)}))}))}))]),a={getField:t=>ju(t,e,"field"),getLabel:t=>ju(t,e,"label")};return{uid:e.uid,dom:e.dom,components:t,behaviours:r,events:s,apis:a}},apis:{getField:(e,t)=>e.getField(t),getLabel:(e,t)=>e.getLabel(t)}});var Tw=Object.freeze({__proto__:null,exhibit:(e,t)=>ya({attributes:kr([{key:t.tabAttr,value:"true"}])})}),Ew=[ur("tabAttr","data-alloy-tabstop")];const Mw=hl({fields:Ew,name:"tabstopping",active:Tw});var Aw=tinymce.util.Tools.resolve("tinymce.html.Entities");const Dw=(e,t,o,n)=>{const r=Bw(e,t,o,n);return _w.sketch(r)},Bw=(e,t,o,n)=>({dom:Fw(o),components:e.toArray().concat([t]),fieldBehaviours:gl(n)}),Fw=e=>({tag:"div",classes:["tox-form__group"].concat(e)}),Iw=(e,t)=>_w.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[Ga(t.translate(e))]}),Rw=Qs("form-component-change"),Nw=Qs("form-close"),Vw=Qs("form-cancel"),Hw=Qs("form-action"),zw=Qs("form-submit"),Lw=Qs("form-block"),Pw=Qs("form-unblock"),Uw=Qs("form-tabchange"),Ww=Qs("form-resize"),jw=["input","textarea"],Gw=e=>{const t=ze(e);return R(jw,t)},$w=(e,t)=>{const o=t.getRoot(e).getOr(e.element);Ba(o,t.invalidClass),t.notify.each((t=>{Gw(e.element)&&vt(e.element,"aria-invalid",!1),t.getContainer(e).each((e=>{$s(e,t.validHtml)})),t.onValid(e)}))},qw=(e,t,o,n)=>{const r=t.getRoot(e).getOr(e.element);Da(r,t.invalidClass),t.notify.each((t=>{Gw(e.element)&&vt(e.element,"aria-invalid",!0),t.getContainer(e).each((e=>{$s(e,n)})),t.onInvalid(e,n)}))},Xw=(e,t,o)=>t.validator.fold((()=>Ux(Jo.value(!0))),(t=>t.validate(e))),Kw=(e,t,o)=>(t.notify.each((t=>{t.onValidate(e)})),Xw(e,t).map((o=>e.getSystem().isConnected()?o.fold((o=>(qw(e,t,0,o),Jo.error(o))),(o=>($w(e,t),Jo.value(o)))):Jo.error("No longer in system"))));var Yw=Object.freeze({__proto__:null,markValid:$w,markInvalid:qw,query:Xw,run:Kw,isInvalid:(e,t)=>{const o=t.getRoot(e).getOr(e.element);return Fa(o,t.invalidClass)}}),Jw=Object.freeze({__proto__:null,events:(e,t)=>e.validator.map((t=>As([Fs(t.onEvent,(t=>{Kw(t,e).get(x)}))].concat(t.validateOnLoad?[Ps((t=>{Kw(t,e).get(b)}))]:[])))).getOr({})}),Zw=[Xn("invalidClass"),ur("getRoot",M.none),dr("notify",[ur("aria","alert"),ur("getContainer",M.none),ur("validHtml",""),wi("onValid"),wi("onInvalid"),wi("onValidate")]),dr("validator",[Xn("validate"),ur("onEvent","input"),ur("validateOnLoad",!0)])];const Qw=hl({fields:Zw,name:"invalidating",active:Jw,apis:Yw,extra:{validation:e=>t=>{const o=ou.getValue(t);return Ux(e(o))}}}),eS=hl({fields:[],name:"unselecting",active:Object.freeze({__proto__:null,events:()=>As([Ds(Yr(),T)]),exhibit:()=>ya({styles:{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{unselectable:"on"}})})}),tS=Qs("color-input-change"),oS=Qs("color-swatch-change"),nS=Qs("color-picker-cancel"),rS=Bu({schema:[Xn("dom")],name:"label"}),sS=e=>Bu({name:e+"-edge",overrides:t=>t.model.manager.edgeActions[e].fold((()=>({})),(e=>({events:As([Is(Dr(),((t,o,n)=>e(t,n)),[t]),Is(Rr(),((t,o,n)=>e(t,n)),[t]),Is(Nr(),((t,o,n)=>{n.mouseIsDown.get()&&e(t,n)}),[t])])})))}),aS=sS("top-left"),iS=sS("top"),lS=sS("top-right"),cS=sS("right"),dS=sS("bottom-right"),uS=sS("bottom"),mS=sS("bottom-left");var gS=[rS,sS("left"),cS,iS,uS,aS,lS,mS,dS,Au({name:"thumb",defaults:y({dom:{styles:{position:"absolute"}}}),overrides:e=>({events:As([Ns(Dr(),e,"spectrum"),Ns(Br(),e,"spectrum"),Ns(Fr(),e,"spectrum"),Ns(Rr(),e,"spectrum"),Ns(Nr(),e,"spectrum"),Ns(Hr(),e,"spectrum")])})}),Au({schema:[$n("mouseIsDown",(()=>xr(!1)))],name:"spectrum",overrides:e=>{const t=e.model.manager,o=(o,n)=>t.getValueFromEvent(n).map((n=>t.setValueFrom(o,e,n)));return{behaviours:gl([Tp.config({mode:"special",onLeft:o=>t.onLeft(o,e),onRight:o=>t.onRight(o,e),onUp:o=>t.onUp(o,e),onDown:o=>t.onDown(o,e)}),Up.config({})]),events:As([Fs(Dr(),o),Fs(Br(),o),Fs(Rr(),o),Fs(Nr(),((t,n)=>{e.mouseIsDown.get()&&o(t,n)}))])}}})];const pS=y("slider.change.value"),hS=e=>{const t=e.event.raw;if((e=>-1!==e.type.indexOf("touch"))(t)){const e=t;return void 0!==e.touches&&1===e.touches.length?M.some(e.touches[0]).map((e=>Pt(e.clientX,e.clientY))):M.none()}{const e=t;return void 0!==e.clientX?M.some(e).map((e=>Pt(e.clientX,e.clientY))):M.none()}},fS=e=>e.model.minX,bS=e=>e.model.minY,vS=e=>e.model.minX-1,yS=e=>e.model.minY-1,xS=e=>e.model.maxX,wS=e=>e.model.maxY,SS=e=>e.model.maxX+1,kS=e=>e.model.maxY+1,CS=(e,t,o)=>t(e)-o(e),OS=e=>CS(e,xS,fS),_S=e=>CS(e,wS,bS),TS=e=>OS(e)/2,ES=e=>_S(e)/2,MS=e=>e.stepSize,AS=e=>e.snapToGrid,DS=e=>e.snapStart,BS=e=>e.rounded,FS=(e,t)=>void 0!==e[t+"-edge"],IS=e=>FS(e,"left"),RS=e=>FS(e,"right"),NS=e=>FS(e,"top"),VS=e=>FS(e,"bottom"),HS=e=>e.model.value.get(),zS=(e,t)=>({x:e,y:t}),LS=(e,t)=>{Os(e,pS(),{value:t})},PS=(e,t,o,n)=>e<t?e:e>o?o:e===t?t-1:Math.max(t,e-n),US=(e,t,o,n)=>e>o?e:e<t?t:e===o?o+1:Math.min(o,e+n),WS=(e,t,o)=>Math.max(t,Math.min(o,e)),jS=e=>{const{min:t,max:o,range:n,value:r,step:s,snap:a,snapStart:i,rounded:l,hasMinEdge:c,hasMaxEdge:d,minBound:u,maxBound:m,screenRange:g}=e,p=c?t-1:t,h=d?o+1:o;if(r<u)return p;if(r>m)return h;{const e=((e,t,o)=>Math.min(o,Math.max(e,t))-t)(r,u,m),c=WS(e/g*n+t,p,h);return a&&c>=t&&c<=o?((e,t,o,n,r)=>r.fold((()=>{const r=e-t,s=Math.round(r/n)*n;return WS(t+s,t-1,o+1)}),(t=>{const r=(e-t)%n,s=Math.round(r/n),a=Math.floor((e-t)/n),i=Math.floor((o-t)/n),l=t+Math.min(i,a+s)*n;return Math.max(t,l)})))(c,t,o,s,i):l?Math.round(c):c}},GS=e=>{const{min:t,max:o,range:n,value:r,hasMinEdge:s,hasMaxEdge:a,maxBound:i,maxOffset:l,centerMinEdge:c,centerMaxEdge:d}=e;return r<t?s?0:c:r>o?a?i:d:(r-t)/n*l},$S="top",qS="right",XS="bottom",KS="left",YS=e=>e.element.dom.getBoundingClientRect(),JS=(e,t)=>e[t],ZS=e=>{const t=YS(e);return JS(t,KS)},QS=e=>{const t=YS(e);return JS(t,qS)},ek=e=>{const t=YS(e);return JS(t,$S)},tk=e=>{const t=YS(e);return JS(t,XS)},ok=e=>{const t=YS(e);return JS(t,"width")},nk=e=>{const t=YS(e);return JS(t,"height")},rk=(e,t,o)=>(e+t)/2-o,sk=(e,t)=>{const o=YS(e),n=YS(t),r=JS(o,KS),s=JS(o,qS),a=JS(n,KS);return rk(r,s,a)},ak=(e,t)=>{const o=YS(e),n=YS(t),r=JS(o,$S),s=JS(o,XS),a=JS(n,$S);return rk(r,s,a)},ik=(e,t)=>{Os(e,pS(),{value:t})},lk=(e,t,o)=>{const n={min:fS(t),max:xS(t),range:OS(t),value:o,step:MS(t),snap:AS(t),snapStart:DS(t),rounded:BS(t),hasMinEdge:IS(t),hasMaxEdge:RS(t),minBound:ZS(e),maxBound:QS(e),screenRange:ok(e)};return jS(n)},ck=e=>(t,o)=>((e,t,o)=>{const n=(e>0?US:PS)(HS(o),fS(o),xS(o),MS(o));return ik(t,n),M.some(n)})(e,t,o).map(T),dk=(e,t,o,n,r,s)=>{const a=((e,t,o,n,r)=>{const s=ok(e),a=n.bind((t=>M.some(sk(t,e)))).getOr(0),i=r.bind((t=>M.some(sk(t,e)))).getOr(s),l={min:fS(t),max:xS(t),range:OS(t),value:o,hasMinEdge:IS(t),hasMaxEdge:RS(t),minBound:ZS(e),minOffset:0,maxBound:QS(e),maxOffset:s,centerMinEdge:a,centerMaxEdge:i};return GS(l)})(t,s,o,n,r);return ZS(t)-ZS(e)+a},uk=ck(-1),mk=ck(1),gk=M.none,pk=M.none,hk={"top-left":M.none(),top:M.none(),"top-right":M.none(),right:M.some(((e,t)=>{LS(e,SS(t))})),"bottom-right":M.none(),bottom:M.none(),"bottom-left":M.none(),left:M.some(((e,t)=>{LS(e,vS(t))}))};var fk=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=lk(e,t,o);return ik(e,n),n},setToMin:(e,t)=>{const o=fS(t);ik(e,o)},setToMax:(e,t)=>{const o=xS(t);ik(e,o)},findValueOfOffset:lk,getValueFromEvent:e=>hS(e).map((e=>e.left)),findPositionOfValue:dk,setPositionFromValue:(e,t,o,n)=>{const r=HS(o),s=dk(e,n.getSpectrum(e),r,n.getLeftEdge(e),n.getRightEdge(e),o),a=$t(t.element)/2;_t(t.element,"left",s-a+"px")},onLeft:uk,onRight:mk,onUp:gk,onDown:pk,edgeActions:hk});const bk=(e,t)=>{Os(e,pS(),{value:t})},vk=(e,t,o)=>{const n={min:bS(t),max:wS(t),range:_S(t),value:o,step:MS(t),snap:AS(t),snapStart:DS(t),rounded:BS(t),hasMinEdge:NS(t),hasMaxEdge:VS(t),minBound:ek(e),maxBound:tk(e),screenRange:nk(e)};return jS(n)},yk=e=>(t,o)=>((e,t,o)=>{const n=(e>0?US:PS)(HS(o),bS(o),wS(o),MS(o));return bk(t,n),M.some(n)})(e,t,o).map(T),xk=(e,t,o,n,r,s)=>{const a=((e,t,o,n,r)=>{const s=nk(e),a=n.bind((t=>M.some(ak(t,e)))).getOr(0),i=r.bind((t=>M.some(ak(t,e)))).getOr(s),l={min:bS(t),max:wS(t),range:_S(t),value:o,hasMinEdge:NS(t),hasMaxEdge:VS(t),minBound:ek(e),minOffset:0,maxBound:tk(e),maxOffset:s,centerMinEdge:a,centerMaxEdge:i};return GS(l)})(t,s,o,n,r);return ek(t)-ek(e)+a},wk=M.none,Sk=M.none,kk=yk(-1),Ck=yk(1),Ok={"top-left":M.none(),top:M.some(((e,t)=>{LS(e,yS(t))})),"top-right":M.none(),right:M.none(),"bottom-right":M.none(),bottom:M.some(((e,t)=>{LS(e,kS(t))})),"bottom-left":M.none(),left:M.none()};var _k=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=vk(e,t,o);return bk(e,n),n},setToMin:(e,t)=>{const o=bS(t);bk(e,o)},setToMax:(e,t)=>{const o=wS(t);bk(e,o)},findValueOfOffset:vk,getValueFromEvent:e=>hS(e).map((e=>e.top)),findPositionOfValue:xk,setPositionFromValue:(e,t,o,n)=>{const r=HS(o),s=xk(e,n.getSpectrum(e),r,n.getTopEdge(e),n.getBottomEdge(e),o),a=Ht(t.element)/2;_t(t.element,"top",s-a+"px")},onLeft:wk,onRight:Sk,onUp:kk,onDown:Ck,edgeActions:Ok});const Tk=(e,t)=>{Os(e,pS(),{value:t})},Ek=(e,t)=>({x:e,y:t}),Mk=(e,t)=>(o,n)=>((e,t,o,n)=>{const r=e>0?US:PS,s=t?HS(n).x:r(HS(n).x,fS(n),xS(n),MS(n)),a=t?r(HS(n).y,bS(n),wS(n),MS(n)):HS(n).y;return Tk(o,Ek(s,a)),M.some(s)})(e,t,o,n).map(T),Ak=Mk(-1,!1),Dk=Mk(1,!1),Bk=Mk(-1,!0),Fk=Mk(1,!0),Ik={"top-left":M.some(((e,t)=>{LS(e,zS(vS(t),yS(t)))})),top:M.some(((e,t)=>{LS(e,zS(TS(t),yS(t)))})),"top-right":M.some(((e,t)=>{LS(e,zS(SS(t),yS(t)))})),right:M.some(((e,t)=>{LS(e,zS(SS(t),ES(t)))})),"bottom-right":M.some(((e,t)=>{LS(e,zS(SS(t),kS(t)))})),bottom:M.some(((e,t)=>{LS(e,zS(TS(t),kS(t)))})),"bottom-left":M.some(((e,t)=>{LS(e,zS(vS(t),kS(t)))})),left:M.some(((e,t)=>{LS(e,zS(vS(t),ES(t)))}))};var Rk=Object.freeze({__proto__:null,setValueFrom:(e,t,o)=>{const n=lk(e,t,o.left),r=vk(e,t,o.top),s=Ek(n,r);return Tk(e,s),s},setToMin:(e,t)=>{const o=fS(t),n=bS(t);Tk(e,Ek(o,n))},setToMax:(e,t)=>{const o=xS(t),n=wS(t);Tk(e,Ek(o,n))},getValueFromEvent:e=>hS(e),setPositionFromValue:(e,t,o,n)=>{const r=HS(o),s=dk(e,n.getSpectrum(e),r.x,n.getLeftEdge(e),n.getRightEdge(e),o),a=xk(e,n.getSpectrum(e),r.y,n.getTopEdge(e),n.getBottomEdge(e),o),i=$t(t.element)/2,l=Ht(t.element)/2;_t(t.element,"left",s-i+"px"),_t(t.element,"top",a-l+"px")},onLeft:Ak,onRight:Dk,onUp:Bk,onDown:Fk,edgeActions:Ik});const Nk=sm({name:"Slider",configFields:[ur("stepSize",1),ur("onChange",b),ur("onChoose",b),ur("onInit",b),ur("onDragStart",b),ur("onDragEnd",b),ur("snapToGrid",!1),ur("rounded",!0),nr("snapStart"),Kn("model",jn("mode",{x:[ur("minX",0),ur("maxX",100),$n("value",(e=>xr(e.mode.minX))),Xn("getInitialValue"),Oi("manager",fk)],y:[ur("minY",0),ur("maxY",100),$n("value",(e=>xr(e.mode.minY))),Xn("getInitialValue"),Oi("manager",_k)],xy:[ur("minX",0),ur("maxX",100),ur("minY",0),ur("maxY",100),$n("value",(e=>xr({x:e.mode.minX,y:e.mode.minY}))),Xn("getInitialValue"),Oi("manager",Rk)]})),nu("sliderBehaviours",[Tp,ou]),$n("mouseIsDown",(()=>xr(!1)))],partFields:gS,factory:(e,t,o,n)=>{const r=t=>Gu(t,e,"thumb"),s=t=>Gu(t,e,"spectrum"),a=t=>ju(t,e,"left-edge"),i=t=>ju(t,e,"right-edge"),l=t=>ju(t,e,"top-edge"),c=t=>ju(t,e,"bottom-edge"),d=e.model,u=d.manager,m=(t,o)=>{u.setPositionFromValue(t,o,e,{getLeftEdge:a,getRightEdge:i,getTopEdge:l,getBottomEdge:c,getSpectrum:s})},g=(e,t)=>{d.value.set(t);const o=r(e);m(e,o)},p=t=>{const o=e.mouseIsDown.get();e.mouseIsDown.set(!1),o&&ju(t,e,"thumb").each((o=>{const n=d.value.get();e.onChoose(t,o,n)}))},h=(t,o)=>{o.stop(),e.mouseIsDown.set(!0),e.onDragStart(t,r(t))},f=(t,o)=>{o.stop(),e.onDragEnd(t,r(t)),p(t)};return{uid:e.uid,dom:e.dom,components:t,behaviours:su(e.sliderBehaviours,[Tp.config({mode:"special",focusIn:t=>ju(t,e,"spectrum").map(Tp.focusIn).map(T)}),ou.config({store:{mode:"manual",getValue:e=>d.value.get(),setValue:g}}),yl.config({channels:{[zd()]:{onReceive:p}}})]),events:As([Fs(pS(),((t,o)=>{((t,o)=>{g(t,o);const n=r(t);e.onChange(t,n,o),M.some(!0)})(t,o.event.value)})),Ps(((t,o)=>{const n=d.getInitialValue();d.value.set(n);const a=r(t);m(t,a);const i=s(t);e.onInit(t,a,i,d.value.get())})),Fs(Dr(),h),Fs(Fr(),f),Fs(Rr(),h),Fs(Hr(),f)]),apis:{resetToMin:t=>{u.setToMin(t,e)},resetToMax:t=>{u.setToMax(t,e)},setValue:g,refresh:m},domModification:{styles:{position:"relative"}}}},apis:{setValue:(e,t,o)=>{e.setValue(t,o)},resetToMin:(e,t)=>{e.resetToMin(t)},resetToMax:(e,t)=>{e.resetToMax(t)},refresh:(e,t)=>{e.refresh(t)}}}),Vk=Qs("rgb-hex-update"),Hk=Qs("slider-update"),zk=Qs("palette-update"),Lk="form",Pk=[nu("formBehaviours",[ou])],Uk=e=>"<alloy.field."+e+">",Wk=(e,t)=>({uid:e.uid,dom:e.dom,components:t,behaviours:su(e.formBehaviours,[ou.config({store:{mode:"manual",getValue:t=>{const o=qu(t,e);return ce(o,((e,t)=>e().bind((e=>{return o=cm.getCurrent(e),n=new Error(`Cannot find a current component to extract the value from for form part '${t}': `+Xs(e.element)),o.fold((()=>Jo.error(n)),Jo.value);var o,n})).map(ou.getValue)))},setValue:(t,o)=>{le(o,((o,n)=>{ju(t,e,n).each((e=>{cm.getCurrent(e).each((e=>{ou.setValue(e,o)}))}))}))}}})]),apis:{getField:(t,o)=>ju(t,e,o).bind(cm.getCurrent)}}),jk={getField:ha(((e,t,o)=>e.getField(t,o))),sketch:e=>{const t=(()=>{const e=[];return{field:(t,o)=>(e.push(t),zu(Lk,Uk(t),o)),record:y(e)}})(),o=e(t),n=t.record(),r=z(n,(e=>Au({name:e,pname:Uk(e)})));return em(Lk,Pk,r,Wk,o)}},Gk=Qs("valid-input"),$k=Qs("invalid-input"),qk=Qs("validating-input"),Xk="colorcustom.rgb.",Kk=(e,t,o,n)=>{const r=(o,n)=>Qw.config({invalidClass:t("invalid"),notify:{onValidate:e=>{Os(e,qk,{type:o})},onValid:e=>{Os(e,Gk,{type:o,value:ou.getValue(e)})},onInvalid:e=>{Os(e,$k,{type:o,value:ou.getValue(e)})}},validator:{validate:t=>{const o=ou.getValue(t),r=n(o)?Jo.value(!0):Jo.error(e("aria.input.invalid"));return Ux(r)},validateOnLoad:!1}}),s=(o,n,s,a,i)=>{const l=e("colorcustom.rgb.range"),c=_w.parts.label({dom:{tag:"label",attributes:{"aria-label":a}},components:[Ga(s)]}),d=_w.parts.field({data:i,factory:yb,inputAttributes:{type:"text",..."hex"===n?{"aria-live":"polite"}:{}},inputClasses:[t("textfield")],inputBehaviours:gl([r(n,o),Mw.config({})]),onSetValue:e=>{Qw.isInvalid(e)&&Qw.run(e).get(b)}}),u=[c,d],m="hex"!==n?[_w.parts["aria-descriptor"]({text:l})]:[];return{dom:{tag:"div",attributes:{role:"presentation"}},components:u.concat(m)}},a=(e,t)=>{const o=t.red,n=t.green,r=t.blue;ou.setValue(e,{red:o,green:n,blue:r})},i=Ah({dom:{tag:"div",classes:[t("rgba-preview")],styles:{"background-color":"white"},attributes:{role:"presentation"}}}),l=(e,t)=>{i.getOpt(e).each((e=>{_t(e.element,"background-color","#"+t.value)}))},c=rm({factory:()=>{const r={red:xr(M.some(255)),green:xr(M.some(255)),blue:xr(M.some(255)),hex:xr(M.some("ffffff"))},c=e=>r[e].get(),d=(e,t)=>{r[e].set(t)},u=e=>{const t=e.red,o=e.green,n=e.blue;d("red",M.some(t)),d("green",M.some(o)),d("blue",M.some(n))},m=(e,t)=>{const o=t.event;"hex"!==o.type?d(o.type,M.none()):n(e)},g=(e,t)=>{const n=t.event;(e=>"hex"===e.type)(n)?((e,t)=>{o(e);const n=Ty(t);d("hex",M.some(t));const r=Uy(n);a(e,r),u(r),Os(e,Vk,{hex:n}),l(e,n)})(e,n.value):((e,t,o)=>{const n=parseInt(o,10);d(t,M.some(n)),c("red").bind((e=>c("green").bind((t=>c("blue").map((o=>zy(e,t,o,1))))))).each((t=>{const o=((e,t)=>{const o=Fy(t);return jk.getField(e,"hex").each((t=>{Up.isFocused(t)||ou.setValue(e,{hex:o.value})})),o})(e,t);Os(e,Vk,{hex:o}),l(e,o)}))})(e,n.type,n.value)},p=t=>({label:e(Xk+t+".label"),description:e(Xk+t+".description")}),h=p("red"),f=p("green"),b=p("blue"),v=p("hex");return cn(jk.sketch((o=>({dom:{tag:"form",classes:[t("rgb-form")],attributes:{"aria-label":e("aria.color.picker")}},components:[o.field("red",_w.sketch(s(Ly,"red",h.label,h.description,255))),o.field("green",_w.sketch(s(Ly,"green",f.label,f.description,255))),o.field("blue",_w.sketch(s(Ly,"blue",b.label,b.description,255))),o.field("hex",_w.sketch(s(Ay,"hex",v.label,v.description,"ffffff"))),i.asSpec()],formBehaviours:gl([Qw.config({invalidClass:t("form-invalid")}),Vp("rgb-form-events",[Fs(Gk,g),Fs($k,m),Fs(qk,m)])])}))),{apis:{updateHex:(e,t)=>{ou.setValue(e,{hex:t.value}),((e,t)=>{const o=Uy(t);a(e,o),u(o)})(e,t),l(e,t)}}})},name:"RgbForm",configFields:[],apis:{updateHex:(e,t,o)=>{e.updateHex(t,o)}},extraApis:{}});return c},Yk=(e,t)=>{const o=rm({name:"ColourPicker",configFields:[Xn("dom"),ur("onValidHex",b),ur("onInvalidHex",b)],factory:o=>{const n=Kk(e,t,o.onValidHex,o.onInvalidHex),r=((e,t)=>{const o=Nk.parts.spectrum({dom:{tag:"canvas",attributes:{role:"presentation"},classes:[t("sv-palette-spectrum")]}}),n=Nk.parts.thumb({dom:{tag:"div",attributes:{role:"presentation"},classes:[t("sv-palette-thumb")],innerHtml:`<div class=${t("sv-palette-inner-thumb")} role="presentation"></div>`}}),r=(e,t)=>{const{width:o,height:n}=e,r=e.getContext("2d");if(null===r)return;r.fillStyle=t,r.fillRect(0,0,o,n);const s=r.createLinearGradient(0,0,o,0);s.addColorStop(0,"rgba(255,255,255,1)"),s.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=s,r.fillRect(0,0,o,n);const a=r.createLinearGradient(0,0,0,n);a.addColorStop(0,"rgba(0,0,0,0)"),a.addColorStop(1,"rgba(0,0,0,1)"),r.fillStyle=a,r.fillRect(0,0,o,n)};return rm({factory:e=>{const s=y({x:0,y:0}),a=gl([cm.config({find:M.some}),Up.config({})]);return Nk.sketch({dom:{tag:"div",attributes:{role:"presentation"},classes:[t("sv-palette")]},model:{mode:"xy",getInitialValue:s},rounded:!1,components:[o,n],onChange:(e,t,o)=>{Os(e,zk,{value:o})},onInit:(e,t,o,n)=>{r(o.element.dom,Gy($y))},sliderBehaviours:a})},name:"SaturationBrightnessPalette",configFields:[],apis:{setHue:(e,t,o)=>{((e,t)=>{const o=e.components()[0].element.dom,n=Qy(t,100,100),s=Py(n);r(o,Gy(s))})(t,o)},setThumb:(e,t,o)=>{((e,t)=>{const o=ex(Uy(t));Nk.setValue(e,{x:o.saturation,y:100-o.value})})(t,o)}},extraApis:{}})})(0,t),s={paletteRgba:xr($y),paletteHue:xr(0)},a=Ah(((e,t)=>{const o=Nk.parts.spectrum({dom:{tag:"div",classes:[t("hue-slider-spectrum")],attributes:{role:"presentation"}}}),n=Nk.parts.thumb({dom:{tag:"div",classes:[t("hue-slider-thumb")],attributes:{role:"presentation"}}});return Nk.sketch({dom:{tag:"div",classes:[t("hue-slider")],attributes:{role:"presentation"}},rounded:!1,model:{mode:"y",getInitialValue:y(0)},components:[o,n],sliderBehaviours:gl([Up.config({})]),onChange:(e,t,o)=>{Os(e,Hk,{value:o})}})})(0,t)),i=Ah(r.sketch({})),l=Ah(n.sketch({})),c=(e,t,o)=>{i.getOpt(e).each((e=>{r.setHue(e,o)}))},d=(e,t)=>{l.getOpt(e).each((e=>{n.updateHex(e,t)}))},u=(e,t,o)=>{a.getOpt(e).each((e=>{Nk.setValue(e,(e=>100-e/360*100)(o))}))},m=(e,t)=>{i.getOpt(e).each((e=>{r.setThumb(e,t)}))},g=(e,t,o,n)=>{((e,t)=>{const o=Uy(e);s.paletteRgba.set(o),s.paletteHue.set(t)})(t,o),L(n,(n=>{n(e,t,o)}))};return{uid:o.uid,dom:o.dom,components:[i.asSpec(),a.asSpec(),l.asSpec()],behaviours:gl([Vp("colour-picker-events",[Fs(Vk,(()=>{const e=[c,u,m];return(t,o)=>{const n=o.event.hex,r=(e=>ex(Uy(e)))(n);g(t,n,r.hue,e)}})()),Fs(zk,(()=>{const e=[d];return(t,o)=>{const n=o.event.value,r=s.paletteHue.get(),a=Qy(r,n.x,100-n.y),i=tx(a);g(t,i,r,e)}})()),Fs(Hk,(()=>{const e=[c,d];return(t,o)=>{const n=(e=>(100-e)/100*360)(o.event.value),r=s.paletteRgba.get(),a=ex(r),i=Qy(n,a.saturation,a.value),l=tx(i);g(t,l,n,e)}})())]),cm.config({find:e=>l.getOpt(e)}),Tp.config({mode:"acyclic"})])}}});return o},Jk=()=>cm.config({find:M.some}),Zk=e=>cm.config({find:t=>rt(t.element,e).bind((e=>t.getSystem().getByDom(e).toOptional()))}),Qk=Cn([ur("preprocess",x),ur("postprocess",x)]),eC=(e,t,o)=>ou.config({store:{mode:"manual",...e.map((e=>({initialValue:e}))).getOr({}),getValue:t,setValue:o}}),tC=(e,t,o)=>eC(e,(e=>t(e.element)),((e,t)=>o(e.element,t))),oC=(e,t)=>{const o=Un("RepresentingConfigs.memento processors",Qk,t);return ou.config({store:{mode:"manual",getValue:t=>{const n=e.get(t),r=ou.getValue(n);return o.postprocess(r)},setValue:(t,n)=>{const r=o.preprocess(n),s=e.get(t);ou.setValue(s,r)}}})},nC=tC,rC=eC,sC=e=>ou.config({store:{mode:"memory",initialValue:e}}),aC={"colorcustom.rgb.red.label":"R","colorcustom.rgb.red.description":"Red component","colorcustom.rgb.green.label":"G","colorcustom.rgb.green.description":"Green component","colorcustom.rgb.blue.label":"B","colorcustom.rgb.blue.description":"Blue component","colorcustom.rgb.hex.label":"#","colorcustom.rgb.hex.description":"Hex color code","colorcustom.rgb.range":"Range 0 to 255","aria.color.picker":"Color Picker","aria.input.invalid":"Invalid input"};var iC=tinymce.util.Tools.resolve("tinymce.Resource"),lC=tinymce.util.Tools.resolve("tinymce.util.Tools");const cC=Qs("alloy-fake-before-tabstop"),dC=Qs("alloy-fake-after-tabstop"),uC=e=>({dom:{tag:"div",styles:{width:"1px",height:"1px",outline:"none"},attributes:{tabindex:"0"},classes:e},behaviours:gl([Up.config({ignore:!0}),Mw.config({})])}),mC=e=>({dom:{tag:"div",classes:["tox-navobj"]},components:[uC([cC]),e,uC([dC])],behaviours:gl([Zk(1)])}),gC=(e,t)=>{Os(e,Ur(),{raw:{which:9,shiftKey:t}})},pC=(e,t)=>{const o=t.element;Fa(o,cC)?gC(e,!0):Fa(o,dC)&&gC(e,!1)},hC=e=>mw(e,["."+cC,"."+dC].join(","),_),fC=Qs("toolbar.button.execute"),bC={[ns()]:["disabling","alloy.base.behaviour","toggling","toolbar-button-events"]},vC=(e,t,o)=>Lh(e,{tag:"span",classes:["tox-icon","tox-tbtn__icon-wrap"],behaviours:o},t),yC=(e,t)=>vC(e,t,[]),xC=(e,t)=>vC(e,t,[Np.config({})]),wC=(e,t,o)=>({dom:{tag:"span",classes:[`${t}__select-label`]},components:[Ga(o.translate(e))],behaviours:gl([Np.config({})])}),SC=Qs("update-menu-text"),kC=Qs("update-menu-icon"),CC=(e,t,o)=>{const n=xr(b),r=e.text.map((e=>Ah(wC(e,t,o.providers)))),s=e.icon.map((e=>Ah(xC(e,o.providers.icons)))),a=(e,t)=>{const o=ou.getValue(e);return Up.focus(o),Os(o,"keydown",{raw:t.event.raw}),ow.close(o),M.some(!0)},i=e.role.fold((()=>({})),(e=>({role:e}))),l=e.tooltip.fold((()=>({})),(e=>{const t=o.providers.translate(e);return{title:t,"aria-label":t}})),c=Lh("chevron-down",{tag:"div",classes:[`${t}__select-chevron`]},o.providers.icons),d=Ah(ow.sketch({...e.uid?{uid:e.uid}:{},...i,dom:{tag:"button",classes:[t,`${t}--select`].concat(z(e.classes,(e=>`${t}--${e}`))),attributes:{...l}},components:uy([s.map((e=>e.asSpec())),r.map((e=>e.asSpec())),M.some(c)]),matchWidth:!0,useMinWidth:!0,onOpen:(t,o,n)=>{e.searchable&&(e=>{kb(e).each((e=>Up.focus(e)))})(n)},dropdownBehaviours:gl([...e.dropdownBehaviours,ny((()=>e.disabled||o.providers.isDisabled())),oy(),eS.config({}),Np.config({}),Vp("dropdown-events",[iy(e,n),ly(e,n)]),Vp("menubutton-update-display-text",[Fs(SC,((e,t)=>{r.bind((t=>t.getOpt(e))).each((e=>{Np.set(e,[Ga(o.providers.translate(t.event.text))])}))})),Fs(kC,((e,t)=>{s.bind((t=>t.getOpt(e))).each((e=>{Np.set(e,[xC(t.event.icon,o.providers.icons)])}))}))])]),eventOrder:cn(bC,{mousedown:["focusing","alloy.base.behaviour","item-type-events","normal-dropdown-events"]}),sandboxBehaviours:gl([Tp.config({mode:"special",onLeft:a,onRight:a}),Vp("dropdown-sandbox-events",[Fs(xb,((e,t)=>{(e=>{const t=ou.getValue(e),o=Sb(e).map(Cb);ow.refetch(t).get((()=>{const e=Nx.getCoupled(t,"sandbox");o.each((t=>Sb(e).each((e=>((e,t)=>{ou.setValue(e,t.fetchPattern),e.element.dom.selectionStart=t.selectionStart,e.element.dom.selectionEnd=t.selectionEnd})(e,t)))))}))})(e),t.stop()})),Fs(wb,((e,t)=>{((e,t)=>{(e=>Nd.getState(e).bind(Fm.getHighlighted).bind(Fm.getHighlighted))(e).each((o=>{((e,t,o,n)=>{const r={...n,target:t};e.getSystem().triggerEvent(o,t,r)})(e,o.element,t.event.eventType,t.event.interactionEvent)}))})(e,t),t.stop()}))])]),lazySink:o.getSink,toggleClass:`${t}--active`,parts:{menu:{...pb(0,e.columns,e.presets),fakeFocus:e.searchable,onHighlightItem:nw,onCollapseMenu:(e,t,o)=>{Fm.getHighlighted(o).each((t=>{nw(e,o,t)}))},onDehighlightItem:rw}},fetch:t=>Px(S(e.fetch,t))}));return d.asSpec()},OC=e=>"separator"===e.type,_C={type:"separator"},TC=(e,t)=>{const o=((e,t)=>{const o=j(e,((e,o)=>(e=>s(e))(o)?""===o?e:"|"===o?e.length>0&&!OC(e[e.length-1])?e.concat([_C]):e:ve(t,o.toLowerCase())?e.concat([t[o.toLowerCase()]]):e:e.concat([o])),[]);return o.length>0&&OC(o[o.length-1])&&o.pop(),o})(s(e)?e.split(" "):e,t);return W(o,((e,o)=>{if((e=>ve(e,"getSubmenuItems"))(o)){const n=(e=>{const t=be(e,"value").getOrThunk((()=>Qs("generated-menu-item")));return cn({value:t},e)})(o),r=((e,t)=>{const o=e.getSubmenuItems(),n=TC(o,t);return{item:e,menus:cn(n.menus,{[e.value]:n.items}),expansions:cn(n.expansions,{[e.value]:e.value})}})(n,t);return{menus:cn(e.menus,r.menus),items:[r.item,...e.items],expansions:cn(e.expansions,r.expansions)}}return{...e,items:[o,...e.items]}}),{menus:{},expansions:{},items:[]})},EC=(e,t,o,n)=>{const r=Qs("primary-menu"),s=TC(e,o.shared.providers.menuItems());if(0===s.items.length)return M.none();const a=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-field",placeholder:e.placeholder}))))(n),i=cw(r,s.items,t,o,n.isHorizontalMenu,a),l=(e=>e.search.fold((()=>({searchMode:"no-search"})),(e=>({searchMode:"search-with-results"}))))(n),c=ce(s.menus,((e,n)=>cw(n,e,t,o,!1,l))),d=cn(c,Sr(r,i));return M.from(_h.tieredData(r,d,s.expansions))},MC=e=>!ve(e,"items"),AC="data-value",DC=(e,t,o,n)=>z(o,(o=>MC(o)?{type:"togglemenuitem",text:o.text,value:o.value,active:o.value===n,onAction:()=>{ou.setValue(e,o.value),Os(e,Rw,{name:t}),Up.focus(e)}}:{type:"nestedmenuitem",text:o.text,getSubmenuItems:()=>DC(e,t,o.items,n)})),BC=(e,t)=>se(e,(e=>MC(e)?ke(e.value===t,e):BC(e.items,t))),FC=rm({name:"HtmlSelect",configFields:[Xn("options"),nu("selectBehaviours",[Up,ou]),ur("selectClasses",[]),ur("selectAttributes",{}),nr("data")],factory:(e,t)=>{const o=z(e.options,(e=>({dom:{tag:"option",value:e.value,innerHtml:e.text}}))),n=e.data.map((e=>Sr("initialValue",e))).getOr({});return{uid:e.uid,dom:{tag:"select",classes:e.selectClasses,attributes:e.selectAttributes},components:o,behaviours:su(e.selectBehaviours,[Up.config({}),ou.config({store:{mode:"manual",getValue:e=>Na(e.element),setValue:(t,o)=>{G(e.options,(e=>e.value===o)).isSome()&&Va(t.element,o)},...n}})])}}}),IC=y([ur("field1Name","field1"),ur("field2Name","field2"),ki("onLockedChange"),yi(["lockClass"]),ur("locked",!1),au("coupledFieldBehaviours",[cm,ou])]),RC=(e,t)=>Au({factory:_w,name:e,overrides:e=>({fieldBehaviours:gl([Vp("coupled-input-behaviour",[Fs(jr(),(o=>{((e,t,o)=>ju(e,t,o).bind(cm.getCurrent))(o,e,t).each((t=>{ju(o,e,"lock").each((n=>{Yp.isOn(n)&&e.onLockedChange(o,t,n)}))}))}))])])})}),NC=y([RC("field1","field2"),RC("field2","field1"),Au({factory:Mh,schema:[Xn("dom")],name:"lock",overrides:e=>({buttonBehaviours:gl([Yp.config({selected:e.locked,toggleClass:e.markers.lockClass,aria:{mode:"pressed"}})])})})]),VC=sm({name:"FormCoupledInputs",configFields:IC(),partFields:NC(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:iu(e.coupledFieldBehaviours,[cm.config({find:M.some}),ou.config({store:{mode:"manual",getValue:t=>{const o=Ku(t,e,["field1","field2"]);return{[e.field1Name]:ou.getValue(o.field1()),[e.field2Name]:ou.getValue(o.field2())}},setValue:(t,o)=>{const n=Ku(t,e,["field1","field2"]);ye(o,e.field1Name)&&ou.setValue(n.field1(),o[e.field1Name]),ye(o,e.field2Name)&&ou.setValue(n.field2(),o[e.field2Name])}}})]),apis:{getField1:t=>ju(t,e,"field1"),getField2:t=>ju(t,e,"field2"),getLock:t=>ju(t,e,"lock")}}),apis:{getField1:(e,t)=>e.getField1(t),getField2:(e,t)=>e.getField2(t),getLock:(e,t)=>e.getLock(t)}}),HC=e=>{const t=/^\s*(\d+(?:\.\d+)?)\s*(|cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)\s*$/.exec(e);if(null!==t){const e=parseFloat(t[1]),o=t[2];return Jo.value({value:e,unit:o})}return Jo.error(e)},zC=(e,t)=>{const o={"":96,px:96,pt:72,cm:2.54,pc:12,mm:25.4,in:1},n=e=>ve(o,e);return e.unit===t?M.some(e.value):n(e.unit)&&n(t)?o[e.unit]===o[t]?M.some(e.value):M.some(e.value/o[e.unit]*o[t]):M.none()},LC=e=>M.none(),PC=(e,t)=>{const o=e.label.map((e=>Iw(e,t))),n=[km.config({disabled:()=>e.disabled||t.isDisabled()}),oy(),Tp.config({mode:"execution",useEnter:!0!==e.multiline,useControlEnter:!0===e.multiline,execute:e=>(Cs(e,zw),M.some(!0))}),Vp("textfield-change",[Fs(jr(),((t,o)=>{Os(t,Rw,{name:e.name})})),Fs(ts(),((t,o)=>{Os(t,Rw,{name:e.name})}))]),Mw.config({})],r=e.validation.map((e=>Qw.config({getRoot:e=>tt(e.element),invalidClass:"tox-invalid",validator:{validate:t=>{const o=ou.getValue(t),n=e.validator(o);return Ux(!0===n?Jo.value(o):Jo.error(n))},validateOnLoad:e.validateOnLoad}}))).toArray(),s={...e.placeholder.fold(y({}),(e=>({placeholder:t.translate(e)}))),...e.inputMode.fold(y({}),(e=>({inputmode:e})))},a=_w.parts.field({tag:!0===e.multiline?"textarea":"input",...e.data.map((e=>({data:e}))).getOr({}),inputAttributes:s,inputClasses:[e.classname],inputBehaviours:gl(q([n,r])),selectOnFocus:!1,factory:yb}),i=(e.flex?["tox-form__group--stretched"]:[]).concat(e.maximized?["tox-form-group--maximize"]:[]),l=[km.config({disabled:()=>e.disabled||t.isDisabled(),onDisabled:e=>{_w.getField(e).each(km.disable)},onEnabled:e=>{_w.getField(e).each(km.enable)}}),oy()];return Dw(o,a,i,l)};var UC=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.stream.streams.setup(e,t);return As([Fs(e.event,o),Us((()=>t.cancel()))].concat(e.cancelEvent.map((e=>[Fs(e,(()=>t.cancel()))])).getOr([])))}});const WC=(e,t)=>{let o=null;const n=()=>{c(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}},jC=e=>{const t=xr(null);return ba({readState:()=>({timer:null!==t.get()?"set":"unset"}),setTimer:e=>{t.set(e)},cancel:()=>{const e=t.get();null!==e&&e.cancel()}})};var GC=Object.freeze({__proto__:null,throttle:jC,init:e=>e.stream.streams.state(e)}),$C=[Kn("stream",jn("mode",{throttle:[Xn("delay"),ur("stopEvent",!0),Oi("streams",{setup:(e,t)=>{const o=e.stream,n=WC(e.onStream,o.delay);return t.setTimer(n),(e,t)=>{n.throttle(e,t),o.stopEvent&&t.stop()}},state:jC})]})),ur("event","input"),nr("cancelEvent"),ki("onStream")];const qC=hl({fields:$C,name:"streaming",active:UC,state:GC}),XC=(e,t,o)=>{const n=ou.getValue(o);ou.setValue(t,n),YC(t)},KC=(e,t)=>{const o=e.element,n=Na(o),r=o.dom;"number"!==xt(o,"type")&&t(r,n)},YC=e=>{KC(e,((e,t)=>e.setSelectionRange(t.length,t.length)))},JC=y("alloy.typeahead.itemexecute"),ZC=y([nr("lazySink"),Xn("fetch"),ur("minChars",5),ur("responseTime",1e3),wi("onOpen"),ur("getHotspot",M.some),ur("getAnchorOverrides",y({})),ur("layouts",M.none()),ur("eventOrder",{}),yr("model",{},[ur("getDisplayText",(e=>void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.value)),ur("selectsOver",!0),ur("populateFromBrowse",!0)]),wi("onSetValue"),Si("onExecute"),wi("onItemExecute"),ur("inputClasses",[]),ur("inputAttributes",{}),ur("inputStyles",{}),ur("matchWidth",!0),ur("useMinWidth",!1),ur("dismissOnBlur",!0),yi(["openClass"]),nr("initialData"),nu("typeaheadBehaviours",[Up,ou,qC,Tp,Yp,Nx]),$n("lazyTypeaheadComp",(()=>xr(M.none))),$n("previewing",(()=>xr(!0)))].concat(hb()).concat(Qx())),QC=y([Du({schema:[vi()],name:"menu",overrides:e=>({fakeFocus:!0,onHighlightItem:(t,o,n)=>{e.previewing.get()?e.lazyTypeaheadComp.get().each((t=>{((e,t,o)=>{if(e.selectsOver){const n=ou.getValue(t),r=e.getDisplayText(n),s=ou.getValue(o);return 0===e.getDisplayText(s).indexOf(r)?M.some((()=>{XC(0,t,o),((e,t)=>{KC(e,((e,o)=>e.setSelectionRange(t,o.length)))})(t,r.length)})):M.none()}return M.none()})(e.model,t,n).fold((()=>{e.model.selectsOver?(Fm.dehighlight(o,n),e.previewing.set(!0)):e.previewing.set(!1)}),(t=>{t(),e.previewing.set(!1)}))})):e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&XC(e.model,t,n)}))},onExecute:(t,o)=>e.lazyTypeaheadComp.get().map((e=>(Os(e,JC(),{item:o}),!0))),onHover:(t,o)=>{e.previewing.set(!1),e.lazyTypeaheadComp.get().each((t=>{e.model.populateFromBrowse&&XC(e.model,t,o)}))}})})]),eO=sm({name:"Typeahead",configFields:ZC(),partFields:QC(),factory:(e,t,o,n)=>{const r=(t,o,r)=>{e.previewing.set(!1);const s=Nx.getCoupled(t,"sandbox");if(Nd.isOpen(s))cm.getCurrent(s).each((e=>{Fm.getHighlighted(e).fold((()=>{r(e)}),(()=>{Ms(s,e.element,"keydown",o)}))}));else{const o=e=>{cm.getCurrent(e).each(r)};$x(e,a(t),t,s,n,o,Ch.HighlightMenuAndItem).get(b)}},s=fb(e),a=e=>t=>t.map((t=>{const o=fe(t.menus),n=X(o,(e=>U(e.items,(e=>"item"===e.type))));return ou.getState(e).update(z(n,(e=>e.data))),t})),i=e=>cm.getCurrent(e),l="typeaheadevents",c=[Up.config({}),ou.config({onSetValue:e.onSetValue,store:{mode:"dataset",getDataKey:e=>Na(e.element),getFallbackEntry:e=>({value:e,meta:{}}),setValue:(t,o)=>{Va(t.element,e.model.getDisplayText(o))},...e.initialData.map((e=>Sr("initialValue",e))).getOr({})}}),qC.config({stream:{mode:"throttle",delay:e.responseTime,stopEvent:!1},onStream:(t,o)=>{const r=Nx.getCoupled(t,"sandbox");if(Up.isFocused(t)&&Na(t.element).length>=e.minChars){const o=i(r).bind((e=>Fm.getHighlighted(e).map(ou.getValue)));e.previewing.set(!0);const s=t=>{i(r).each((t=>{o.fold((()=>{e.model.selectsOver&&Fm.highlightFirst(t)}),(e=>{Fm.highlightBy(t,(t=>ou.getValue(t).value===e.value)),Fm.getHighlighted(t).orThunk((()=>(Fm.highlightFirst(t),M.none())))}))}))};$x(e,a(t),t,r,n,s,Ch.HighlightJustMenu).get(b)}},cancelEvent:ls()}),Tp.config({mode:"special",onDown:(e,t)=>(r(e,t,Fm.highlightFirst),M.some(!0)),onEscape:e=>{const t=Nx.getCoupled(e,"sandbox");return Nd.isOpen(t)?(Nd.close(t),M.some(!0)):M.none()},onUp:(e,t)=>(r(e,t,Fm.highlightLast),M.some(!0)),onEnter:t=>{const o=Nx.getCoupled(t,"sandbox"),n=Nd.isOpen(o);if(n&&!e.previewing.get())return i(o).bind((e=>Fm.getHighlighted(e))).map((e=>(Os(t,JC(),{item:e}),!0)));{const r=ou.getValue(t);return Cs(t,ls()),e.onExecute(o,t,r),n&&Nd.close(o),M.some(!0)}}}),Yp.config({toggleClass:e.markers.openClass,aria:{mode:"expanded"}}),Nx.config({others:{sandbox:t=>Jx(e,t,{onOpen:()=>Yp.on(t),onClose:()=>Yp.off(t)})}}),Vp(l,[Ps((t=>{e.lazyTypeaheadComp.set(M.some(t))})),Us((t=>{e.lazyTypeaheadComp.set(M.none())})),js((t=>{const o=b;Xx(e,a(t),t,n,o,Ch.HighlightMenuAndItem).get(b)})),Fs(JC(),((t,o)=>{const n=Nx.getCoupled(t,"sandbox");XC(e.model,t,o.event.item),Cs(t,ls()),e.onItemExecute(t,n,o.event.item,ou.getValue(t)),Nd.close(n),YC(t)}))].concat(e.dismissOnBlur?[Fs(es(),(e=>{const t=Nx.getCoupled(e,"sandbox");Cl(t.element).isNone()&&Nd.close(t)}))]:[]))],d={[hs()]:[ou.name(),qC.name(),l],...e.eventOrder};return{uid:e.uid,dom:vb(cn(e,{inputAttributes:{role:"combobox","aria-autocomplete":"list","aria-haspopup":"true"}})),behaviours:{...s,...su(e.typeaheadBehaviours,c)},eventOrder:d}}}),tO=e=>({...e,toCached:()=>tO(e.toCached()),bindFuture:t=>tO(e.bind((e=>e.fold((e=>Ux(Jo.error(e))),(e=>t(e)))))),bindResult:t=>tO(e.map((e=>e.bind(t)))),mapResult:t=>tO(e.map((e=>e.map(t)))),mapError:t=>tO(e.map((e=>e.mapError(t)))),foldResult:(t,o)=>e.map((e=>e.fold(t,o))),withTimeout:(t,o)=>tO(Px((n=>{let r=!1;const s=setTimeout((()=>{r=!0,n(Jo.error(o()))}),t);e.get((e=>{r||(clearTimeout(s),n(e))}))})))}),oO=e=>tO(Px(e)),nO=e=>({isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t),setActive:t=>{const o=e.element;t?(Da(o,"tox-tbtn--enabled"),vt(o,"aria-pressed",!0)):(Ba(o,"tox-tbtn--enabled"),kt(o,"aria-pressed"))},isActive:()=>Fa(e.element,"tox-tbtn--enabled")}),rO=(e,t,o,n)=>CC({text:e.text,icon:e.icon,tooltip:e.tooltip,searchable:e.search.isSome(),role:n,fetch:(t,n)=>{const r={pattern:e.search.isSome()?sw(t):""};e.fetch((t=>{n(EC(t,Jf.CLOSE_ON_EXECUTE,o,{isHorizontalMenu:!1,search:e.search}))}),r)},onSetup:e.onSetup,getApi:nO,columns:1,presets:"normal",classes:[],dropdownBehaviours:[Mw.config({})]},t,o.shared),sO=(e,t,o)=>{const n=e=>n=>{const r=!n.isActive();n.setActive(r),e.storage.set(r),o.shared.getSink().each((o=>{t().getOpt(o).each((t=>{wl(t.element),Os(t,Hw,{name:e.name,value:e.storage.get()})}))}))},r=e=>t=>{t.setActive(e.storage.get())};return t=>{t(z(e,(e=>{const t=e.text.fold((()=>({})),(e=>({text:e})));return{type:e.type,active:!1,...t,onAction:n(e),onSetup:r(e)}})))}},aO=(e,t,o=[],n,r,s)=>{const a=t.fold((()=>({})),(e=>({action:e}))),i={buttonBehaviours:gl([ny((()=>!e.enabled||s.isDisabled())),oy(),Mw.config({}),Vp("button press",[Bs("click"),Bs("mousedown")])].concat(o)),eventOrder:{click:["button press","alloy.base.behaviour"],mousedown:["button press","alloy.base.behaviour"]},...a},l=cn(i,{dom:n});return cn(l,{components:r})},iO=(e,t,o,n=[])=>{const r={tag:"button",classes:["tox-tbtn"],attributes:e.tooltip.map((e=>({"aria-label":o.translate(e),title:o.translate(e)}))).getOr({})},s=e.icon.map((e=>yC(e,o.icons))),a=uy([s]);return aO(e,t,n,r,a,o)},lO=(e,t,o,n=[],r=[])=>{const s=o.translate(e.text),a=e.icon.map((e=>yC(e,o.icons))),i=[a.getOrThunk((()=>Ga(s)))],l=[...(e=>{switch(e){case"primary":return["tox-button"];case"toolbar":return["tox-tbtn"];default:return["tox-button","tox-button--secondary"]}})(e.buttonType.getOr(e.primary||e.borderless?"primary":"secondary")),...a.isSome()?["tox-button--icon"]:[],...e.borderless?["tox-button--naked"]:[],...r];return aO(e,t,n,{tag:"button",classes:l,attributes:{title:s}},i,o)},cO=(e,t,o,n=[],r=[])=>{const s=lO(e,M.some(t),o,n,r);return Mh.sketch(s)},dO=(e,t)=>o=>{"custom"===t?Os(o,Hw,{name:e,value:{}}):"submit"===t?Cs(o,zw):"cancel"===t?Cs(o,Vw):console.error("Unknown button type: ",t)},uO=(e,t,o)=>{if(((e,t)=>"menu"===t)(0,t)){const t=()=>s,n=e,r={...e,type:"menubutton",search:M.none(),onSetup:t=>(t.setEnabled(e.enabled),b),fetch:sO(n.items,t,o)},s=Ah(rO(r,"tox-tbtn",o,M.none()));return s.asSpec()}if(((e,t)=>"custom"===t||"cancel"===t||"submit"===t)(0,t)){const n=dO(e.name,t),r={...e,borderless:!1};return cO(r,n,o.shared.providers,[])}throw console.error("Unknown footer button type: ",t),new Error("Unknown footer button type")},mO={type:"separator"},gO=e=>({type:"menuitem",value:e.url,text:e.title,meta:{attach:e.attach},onAction:b}),pO=(e,t)=>({type:"menuitem",value:t,text:e,meta:{attach:void 0},onAction:b}),hO=(e,t)=>(e=>z(e,gO))(((e,t)=>U(t,(t=>t.type===e)))(e,t)),fO=e=>hO("header",e.targets),bO=e=>hO("anchor",e.targets),vO=e=>M.from(e.anchorTop).map((e=>pO("<top>",e))).toArray(),yO=e=>M.from(e.anchorBottom).map((e=>pO("<bottom>",e))).toArray(),xO=(e,t)=>{const o=e.toLowerCase();return U(t,(e=>{var t;const n=void 0!==e.meta&&void 0!==e.meta.text?e.meta.text:e.text,r=null!==(t=e.value)&&void 0!==t?t:"";return Oe(n.toLowerCase(),o)||Oe(r.toLowerCase(),o)}))},wO=Qs("aria-invalid"),SO=(e,t)=>{e.dom.checked=t},kO=e=>e.dom.checked,CO=e=>(t,o,n,r)=>be(o,"name").fold((()=>e(o,r,M.none())),(s=>t.field(s,e(o,r,be(n,s))))),OO={bar:CO(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-bar","tox-form__controls-h-stack"]},components:z(e.items,t.interpreter)}))(e,t.shared))),collection:CO(((e,t,o)=>((e,t,o)=>{const n=e.label.map((e=>Iw(e,t))),r=e=>(t,o)=>{si(o.event.target,"[data-collection-item-value]").each((n=>{e(t,o,n,xt(n,"data-collection-item-value"))}))},s=r(((o,n,r,s)=>{n.stop(),t.isDisabled()||Os(o,Hw,{name:e.name,value:s})})),a=[Fs(zr(),r(((e,t,o)=>{wl(o)}))),Fs($r(),s),Fs(ss(),s),Fs(Lr(),r(((e,t,o)=>{ri(e.element,"."+sb).each((e=>{Ba(e,sb)})),Da(o,sb)}))),Fs(Pr(),r((e=>{ri(e.element,"."+sb).each((e=>{Ba(e,sb)}))}))),js(r(((t,o,n,r)=>{Os(t,Hw,{name:e.name,value:r})})))],i=(e,t)=>z(Nc(e.element,".tox-collection__item"),t),l=_w.parts.field({dom:{tag:"div",classes:["tox-collection"].concat(1!==e.columns?["tox-collection--grid"]:["tox-collection--list"])},components:[],factory:{sketch:x},behaviours:gl([km.config({disabled:t.isDisabled,onDisabled:e=>{i(e,(e=>{Da(e,"tox-collection__item--state-disabled"),vt(e,"aria-disabled",!0)}))},onEnabled:e=>{i(e,(e=>{Ba(e,"tox-collection__item--state-disabled"),kt(e,"aria-disabled")}))}}),oy(),Np.config({}),ou.config({store:{mode:"memory",initialValue:o.getOr([])},onSetValue:(o,n)=>{((o,n)=>{const r=z(n,(o=>{const n=Dh.translate(o.text),r=1===e.columns?`<div class="tox-collection__item-label">${n}</div>`:"",s=`<div class="tox-collection__item-icon">${o.icon}</div>`,a={_:" "," - ":" ","-":" "},i=n.replace(/\_| \- |\-/g,(e=>a[e]));return`<div class="tox-collection__item${t.isDisabled()?" tox-collection__item--state-disabled":""}" tabindex="-1" data-collection-item-value="${Aw.encodeAllRaw(o.value)}" title="${i}" aria-label="${i}">${s}${r}</div>`})),s="auto"!==e.columns&&e.columns>1?H(r,e.columns):[r],a=z(s,(e=>`<div class="tox-collection__group">${e.join("")}</div>`));$s(o.element,a.join(""))})(o,n),"auto"===e.columns&&Uv(o,5,"tox-collection__item").each((({numRows:e,numColumns:t})=>{Tp.setGridSize(o,e,t)})),Cs(o,Ww)}}),Mw.config({}),Tp.config((c=e.columns,1===c?{mode:"menu",moveOnTab:!1,selector:".tox-collection__item"}:"auto"===c?{mode:"flatgrid",selector:".tox-collection__item",initSize:{numColumns:1,numRows:1}}:{mode:"matrix",selectors:{row:".tox-collection__group",cell:`.${Qf}`}})),Vp("collection-events",a)]),eventOrder:{[ns()]:["disabling","alloy.base.behaviour","collection-events"]}});var c;return Dw(n,l,["tox-form__group--collection"],[])})(e,t.shared.providers,o))),alertbanner:CO(((e,t)=>((e,t)=>Sw.sketch({dom:{tag:"div",attributes:{role:"alert"},classes:["tox-notification","tox-notification--in",`tox-notification--${e.level}`]},components:[{dom:{tag:"div",classes:["tox-notification__icon"]},components:[Mh.sketch({dom:{tag:"button",classes:["tox-button","tox-button--naked","tox-button--icon"],innerHtml:Vh(e.icon,t.icons),attributes:{title:t.translate(e.iconTooltip)}},action:t=>{Os(t,Hw,{name:"alert-banner",value:e.url})},buttonBehaviours:gl([Hh()])})]},{dom:{tag:"div",classes:["tox-notification__body"],innerHtml:t.translate(e.text)}}]}))(e,t.shared.providers))),input:CO(((e,t,o)=>((e,t,o)=>PC({name:e.name,multiline:!1,label:e.label,inputMode:e.inputMode,placeholder:e.placeholder,flex:!1,disabled:!e.enabled,classname:"tox-textfield",validation:M.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),textarea:CO(((e,t,o)=>((e,t,o)=>PC({name:e.name,multiline:!0,label:e.label,inputMode:M.none(),placeholder:e.placeholder,flex:!0,disabled:!e.enabled,classname:"tox-textarea",validation:M.none(),maximized:e.maximized,data:o},t))(e,t.shared.providers,o))),label:CO(((e,t)=>((e,t)=>{return{dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"label",classes:["tox-label"]},components:[Ga(t.providers.translate(e.label))]},...z(e.items,t.interpreter)],behaviours:gl([Jk(),Np.config({}),(o=M.none(),tC(o,Gs,$s)),Tp.config({mode:"acyclic"})])};var o})(e,t.shared))),iframe:(Y_=(e,t,o)=>((e,t,o)=>{const n=e.sandboxed,r=e.transparent,s="tox-dialog__iframe",a={...e.label.map((e=>({title:e}))).getOr({}),...o.map((e=>({srcdoc:e}))).getOr({}),...n?{sandbox:"allow-scripts allow-same-origin"}:{}},i=(e=>{const t=xr(e.getOr(""));return{getValue:e=>t.get(),setValue:(e,o)=>{t.get()!==o&&vt(e.element,"srcdoc",o),t.set(o)}}})(o),l=e.label.map((e=>Iw(e,t))),c=_w.parts.field({factory:{sketch:e=>mC({uid:e.uid,dom:{tag:"iframe",attributes:a,classes:r?[s]:[s,`${s}--opaque`]},behaviours:gl([Mw.config({}),Up.config({}),rC(o,i.getValue,i.setValue)])})}});return Dw(l,c,["tox-form__group--stretched"],[])})(e,t.shared.providers,o),(e,t,o,n)=>{const r=cn(t,{source:"dynamic"});return CO(Y_)(e,r,o,n)}),button:CO(((e,t)=>((e,t)=>{const o=dO(e.name,"custom");return n=M.none(),r=_w.parts.field({factory:Mh,...lO(e,M.some(o),t,[sC(""),Jk()])}),Dw(n,r,[],[]);var n,r})(e,t.shared.providers))),checkbox:CO(((e,t,o)=>((e,t,o)=>{const n=e=>(e.element.dom.click(),M.some(!0)),r=_w.parts.field({factory:{sketch:x},dom:{tag:"input",classes:["tox-checkbox__input"],attributes:{type:"checkbox"}},behaviours:gl([Jk(),km.config({disabled:()=>!e.enabled||t.isDisabled()}),Mw.config({}),Up.config({}),nC(o,kO,SO),Tp.config({mode:"special",onEnter:n,onSpace:n,stopSpaceKeyup:!0}),Vp("checkbox-events",[Fs(Gr(),((t,o)=>{Os(t,Rw,{name:e.name})}))])])}),s=_w.parts.label({dom:{tag:"span",classes:["tox-checkbox__label"]},components:[Ga(t.translate(e.label))],behaviours:gl([eS.config({})])}),a=e=>Lh("checked"===e?"selected":"unselected",{tag:"span",classes:["tox-icon","tox-checkbox-icon__"+e]},t.icons),i=Ah({dom:{tag:"div",classes:["tox-checkbox__icons"]},components:[a("checked"),a("unchecked")]});return _w.sketch({dom:{tag:"label",classes:["tox-checkbox"]},components:[r,i.asSpec(),s],fieldBehaviours:gl([km.config({disabled:()=>!e.enabled||t.isDisabled(),disableClass:"tox-checkbox--disabled",onDisabled:e=>{_w.getField(e).each(km.disable)},onEnabled:e=>{_w.getField(e).each(km.enable)}}),oy()])})})(e,t.shared.providers,o))),colorinput:CO(((e,t,o)=>((e,t,o,n)=>{const r=_w.parts.field({factory:yb,inputClasses:["tox-textfield"],data:n,onSetValue:e=>Qw.run(e).get(b),inputBehaviours:gl([km.config({disabled:t.providers.isDisabled}),oy(),Mw.config({}),Qw.config({invalidClass:"tox-textbox-field-invalid",getRoot:e=>tt(e.element),notify:{onValid:e=>{const t=ou.getValue(e);Os(e,tS,{color:t})}},validator:{validateOnLoad:!1,validate:e=>{const t=ou.getValue(e);if(0===t.length)return Ux(Jo.value(!0));{const e=Be("span");_t(e,"background-color",t);const o=Dt(e,"background-color").fold((()=>Jo.error("blah")),(e=>Jo.value(t)));return Ux(o)}}}})]),selectOnFocus:!1}),s=e.label.map((e=>Iw(e,t.providers))),a=(e,t)=>{Os(e,oS,{value:t})},i=Ah(((e,t)=>ow.sketch({dom:e.dom,components:e.components,toggleClass:"mce-active",dropdownBehaviours:gl([ny(t.providers.isDisabled),oy(),eS.config({}),Mw.config({})]),layouts:e.layouts,sandboxClasses:["tox-dialog__popups"],lazySink:t.getSink,fetch:o=>Px((t=>e.fetch(t))).map((n=>M.from(dw(cn(kx(Qs("menu-value"),n,(t=>{e.onItemAction(o,t)}),e.columns,e.presets,Jf.CLOSE_ON_EXECUTE,_,t.providers),{movement:Ox(e.columns,e.presets)}))))),parts:{menu:pb(0,0,e.presets)}}))({dom:{tag:"span",attributes:{"aria-label":t.providers.translate("Color swatch")}},layouts:{onRtl:()=>[Ki,Xi,Qi],onLtr:()=>[Xi,Ki,Qi]},components:[],fetch:vx(o.getColors(e.storageKey),e.storageKey,o.hasCustomColors()),columns:o.getColorCols(e.storageKey),presets:"color",onItemAction:(t,n)=>{i.getOpt(t).each((t=>{"custom"===n?o.colorPicker((o=>{o.fold((()=>Cs(t,nS)),(o=>{a(t,o),Zy(e.storageKey,o)}))}),"#ffffff"):a(t,"remove"===n?"":n)}))}},t));return _w.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:s.toArray().concat([{dom:{tag:"div",classes:["tox-color-input"]},components:[r,i.asSpec()]}]),fieldBehaviours:gl([Vp("form-field-events",[Fs(tS,((t,o)=>{i.getOpt(t).each((e=>{_t(e.element,"background-color",o.event.color)})),Os(t,Rw,{name:e.name})})),Fs(oS,((e,t)=>{_w.getField(e).each((o=>{ou.setValue(o,t.event.value),cm.getCurrent(e).each(Up.focus)}))})),Fs(nS,((e,t)=>{_w.getField(e).each((t=>{cm.getCurrent(e).each(Up.focus)}))}))])])})})(e,t.shared,t.colorinput,o))),colorpicker:CO(((e,t,o)=>((e,t,o)=>{const n=e=>"tox-"+e,r=Yk((e=>t=>e.translate(aC[t]))(t),n),s=Ah(r.sketch({dom:{tag:"div",classes:[n("color-picker-container")],attributes:{role:"presentation"}},onValidHex:e=>{Os(e,Hw,{name:"hex-valid",value:!0})},onInvalidHex:e=>{Os(e,Hw,{name:"hex-valid",value:!1})}}));return{dom:{tag:"div"},components:[s.asSpec()],behaviours:gl([rC(o,(e=>{const t=s.get(e);return cm.getCurrent(t).bind((e=>ou.getValue(e).hex)).map((e=>"#"+e)).getOr("")}),((e,t)=>{const o=M.from(/^#([a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?)/.exec(t)).bind((e=>te(e,1))),n=s.get(e);cm.getCurrent(n).fold((()=>{console.log("Can not find form")}),(e=>{ou.setValue(e,{hex:o.getOr("")}),jk.getField(e,"hex").each((e=>{Cs(e,jr())}))}))})),Jk()])}})(0,t.shared.providers,o))),dropzone:CO(((e,t,o)=>((e,t,o)=>{const n=(e,t)=>{t.stop()},r=e=>(t,o)=>{L(e,(e=>{e(t,o)}))},s=(e,t)=>{var o;if(!km.isDisabled(e)){const n=t.event.raw;i(e,null===(o=n.dataTransfer)||void 0===o?void 0:o.files)}},a=(e,t)=>{const o=t.event.raw.target;i(e,o.files)},i=(o,n)=>{n&&(ou.setValue(o,((e,t)=>{const o=lC.explode(t.getOption("images_file_types"));return U(re(e),(e=>N(o,(t=>_e(e.name.toLowerCase(),`.${t.toLowerCase()}`)))))})(n,t)),Os(o,Rw,{name:e.name}))},l=Ah({dom:{tag:"input",attributes:{type:"file",accept:"image/*"},styles:{display:"none"}},behaviours:gl([Vp("input-file-events",[Hs($r()),Hs(ss())])])}),c=e.label.map((e=>Iw(e,t))),d=_w.parts.field({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-dropzone-container"]},behaviours:gl([sC(o.getOr([])),Jk(),km.config({}),Yp.config({toggleClass:"dragenter",toggleOnExecute:!1}),Vp("dropzone-events",[Fs("dragenter",r([n,Yp.toggle])),Fs("dragleave",r([n,Yp.toggle])),Fs("dragover",n),Fs("drop",r([n,s])),Fs(Gr(),a)])]),components:[{dom:{tag:"div",classes:["tox-dropzone"],styles:{}},components:[{dom:{tag:"p"},components:[Ga(t.translate("Drop an image here"))]},Mh.sketch({dom:{tag:"button",styles:{position:"relative"},classes:["tox-button","tox-button--secondary"]},components:[Ga(t.translate("Browse for an image")),l.asSpec()],action:e=>{l.get(e).element.dom.click()},buttonBehaviours:gl([Mw.config({}),ny(t.isDisabled),oy()])})]}]})}});return Dw(c,d,["tox-form__group--stretched"],[])})(e,t.shared.providers,o))),grid:CO(((e,t)=>((e,t)=>({dom:{tag:"div",classes:["tox-form__grid",`tox-form__grid--${e.columns}col`]},components:z(e.items,t.interpreter)}))(e,t.shared))),listbox:CO(((e,t,o)=>((e,t,o)=>{const n=t.shared.providers,r=o.bind((t=>BC(e.items,t))).orThunk((()=>oe(e.items).filter(MC))),s=e.label.map((e=>Iw(e,n))),a=_w.parts.field({dom:{},factory:{sketch:o=>CC({uid:o.uid,text:r.map((e=>e.text)),icon:M.none(),tooltip:e.label,role:M.none(),fetch:(o,n)=>{const r=DC(o,e.name,e.items,ou.getValue(o));n(EC(r,Jf.CLOSE_ON_EXECUTE,t,{isHorizontalMenu:!1,search:M.none()}))},onSetup:y(b),getApi:y({}),columns:1,presets:"normal",classes:[],dropdownBehaviours:[Mw.config({}),rC(r.map((e=>e.value)),(e=>xt(e.element,AC)),((t,o)=>{BC(e.items,o).each((e=>{vt(t.element,AC,e.value),Os(t,SC,{text:e.text})}))}))]},"tox-listbox",t.shared)}}),i={dom:{tag:"div",classes:["tox-listboxfield"]},components:[a]};return _w.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([s.toArray(),[i]]),fieldBehaviours:gl([km.config({disabled:y(!e.enabled),onDisabled:e=>{_w.getField(e).each(km.disable)},onEnabled:e=>{_w.getField(e).each(km.enable)}})])})})(e,t,o))),selectbox:CO(((e,t,o)=>((e,t,o)=>{const n=z(e.items,(e=>({text:t.translate(e.text),value:e.value}))),r=e.label.map((e=>Iw(e,t))),s=_w.parts.field({dom:{},...o.map((e=>({data:e}))).getOr({}),selectAttributes:{size:e.size},options:n,factory:FC,selectBehaviours:gl([km.config({disabled:()=>!e.enabled||t.isDisabled()}),Mw.config({}),Vp("selectbox-change",[Fs(Gr(),((t,o)=>{Os(t,Rw,{name:e.name})}))])])}),a=e.size>1?M.none():M.some(Lh("chevron-down",{tag:"div",classes:["tox-selectfield__icon-js"]},t.icons)),i={dom:{tag:"div",classes:["tox-selectfield"]},components:q([[s],a.toArray()])};return _w.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:q([r.toArray(),[i]]),fieldBehaviours:gl([km.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{_w.getField(e).each(km.disable)},onEnabled:e=>{_w.getField(e).each(km.enable)}}),oy()])})})(e,t.shared.providers,o))),sizeinput:CO(((e,t)=>((e,t)=>{let o=LC;const n=Qs("ratio-event"),r=e=>Lh(e,{tag:"span",classes:["tox-icon","tox-lock-icon__"+e]},t.icons),s=VC.parts.lock({dom:{tag:"button",classes:["tox-lock","tox-button","tox-button--naked","tox-button--icon"],attributes:{title:t.translate(e.label.getOr("Constrain proportions"))}},components:[r("lock"),r("unlock")],buttonBehaviours:gl([km.config({disabled:()=>!e.enabled||t.isDisabled()}),oy(),Mw.config({})])}),a=e=>({dom:{tag:"div",classes:["tox-form__group"]},components:e}),i=o=>_w.parts.field({factory:yb,inputClasses:["tox-textfield"],inputBehaviours:gl([km.config({disabled:()=>!e.enabled||t.isDisabled()}),oy(),Mw.config({}),Vp("size-input-events",[Fs(Lr(),((e,t)=>{Os(e,n,{isField1:o})})),Fs(Gr(),((t,o)=>{Os(t,Rw,{name:e.name})}))])]),selectOnFocus:!1}),l=e=>({dom:{tag:"label",classes:["tox-label"]},components:[Ga(t.translate(e))]}),c=VC.parts.field1(a([_w.parts.label(l("Width")),i(!0)])),d=VC.parts.field2(a([_w.parts.label(l("Height")),i(!1)]));return VC.sketch({dom:{tag:"div",classes:["tox-form__group"]},components:[{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:[c,d,a([l("\xa0"),s])]}],field1Name:"width",field2Name:"height",locked:!0,markers:{lockClass:"tox-locked"},onLockedChange:(e,t,n)=>{HC(ou.getValue(e)).each((e=>{o(e).each((e=>{ou.setValue(t,(e=>{const t={"":0,px:0,pt:1,mm:1,pc:2,ex:2,em:2,ch:2,rem:2,cm:3,in:4,"%":4};let o=e.value.toFixed((n=e.unit)in t?t[n]:1);var n;return-1!==o.indexOf(".")&&(o=o.replace(/\.?0*$/,"")),o+e.unit})(e))}))}))},coupledFieldBehaviours:gl([km.config({disabled:()=>!e.enabled||t.isDisabled(),onDisabled:e=>{VC.getField1(e).bind(_w.getField).each(km.disable),VC.getField2(e).bind(_w.getField).each(km.disable),VC.getLock(e).each(km.disable)},onEnabled:e=>{VC.getField1(e).bind(_w.getField).each(km.enable),VC.getField2(e).bind(_w.getField).each(km.enable),VC.getLock(e).each(km.enable)}}),oy(),Vp("size-input-events2",[Fs(n,((e,t)=>{const n=t.event.isField1,r=n?VC.getField1(e):VC.getField2(e),s=n?VC.getField2(e):VC.getField1(e),a=r.map(ou.getValue).getOr(""),i=s.map(ou.getValue).getOr("");o=((e,t)=>{const o=HC(e).toOptional(),n=HC(t).toOptional();return Se(o,n,((e,t)=>zC(e,t.unit).map((e=>t.value/e)).map((e=>{return o=e,n=t.unit,e=>zC(e,n).map((e=>({value:e*o,unit:n})));var o,n})).getOr(LC))).getOr(LC)})(a,i)}))])])})})(e,t.shared.providers))),slider:CO(((e,t,o)=>((e,t,o)=>{const n=Nk.parts.label({dom:{tag:"label",classes:["tox-label"]},components:[Ga(t.translate(e.label))]}),r=Nk.parts.spectrum({dom:{tag:"div",classes:["tox-slider__rail"],attributes:{role:"presentation"}}}),s=Nk.parts.thumb({dom:{tag:"div",classes:["tox-slider__handle"],attributes:{role:"presentation"}}});return Nk.sketch({dom:{tag:"div",classes:["tox-slider"],attributes:{role:"presentation"}},model:{mode:"x",minX:e.min,maxX:e.max,getInitialValue:y(o.getOrThunk((()=>(Math.abs(e.max)-Math.abs(e.min))/2)))},components:[n,r,s],sliderBehaviours:gl([Jk(),Up.config({})]),onChoose:(t,o,n)=>{Os(t,Rw,{name:e.name,value:n})}})})(e,t.shared.providers,o))),urlinput:CO(((e,t,o)=>((e,t,o,n)=>{const r=t.shared.providers,s=t=>{const n=ou.getValue(t);o.addToHistory(n.value,e.filetype)},a={...n.map((e=>({initialData:e}))).getOr({}),dismissOnBlur:!0,inputClasses:["tox-textfield"],sandboxClasses:["tox-dialog__popups"],inputAttributes:{"aria-errormessage":wO,type:"url"},minChars:0,responseTime:0,fetch:n=>{const r=((e,t,o)=>{const n=ou.getValue(t),r=void 0!==n.meta.text?n.meta.text:n.value;return o.getLinkInformation().fold((()=>[]),(t=>{const n=xO(r,(e=>z(e,(e=>pO(e,e))))(o.getHistory(e)));return"file"===e?(s=[n,xO(r,fO(t)),xO(r,q([vO(t),bO(t),yO(t)]))],j(s,((e,t)=>0===e.length||0===t.length?e.concat(t):e.concat(mO,t)),[])):n;var s}))})(e.filetype,n,o),s=EC(r,Jf.BUBBLE_TO_SANDBOX,t,{isHorizontalMenu:!1,search:M.none()});return Ux(s)},getHotspot:e=>g.getOpt(e),onSetValue:(e,t)=>{e.hasConfigured(Qw)&&Qw.run(e).get(b)},typeaheadBehaviours:gl([...o.getValidationHandler().map((t=>Qw.config({getRoot:e=>tt(e.element),invalidClass:"tox-control-wrap--status-invalid",notify:{onInvalid:(e,t)=>{c.getOpt(e).each((e=>{vt(e.element,"title",r.translate(t))}))}},validator:{validate:o=>{const n=ou.getValue(o);return oO((o=>{t({type:e.filetype,url:n.value},(e=>{if("invalid"===e.status){const t=Jo.error(e.message);o(t)}else{const t=Jo.value(e.message);o(t)}}))}))},validateOnLoad:!1}}))).toArray(),km.config({disabled:()=>!e.enabled||r.isDisabled()}),Mw.config({}),Vp("urlinput-events",[Fs(jr(),(t=>{const o=Na(t.element),n=o.trim();n!==o&&Va(t.element,n),"file"===e.filetype&&Os(t,Rw,{name:e.name})})),Fs(Gr(),(t=>{Os(t,Rw,{name:e.name}),s(t)})),Fs(ts(),(t=>{Os(t,Rw,{name:e.name}),s(t)}))])]),eventOrder:{[jr()]:["streaming","urlinput-events","invalidating"]},model:{getDisplayText:e=>e.value,selectsOver:!1,populateFromBrowse:!1},markers:{openClass:"tox-textfield--popup-open"},lazySink:t.shared.getSink,parts:{menu:pb(0,0,"normal")},onExecute:(e,t,o)=>{Os(t,zw,{})},onItemExecute:(t,o,n,r)=>{s(t),Os(t,Rw,{name:e.name})}},i=_w.parts.field({...a,factory:eO}),l=e.label.map((e=>Iw(e,r))),c=Ah(((e,t,o=e,n=e)=>Lh(o,{tag:"div",classes:["tox-icon","tox-control-wrap__status-icon-"+e],attributes:{title:r.translate(n),"aria-live":"polite",...t.fold((()=>({})),(e=>({id:e})))}},r.icons))("invalid",M.some(wO),"warning")),d=Ah({dom:{tag:"div",classes:["tox-control-wrap__status-icon-wrap"]},components:[c.asSpec()]}),u=o.getUrlPicker(e.filetype),m=Qs("browser.url.event"),g=Ah({dom:{tag:"div",classes:["tox-control-wrap"]},components:[i,d.asSpec()],behaviours:gl([km.config({disabled:()=>!e.enabled||r.isDisabled()})])}),p=Ah(cO({name:e.name,icon:M.some("browse"),text:e.label.getOr(""),enabled:e.enabled,primary:!1,buttonType:M.none(),borderless:!0},(e=>Cs(e,m)),r,[],["tox-browse-url"]));return _w.sketch({dom:Fw([]),components:l.toArray().concat([{dom:{tag:"div",classes:["tox-form__controls-h-stack"]},components:q([[g.asSpec()],u.map((()=>p.asSpec())).toArray()])}]),fieldBehaviours:gl([km.config({disabled:()=>!e.enabled||r.isDisabled(),onDisabled:e=>{_w.getField(e).each(km.disable),p.getOpt(e).each(km.disable)},onEnabled:e=>{_w.getField(e).each(km.enable),p.getOpt(e).each(km.enable)}}),oy(),Vp("url-input-events",[Fs(m,(t=>{cm.getCurrent(t).each((o=>{const n=ou.getValue(o),r={fieldname:e.name,...n};u.each((n=>{n(r).get((n=>{ou.setValue(o,n),Os(t,Rw,{name:e.name})}))}))}))}))])])})})(e,t,t.urlinput,o))),customeditor:CO((e=>{const t=Ul(),o=Ah({dom:{tag:e.tag}}),n=Ul();return{dom:{tag:"div",classes:["tox-custom-editor"]},behaviours:gl([Vp("custom-editor-events",[Ps((r=>{o.getOpt(r).each((o=>{((e=>ve(e,"init"))(e)?e.init(o.element.dom):iC.load(e.scriptId,e.scriptUrl).then((t=>t(o.element.dom,e.settings)))).then((e=>{n.on((t=>{e.setValue(t)})),n.clear(),t.set(e)}))}))}))]),rC(M.none(),(()=>t.get().fold((()=>n.get().getOr("")),(e=>e.getValue()))),((e,o)=>{t.get().fold((()=>n.set(o)),(e=>e.setValue(o)))})),Jk()]),components:[o.asSpec()]}})),htmlpanel:CO((e=>"presentation"===e.presets?Sw.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html}}):Sw.sketch({dom:{tag:"div",classes:["tox-form__group"],innerHtml:e.html,attributes:{role:"document"}},containerBehaviours:gl([Mw.config({}),Up.config({})])}))),imagepreview:CO(((e,t,o)=>((e,t)=>{const o=xr(t.getOr({url:""})),n=Ah({dom:{tag:"img",classes:["tox-imagepreview__image"],attributes:t.map((e=>({src:e.url}))).getOr({})}}),r=Ah({dom:{tag:"div",classes:["tox-imagepreview__container"],attributes:{role:"presentation"}},components:[n.asSpec()]}),s={};e.height.each((e=>s.height=e));const a=t.map((e=>({url:e.url,zoom:M.from(e.zoom),cachedWidth:M.from(e.cachedWidth),cachedHeight:M.from(e.cachedHeight)})));return{dom:{tag:"div",classes:["tox-imagepreview"],styles:s,attributes:{role:"presentation"}},components:[r.asSpec()],behaviours:gl([Jk(),rC(a,(()=>o.get()),((e,t)=>{const s={url:t.url};t.zoom.each((e=>s.zoom=e)),t.cachedWidth.each((e=>s.cachedWidth=e)),t.cachedHeight.each((e=>s.cachedHeight=e)),o.set(s);const a=()=>{const{cachedWidth:t,cachedHeight:o,zoom:n}=s;if(!u(t)&&!u(o)){if(u(n)){const n=((e,t,o)=>{const n=$t(e),r=Ht(e);return Math.min(n/t,r/o,1)})(e.element,t,o);s.zoom=n}const a=((e,t,o,n,r)=>{const s=o*r,a=n*r,i=Math.max(0,e/2-s/2),l=Math.max(0,t/2-a/2);return{left:i.toString()+"px",top:l.toString()+"px",width:s.toString()+"px",height:a.toString()+"px"}})($t(e.element),Ht(e.element),t,o,s.zoom);r.getOpt(e).each((e=>{Tt(e.element,a)}))}};n.getOpt(e).each((o=>{const n=o.element;var r;t.url!==xt(n,"src")&&(vt(n,"src",t.url),Ba(e.element,"tox-imagepreview__loaded")),a(),(r=n,new Promise(((e,t)=>{const o=()=>{s(),e(r)},n=[jl(r,"load",o),jl(r,"error",(()=>{s(),t("Unable to load data from image: "+r.dom.src)}))],s=()=>L(n,(e=>e.unbind()));r.dom.complete&&o()}))).then((t=>{e.getSystem().isConnected()&&(Da(e.element,"tox-imagepreview__loaded"),s.cachedWidth=t.dom.naturalWidth,s.cachedHeight=t.dom.naturalHeight,a())}))}))}))])}})(e,o))),table:CO(((e,t)=>((e,t)=>{const o=e=>({dom:{tag:"td",innerHtml:t.translate(e)}});return{dom:{tag:"table",classes:["tox-dialog__table"]},components:[(r=e.header,{dom:{tag:"thead"},components:[{dom:{tag:"tr"},components:z(r,(e=>({dom:{tag:"th",innerHtml:t.translate(e)}})))}]}),(n=e.cells,{dom:{tag:"tbody"},components:z(n,(e=>({dom:{tag:"tr"},components:z(e,o)})))})],behaviours:gl([Mw.config({}),Up.config({})])};var n,r})(e,t.shared.providers))),panel:CO(((e,t)=>((e,t)=>({dom:{tag:"div",classes:e.classes},components:z(e.items,t.shared.interpreter)}))(e,t)))},_O={field:(e,t)=>t,record:y([])},TO=(e,t,o,n)=>{const r=cn(n,{shared:{interpreter:t=>EO(e,t,o,r)}});return EO(e,t,o,r)},EO=(e,t,o,n)=>be(OO,t.type).fold((()=>(console.error(`Unknown factory type "${t.type}", defaulting to container: `,t),t)),(r=>r(e,t,o,n))),MO=(e,t,o)=>EO(_O,e,t,o),AO="layout-inset",DO=e=>e.x,BO=(e,t)=>e.x+e.width/2-t.width/2,FO=(e,t)=>e.x+e.width-t.width,IO=e=>e.y,RO=(e,t)=>e.y+e.height-t.height,NO=(e,t)=>e.y+e.height/2-t.height/2,VO=(e,t,o)=>Ei(FO(e,t),RO(e,t),o.insetSouthwest(),Fi(),"southwest",Li(e,{right:0,bottom:3}),AO),HO=(e,t,o)=>Ei(DO(e),RO(e,t),o.insetSoutheast(),Bi(),"southeast",Li(e,{left:1,bottom:3}),AO),zO=(e,t,o)=>Ei(FO(e,t),IO(e),o.insetNorthwest(),Di(),"northwest",Li(e,{right:0,top:2}),AO),LO=(e,t,o)=>Ei(DO(e),IO(e),o.insetNortheast(),Ai(),"northeast",Li(e,{left:1,top:2}),AO),PO=(e,t,o)=>Ei(BO(e,t),IO(e),o.insetNorth(),Ii(),"north",Li(e,{top:2}),AO),UO=(e,t,o)=>Ei(BO(e,t),RO(e,t),o.insetSouth(),Ri(),"south",Li(e,{bottom:3}),AO),WO=(e,t,o)=>Ei(FO(e,t),NO(e,t),o.insetEast(),Vi(),"east",Li(e,{right:0}),AO),jO=(e,t,o)=>Ei(DO(e),NO(e,t),o.insetWest(),Ni(),"west",Li(e,{left:1}),AO),GO=e=>{switch(e){case"north":return PO;case"northeast":return LO;case"northwest":return zO;case"south":return UO;case"southeast":return HO;case"southwest":return VO;case"east":return WO;case"west":return jO}},$O=(e,t,o,n,r)=>Vl(n).map(GO).getOr(PO)(e,t,o,n,r),qO=e=>{switch(e){case"north":return UO;case"northeast":return HO;case"northwest":return VO;case"south":return PO;case"southeast":return LO;case"southwest":return zO;case"east":return jO;case"west":return WO}},XO=(e,t,o,n,r)=>Vl(n).map(qO).getOr(PO)(e,t,o,n,r),KO={valignCentre:[],alignCentre:[],alignLeft:[],alignRight:[],right:[],left:[],bottom:[],top:[]},YO=(e,t,o)=>{const n={maxHeightFunction:Zl()};return()=>o()?{type:"node",root:ut(dt(e())),node:M.from(e()),bubble:oc(12,12,KO),layouts:{onRtl:()=>[LO],onLtr:()=>[zO]},overrides:n}:{type:"hotspot",hotspot:t(),bubble:oc(-12,12,KO),layouts:{onRtl:()=>[Xi],onLtr:()=>[Ki]},overrides:n}},JO=(e,t,o)=>()=>o()?{type:"node",root:ut(dt(e())),node:M.from(e()),layouts:{onRtl:()=>[PO],onLtr:()=>[PO]}}:{type:"hotspot",hotspot:t(),layouts:{onRtl:()=>[Qi],onLtr:()=>[Qi]}},ZO=(e,t)=>()=>({type:"selection",root:t(),getSelection:()=>{const t=e.selection.getRng();return M.some(Mc.range(Ie(t.startContainer),t.startOffset,Ie(t.endContainer),t.endOffset))}}),QO=e=>t=>({type:"node",root:e(),node:t}),e_=(e,t,o)=>{const n=Uf(e),r=()=>Ie(e.getBody()),s=()=>Ie(e.getContentAreaContainer()),a=()=>n||!o();return{inlineDialog:YO(s,t,a),banner:JO(s,t,a),cursor:ZO(e,r),node:QO(r)}},t_=e=>(t,o)=>{Sx(e)(t,o)},o_=e=>()=>dx(e),n_=e=>t=>ux(e,t),r_=e=>t=>cx(e,t),s_=e=>()=>Of(e),a_=e=>ye(e,"items"),i_=e=>ye(e,"format"),l_=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",format:"bold"},{title:"Italic",format:"italic"},{title:"Underline",format:"underline"},{title:"Strikethrough",format:"strikethrough"},{title:"Superscript",format:"superscript"},{title:"Subscript",format:"subscript"},{title:"Code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Align",items:[{title:"Left",format:"alignleft"},{title:"Center",format:"aligncenter"},{title:"Right",format:"alignright"},{title:"Justify",format:"alignjustify"}]}],c_=e=>j(e,((e,t)=>{if(ve(t,"items")){const o=c_(t.items);return{customFormats:e.customFormats.concat(o.customFormats),formats:e.formats.concat([{title:t.title,items:o.formats}])}}if(ve(t,"inline")||(e=>ve(e,"block"))(t)||(e=>ve(e,"selector"))(t)){const o=`custom-${s(t.name)?t.name:t.title.toLowerCase()}`;return{customFormats:e.customFormats.concat([{name:o,format:t}]),formats:e.formats.concat([{title:t.title,format:o,icon:t.icon}])}}return{...e,formats:e.formats.concat(t)}}),{customFormats:[],formats:[]}),d_=e=>rf(e).map((t=>{const o=((e,t)=>{const o=c_(t),n=t=>{L(t,(t=>{e.formatter.has(t.name)||e.formatter.register(t.name,t.format)}))};return e.formatter?n(o.customFormats):e.on("init",(()=>{n(o.customFormats)})),o.formats})(e,t);return sf(e)?l_.concat(o):o})).getOr(l_),u_=(e,t,o)=>({...e,type:"formatter",isSelected:t(e.format),getStylePreview:o(e.format)}),m_=(e,t,o,n)=>{const r=t=>z(t,(t=>a_(t)?(e=>{const t=r(e.items);return{...e,type:"submenu",getStyleItems:y(t)}})(t):i_(t)?(e=>u_(e,o,n))(t):(e=>{const t=ae(e);return 1===t.length&&R(t,"title")})(t)?{...t,type:"separator"}:(t=>{const r=s(t.name)?t.name:Qs(t.title),a=`custom-${r}`,i={...t,type:"formatter",format:a,isSelected:o(a),getStylePreview:n(a)};return e.formatter.register(r,i),i})(t)));return r(t)},g_=lC.trim,p_=e=>t=>{if((e=>g(e)&&1===e.nodeType)(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},h_=p_("true"),f_=p_("false"),b_=(e,t,o,n,r)=>({type:e,title:t,url:o,level:n,attach:r}),v_=e=>e.innerText||e.textContent,y_=e=>(e=>e&&"A"===e.nodeName&&void 0!==(e.id||e.name))(e)&&w_(e),x_=e=>e&&/^(H[1-6])$/.test(e.nodeName),w_=e=>(e=>{let t=e;for(;t=t.parentNode;){const e=t.contentEditable;if(e&&"inherit"!==e)return h_(t)}return!1})(e)&&!f_(e),S_=e=>x_(e)&&w_(e),k_=e=>{var t;const o=(e=>e.id?e.id:Qs("h"))(e);return b_("header",null!==(t=v_(e))&&void 0!==t?t:"","#"+o,(e=>x_(e)?parseInt(e.nodeName.substr(1),10):0)(e),(()=>{e.id=o}))},C_=e=>{const t=e.id||e.name,o=v_(e);return b_("anchor",o||"#"+t,"#"+t,0,b)},O_=e=>g_(e.title).length>0,__=e=>{const t=(e=>{const t=z(Nc(Ie(e),"h1,h2,h3,h4,h5,h6,a:not([href])"),(e=>e.dom));return t})(e);return U((e=>z(U(e,S_),k_))(t).concat((e=>z(U(e,y_),C_))(t)),O_)},T_="tinymce-url-history",E_=e=>s(e)&&/^https?/.test(e),M_=e=>a(e)&&he(e,(e=>{return!(l(t=e)&&t.length<=5&&K(t,E_));var t})).isNone(),A_=()=>{const e=Ky.getItem(T_);if(null===e)return{};let t;try{t=JSON.parse(e)}catch(e){if(e instanceof SyntaxError)return console.log("Local storage "+T_+" was not valid JSON",e),{};throw e}return M_(t)?t:(console.log("Local storage "+T_+" was not valid format",t),{})},D_=e=>{const t=A_();return be(t,e).getOr([])},B_=(e,t)=>{if(!E_(e))return;const o=A_(),n=be(o,t).getOr([]),r=U(n,(t=>t!==e));o[t]=[e].concat(r).slice(0,5),(e=>{if(!M_(e))throw new Error("Bad format for history:\n"+JSON.stringify(e));Ky.setItem(T_,JSON.stringify(e))})(o)},F_=e=>!!e,I_=e=>ce(lC.makeMap(e,/[, ]/),F_),R_=e=>M.from(yf(e)),N_=e=>M.from(e).filter(s).getOrUndefined(),V_=e=>({getHistory:D_,addToHistory:B_,getLinkInformation:()=>(e=>Sf(e)?M.some({targets:__(e.getBody()),anchorTop:N_(kf(e)),anchorBottom:N_(Cf(e))}):M.none())(e),getValidationHandler:()=>(e=>M.from(xf(e)))(e),getUrlPicker:t=>((e,t)=>((e,t)=>{const o=(e=>{const t=M.from(wf(e)).filter(F_).map(I_);return R_(e).fold(_,(e=>t.fold(T,(e=>ae(e).length>0&&e))))})(e);return d(o)?o?R_(e):M.none():o[t]?R_(e):M.none()})(e,t).map((o=>n=>Px((r=>{const i={filetype:t,fieldname:n.fieldname,...M.from(n.meta).getOr({})};o.call(e,((e,t)=>{if(!s(e))throw new Error("Expected value to be string");if(void 0!==t&&!a(t))throw new Error("Expected meta to be a object");r({value:e,meta:t})}),n.value,i)})))))(e,t)}),H_=Zu,z_=Ru,L_=y([ur("shell",!1),Xn("makeItem"),ur("setupItem",b),au("listBehaviours",[Np])]),P_=Bu({name:"items",overrides:()=>({behaviours:gl([Np.config({})])})}),U_=y([P_]),W_=sm({name:y("CustomList")(),configFields:L_(),partFields:U_(),factory:(e,t,o,n)=>{const r=e.shell?{behaviours:[Np.config({})],components:[]}:{behaviours:[],components:t};return{uid:e.uid,dom:e.dom,components:r.components,behaviours:su(e.listBehaviours,r.behaviours),apis:{setItems:(t,o)=>{var n;(n=t,e.shell?M.some(n):ju(n,e,"items")).fold((()=>{throw console.error("Custom List was defined to not be a shell, but no item container was specified in components"),new Error("Custom List was defined to not be a shell, but no item container was specified in components")}),(n=>{const r=Np.contents(n),s=o.length,a=s-r.length,i=a>0?V(a,(()=>e.makeItem())):[],l=r.slice(s);L(l,(e=>Np.remove(n,e))),L(i,(e=>Np.append(n,e)));const c=Np.contents(n);L(c,((n,r)=>{e.setupItem(t,n,o[r],r)}))}))}}}},apis:{setItems:(e,t,o)=>{e.setItems(t,o)}}}),j_=y([Xn("dom"),ur("shell",!0),nu("toolbarBehaviours",[Np])]),G_=y([Bu({name:"groups",overrides:()=>({behaviours:gl([Np.config({})])})})]),$_=sm({name:"Toolbar",configFields:j_(),partFields:G_(),factory:(e,t,o,n)=>{const r=e.shell?{behaviours:[Np.config({})],components:[]}:{behaviours:[],components:t};return{uid:e.uid,dom:e.dom,components:r.components,behaviours:su(e.toolbarBehaviours,r.behaviours),apis:{setGroups:(t,o)=>{var n;(n=t,e.shell?M.some(n):ju(n,e,"groups")).fold((()=>{throw console.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new Error("Toolbar was defined to not be a shell, but no groups container was specified in components")}),(e=>{Np.set(e,o)}))}},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)}}}),q_=b,X_=_,K_=y([]);var Y_,J_=Object.freeze({__proto__:null,setup:q_,isDocked:X_,getBehaviours:K_});const Z_=e=>(xe(Dt(e,"position"),"fixed")?M.none():ot(e)).orThunk((()=>{const t=Be("span");return et(e).bind((e=>{Fo(e,t);const o=ot(t);return No(t),o}))})),Q_=e=>Z_(e).map(Wt).getOrThunk((()=>Pt(0,0))),eT=wr([{static:[]},{absolute:["positionCss"]},{fixed:["positionCss"]}]),tT=(e,t)=>{const o=e.element;Da(o,t.transitionClass),Ba(o,t.fadeOutClass),Da(o,t.fadeInClass),t.onShow(e)},oT=(e,t)=>{const o=e.element;Da(o,t.transitionClass),Ba(o,t.fadeInClass),Da(o,t.fadeOutClass),t.onHide(e)},nT=(e,t,o)=>K(e,(e=>{switch(e){case"bottom":return((e,t)=>e.bottom<=t.bottom)(t,o);case"top":return((e,t)=>e.y>=t.y)(t,o)}})),rT=(e,t)=>t.getInitialPos().map((t=>Go(t.bounds.x,t.bounds.y,$t(e),Ht(e)))),sT=(e,t,o)=>o.getInitialPos().bind((n=>{switch(o.clearInitialPos(),n.position){case"static":return M.some(eT.static());case"absolute":const o=Z_(e).map($o).getOrThunk((()=>$o(ht())));return M.some(eT.absolute(_l("absolute",be(n.style,"left").map((e=>t.x-o.x)),be(n.style,"top").map((e=>t.y-o.y)),be(n.style,"right").map((e=>o.right-t.right)),be(n.style,"bottom").map((e=>o.bottom-t.bottom)))));default:return M.none()}})),aT=(e,t,o)=>{const n=e.element;return xe(Dt(n,"position"),"fixed")?((e,t,o)=>rT(e,o).filter((e=>nT(o.getModes(),e,t))).bind((t=>sT(e,t,o))))(n,t,o):((e,t,o)=>{const n=$o(e);if(nT(o.getModes(),n,t))return M.none();{((e,t,o)=>{o.setInitialPos({style:Bt(e),position:Mt(e,"position")||"static",bounds:t})})(e,n,o);const r=Xo(),s=n.x-r.x,a=t.y-r.y,i=r.bottom-t.bottom,l=n.y<=t.y;return M.some(eT.fixed(_l("fixed",M.some(s),l?M.some(a):M.none(),M.none(),l?M.none():M.some(i))))}})(n,t,o)},iT=(e,t,o)=>{o.setDocked(!1),L(["left","right","top","bottom","position"],(t=>It(e.element,t))),t.onUndocked(e)},lT=(e,t,o,n)=>{const r="fixed"===n.position;o.setDocked(r),Tl(e.element,n),(r?t.onDocked:t.onUndocked)(e)},cT=(e,t,o,n,r=!1)=>{t.contextual.each((t=>{t.lazyContext(e).each((s=>{const a=((e,t)=>e.y<t.bottom&&e.bottom>t.y)(s,n);a!==o.isVisible()&&(o.setVisible(a),r&&!a?(Ia(e.element,[t.fadeOutClass]),t.onHide(e)):(a?tT:oT)(e,t))}))}))},dT=(e,t,o)=>{e.getSystem().isConnected()&&((e,t,o)=>{const n=t.lazyViewport(e);o.isDocked()&&cT(e,t,o,n),aT(e,n,o).each((r=>{r.fold((()=>iT(e,t,o)),(n=>lT(e,t,o,n)),(r=>{cT(e,t,o,n,!0),lT(e,t,o,r)}))}))})(e,t,o)},uT=(e,t,o)=>{o.isDocked()&&((e,t,o)=>{const n=e.element;o.setDocked(!1),((e,t)=>{const o=e.element;return rT(o,t).bind((e=>sT(o,e,t)))})(e,o).each((n=>{n.fold((()=>iT(e,t,o)),(n=>lT(e,t,o,n)),b)})),o.setVisible(!0),t.contextual.each((t=>{Ra(n,[t.fadeInClass,t.fadeOutClass,t.transitionClass]),t.onShow(e)})),dT(e,t,o)})(e,t,o)};var mT=Object.freeze({__proto__:null,refresh:dT,reset:uT,isDocked:(e,t,o)=>o.isDocked(),getModes:(e,t,o)=>o.getModes(),setModes:(e,t,o,n)=>o.setModes(n)}),gT=Object.freeze({__proto__:null,events:(e,t)=>As([Ls(Xr(),((o,n)=>{e.contextual.each((e=>{Fa(o.element,e.transitionClass)&&(Ra(o.element,[e.transitionClass,e.fadeInClass]),(t.isVisible()?e.onShown:e.onHidden)(o)),n.stop()}))})),Fs(ms(),((o,n)=>{dT(o,e,t)})),Fs(gs(),((o,n)=>{uT(o,e,t)}))])}),pT=[dr("contextual",[Jn("fadeInClass"),Jn("fadeOutClass"),Jn("transitionClass"),Qn("lazyContext"),wi("onShow"),wi("onShown"),wi("onHide"),wi("onHidden")]),br("lazyViewport",Xo),vr("modes",["top","bottom"],Bn),wi("onDocked"),wi("onUndocked")];const hT=hl({fields:pT,name:"docking",active:gT,apis:mT,state:Object.freeze({__proto__:null,init:e=>{const t=xr(!1),o=xr(!0),n=Ul(),r=xr(e.modes);return ba({isDocked:t.get,setDocked:t.set,getInitialPos:n.get,setInitialPos:n.set,clearInitialPos:n.clear,isVisible:o.get,setVisible:o.set,getModes:r.get,setModes:r.set,readState:()=>`docked:  ${t.get()}, visible: ${o.get()}, modes: ${r.get().join(",")}`})}})}),fT=y(Qs("toolbar-height-change")),bT={fadeInClass:"tox-editor-dock-fadein",fadeOutClass:"tox-editor-dock-fadeout",transitionClass:"tox-editor-dock-transition"},vT="tox-tinymce--toolbar-sticky-on",yT="tox-tinymce--toolbar-sticky-off",xT=(e,t)=>R(hT.getModes(e),t),wT=e=>{const t=e.element;tt(t).each((o=>{const n="padding-"+hT.getModes(e)[0];if(hT.isDocked(e)){const e=$t(o);_t(t,"width",e+"px"),_t(o,n,(e=>zt(e)+(parseInt(Mt(e,"margin-top"),10)||0)+(parseInt(Mt(e,"margin-bottom"),10)||0))(t)+"px")}else It(t,"width"),It(o,n)}))},ST=(e,t)=>{t?(Ba(e,bT.fadeOutClass),Ia(e,[bT.transitionClass,bT.fadeInClass])):(Ba(e,bT.fadeInClass),Ia(e,[bT.fadeOutClass,bT.transitionClass]))},kT=(e,t)=>{const o=Ie(e.getContainer());t?(Da(o,vT),Ba(o,yT)):(Da(o,yT),Ba(o,vT))},CT=(e,t)=>{const o=Ul(),n=t.getSink,r=e=>{n().each((t=>e(t.element)))},s=t=>{e.inline||wT(t),kT(e,hT.isDocked(t)),t.getSystem().broadcastOn([Hd()],{}),n().each((e=>e.getSystem().broadcastOn([Hd()],{})))},a=e.inline?[]:[yl.config({channels:{[fT()]:{onReceive:wT}}})];return[Up.config({}),hT.config({contextual:{lazyContext:t=>{const o=zt(t.element),n=e.inline?e.getContentAreaContainer():e.getContainer(),r=$o(Ie(n)),s=r.height-o,a=r.y+(xT(t,"top")?0:o);return M.some(Go(r.x,a,r.width,s))},onShow:()=>{r((e=>ST(e,!0)))},onShown:e=>{r((e=>Ra(e,[bT.transitionClass,bT.fadeInClass]))),o.get().each((t=>{((e,t)=>{const o=Ye(t);kl(o).filter((e=>!Xe(t,e))).filter((t=>Xe(t,Ie(o.dom.body))||Ke(e,t))).each((()=>wl(t)))})(e.element,t),o.clear()}))},onHide:e=>{((e,t)=>Cl(e).orThunk((()=>t().toOptional().bind((e=>Cl(e.element))))))(e.element,n).fold(o.clear,o.set),r((e=>ST(e,!1)))},onHidden:()=>{r((e=>Ra(e,[bT.transitionClass])))},...bT},lazyViewport:t=>{const o=Xo(),n=ff(e),r=o.y+(xT(t,"top")?n:0),s=o.height-(xT(t,"bottom")?n:0);return Go(o.x,r,o.width,s)},modes:[t.header.getDockingMode()],onDocked:s,onUndocked:s}),...a]};var OT=Object.freeze({__proto__:null,setup:(e,t,o)=>{e.inline||(t.header.isPositionedAtTop()||e.on("ResizeEditor",(()=>{o().each(hT.reset)})),e.on("ResizeWindow ResizeEditor",(()=>{o().each(wT)})),e.on("SkinLoaded",(()=>{o().each((e=>{hT.isDocked(e)?hT.reset(e):hT.refresh(e)}))})),e.on("FullscreenStateChanged",(()=>{o().each(hT.reset)}))),e.on("AfterScrollIntoView",(e=>{o().each((t=>{hT.refresh(t);const o=t.element;Sg(o)&&((e,t)=>{const o=Ye(t),n=Qe(t).dom.innerHeight,r=Vo(o),s=Ie(e.elm),a=qo(s),i=Ht(s),l=a.y,c=l+i,d=Wt(t),u=Ht(t),m=d.top,g=m+u,p=Math.abs(m-r.top)<2,h=Math.abs(g-(r.top+n))<2;if(p&&l<g)Ho(r.left,l-u,o);else if(h&&c>m){const e=l-n+i+u;Ho(r.left,e,o)}})(e,o)}))})),e.on("PostRender",(()=>{kT(e,!1)}))},isDocked:e=>e().map(hT.isDocked).getOr(!1),getBehaviours:CT});const _T=Cn([Nb,Kn("items",_n([En([Vb,or("items",Bn)]),Bn]))].concat(mv)),TT=[ar("text"),ar("tooltip"),ar("icon"),mr("search",!1,_n([Fn,Cn([ar("placeholder")])],(e=>d(e)?e?M.some({placeholder:M.none()}):M.none():M.some(e)))),Qn("fetch"),br("onSetup",(()=>b))],ET=Cn([Nb,...TT]),MT=e=>Ln("menubutton",ET,e),AT=Cn([Nb,Jb,Yb,Kb,ev,Wb,qb,hr("presets","normal",["normal","color","listpreview"]),sv(1),Gb,$b]);var DT=rm({factory:(e,t)=>{const o={focus:Tp.focusIn,setMenus:(e,o)=>{const n=z(o,(e=>{const o={type:"menubutton",text:e.text,fetch:t=>{t(e.getItems())}},n=MT(o).mapError((e=>Wn(e))).getOrDie();return rO(n,"tox-mbtn",t.backstage,M.some("menuitem"))}));Np.set(e,n)}};return{uid:e.uid,dom:e.dom,components:[],behaviours:gl([Np.config({}),Vp("menubar-events",[Ps((t=>{e.onSetup(t)})),Fs(zr(),((e,t)=>{ri(e.element,".tox-mbtn--active").each((o=>{si(t.event.target,".tox-mbtn").each((t=>{Xe(o,t)||e.getSystem().getByDom(o).each((o=>{e.getSystem().getByDom(t).each((e=>{ow.expand(e),ow.close(o),Up.focus(e)}))}))}))}))})),Fs(vs(),((e,t)=>{t.event.prevFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((o=>{t.event.newFocus.bind((t=>e.getSystem().getByDom(t).toOptional())).each((e=>{ow.isOpen(o)&&(ow.expand(e),ow.close(o))}))}))}))]),Tp.config({mode:"flow",selector:".tox-mbtn",onEscape:t=>(e.onEscape(t),M.some(!0))}),Mw.config({})]),apis:o,domModification:{attributes:{role:"menubar"}}}},name:"silver.Menubar",configFields:[Xn("dom"),Xn("uid"),Xn("onEscape"),Xn("backstage"),ur("onSetup",b)],apis:{focus:(e,t)=>{e.focus(t)},setMenus:(e,t,o)=>{e.setMenus(t,o)}}});const BT=(e,t)=>t.getAnimationRoot.fold((()=>e.element),(t=>t(e))),FT=e=>e.dimension.property,IT=(e,t)=>e.dimension.getDimension(t),RT=(e,t)=>{const o=BT(e,t);Ra(o,[t.shrinkingClass,t.growingClass])},NT=(e,t)=>{Ba(e.element,t.openClass),Da(e.element,t.closedClass),_t(e.element,FT(t),"0px"),Rt(e.element)},VT=(e,t)=>{Ba(e.element,t.closedClass),Da(e.element,t.openClass),It(e.element,FT(t))},HT=(e,t,o,n)=>{o.setCollapsed(),_t(e.element,FT(t),IT(t,e.element)),RT(e,t),NT(e,t),t.onStartShrink(e),t.onShrunk(e)},zT=(e,t,o,n)=>{const r=n.getOrThunk((()=>IT(t,e.element)));o.setCollapsed(),_t(e.element,FT(t),r),Rt(e.element);const s=BT(e,t);Ba(s,t.growingClass),Da(s,t.shrinkingClass),NT(e,t),t.onStartShrink(e)},LT=(e,t,o)=>{const n=IT(t,e.element);("0px"===n?HT:zT)(e,t,o,M.some(n))},PT=(e,t,o)=>{const n=BT(e,t),r=Fa(n,t.shrinkingClass),s=IT(t,e.element);VT(e,t);const a=IT(t,e.element);(r?()=>{_t(e.element,FT(t),s),Rt(e.element)}:()=>{NT(e,t)})(),Ba(n,t.shrinkingClass),Da(n,t.growingClass),VT(e,t),_t(e.element,FT(t),a),o.setExpanded(),t.onStartGrow(e)},UT=(e,t,o)=>{const n=BT(e,t);return!0===Fa(n,t.growingClass)},WT=(e,t,o)=>{const n=BT(e,t);return!0===Fa(n,t.shrinkingClass)};var jT=Object.freeze({__proto__:null,refresh:(e,t,o)=>{if(o.isExpanded()){It(e.element,FT(t));const o=IT(t,e.element);_t(e.element,FT(t),o)}},grow:(e,t,o)=>{o.isExpanded()||PT(e,t,o)},shrink:(e,t,o)=>{o.isExpanded()&&LT(e,t,o)},immediateShrink:(e,t,o)=>{o.isExpanded()&&HT(e,t,o)},hasGrown:(e,t,o)=>o.isExpanded(),hasShrunk:(e,t,o)=>o.isCollapsed(),isGrowing:UT,isShrinking:WT,isTransitioning:(e,t,o)=>UT(e,t)||WT(e,t),toggleGrow:(e,t,o)=>{(o.isExpanded()?LT:PT)(e,t,o)},disableTransitions:RT,immediateGrow:(e,t,o)=>{o.isExpanded()||(VT(e,t),_t(e.element,FT(t),IT(t,e.element)),RT(e,t),o.setExpanded(),t.onStartGrow(e),t.onGrown(e))}}),GT=Object.freeze({__proto__:null,exhibit:(e,t,o)=>{const n=t.expanded;return ya(n?{classes:[t.openClass],styles:{}}:{classes:[t.closedClass],styles:Sr(t.dimension.property,"0px")})},events:(e,t)=>As([Ls(Xr(),((o,n)=>{n.event.raw.propertyName===e.dimension.property&&(RT(o,e),t.isExpanded()&&It(o.element,e.dimension.property),(t.isExpanded()?e.onGrown:e.onShrunk)(o))}))])}),$T=[Xn("closedClass"),Xn("openClass"),Xn("shrinkingClass"),Xn("growingClass"),nr("getAnimationRoot"),wi("onShrunk"),wi("onStartShrink"),wi("onGrown"),wi("onStartGrow"),ur("expanded",!1),Kn("dimension",jn("property",{width:[Oi("property","width"),Oi("getDimension",(e=>$t(e)+"px"))],height:[Oi("property","height"),Oi("getDimension",(e=>Ht(e)+"px"))]}))];const qT=hl({fields:$T,name:"sliding",active:GT,apis:jT,state:Object.freeze({__proto__:null,init:e=>{const t=xr(e.expanded);return ba({isExpanded:()=>!0===t.get(),isCollapsed:()=>!1===t.get(),setCollapsed:S(t.set,!1),setExpanded:S(t.set,!0),readState:()=>"expanded: "+t.get()})}})}),XT="container",KT=[nu("slotBehaviours",[])],YT=e=>"<alloy.field."+e+">",JT=(e,t)=>{const o=t=>Xu(e),n=(t,o)=>(n,r)=>ju(n,e,r).map((e=>t(e,r))).getOr(o),r=(e,t)=>"true"!==xt(e.element,"aria-hidden"),s=n(r,!1),a=n(((e,t)=>{if(r(e)){const o=e.element;_t(o,"display","none"),vt(o,"aria-hidden","true"),Os(e,ys(),{name:t,visible:!1})}})),i=(l=a,(e,t)=>{L(t,(t=>l(e,t)))});var l;const c=n(((e,t)=>{if(!r(e)){const o=e.element;It(o,"display"),kt(o,"aria-hidden"),Os(e,ys(),{name:t,visible:!0})}})),d={getSlotNames:o,getSlot:(t,o)=>ju(t,e,o),isShowing:s,hideSlot:a,hideAllSlots:e=>i(e,o()),showSlot:c};return{uid:e.uid,dom:e.dom,components:t,behaviours:ru(e.slotBehaviours),apis:d}},ZT=ce({getSlotNames:(e,t)=>e.getSlotNames(t),getSlot:(e,t,o)=>e.getSlot(t,o),isShowing:(e,t,o)=>e.isShowing(t,o),hideSlot:(e,t,o)=>e.hideSlot(t,o),hideAllSlots:(e,t)=>e.hideAllSlots(t),showSlot:(e,t,o)=>e.showSlot(t,o)},(e=>ha(e))),QT={...ZT,sketch:e=>{const t=(()=>{const e=[];return{slot:(t,o)=>(e.push(t),zu(XT,YT(t),o)),record:y(e)}})(),o=e(t),n=t.record(),r=z(n,(e=>Au({name:e,pname:YT(e)})));return em(XT,KT,r,JT,o)}},eE=Cn([Yb,Jb,br("onShow",b),br("onHide",b),qb]),tE=e=>({element:()=>e.element.dom}),oE=(e,t)=>{const o=z(ae(t),(e=>{const o=t[e],n=Pn((e=>Ln("sidebar",eE,e))(o));return{name:e,getApi:tE,onSetup:n.onSetup,onShow:n.onShow,onHide:n.onHide}}));return z(o,(t=>{const n=xr(b);return e.slot(t.name,{dom:{tag:"div",classes:["tox-sidebar__pane"]},behaviours:Wv([iy(t,n),ly(t,n),Fs(ys(),((e,t)=>{const n=t.event,r=G(o,(e=>e.name===n.name));r.each((t=>{(n.visible?t.onShow:t.onHide)(t.getApi(e))}))}))])})}))},nE=e=>QT.sketch((t=>({dom:{tag:"div",classes:["tox-sidebar__pane-container"]},components:oE(t,e),slotBehaviours:Wv([Ps((e=>QT.hideAllSlots(e)))])}))),rE=e=>cm.getCurrent(e).bind((e=>qT.isGrowing(e)||qT.hasGrown(e)?cm.getCurrent(e).bind((e=>G(QT.getSlotNames(e),(t=>QT.isShowing(e,t))))):M.none())),sE=Qs("FixSizeEvent"),aE=Qs("AutoSizeEvent");var iE=Object.freeze({__proto__:null,block:(e,t,o,n)=>{vt(e.element,"aria-busy",!0);const r=t.getRoot(e).getOr(e),s=gl([Tp.config({mode:"special",onTab:()=>M.some(!0),onShiftTab:()=>M.some(!0)}),Up.config({})]),a=n(r,s),i=r.getSystem().build(a);Np.append(r,Ya(i)),i.hasConfigured(Tp)&&t.focus&&Tp.focusIn(i),o.isBlocked()||t.onBlock(e),o.blockWith((()=>Np.remove(r,i)))},unblock:(e,t,o)=>{kt(e.element,"aria-busy"),o.isBlocked()&&t.onUnblock(e),o.clear()}}),lE=[br("getRoot",M.none),fr("focus",!0),wi("onBlock"),wi("onUnblock")];const cE=hl({fields:lE,name:"blocking",apis:iE,state:Object.freeze({__proto__:null,init:()=>{const e=Ll((e=>e.destroy()));return ba({readState:e.isSet,blockWith:t=>{e.set({destroy:t})},clear:e.clear,isBlocked:e.isSet})}})}),dE=e=>{const t=De(e),o=nt(t),n=(e=>{const t=void 0!==e.dom.attributes?e.dom.attributes:[];return j(t,((e,t)=>"class"===t.name?e:{...e,[t.name]:t.value}),{})})(t),r=(e=>Array.prototype.slice.call(e.dom.classList,0))(t),s=0===o.length?{}:{innerHtml:Gs(t)};return{tag:ze(t),classes:r,attributes:n,...s}},uE=e=>cm.getCurrent(e).each((e=>wl(e.element))),mE=(e,t,o)=>{const n=xr(!1),r=Ul(),s=o=>{var r;n.get()&&(!(e=>"focusin"===e.type)(r=o)||!(r.composed?oe(r.composedPath()):M.from(r.target)).map(Ie).filter(Pe).exists((e=>Fa(e,"mce-pastebin"))))&&(o.preventDefault(),uE(t()),e.editorManager.setActive(e))};e.inline||e.on("PreInit",(()=>{e.dom.bind(e.getWin(),"focusin",s),e.on("BeforeExecCommand",(e=>{"mcefocus"===e.command.toLowerCase()&&!0!==e.value&&s(e)}))}));const a=r=>{r!==n.get()&&(n.set(r),((e,t,o,n)=>{const r=t.element;if(((e,t)=>{const o="tabindex",n="data-mce-tabindex";M.from(e.iframeElement).map(Ie).each((e=>{t?(wt(e,o).each((t=>vt(e,n,t))),vt(e,o,-1)):(kt(e,o),wt(e,n).each((t=>{vt(e,o,t),kt(e,n)})))}))})(e,o),o)cE.block(t,(e=>(t,o)=>({dom:{tag:"div",attributes:{"aria-label":e.translate("Loading..."),tabindex:"0"},classes:["tox-throbber__busy-spinner"]},components:[{dom:dE('<div class="tox-spinner"><div></div><div></div><div></div></div>')}]}))(n)),It(r,"display"),kt(r,"aria-hidden"),e.hasFocus()&&uE(t);else{const o=cm.getCurrent(t).exists((e=>Sl(e.element)));cE.unblock(t),_t(r,"display","none"),vt(r,"aria-hidden","true"),o&&e.focus()}})(e,t(),r,o.providers),((e,t)=>{e.dispatch("AfterProgressState",{state:t})})(e,r))};e.on("ProgressState",(t=>{if(r.on(clearTimeout),h(t.time)){const o=Eh.setEditorTimeout(e,(()=>a(t.state)),t.time);r.set(o)}else a(t.state),r.clear()}))},gE=(e,t,o)=>({within:e,extra:t,withinWidth:o}),pE=(e,t,o)=>{const n=j(e,((e,t)=>((e,t)=>{const n=o(e);return M.some({element:e,start:t,finish:t+n,width:n})})(t,e.len).fold(y(e),(t=>({len:t.finish,list:e.list.concat([t])})))),{len:0,list:[]}).list,r=U(n,(e=>e.finish<=t)),s=W(r,((e,t)=>e+t.width),0);return{within:r,extra:n.slice(r.length),withinWidth:s}},hE=e=>z(e,(e=>e.element)),fE=(e,t)=>{const o=z(t,(e=>Ya(e)));$_.setGroups(e,o)},bE=(e,t,o)=>{const n=t.builtGroups.get();if(0===n.length)return;const r=Gu(e,t,"primary"),s=Nx.getCoupled(e,"overflowGroup");_t(r.element,"visibility","hidden");const a=n.concat([s]),i=se(a,(e=>Cl(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()))));o([]),fE(r,a);const l=((e,t,o,n)=>{const r=((e,t,o)=>{const n=pE(t,e,o);return 0===n.extra.length?M.some(n):M.none()})(e,t,o).getOrThunk((()=>pE(t,e-o(n),o))),s=r.within,a=r.extra,i=r.withinWidth;return 1===a.length&&a[0].width<=o(n)?((e,t,o)=>{const n=hE(e.concat(t));return gE(n,[],o)})(s,a,i):a.length>=1?((e,t,o,n)=>{const r=hE(e).concat([o]);return gE(r,hE(t),n)})(s,a,n,i):((e,t,o)=>gE(hE(e),[],o))(s,0,i)})($t(r.element),t.builtGroups.get(),(e=>$t(e.element)),s);0===l.extra.length?(Np.remove(r,s),o([])):(fE(r,l.within),o(l.extra)),It(r.element,"visibility"),Rt(r.element),i.each(Up.focus)},vE=y([nu("splitToolbarBehaviours",[Nx]),$n("builtGroups",(()=>xr([])))]),yE=y([yi(["overflowToggledClass"]),lr("getOverflowBounds"),Xn("lazySink"),$n("overflowGroups",(()=>xr([]))),wi("onOpened"),wi("onClosed")].concat(vE())),xE=y([Au({factory:$_,schema:j_(),name:"primary"}),Du({schema:j_(),name:"overflow"}),Du({name:"overflow-button"}),Du({name:"overflow-group"})]),wE=y(((e,t)=>{((e,t)=>{const o=Gt.max(e,t,["margin-left","border-left-width","padding-left","padding-right","border-right-width","margin-right"]);_t(e,"max-width",o+"px")})(e,Math.floor(t))})),SE=y([yi(["toggledClass"]),Xn("lazySink"),Qn("fetch"),lr("getBounds"),dr("fireDismissalEventInstead",[ur("event",fs())]),dc(),wi("onToggled")]),kE=y([Du({name:"button",overrides:e=>({dom:{attributes:{"aria-haspopup":"true"}},buttonBehaviours:gl([Yp.config({toggleClass:e.markers.toggledClass,aria:{mode:"expanded"},toggleOnExecute:!1,onToggled:e.onToggled})])})}),Du({factory:$_,schema:j_(),name:"toolbar",overrides:e=>({toolbarBehaviours:gl([Tp.config({mode:"cyclic",onEscape:t=>(ju(t,e,"button").each(Up.focus),M.none())})])})})]),CE=(e,t)=>{const o=Nx.getCoupled(e,"toolbarSandbox");Nd.isOpen(o)?Nd.close(o):Nd.open(o,t.toolbar())},OE=(e,t,o,n)=>{const r=o.getBounds.map((e=>e())),s=o.lazySink(e).getOrDie();ud.positionWithinBounds(s,t,{anchor:{type:"hotspot",hotspot:e,layouts:n,overrides:{maxWidthFunction:wE()}}},r)},_E=(e,t,o,n,r)=>{$_.setGroups(t,r),OE(e,t,o,n),Yp.on(e)},TE=sm({name:"FloatingToolbarButton",factory:(e,t,o,n)=>({...Mh.sketch({...n.button(),action:e=>{CE(e,n)},buttonBehaviours:iu({dump:n.button().buttonBehaviours},[Nx.config({others:{toolbarSandbox:t=>((e,t,o)=>{const n=ii();return{dom:{tag:"div",attributes:{id:n.id}},behaviours:gl([Tp.config({mode:"special",onEscape:e=>(Nd.close(e),M.some(!0))}),Nd.config({onOpen:(r,s)=>{o.fetch().get((r=>{_E(e,s,o,t.layouts,r),n.link(e.element),Tp.focusIn(s)}))},onClose:()=>{Yp.off(e),Up.focus(e),n.unlink(e.element)},isPartOf:(t,o,n)=>li(o,n)||li(e,n),getAttachPoint:()=>o.lazySink(e).getOrDie()}),yl.config({channels:{...Pd({isExtraPart:_,...o.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...Wd({doReposition:()=>{Nd.getState(Nx.getCoupled(e,"toolbarSandbox")).each((n=>{OE(e,n,o,t.layouts)}))}})}})])}})(t,o,e)}})])}),apis:{setGroups:(t,n)=>{Nd.getState(Nx.getCoupled(t,"toolbarSandbox")).each((r=>{_E(t,r,e,o.layouts,n)}))},reposition:t=>{Nd.getState(Nx.getCoupled(t,"toolbarSandbox")).each((n=>{OE(t,n,e,o.layouts)}))},toggle:e=>{CE(e,n)},getToolbar:e=>Nd.getState(Nx.getCoupled(e,"toolbarSandbox")),isOpen:e=>Nd.isOpen(Nx.getCoupled(e,"toolbarSandbox"))}}),configFields:SE(),partFields:kE(),apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},getToolbar:(e,t)=>e.getToolbar(t),isOpen:(e,t)=>e.isOpen(t)}}),EE=y([Xn("items"),yi(["itemSelector"]),nu("tgroupBehaviours",[Tp])]),ME=y([Fu({name:"items",unit:"item"})]),AE=sm({name:"ToolbarGroup",configFields:EE(),partFields:ME(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,behaviours:su(e.tgroupBehaviours,[Tp.config({mode:"flow",selector:e.markers.itemSelector})]),domModification:{attributes:{role:"toolbar"}}})}),DE=e=>z(e,(e=>Ya(e))),BE=(e,t,o)=>{bE(e,o,(n=>{o.overflowGroups.set(n),t.getOpt(e).each((e=>{TE.setGroups(e,DE(n))}))}))},FE=sm({name:"SplitFloatingToolbar",configFields:yE(),partFields:xE(),factory:(e,t,o,n)=>{const r=Ah(TE.sketch({fetch:()=>Px((t=>{t(DE(e.overflowGroups.get()))})),layouts:{onLtr:()=>[Ki,Xi],onRtl:()=>[Xi,Ki],onBottomLtr:()=>[Ji,Yi],onBottomRtl:()=>[Yi,Ji]},getBounds:o.getOverflowBounds,lazySink:e.lazySink,fireDismissalEventInstead:{},markers:{toggledClass:e.markers.overflowToggledClass},parts:{button:n["overflow-button"](),toolbar:n.overflow()},onToggled:(t,o)=>e[o?"onOpened":"onClosed"](t)}));return{uid:e.uid,dom:e.dom,components:t,behaviours:su(e.splitToolbarBehaviours,[Nx.config({others:{overflowGroup:()=>AE.sketch({...n["overflow-group"](),items:[r.asSpec()]})}})]),apis:{setGroups:(t,o)=>{e.builtGroups.set(z(o,t.getSystem().build)),BE(t,r,e)},refresh:t=>BE(t,r,e),toggle:e=>{r.getOpt(e).each((e=>{TE.toggle(e)}))},isOpen:e=>r.getOpt(e).map(TE.isOpen).getOr(!1),reposition:e=>{r.getOpt(e).each((e=>{TE.reposition(e)}))},getOverflow:e=>r.getOpt(e).bind(TE.getToolbar)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},reposition:(e,t)=>{e.reposition(t)},toggle:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t),getOverflow:(e,t)=>e.getOverflow(t)}}),IE=y([yi(["closedClass","openClass","shrinkingClass","growingClass","overflowToggledClass"]),wi("onOpened"),wi("onClosed")].concat(vE())),RE=y([Au({factory:$_,schema:j_(),name:"primary"}),Au({factory:$_,schema:j_(),name:"overflow",overrides:e=>({toolbarBehaviours:gl([qT.config({dimension:{property:"height"},closedClass:e.markers.closedClass,openClass:e.markers.openClass,shrinkingClass:e.markers.shrinkingClass,growingClass:e.markers.growingClass,onShrunk:t=>{ju(t,e,"overflow-button").each((e=>{Yp.off(e),Up.focus(e)})),e.onClosed(t)},onGrown:t=>{Tp.focusIn(t),e.onOpened(t)},onStartGrow:t=>{ju(t,e,"overflow-button").each(Yp.on)}}),Tp.config({mode:"acyclic",onEscape:t=>(ju(t,e,"overflow-button").each(Up.focus),M.some(!0))})])})}),Du({name:"overflow-button",overrides:e=>({buttonBehaviours:gl([Yp.config({toggleClass:e.markers.overflowToggledClass,aria:{mode:"pressed"},toggleOnExecute:!1})])})}),Du({name:"overflow-group"})]),NE=(e,t)=>{ju(e,t,"overflow-button").bind((()=>ju(e,t,"overflow"))).each((o=>{VE(e,t),qT.toggleGrow(o)}))},VE=(e,t)=>{ju(e,t,"overflow").each((o=>{bE(e,t,(e=>{const t=z(e,(e=>Ya(e)));$_.setGroups(o,t)})),ju(e,t,"overflow-button").each((e=>{qT.hasGrown(o)&&Yp.on(e)})),qT.refresh(o)}))},HE=sm({name:"SplitSlidingToolbar",configFields:IE(),partFields:RE(),factory:(e,t,o,n)=>{const r="alloy.toolbar.toggle";return{uid:e.uid,dom:e.dom,components:t,behaviours:su(e.splitToolbarBehaviours,[Nx.config({others:{overflowGroup:e=>AE.sketch({...n["overflow-group"](),items:[Mh.sketch({...n["overflow-button"](),action:t=>{Cs(e,r)}})]})}}),Vp("toolbar-toggle-events",[Fs(r,(t=>{NE(t,e)}))])]),apis:{setGroups:(t,o)=>{((t,o)=>{const n=z(o,t.getSystem().build);e.builtGroups.set(n)})(t,o),VE(t,e)},refresh:t=>VE(t,e),toggle:t=>NE(t,e),isOpen:t=>((e,t)=>ju(e,t,"overflow").map(qT.hasGrown).getOr(!1))(t,e)},domModification:{attributes:{role:"group"}}}},apis:{setGroups:(e,t,o)=>{e.setGroups(t,o)},refresh:(e,t)=>{e.refresh(t)},toggle:(e,t)=>{e.toggle(t)},isOpen:(e,t)=>e.isOpen(t)}}),zE=e=>{const t=e.title.fold((()=>({})),(e=>({attributes:{title:e}})));return{dom:{tag:"div",classes:["tox-toolbar__group"],...t},components:[AE.parts.items({})],items:e.items,markers:{itemSelector:"*:not(.tox-split-button) > .tox-tbtn:not([disabled]), .tox-split-button:not([disabled]), .tox-toolbar-nav-js:not([disabled])"},tgroupBehaviours:gl([Mw.config({}),Up.config({})])}},LE=e=>AE.sketch(zE(e)),PE=(e,t)=>{const o=Ps((t=>{const o=z(e.initGroups,LE);$_.setGroups(t,o)}));return gl([sy(e.providers.isDisabled),oy(),Tp.config({mode:t,onEscape:e.onEscape,selector:".tox-toolbar__group"}),Vp("toolbar-events",[o])])},UE=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return{uid:e.uid,dom:{tag:"div",classes:["tox-toolbar-overlord"]},parts:{"overflow-group":zE({title:M.none(),items:[]}),"overflow-button":iO({name:"more",icon:M.some("more-drawer"),enabled:!0,tooltip:M.some("More..."),primary:!1,buttonType:M.none(),borderless:!1},M.none(),e.providers)},splitToolbarBehaviours:PE(e,t)}},WE=e=>{const t=UE(e),o=FE.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}});return FE.sketch({...t,lazySink:e.getSink,getOverflowBounds:()=>{const t=e.moreDrawerData.lazyHeader().element,o=qo(t),n=Ze(t),r=qo(n),s=Math.max(n.dom.scrollHeight,r.height);return Go(o.x+4,r.y,o.width-8,s)},parts:{...t.parts,overflow:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:e.attributes}}},components:[o],markers:{overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>e.onToggled(t,!0),onClosed:t=>e.onToggled(t,!1)})},jE=e=>{const t=HE.parts.primary({dom:{tag:"div",classes:["tox-toolbar__primary"]}}),o=HE.parts.overflow({dom:{tag:"div",classes:["tox-toolbar__overflow"]}}),n=UE(e);return HE.sketch({...n,components:[t,o],markers:{openClass:"tox-toolbar__overflow--open",closedClass:"tox-toolbar__overflow--closed",growingClass:"tox-toolbar__overflow--growing",shrinkingClass:"tox-toolbar__overflow--shrinking",overflowToggledClass:"tox-tbtn--enabled"},onOpened:t=>{t.getSystem().broadcastOn([fT()],{type:"opened"}),e.onToggled(t,!0)},onClosed:t=>{t.getSystem().broadcastOn([fT()],{type:"closed"}),e.onToggled(t,!1)}})},GE=e=>{const t=e.cyclicKeying?"cyclic":"acyclic";return $_.sketch({uid:e.uid,dom:{tag:"div",classes:["tox-toolbar"].concat(e.type===Wh.scrolling?["tox-toolbar--scrolling"]:[])},components:[$_.parts.groups({})],toolbarBehaviours:PE(e,t)})},$E=[Zn("type",["button"]),zb,hr("buttonType","secondary",["primary","secondary"]),Qn("onAction")],qE=jn("type",{button:$E}),XE=Cn([vr("buttons",[],qE),Qn("onShow"),Qn("onHide")]);var KE=sm({name:"silver.View",configFields:[Xn("viewConfig")],partFields:[Bu({factory:{sketch:e=>{const t=z(e.buttons,(t=>((e,t)=>cO({text:e.text,enabled:!0,primary:!1,name:"name",icon:M.none(),borderless:!1,buttonType:M.some(e.buttonType)},(t=>{e.onAction()}),t))(t,e.providers)));return{uid:e.uid,dom:{tag:"div",classes:["tox-view__header"]},components:[Sw.sketch({dom:{tag:"div",classes:["tox-view__header-start"]},components:[]}),Sw.sketch({dom:{tag:"div",classes:["tox-view__header-end"]},components:t})]}}},schema:[Xn("buttons"),Xn("providers")],name:"header"}),Bu({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-view__pane"]}})},schema:[],name:"pane"})],factory:(e,t,o,n)=>{const r={getPane:t=>H_.getPart(t,e,"pane"),getOnShow:t=>e.viewConfig.onShow,getOnHide:t=>e.viewConfig.onHide};return{uid:e.uid,dom:e.dom,components:t,apis:r}},apis:{getPane:(e,t)=>e.getPane(t),getOnShow:(e,t)=>e.getOnShow(t),getOnHide:(e,t)=>e.getOnHide(t)}});const YE=(e,t,o)=>pe(t,((t,n)=>{const r=Pn(Ln("view",XE,t));return e.slot(n,KE.sketch({dom:{tag:"div",classes:["tox-view"]},viewConfig:r,components:[...r.buttons.length>0?[KE.parts.header({buttons:r.buttons,providers:o})]:[],KE.parts.pane({})]}))})),JE=(e,t)=>QT.sketch((o=>({dom:{tag:"div",classes:["tox-view-wrap__slot-container"]},components:YE(o,e,t),slotBehaviours:Wv([Ps((e=>QT.hideAllSlots(e)))])}))),ZE=e=>G(QT.getSlotNames(e),(t=>QT.isShowing(e,t))),QE=(e,t,o)=>{QT.getSlot(e,t).each((e=>{KE.getPane(e).each((t=>{var n;o(e)((n=t.element.dom,{getContainer:y(n)}))}))}))};var eM=rm({factory:(e,t)=>{const o={setViews:(e,o)=>{Np.set(e,[JE(o,t.backstage.shared.providers)])},whichView:e=>cm.getCurrent(e).bind(ZE),toggleView:(e,t,o,n)=>cm.getCurrent(e).exists((r=>{const s=ZE(r),a=s.exists((e=>n===e)),i=QT.getSlot(r,n).isSome();return i&&(QT.hideAllSlots(r),a?((e=>{const t=e.element;_t(t,"display","none"),vt(t,"aria-hidden","true")})(e),t()):(o(),(e=>{const t=e.element;It(t,"display"),kt(t,"aria-hidden")})(e),QT.showSlot(r,n),((e,t)=>{QE(e,t,KE.getOnShow)})(r,n)),s.each((e=>((e,t)=>QE(e,t,KE.getOnHide))(r,e)))),i}))};return{uid:e.uid,dom:{tag:"div",classes:["tox-view-wrap"],attributes:{"aria-hidden":"true"},styles:{display:"none"}},components:[],behaviours:gl([Np.config({}),cm.config({find:e=>{const t=Np.contents(e);return oe(t)}})]),apis:o}},name:"silver.ViewWrapper",configFields:[Xn("backstage")],apis:{setViews:(e,t,o)=>e.setViews(t,o),toggleView:(e,t,o,n,r)=>e.toggleView(t,o,n,r),whichView:(e,t)=>e.whichView(t)}});const tM=z_.optional({factory:DT,name:"menubar",schema:[Xn("backstage")]}),oM=z_.optional({factory:{sketch:e=>W_.sketch({uid:e.uid,dom:e.dom,listBehaviours:gl([Tp.config({mode:"acyclic",selector:".tox-toolbar"})]),makeItem:()=>GE({type:e.type,uid:Qs("multiple-toolbar-item"),cyclicKeying:!1,initGroups:[],providers:e.providers,onEscape:()=>(e.onEscape(),M.some(!0))}),setupItem:(e,t,o,n)=>{$_.setGroups(t,o)},shell:!0})},name:"multiple-toolbar",schema:[Xn("dom"),Xn("onEscape")]}),nM=z_.optional({factory:{sketch:e=>{const t=(e=>e.type===Wh.sliding?jE:e.type===Wh.floating?WE:GE)(e);return t({type:e.type,uid:e.uid,onEscape:()=>(e.onEscape(),M.some(!0)),onToggled:(t,o)=>e.onToolbarToggled(o),cyclicKeying:!1,initGroups:[],getSink:e.getSink,providers:e.providers,moreDrawerData:{lazyToolbar:e.lazyToolbar,lazyMoreButton:e.lazyMoreButton,lazyHeader:e.lazyHeader},attributes:e.attributes})}},name:"toolbar",schema:[Xn("dom"),Xn("onEscape"),Xn("getSink")]}),rM=z_.optional({factory:{sketch:e=>{const t=e.editor,o=e.sticky?CT:K_;return{uid:e.uid,dom:e.dom,components:e.components,behaviours:gl(o(t,e.sharedBackstage))}}},name:"header",schema:[Xn("dom")]}),sM=z_.optional({factory:{sketch:e=>({uid:e.uid,dom:e.dom,components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/tinymce-self-hosted-premium-features/?utm_source=TinyMCE&utm_medium=SPAP&utm_campaign=SPAP&utm_id=editorreferral",rel:"noopener",target:"_blank","aria-hidden":"true"},classes:["tox-promotion-link"],innerHtml:"\u26a1\ufe0fUpgrade"}}]})},name:"promotion",schema:[Xn("dom")]}),aM=z_.optional({name:"socket",schema:[Xn("dom")]}),iM=z_.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-sidebar"],attributes:{role:"complementary"}},components:[{dom:{tag:"div",classes:["tox-sidebar__slider"]},components:[],behaviours:gl([Mw.config({}),Up.config({}),qT.config({dimension:{property:"width"},closedClass:"tox-sidebar--sliding-closed",openClass:"tox-sidebar--sliding-open",shrinkingClass:"tox-sidebar--sliding-shrinking",growingClass:"tox-sidebar--sliding-growing",onShrunk:e=>{cm.getCurrent(e).each(QT.hideAllSlots),Cs(e,aE)},onGrown:e=>{Cs(e,aE)},onStartGrow:e=>{Os(e,sE,{width:Dt(e.element,"width").getOr("")})},onStartShrink:e=>{Os(e,sE,{width:$t(e.element)+"px"})}}),Np.config({}),cm.config({find:e=>{const t=Np.contents(e);return oe(t)}})])}],behaviours:gl([Zk(0),Vp("sidebar-sliding-events",[Fs(sE,((e,t)=>{_t(e.element,"width",t.event.width)})),Fs(aE,((e,t)=>{It(e.element,"width")}))])])})},name:"sidebar",schema:[Xn("dom")]}),lM=z_.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",attributes:{"aria-hidden":"true"},classes:["tox-throbber"],styles:{display:"none"}},behaviours:gl([Np.config({}),cE.config({focus:!1}),cm.config({find:e=>oe(e.components())})]),components:[]})},name:"throbber",schema:[Xn("dom")]}),cM=z_.optional({factory:eM,name:"viewWrapper",schema:[Xn("backstage")]}),dM=z_.optional({factory:{sketch:e=>({uid:e.uid,dom:{tag:"div",classes:["tox-editor-container"]},components:e.components})},name:"editorContainer",schema:[]});var uM=sm({name:"OuterContainer",factory:(e,t,o)=>{let n=!1;const r={getSocket:t=>H_.getPart(t,e,"socket"),setSidebar:(t,o,n)=>{H_.getPart(t,e,"sidebar").each((e=>((e,t,o)=>{cm.getCurrent(e).each((e=>{Np.set(e,[nE(t)]);const n=null==o?void 0:o.toLowerCase();s(n)&&ve(t,n)&&cm.getCurrent(e).each((t=>{QT.showSlot(t,n),qT.immediateGrow(e),It(e.element,"width")}))}))})(e,o,n)))},toggleSidebar:(t,o)=>{H_.getPart(t,e,"sidebar").each((e=>((e,t)=>{cm.getCurrent(e).each((e=>{cm.getCurrent(e).each((o=>{qT.hasGrown(e)?QT.isShowing(o,t)?qT.shrink(e):(QT.hideAllSlots(o),QT.showSlot(o,t)):(QT.hideAllSlots(o),QT.showSlot(o,t),qT.grow(e))}))}))})(e,o)))},whichSidebar:t=>H_.getPart(t,e,"sidebar").bind(rE).getOrNull(),getHeader:t=>H_.getPart(t,e,"header"),getToolbar:t=>H_.getPart(t,e,"toolbar"),setToolbar:(t,o)=>{H_.getPart(t,e,"toolbar").each((e=>{const t=z(o,LE);e.getApis().setGroups(e,t)}))},setToolbars:(t,o)=>{H_.getPart(t,e,"multiple-toolbar").each((e=>{const t=z(o,(e=>z(e,LE)));W_.setItems(e,t)}))},refreshToolbar:t=>{H_.getPart(t,e,"toolbar").each((e=>e.getApis().refresh(e)))},toggleToolbarDrawer:t=>{H_.getPart(t,e,"toolbar").each((e=>{var t,o;o=t=>t(e),null!=(t=e.getApis().toggle)?M.some(o(t)):M.none()}))},isToolbarDrawerToggled:t=>H_.getPart(t,e,"toolbar").bind((e=>M.from(e.getApis().isOpen).map((t=>t(e))))).getOr(!1),getThrobber:t=>H_.getPart(t,e,"throbber"),focusToolbar:t=>{H_.getPart(t,e,"toolbar").orThunk((()=>H_.getPart(t,e,"multiple-toolbar"))).each((e=>{Tp.focusIn(e)}))},setMenubar:(t,o)=>{H_.getPart(t,e,"menubar").each((e=>{DT.setMenus(e,o)}))},focusMenubar:t=>{H_.getPart(t,e,"menubar").each((e=>{DT.focus(e)}))},setViews:(t,o)=>{H_.getPart(t,e,"viewWrapper").each((e=>{eM.setViews(e,o)}))},toggleView:(t,o)=>H_.getPart(t,e,"viewWrapper").exists((e=>eM.toggleView(e,(()=>r.showMainView(t)),(()=>r.hideMainView(t)),o))),whichView:t=>H_.getPart(t,e,"viewWrapper").bind(eM.whichView).getOrNull(),hideMainView:t=>{n=r.isToolbarDrawerToggled(t),n&&r.toggleToolbarDrawer(t),H_.getPart(t,e,"editorContainer").each((e=>{const t=e.element;_t(t,"display","none"),vt(t,"aria-hidden","true")}))},showMainView:t=>{n&&r.toggleToolbarDrawer(t),H_.getPart(t,e,"editorContainer").each((e=>{const t=e.element;It(t,"display"),kt(t,"aria-hidden")}))}};return{uid:e.uid,dom:e.dom,components:t,apis:r,behaviours:e.behaviours}},configFields:[Xn("dom"),Xn("behaviours")],partFields:[rM,tM,nM,oM,aM,iM,sM,lM,cM,dM],apis:{getSocket:(e,t)=>e.getSocket(t),setSidebar:(e,t,o,n)=>{e.setSidebar(t,o,n)},toggleSidebar:(e,t,o)=>{e.toggleSidebar(t,o)},whichSidebar:(e,t)=>e.whichSidebar(t),getHeader:(e,t)=>e.getHeader(t),getToolbar:(e,t)=>e.getToolbar(t),setToolbar:(e,t,o)=>{e.setToolbar(t,o)},setToolbars:(e,t,o)=>{e.setToolbars(t,o)},refreshToolbar:(e,t)=>e.refreshToolbar(t),toggleToolbarDrawer:(e,t)=>{e.toggleToolbarDrawer(t)},isToolbarDrawerToggled:(e,t)=>e.isToolbarDrawerToggled(t),getThrobber:(e,t)=>e.getThrobber(t),setMenubar:(e,t,o)=>{e.setMenubar(t,o)},focusMenubar:(e,t)=>{e.focusMenubar(t)},focusToolbar:(e,t)=>{e.focusToolbar(t)},setViews:(e,t,o)=>{e.setViews(t,o)},toggleView:(e,t,o)=>e.toggleView(t,o),whichView:(e,t)=>e.whichView(t)}});const mM={file:{title:"File",items:"newdocument restoredraft | preview | export print | deleteallconversations"},edit:{title:"Edit",items:"undo redo | cut copy paste pastetext | selectall | searchreplace"},view:{title:"View",items:"code | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments"},insert:{title:"Insert",items:"image link media addcomment pageembed template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents footnotes | mergetags | insertdatetime"},format:{title:"Format",items:"bold italic underline strikethrough superscript subscript codeformat | styles blocks fontfamily fontsize align lineheight | forecolor backcolor | language | removeformat"},tools:{title:"Tools",items:"spellchecker spellcheckerlanguage | autocorrect capitalization | a11ycheck code wordcount"},table:{title:"Table",items:"inserttable | cell row column | advtablesort | tableprops deletetable"},help:{title:"Help",items:"help"}},gM=e=>e.split(" "),pM=(e,t)=>{const o={...mM,...t.menus},n=ae(t.menus).length>0,r=void 0===t.menubar||!0===t.menubar?gM("file edit view insert format tools table help"):gM(!1===t.menubar?"":t.menubar),a=U(r,(e=>{const o=ve(mM,e);return n?o||be(t.menus,e).exists((e=>ve(e,"items"))):o})),i=z(a,(n=>{const r=o[n];return((e,t,o)=>{const n=cf(o).split(/[ ,]/);return{text:e.title,getItems:()=>X(e.items,(e=>{const o=e.toLowerCase();return 0===o.trim().length||N(n,(e=>e===o))?[]:"separator"===o||"|"===o?[{type:"separator"}]:t.menuItems[o]?[t.menuItems[o]]:[]}))}})({title:r.title,items:gM(r.items)},t,e)}));return U(i,(e=>e.getItems().length>0&&N(e.getItems(),(e=>s(e)||"separator"!==e.type))))},hM=e=>{const t=()=>{e._skinLoaded=!0,(e=>{e.dispatch("SkinLoaded")})(e)};return()=>{e.initialized?t():e.on("init",t)}},fM=(e,t,o)=>(e.on("remove",(()=>o.unload(t))),o.load(t)),bM=(e,t)=>fM(e,t+"/skin.min.css",e.ui.styleSheetLoader),vM=(e,t)=>{var o;return o=Ie(e.getElement()),mt(o).isSome()?fM(e,t+"/skin.shadowdom.min.css",Gh.DOM.styleSheetLoader):Promise.resolve()},yM=(e,t)=>{const o=Rf(t);o&&t.contentCSS.push(o+(e?"/content.inline":"/content")+".min.css"),!Ff(t)&&s(o)?Promise.all([bM(t,o),vM(t,o)]).then(hM(t),((e,t)=>()=>((e,t)=>{e.dispatch("SkinLoadError",t)})(e,{message:"Skin could not be loaded"}))(t)):hM(t)()},xM=S(yM,!1),wM=S(yM,!0),SM=(e,t)=>o=>{const n=Pl(),r=()=>{o.setActive(e.formatter.match(t));const r=e.formatter.formatChanged(t,o.setActive);n.set(r)};return e.initialized?r():e.once("init",r),()=>{e.off("init",r),n.clear()}},kM=(e,t,o)=>n=>{const r=()=>o(n),s=()=>{o(n),e.on(t,r)};return e.initialized?s():e.once("init",s),()=>{e.off("init",s),e.off(t,r)}},CM=e=>t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("mceToggleFormat",!1,t.format)}))},OM=(e,t)=>()=>e.execCommand(t),_M=(e,t,o)=>{const n=(e,n,s,a)=>{const i=t.shared.providers.translate(e.title);if("separator"===e.type)return M.some({type:"separator",text:i});if("submenu"===e.type){const t=X(e.getStyleItems(),(e=>r(e,n,a)));return 0===n&&t.length<=0?M.none():M.some({type:"nestedmenuitem",text:i,enabled:t.length>0,getSubmenuItems:()=>X(e.getStyleItems(),(e=>r(e,n,a)))})}return M.some({type:"togglemenuitem",text:i,icon:e.icon,active:e.isSelected(a),enabled:!s,onAction:o.onAction(e),...e.getStylePreview().fold((()=>({})),(e=>({meta:{style:e}})))})},r=(e,t,r)=>{const s="formatter"===e.type&&o.isInvalid(e);return 0===t?s?[]:n(e,t,!1,r).toArray():n(e,t,s,r).toArray()},s=e=>{const t=o.getCurrentValue(),n=o.shouldHide?0:1;return X(e,(e=>r(e,n,t)))};return{validateItems:s,getFetch:(e,t)=>(o,n)=>{const r=t(),a=s(r);n(EC(a,Jf.CLOSE_ON_EXECUTE,e,{isHorizontalMenu:!1,search:M.none()}))}}},TM=(e,t,o)=>{const n=o.dataset,r="basic"===n.type?()=>z(n.data,(e=>u_(e,o.isSelectedFor,o.getPreviewFor))):n.getData;return{items:_M(0,t,o),getStyleItems:r}},EM=(e,t,o)=>{const{items:n,getStyleItems:r}=TM(0,t,o),s=kM(e,"NodeChange",(e=>{const t=e.getComponent();o.updateText(t)}));return CC({text:o.icon.isSome()?M.none():o.text,icon:o.icon,tooltip:M.from(o.tooltip),role:M.none(),fetch:n.getFetch(t,r),onSetup:s,getApi:e=>({getComponent:y(e)}),columns:1,presets:"normal",classes:o.icon.isSome()?[]:["bespoke"],dropdownBehaviours:[]},"tox-tbtn",t.shared)};var MM;!function(e){e[e.SemiColon=0]="SemiColon",e[e.Space=1]="Space"}(MM||(MM={}));const AM=(e,t,o)=>{const n=(r=((e,t)=>t===MM.SemiColon?e.replace(/;$/,"").split(";"):e.split(" "))(e.options.get(t),o),z(r,(e=>{let t=e,o=e;const n=e.split("=");return n.length>1&&(t=n[0],o=n[1]),{title:t,format:o}})));var r;return{type:"basic",data:n}},DM=[{title:"Left",icon:"align-left",format:"alignleft",command:"JustifyLeft"},{title:"Center",icon:"align-center",format:"aligncenter",command:"JustifyCenter"},{title:"Right",icon:"align-right",format:"alignright",command:"JustifyRight"},{title:"Justify",icon:"align-justify",format:"alignjustify",command:"JustifyFull"}],BM=e=>{const t={type:"basic",data:DM};return{tooltip:"Align",text:M.none(),icon:M.some("align-left"),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:M.none,getPreviewFor:e=>M.none,onAction:t=>()=>G(DM,(e=>e.format===t.format)).each((t=>e.execCommand(t.command))),updateText:t=>{const o=G(DM,(t=>e.formatter.match(t.format))).fold(y("left"),(e=>e.title.toLowerCase()));Os(t,kC,{icon:`align-${o}`})},dataset:t,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},FM=(e,t)=>{const o=t(),n=z(o,(e=>e.format));return M.from(e.formatter.closest(n)).bind((e=>G(o,(t=>t.format===e)))).orThunk((()=>ke(e.formatter.match("p"),{title:"Paragraph",format:"p"})))},IM=e=>{const t="Paragraph",o=AM(e,"block_formats",MM.SemiColon);return{tooltip:"Blocks",text:M.some(t),icon:M.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:M.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return o?M.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):M.none()},onAction:CM(e),updateText:n=>{const r=FM(e,(()=>o.data)).fold(y(t),(e=>e.title));Os(n,SC,{text:r})},dataset:o,shouldHide:!1,isInvalid:t=>!e.formatter.canApply(t.format)}},RM=["-apple-system","Segoe UI","Roboto","Helvetica Neue","sans-serif"],NM=e=>{const t=e.split(/\s*,\s*/);return z(t,(e=>e.replace(/^['"]+|['"]+$/g,"")))},VM=e=>{const t="System Font",o=()=>{const o=e=>e?NM(e)[0]:"",r=e.queryCommandValue("FontName"),s=n.data,a=r?r.toLowerCase():"",i=G(s,(e=>{const t=e.format;return t.toLowerCase()===a||o(t).toLowerCase()===o(a).toLowerCase()})).orThunk((()=>ke((e=>0===e.indexOf("-apple-system")&&(()=>{const t=NM(e.toLowerCase());return K(RM,(e=>t.indexOf(e.toLowerCase())>-1))})())(a),{title:t,format:a})));return{matchOpt:i,font:r}},n=AM(e,"font_family_formats",MM.SemiColon);return{tooltip:"Fonts",text:M.some(t),icon:M.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getCurrentValue:()=>{const{matchOpt:e}=o();return e},getPreviewFor:e=>()=>M.some({tag:"div",styles:-1===e.indexOf("dings")?{"font-family":e}:{}}),onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontName",!1,t.format)}))},updateText:e=>{const{matchOpt:t,font:n}=o(),r=t.fold(y(n),(e=>e.title));Os(e,SC,{text:r})},dataset:n,shouldHide:!1,isInvalid:_}},HM={"8pt":"1","10pt":"2","12pt":"3","14pt":"4","18pt":"5","24pt":"6","36pt":"7"},zM={"xx-small":"7pt","x-small":"8pt",small:"10pt",medium:"12pt",large:"14pt","x-large":"18pt","xx-large":"24pt"},LM=(e,t)=>/[0-9.]+px$/.test(e)?((e,t)=>{const o=Math.pow(10,t);return Math.round(e*o)/o})(72*parseInt(e,10)/96,t||0)+"pt":be(zM,e).getOr(e),PM=e=>be(HM,e).getOr(""),UM=e=>{const t=()=>{let t=M.none();const o=n.data,r=e.queryCommandValue("FontSize");if(r)for(let e=3;t.isNone()&&e>=0;e--){const n=LM(r,e),s=PM(n);t=G(o,(e=>e.format===r||e.format===n||e.format===s))}return{matchOpt:t,size:r}},o=y(M.none),n=AM(e,"font_size_formats",MM.Space);return{tooltip:"Font sizes",text:M.some("12pt"),icon:M.none(),isSelectedFor:e=>t=>t.exists((t=>t.format===e)),getPreviewFor:o,getCurrentValue:()=>{const{matchOpt:e}=t();return e},onAction:t=>()=>{e.undoManager.transact((()=>{e.focus(),e.execCommand("FontSize",!1,t.format)}))},updateText:e=>{const{matchOpt:o,size:n}=t(),r=o.fold(y(n),(e=>e.title));Os(e,SC,{text:r})},dataset:n,shouldHide:!1,isInvalid:_}},WM=(e,t)=>{const o="Paragraph";return{tooltip:"Formats",text:M.some(o),icon:M.none(),isSelectedFor:t=>()=>e.formatter.match(t),getCurrentValue:M.none,getPreviewFor:t=>()=>{const o=e.formatter.get(t);return void 0!==o?M.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):M.none()},onAction:CM(e),updateText:t=>{const n=e=>a_(e)?X(e.items,n):i_(e)?[{title:e.title,format:e.format}]:[],r=X(d_(e),n),s=FM(e,y(r)).fold(y(o),(e=>e.title));Os(t,SC,{text:s})},shouldHide:af(e),isInvalid:t=>!e.formatter.canApply(t.format),dataset:t}};var jM=Object.freeze({__proto__:null,events:(e,t)=>{const o=(o,n)=>{e.updateState.each((e=>{const r=e(o,n);t.set(r)})),e.renderComponents.each((r=>{const s=r(n,t.get());(e.reuseDom?Mp:Ep)(o,s)}))};return As([Fs(os(),((t,n)=>{const r=n;if(!r.universal){const n=e.channel;R(r.channels,n)&&o(t,r.data)}})),Ps(((t,n)=>{e.initialData.each((e=>{o(t,e)}))}))])}}),GM=Object.freeze({__proto__:null,getState:(e,t,o)=>o}),$M=[Xn("channel"),nr("renderComponents"),nr("updateState"),nr("initialData"),fr("reuseDom",!0)];const qM=hl({fields:$M,name:"reflecting",active:jM,apis:GM,state:Object.freeze({__proto__:null,init:()=>{const e=xr(M.none());return{readState:()=>e.get().getOr("none"),get:e.get,set:e.set,clear:()=>e.set(M.none())}}})}),XM=y([Xn("toggleClass"),Xn("fetch"),ki("onExecute"),ur("getHotspot",M.some),ur("getAnchorOverrides",y({})),dc(),ki("onItemExecute"),nr("lazySink"),Xn("dom"),wi("onOpen"),nu("splitDropdownBehaviours",[Nx,Tp,Up]),ur("matchWidth",!1),ur("useMinWidth",!1),ur("eventOrder",{}),nr("role")].concat(Qx())),KM=Au({factory:Mh,schema:[Xn("dom")],name:"arrow",defaults:()=>({buttonBehaviours:gl([Up.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each(_s)},buttonBehaviours:gl([Yp.config({toggleOnExecute:!1,toggleClass:e.toggleClass})])})}),YM=Au({factory:Mh,schema:[Xn("dom")],name:"button",defaults:()=>({buttonBehaviours:gl([Up.revoke()])}),overrides:e=>({dom:{tag:"span",attributes:{role:"presentation"}},action:t=>{t.getSystem().getByUid(e.uid).each((o=>{e.onExecute(o,t)}))}})}),JM=y([KM,YM,Bu({factory:{sketch:e=>({uid:e.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:e.text}})},schema:[Xn("text")],name:"aria-descriptor"}),Du({schema:[vi()],name:"menu",defaults:e=>({onExecute:(t,o)=>{t.getSystem().getByUid(e.uid).each((n=>{e.onItemExecute(n,t,o)}))}})}),jx()]),ZM=sm({name:"SplitDropdown",configFields:XM(),partFields:JM(),factory:(e,t,o,n)=>{const r=e=>{cm.getCurrent(e).each((e=>{Fm.highlightFirst(e),Tp.focusIn(e)}))},s=t=>{Xx(e,x,t,n,r,Ch.HighlightMenuAndItem).get(b)},a=t=>{const o=Gu(t,e,"button");return _s(o),M.some(!0)},i={...As([Ps(((t,o)=>{ju(t,e,"aria-descriptor").each((e=>{const o=Qs("aria");vt(e.element,"id",o),vt(t.element,"aria-describedby",o)}))}))]),...Zp(M.some(s))},l={repositionMenus:e=>{Yp.isOn(e)&&Zx(e)}};return{uid:e.uid,dom:e.dom,components:t,apis:l,eventOrder:{...e.eventOrder,[ns()]:["disabling","toggling","alloy.base.behaviour"]},events:i,behaviours:su(e.splitDropdownBehaviours,[Nx.config({others:{sandbox:t=>{const o=Gu(t,e,"arrow");return Jx(e,t,{onOpen:()=>{Yp.on(o),Yp.on(t)},onClose:()=>{Yp.off(o),Yp.off(t)}})}}}),Tp.config({mode:"special",onSpace:a,onEnter:a,onDown:e=>(s(e),M.some(!0))}),Up.config({}),Yp.config({toggleOnExecute:!1,aria:{mode:"expanded"}})]),domModification:{attributes:{role:e.role.getOr("button"),"aria-haspopup":!0}}}},apis:{repositionMenus:(e,t)=>e.repositionMenus(t)}}),QM=e=>({isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t)}),eA=e=>({setActive:t=>{Yp.set(e,t)},isActive:()=>Yp.isOn(e),isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t)}),tA=(e,t)=>e.map((e=>({"aria-label":t.translate(e),title:t.translate(e)}))).getOr({}),oA=Qs("focus-button"),nA=(e,t,o,n,r,s)=>({dom:{tag:"button",classes:["tox-tbtn"].concat(t.isSome()?["tox-tbtn--select"]:[]),attributes:tA(o,s)},components:uy([e.map((e=>yC(e,s.icons))),t.map((e=>wC(e,"tox-tbtn",s)))]),eventOrder:{[Rr()]:["focusing","alloy.base.behaviour","common-button-display-events"]},buttonBehaviours:gl([sy(s.isDisabled),oy(),Vp("common-button-display-events",[Fs(Rr(),((e,t)=>{t.event.prevent(),Cs(e,oA)}))])].concat(n.map((o=>qM.config({channel:o,initialData:{icon:e,text:t},renderComponents:(e,t)=>uy([e.icon.map((e=>yC(e,s.icons))),e.text.map((e=>wC(e,"tox-tbtn",s)))])}))).toArray()).concat(r.getOr([])))}),rA=(e,t,o)=>{const n=xr(b),r=nA(e.icon,e.text,e.tooltip,M.none(),M.none(),o);return Mh.sketch({dom:r.dom,components:r.components,eventOrder:bC,buttonBehaviours:gl([Vp("toolbar-button-events",[(s={onAction:e.onAction,getApi:t.getApi},js(((e,t)=>{ay(s,e)((t=>{Os(e,fC,{buttonApi:t}),s.onAction(t)}))}))),iy(t,n),ly(t,n)]),sy((()=>!e.enabled||o.isDisabled())),oy()].concat(t.toolbarButtonBehaviours))});var s},sA=(e,t,o)=>rA(e,{toolbarButtonBehaviours:o.length>0?[Vp("toolbarButtonWith",o)]:[],getApi:QM,onSetup:e.onSetup},t),aA=(e,t,o)=>rA(e,{toolbarButtonBehaviours:[Np.config({}),Yp.config({toggleClass:"tox-tbtn--enabled",aria:{mode:"pressed"},toggleOnExecute:!1})].concat(o.length>0?[Vp("toolbarToggleButtonWith",o)]:[]),getApi:eA,onSetup:e.onSetup},t),iA=(e,t,o)=>n=>Px((e=>t.fetch(e))).map((r=>M.from(dw(cn(kx(Qs("menu-value"),r,(o=>{t.onItemAction(e(n),o)}),t.columns,t.presets,Jf.CLOSE_ON_EXECUTE,t.select.getOr(_),o),{movement:Ox(t.columns,t.presets),menuBehaviours:Wv("auto"!==t.columns?[]:[Ps(((e,o)=>{Uv(e,4,lb(t.presets)).each((({numRows:t,numColumns:o})=>{Tp.setGridSize(e,t,o)}))}))])}))))),lA=[{name:"history",items:["undo","redo"]},{name:"styles",items:["styles"]},{name:"formatting",items:["bold","italic"]},{name:"alignment",items:["alignleft","aligncenter","alignright","alignjustify"]},{name:"indentation",items:["outdent","indent"]},{name:"permanent pen",items:["permanentpen"]},{name:"comments",items:["addcomment"]}],cA=(e,t)=>(o,n,r)=>{const s=e(o).mapError((e=>Wn(e))).getOrDie();return t(s,n,r)},dA={button:cA(pv,((e,t)=>{return o=e,n=t.shared.providers,sA(o,n,[]);var o,n})),togglebutton:cA(bv,((e,t)=>{return o=e,n=t.shared.providers,aA(o,n,[]);var o,n})),menubutton:cA(MT,((e,t)=>rO(e,"tox-tbtn",t,M.none()))),splitbutton:cA((e=>Ln("SplitButton",AT,e)),((e,t)=>((e,t)=>{const o=Qs("channel-update-split-dropdown-display"),n=e=>({isEnabled:()=>!km.isDisabled(e),setEnabled:t=>km.set(e,!t),setIconFill:(t,o)=>{ri(e.element,'svg path[id="'+t+'"], rect[id="'+t+'"]').each((e=>{vt(e,"fill",o)}))},setActive:t=>{vt(e.element,"aria-pressed",t),ri(e.element,"span").each((o=>{e.getSystem().getByDom(o).each((e=>Yp.set(e,t)))}))},isActive:()=>ri(e.element,"span").exists((t=>e.getSystem().getByDom(t).exists(Yp.isOn)))}),r=xr(b),s={getApi:n,onSetup:e.onSetup};return ZM.sketch({dom:{tag:"div",classes:["tox-split-button"],attributes:{"aria-pressed":!1,...tA(e.tooltip,t.providers)}},onExecute:t=>{e.onAction(n(t))},onItemExecute:(e,t,o)=>{},splitDropdownBehaviours:gl([ry(t.providers.isDisabled),oy(),Vp("split-dropdown-events",[Fs(oA,Up.focus),iy(s,r),ly(s,r)]),eS.config({})]),eventOrder:{[ps()]:["alloy.base.behaviour","split-dropdown-events"]},toggleClass:"tox-tbtn--enabled",lazySink:t.getSink,fetch:iA(n,e,t.providers),parts:{menu:pb(0,e.columns,e.presets)},components:[ZM.parts.button(nA(e.icon,e.text,M.none(),M.some(o),M.some([Yp.config({toggleClass:"tox-tbtn--enabled",toggleOnExecute:!1})]),t.providers)),ZM.parts.arrow({dom:{tag:"button",classes:["tox-tbtn","tox-split-button__chevron"],innerHtml:Vh("chevron-down",t.providers.icons)},buttonBehaviours:gl([ry(t.providers.isDisabled),oy(),Hh()])}),ZM.parts["aria-descriptor"]({text:t.providers.translate("To open the popup, press Shift+Enter")})]})})(e,t.shared))),grouptoolbarbutton:cA((e=>Ln("GroupToolbarButton",_T,e)),((e,t,o)=>{const n=o.ui.registry.getAll().buttons,r={[lc]:t.shared.header.isPositionedAtTop()?ic.TopToBottom:ic.BottomToTop};if(df(o)===Wh.floating)return((e,t,o,n)=>{const r=t.shared;return TE.sketch({lazySink:r.getSink,fetch:()=>Px((t=>{t(z(o(e.items),LE))})),markers:{toggledClass:"tox-tbtn--enabled"},parts:{button:nA(e.icon,e.text,e.tooltip,M.none(),M.none(),r.providers),toolbar:{dom:{tag:"div",classes:["tox-toolbar__overflow"],attributes:n}}}})})(e,t,(e=>mA(o,{buttons:n,toolbar:e,allowToolbarGroups:!1},t,M.none())),r);throw new Error("Toolbar groups are only supported when using floating toolbar mode")}))},uA={styles:(e,t)=>{const o={type:"advanced",...t.styles};return EM(e,t,WM(e,o))},fontsize:(e,t)=>EM(e,t,UM(e)),fontfamily:(e,t)=>EM(e,t,VM(e)),blocks:(e,t)=>EM(e,t,IM(e)),align:(e,t)=>EM(e,t,BM(e))},mA=(e,t,o,n)=>{const r=(e=>{const t=e.toolbar,o=e.buttons;return!1===t?[]:void 0===t||!0===t?(e=>{const t=z(lA,(t=>{const o=U(t.items,(t=>ve(e,t)||ve(uA,t)));return{name:t.name,items:o}}));return U(t,(e=>e.items.length>0))})(o):s(t)?(e=>{const t=e.split("|");return z(t,(e=>({items:e.trim().split(" ")})))})(t):(e=>f(e,(e=>ve(e,"name")&&ve(e,"items"))))(t)?t:(console.error("Toolbar type should be string, string[], boolean or ToolbarGroup[]"),[])})(t),a=z(r,(r=>{const s=X(r.items,(r=>0===r.trim().length?[]:((e,t,o,n,r,s)=>be(t,o.toLowerCase()).orThunk((()=>s.bind((e=>se(e,(e=>be(t,e+o.toLowerCase()))))))).fold((()=>be(uA,o.toLowerCase()).map((t=>t(e,r)))),(t=>"grouptoolbarbutton"!==t.type||n?((e,t,o)=>be(dA,e.type).fold((()=>(console.error("skipping button defined by",e),M.none())),(n=>M.some(n(e,t,o)))))(t,r,e):(console.warn(`Ignoring the '${o}' toolbar button. Group toolbar buttons are only supported when using floating toolbar mode and cannot be nested.`),M.none()))))(e,t.buttons,r,t.allowToolbarGroups,o,n).toArray()));return{title:M.from(e.translate(r.name)),items:s}}));return U(a,(e=>e.items.length>0))},gA=(e,t,o,n)=>{const r=t.mainUi.outerContainer,a=o.toolbar,i=o.buttons;if(f(a,s)){const t=a.map((t=>{const r={toolbar:t,buttons:i,allowToolbarGroups:o.allowToolbarGroups};return mA(e,r,n,M.none())}));uM.setToolbars(r,t)}else uM.setToolbar(r,mA(e,o,n,M.none()))},pA=_o(),hA=pA.os.isiOS()&&pA.os.version.major<=12;var fA=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:s,uiMotherships:a}=t,i=xr(0),l=s.outerContainer;xM(e);const d=Ie(r.targetNode),u=ut(dt(d));((e,t)=>{Cd(e,t,Do)})(d,s.mothership),((e,t)=>{kd(e,t.dialogUi.mothership)})(u,t),e.on("PostRender",(()=>{uM.setSidebar(l,o.sidebar,Df(e)),gA(e,t,o,n),i.set(e.getWin().innerWidth),uM.setMenubar(l,pM(e,o)),uM.setViews(l,o.views),((e,t)=>{const{uiMotherships:o}=t,n=e.dom;let r=e.getWin();const s=e.getDoc().documentElement,a=xr(Pt(r.innerWidth,r.innerHeight)),i=xr(Pt(s.offsetWidth,s.offsetHeight)),l=()=>{const t=a.get();t.left===r.innerWidth&&t.top===r.innerHeight||(a.set(Pt(r.innerWidth,r.innerHeight)),qy(e))},c=()=>{const t=e.getDoc().documentElement,o=i.get();o.left===t.offsetWidth&&o.top===t.offsetHeight||(i.set(Pt(t.offsetWidth,t.offsetHeight)),qy(e))},d=t=>{((e,t)=>{e.dispatch("ScrollContent",t)})(e,t)};n.bind(r,"resize",l),n.bind(r,"scroll",d);const u=Gl(Ie(e.getBody()),"load",c);e.on("hide",(()=>{L(o,(e=>{_t(e.element,"display","none")}))})),e.on("show",(()=>{L(o,(e=>{It(e.element,"display")}))})),e.on("NodeChange",c),e.on("remove",(()=>{u.unbind(),n.unbind(r,"resize",l),n.unbind(r,"scroll",d),r=null}))})(e,t)}));const m=uM.getSocket(l).getOrDie("Could not find expected socket element");if(hA){Tt(m.element,{overflow:"scroll","-webkit-overflow-scrolling":"touch"});const t=((e,t)=>{let o=null;return{cancel:()=>{c(o)||(clearTimeout(o),o=null)},throttle:(...t)=>{c(o)&&(o=setTimeout((()=>{o=null,e.apply(null,t)}),20))}}})((()=>{e.dispatch("ScrollContent")})),o=jl(m.element,"scroll",t.throttle);e.on("remove",o.unbind)}ty(e,t),e.addCommand("ToggleSidebar",((t,o)=>{uM.toggleSidebar(l,o),e.dispatch("ToggleSidebar")})),e.addQueryValueHandler("ToggleSidebar",(()=>{var e;return null!==(e=uM.whichSidebar(l))&&void 0!==e?e:""})),e.addCommand("ToggleView",((t,o)=>{if(uM.toggleView(l,o)){const t=l.element;s.mothership.broadcastOn([Vd()],{target:t}),L(a,(e=>{e.broadcastOn([Vd()],{target:t})})),c(uM.whichView(l))&&(e.focus(),e.nodeChanged())}})),e.addQueryValueHandler("ToggleView",(()=>{var e;return null!==(e=uM.whichView(l))&&void 0!==e?e:""}));const g=df(e);g!==Wh.sliding&&g!==Wh.floating||e.on("ResizeWindow ResizeEditor ResizeContent",(()=>{const o=e.getWin().innerWidth;o!==i.get()&&(uM.refreshToolbar(t.mainUi.outerContainer),i.set(o))}));const p={setEnabled:e=>{ey(t,!e)},isEnabled:()=>!km.isDisabled(l)};return{iframeContainer:m.element.dom,editorContainer:l.element.dom,api:p}}});const bA=e=>/^[0-9\.]+(|px)$/i.test(""+e)?M.some(parseInt(""+e,10)):M.none(),vA=e=>h(e)?e+"px":e,yA=(e,t,o)=>{const n=t.filter((t=>e<t)),r=o.filter((t=>e>t));return n.or(r).getOr(e)},xA=e=>{const t=Qh(e),o=ef(e),n=of(e);return bA(t).map((e=>yA(e,o,n)))},{ToolbarLocation:wA,ToolbarMode:SA}=qf,kA=(e,t)=>{const o=$o(e);return{pos:t?o.y:o.bottom,bounds:o}};var CA=Object.freeze({__proto__:null,render:(e,t,o,n,r)=>{const{mainUi:s}=t,a=Ul(),i=Ie(r.targetNode),l=((e,t,o,n,r)=>{const{mainUi:s,uiMotherships:a}=o,i=Gh.DOM,l=Uf(e),c=Gf(e),d=of(e).or(xA(e)),u=n.shared.header,m=u.isPositionedAtTop,g=df(e),p=g===SA.sliding||g===SA.floating,h=xr(!1),f=()=>h.get()&&!e.removed,b=e=>p?e.fold(y(0),(e=>e.components().length>1?Ht(e.components()[1].element):0)):0,v=()=>{L(a,(e=>{e.broadcastOn([Hd()],{})}))},x=(e=!1)=>{if(f()){if(l||r.on((e=>{const o=d.getOrThunk((()=>{const e=bA(Mt(ht(),"margin-left")).getOr(0);return $t(ht())-Wt(t).left+e}));_t(e.element,"max-width",o+"px")})),p&&uM.refreshToolbar(s.outerContainer),l||r.on((e=>{const o=uM.getToolbar(s.outerContainer),n=b(o),r=$o(t),a=m()?Math.max(r.y-Ht(e.element)+n,0):r.bottom;Tt(s.outerContainer.element,{position:"absolute",top:Math.round(a)+"px",left:Math.round(r.x)+"px"})})),c){const t=e?hT.reset:hT.refresh;r.on(t)}v()}},w=(o=!0)=>{!l&&c&&f()&&r.on((n=>{const a=u.getDockingMode(),i=(o=>{switch(mf(e)){case wA.auto:const e=uM.getToolbar(s.outerContainer),n=b(e),r=Ht(o.element)-n,a=$o(t);if(a.y>r)return"top";{const e=Ze(t),o=Math.max(e.dom.scrollHeight,Ht(e));return a.bottom<o-r||Xo().bottom<a.bottom-r?"bottom":"top"}case wA.bottom:return"bottom";case wA.top:default:return"top"}})(n);var l;i!==a&&(l=i,r.on((e=>{hT.setModes(e,[l]),u.setDockingMode(l);const t=m()?ic.TopToBottom:ic.BottomToTop;vt(e.element,lc,t)})),o&&x(!0))}))};return{isVisible:f,isPositionedAtTop:m,show:()=>{h.set(!0),_t(s.outerContainer.element,"display","flex"),i.addClass(e.getBody(),"mce-edit-focus"),L(a,(e=>{It(e.element,"display")})),w(!1),x()},hide:()=>{h.set(!1),_t(s.outerContainer.element,"display","none"),i.removeClass(e.getBody(),"mce-edit-focus"),L(a,(e=>{_t(e.element,"display","none")}))},update:x,updateMode:w,repositionPopups:v}})(e,i,t,n,a),c=hf(e);wM(e);const d=()=>{if(a.isSet())return void l.show();a.set(uM.getHeader(s.outerContainer).getOrDie());const r=Wf(e);kd(r,s.mothership),((e,t)=>{kd(e,t.dialogUi.mothership)})(r,t),gA(e,t,o,n),uM.setMenubar(s.outerContainer,pM(e,o)),l.show(),((e,t,o,n)=>{const r=xr(kA(t,o.isPositionedAtTop())),s=n=>{const{pos:s,bounds:a}=kA(t,o.isPositionedAtTop()),{pos:i,bounds:l}=r.get(),c=a.height!==l.height||a.width!==l.width;r.set({pos:s,bounds:a}),c&&qy(e,n),o.isVisible()&&(i!==s?o.update(!0):c&&(o.updateMode(),o.repositionPopups()))};n||(e.on("activate",o.show),e.on("deactivate",o.hide)),e.on("SkinLoaded ResizeWindow",(()=>o.update(!0))),e.on("NodeChange keydown",(e=>{requestAnimationFrame((()=>s(e)))})),e.on("ScrollWindow",(()=>o.updateMode()));const a=Pl();a.set(Gl(Ie(e.getBody()),"load",(e=>s(e.raw)))),e.on("remove",(()=>{a.clear()}))})(e,i,l,c),e.nodeChanged()};e.on("show",d),e.on("hide",l.hide),c||(e.on("focus",d),e.on("blur",l.hide)),e.on("init",(()=>{(e.hasFocus()||c)&&d()})),ty(e,t);const u={show:d,hide:l.hide,setEnabled:e=>{ey(t,!e)},isEnabled:()=>!km.isDisabled(s.outerContainer)};return{editorContainer:s.outerContainer.element.dom,api:u}}});const OA="contexttoolbar-hide",_A=(e,t)=>Fs(fC,((o,n)=>{const r=(e=>({hide:()=>Cs(e,is()),getValue:()=>ou.getValue(e)}))(e.get(o));t.onAction(r,n.event.buttonApi)})),TA=(e,t)=>{const o=e.label.fold((()=>({})),(e=>({"aria-label":e}))),n=Ah(yb.sketch({inputClasses:["tox-toolbar-textfield","tox-toolbar-nav-js"],data:e.initValue(),inputAttributes:o,selectOnFocus:!0,inputBehaviours:gl([Tp.config({mode:"special",onEnter:e=>r.findPrimary(e).map((e=>(_s(e),!0))),onLeft:(e,t)=>(t.cut(),M.none()),onRight:(e,t)=>(t.cut(),M.none())})])})),r=((e,t,o)=>{const n=z(t,(t=>Ah(((e,t,o)=>(e=>"contextformtogglebutton"===e.type)(t)?((e,t,o)=>{const{primary:n,...r}=t.original,s=Pn(bv({...r,type:"togglebutton",onAction:b}));return aA(s,o,[_A(e,t)])})(e,t,o):((e,t,o)=>{const{primary:n,...r}=t.original,s=Pn(pv({...r,type:"button",onAction:b}));return sA(s,o,[_A(e,t)])})(e,t,o))(e,t,o))));return{asSpecs:()=>z(n,(e=>e.asSpec())),findPrimary:e=>se(t,((t,o)=>t.primary?M.from(n[o]).bind((t=>t.getOpt(e))).filter(k(km.isDisabled)):M.none()))}})(n,e.commands,t);return[{title:M.none(),items:[n.asSpec()]},{title:M.none(),items:r.asSpecs()}]},EA=(e,t,o)=>t.bottom-e.y>=o&&e.bottom-t.y>=o,MA=e=>{const t=(e=>{const t=e.getBoundingClientRect();if(t.height<=0&&t.width<=0){const o=at(Ie(e.startContainer),e.startOffset).element;return(Ue(o)?et(o):M.some(o)).filter(Pe).map((e=>e.dom.getBoundingClientRect())).getOr(t)}return t})(e.selection.getRng());if(e.inline){const e=Vo();return Go(e.left+t.left,e.top+t.top,t.width,t.height)}{const o=qo(Ie(e.getBody()));return Go(o.x+t.left,o.y+t.top,t.width,t.height)}},AA=(e,t,o,n=0)=>{const r=Lo(window),s=$o(Ie(e.getContentAreaContainer())),a=If(e)||Vf(e)||zf(e),{x:i,width:l}=((e,t,o)=>{const n=Math.max(e.x+o,t.x);return{x:n,width:Math.min(e.right-o,t.right)-n}})(s,r,n);if(e.inline&&!a)return Go(i,r.y,l,r.height);{const a=t.header.isPositionedAtTop(),{y:c,bottom:d}=((e,t,o,n,r,s)=>{const a=Ie(e.getContainer()),i=ri(a,".tox-editor-header").getOr(a),l=$o(i),c=l.y>=t.bottom,d=n&&!c;if(e.inline&&d)return{y:Math.max(l.bottom+s,o.y),bottom:o.bottom};if(e.inline&&!d)return{y:o.y,bottom:Math.min(l.y-s,o.bottom)};const u="line"===r?$o(a):t;return d?{y:Math.max(l.bottom+s,o.y),bottom:Math.min(u.bottom-s,o.bottom)}:{y:Math.max(u.y+s,o.y),bottom:Math.min(l.y-s,o.bottom)}})(e,s,r,a,o,n);return Go(i,c,l,d-c)}},DA={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"],inset:["tox-pop--inset"]},BA={maxHeightFunction:Zl(),maxWidthFunction:wE()},FA=e=>"node"===e,IA=(e,t,o,n,r)=>{const s=MA(e),a=n.lastElement().exists((e=>Xe(o,e)));return((e,t)=>{const o=e.selection.getRng(),n=at(Ie(o.startContainer),o.startOffset);return o.startContainer===o.endContainer&&o.startOffset===o.endOffset-1&&Xe(n.element,t)})(e,o)?a?$O:PO:a?((e,o,r)=>{const a=Dt(e,"position");_t(e,"position",o);const i=EA(s,$o(t),-20)&&!n.isReposition()?XO:$O;return a.each((t=>_t(e,"position",t))),i})(t,n.getMode()):("fixed"===n.getMode()?r.y+Vo().top:r.y)+(Ht(t)+12)<=s.y?PO:UO},RA=(e,t,o,n)=>{const r=t=>(n,r,s,a,i)=>({...IA(e,a,t,o,i)({...n,y:i.y,height:i.height},r,s,a,i),alwaysFit:!0}),s=e=>FA(n)?[r(e)]:[];return t?{onLtr:e=>[Qi,Xi,Ki,Yi,Ji,Zi].concat(s(e)),onRtl:e=>[Qi,Ki,Xi,Ji,Yi,Zi].concat(s(e))}:{onLtr:e=>[Zi,Qi,Yi,Xi,Ji,Ki].concat(s(e)),onRtl:e=>[Zi,Qi,Ji,Ki,Yi,Xi].concat(s(e))}},NA=(e,t)=>{const o=U(t,(t=>t.predicate(e.dom))),{pass:n,fail:r}=P(o,(e=>"contexttoolbar"===e.type));return{contextToolbars:n,contextForms:r}},VA=(e,t)=>{const o={},n=[],r=[],s={},a={},i=ae(e);return L(i,(i=>{const l=e[i];"contextform"===l.type?((e,i)=>{const l=Pn(Ln("ContextForm",Cv,i));o[e]=l,l.launch.map((o=>{s["form:"+e]={...i.launch,type:"contextformtogglebutton"===o.type?"togglebutton":"button",onAction:()=>{t(l)}}})),"editor"===l.scope?r.push(l):n.push(l),a[e]=l})(i,l):"contexttoolbar"===l.type&&((e,t)=>{var o;(o=t,Ln("ContextToolbar",Ov,o)).each((o=>{"editor"===t.scope?r.push(o):n.push(o),a[e]=o}))})(i,l)})),{forms:o,inNodeScope:n,inEditorScope:r,lookupTable:a,formNavigators:s}},HA=Qs("forward-slide"),zA=Qs("backward-slide"),LA=Qs("change-slide-event"),PA="tox-pop--resizing",UA="tox-pop--transition",WA=(e,t,o,n)=>{const r=n.backstage,s=r.shared,a=_o().deviceType.isTouch,i=Ul(),l=Ul(),c=Ul(),d=Ka((e=>{const t=xr([]);return Th.sketch({dom:{tag:"div",classes:["tox-pop"]},fireDismissalEventInstead:{event:"doNotDismissYet"},onShow:e=>{t.set([]),Th.getContent(e).each((e=>{It(e.element,"visibility")})),Ba(e.element,PA),It(e.element,"width")},inlineBehaviours:gl([Vp("context-toolbar-events",[Ls(Xr(),((e,t)=>{"width"===t.event.raw.propertyName&&(Ba(e.element,PA),It(e.element,"width"))})),Fs(LA,((e,t)=>{const o=e.element;It(o,"width");const n=$t(o);Th.setContent(e,t.event.contents),Da(o,PA);const r=$t(o);_t(o,"width",n+"px"),Th.getContent(e).each((e=>{t.event.focus.bind((e=>(wl(e),Cl(o)))).orThunk((()=>(Tp.focusIn(e),kl(dt(o)))))})),setTimeout((()=>{_t(e.element,"width",r+"px")}),0)})),Fs(HA,((e,o)=>{Th.getContent(e).each((o=>{t.set(t.get().concat([{bar:o,focus:kl(dt(e.element))}]))})),Os(e,LA,{contents:o.event.forwardContents,focus:M.none()})})),Fs(zA,((e,o)=>{ne(t.get()).each((o=>{t.set(t.get().slice(0,t.get().length-1)),Os(e,LA,{contents:Ya(o.bar),focus:o.focus})}))}))]),Tp.config({mode:"special",onEscape:o=>ne(t.get()).fold((()=>e.onEscape()),(e=>(Cs(o,zA),M.some(!0))))})]),lazySink:()=>Jo.value(e.sink)})})({sink:o,onEscape:()=>(e.focus(),M.some(!0))})),u=()=>{const t=c.get().getOr("node"),o=FA(t)?1:0;return AA(e,s,t,o)},m=()=>!(e.removed||a()&&r.isContextMenuOpen()),g=()=>{if(m()){const t=u(),o=xe(c.get(),"node")?((e,t)=>t.filter((e=>pt(e)&&(e=>Pe(e)&&He(e.dom))(e))).map(qo).getOrThunk((()=>MA(e))))(e,i.get()):MA(e);return t.height<=0||!EA(o,t,.01)}return!0},p=()=>{i.clear(),l.clear(),c.clear(),Th.hide(d)},h=()=>{if(Th.isOpen(d)){const e=d.element;It(e,"display"),g()?_t(e,"display","none"):(l.set(0),Th.reposition(d))}},f=t=>({dom:{tag:"div",classes:["tox-pop__dialog"]},components:[t],behaviours:gl([Tp.config({mode:"acyclic"}),Vp("pop-dialog-wrap-events",[Ps((t=>{e.shortcuts.add("ctrl+F9","focus statusbar",(()=>Tp.focusIn(t)))})),Us((t=>{e.shortcuts.remove("ctrl+F9")}))])])}),v=Xt((()=>VA(t,(e=>{const t=y([e]);Os(d,HA,{forwardContents:f(t)})})))),y=t=>{const{buttons:o}=e.ui.registry.getAll(),r={...o,...v().formNavigators},a=df(e)===Wh.scrolling?Wh.scrolling:Wh.default,i=q(z(t,(t=>"contexttoolbar"===t.type?((t,o)=>mA(e,{buttons:t,toolbar:o.items,allowToolbarGroups:!1},n.backstage,M.some(["form:"])))(r,t):((e,t)=>TA(e,t))(t,s.providers))));return GE({type:a,uid:Qs("context-toolbar"),initGroups:i,onEscape:M.none,cyclicKeying:!0,providers:s.providers})},x=(t,n)=>{if(w.cancel(),!m())return;const r=y(t),p=t[0].position,h=((t,n)=>{const r="node"===t?s.anchors.node(n):s.anchors.cursor(),c=((e,t,o,n)=>"line"===t?{bubble:oc(12,0,DA),layouts:{onLtr:()=>[el],onRtl:()=>[tl]},overrides:BA}:{bubble:oc(0,12,DA,1/12),layouts:RA(e,o,n,t),overrides:BA})(e,t,a(),{lastElement:i.get,isReposition:()=>xe(l.get(),0),getMode:()=>ud.getMode(o)});return cn(r,c)})(p,n);c.set(p),l.set(1);const b=d.element;It(b,"display"),(e=>xe(Se(e,i.get(),Xe),!0))(n)||(Ba(b,UA),ud.reset(o,d)),Th.showWithinBounds(d,f(r),{anchor:h,transition:{classes:[UA],mode:"placement"}},(()=>M.some(u()))),n.fold(i.clear,i.set),g()&&_t(b,"display","none")},w=WC((()=>{e.hasFocus()&&!e.removed&&(Fa(d.element,UA)?w.throttle():((e,t)=>{const o=Ie(t.getBody()),n=e=>Xe(e,o),r=Ie(t.selection.getNode());return(e=>!n(e)&&!Ke(o,e))(r)?M.none():((e,t,o)=>{const n=NA(e,t);if(n.contextForms.length>0)return M.some({elem:e,toolbars:[n.contextForms[0]]});{const t=NA(e,o);if(t.contextForms.length>0)return M.some({elem:e,toolbars:[t.contextForms[0]]});if(n.contextToolbars.length>0||t.contextToolbars.length>0){const o=(e=>{if(e.length<=1)return e;{const t=t=>N(e,(e=>e.position===t)),o=t=>U(e,(e=>e.position===t)),n=t("selection"),r=t("node");if(n||r){if(r&&n){const e=o("node"),t=z(o("selection"),(e=>({...e,position:"node"})));return e.concat(t)}return o(n?"selection":"node")}return o("line")}})(n.contextToolbars.concat(t.contextToolbars));return M.some({elem:e,toolbars:o})}return M.none()}})(r,e.inNodeScope,e.inEditorScope).orThunk((()=>((e,t,o)=>e(t)?M.none():Or(t,(e=>{if(Pe(e)){const{contextToolbars:t,contextForms:n}=NA(e,o.inNodeScope),r=n.length>0?n:(e=>{if(e.length<=1)return e;{const t=t=>G(e,(e=>e.position===t));return t("selection").orThunk((()=>t("node"))).orThunk((()=>t("line"))).map((e=>e.position)).fold((()=>[]),(t=>U(e,(e=>e.position===t))))}})(t);return r.length>0?M.some({elem:e,toolbars:r}):M.none()}return M.none()}),e))(n,r,e)))})(v(),e).fold(p,(e=>{x(e.toolbars,M.some(e.elem))})))}),17);e.on("init",(()=>{e.on("remove",p),e.on("ScrollContent ScrollWindow ObjectResized ResizeEditor longpress",h),e.on("click keyup focus SetContent",w.throttle),e.on(OA,p),e.on("contexttoolbar-show",(t=>{const o=v();be(o.lookupTable,t.toolbarKey).each((o=>{x([o],ke(t.target!==e,t.target)),Th.getContent(d).each(Tp.focusIn)}))})),e.on("focusout",(t=>{Eh.setEditorTimeout(e,(()=>{Cl(o.element).isNone()&&Cl(d.element).isNone()&&p()}),0)})),e.on("SwitchMode",(()=>{e.mode.isReadOnly()&&p()})),e.on("AfterProgressState",(t=>{t.state?p():e.hasFocus()&&w.throttle()})),e.on("NodeChange",(e=>{Cl(d.element).fold(w.throttle,b)}))}))},jA={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:[""]},GA=(()=>{const e="[0-9]+",t="[eE][+-]?[0-9]+",o=e=>`(?:${e})?`,n=["Infinity","[0-9]+\\."+o(e)+o(t),"\\.[0-9]+"+o(t),e+o(t)].join("|");return new RegExp(`^([+-]?(?:${n}))(.*)$`)})(),$A=(e,t)=>{const o=()=>{const o=t.getOptions(e),n=t.getCurrent(e).map(t.hash),r=Ul();return z(o,(o=>({type:"togglemenuitem",text:t.display(o),onSetup:s=>{const a=e=>{e&&(r.on((e=>e.setActive(!1))),r.set(s)),s.setActive(e)};a(xe(n,t.hash(o)));const i=t.watcher(e,o,a);return()=>{r.clear(),i()}},onAction:()=>t.setCurrent(e,o)})))};e.ui.registry.addMenuButton(t.name,{tooltip:t.text,icon:t.icon,fetch:e=>e(o()),onSetup:t.onToolbarSetup}),e.ui.registry.addNestedMenuItem(t.name,{type:"nestedmenuitem",text:t.text,getSubmenuItems:o,onSetup:t.onMenuSetup})},qA={name:"lineheight",text:"Line height",icon:"line-height",getOptions:Nf,hash:e=>((e,t)=>((e,t)=>M.from(GA.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>N(t,(t=>N(jA[t],(t=>e===t)))))(n,t)?M.some({value:o,unit:n}):M.none()})))(e,["fixed","relative","empty"]).map((({value:e,unit:t})=>e+t)))(e).getOr(e),display:x,watcher:(e,t,o)=>e.formatter.formatChanged("lineheight",o,!1,{value:t}).unbind,getCurrent:e=>M.from(e.queryCommandValue("LineHeight")),setCurrent:(e,t)=>e.execCommand("LineHeight",!1,t)},XA=e=>kM(e,"NodeChange",(t=>{t.setEnabled(e.queryCommandState("outdent"))})),KA=(e,t)=>o=>{o.setActive(t.get());const n=e=>{t.set(e.state),o.setActive(e.state)};return e.on("PastePlainTextToggle",n),()=>e.off("PastePlainTextToggle",n)},YA=(e,t)=>()=>{e.execCommand("mceToggleFormat",!1,t)},JA=e=>{(e=>{(e=>{lC.each([{name:"bold",text:"Bold",icon:"bold"},{name:"italic",text:"Italic",icon:"italic"},{name:"underline",text:"Underline",icon:"underline"},{name:"strikethrough",text:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",icon:"superscript"}],((t,o)=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onSetup:SM(e,t.name),onAction:YA(e,t.name)})}));for(let t=1;t<=6;t++){const o="h"+t;e.ui.registry.addToggleButton(o,{text:o.toUpperCase(),tooltip:"Heading "+t,onSetup:SM(e,o),onAction:YA(e,o)})}})(e),(e=>{lC.each([{name:"cut",text:"Cut",action:"Cut",icon:"cut"},{name:"copy",text:"Copy",action:"Copy",icon:"copy"},{name:"paste",text:"Paste",action:"Paste",icon:"paste"},{name:"help",text:"Help",action:"mceHelp",icon:"help"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all"},{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"remove",text:"Remove",action:"Delete",icon:"remove"},{name:"print",text:"Print",action:"mcePrint",icon:"print"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addButton(t.name,{tooltip:t.text,icon:t.icon,onAction:OM(e,t.action)})}))})(e),(e=>{lC.each([{name:"blockquote",text:"Blockquote",action:"mceBlockQuote",icon:"quote"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:OM(e,t.action),onSetup:SM(e,t.name)})}))})(e)})(e),(e=>{lC.each([{name:"bold",text:"Bold",action:"Bold",icon:"bold",shortcut:"Meta+B"},{name:"italic",text:"Italic",action:"Italic",icon:"italic",shortcut:"Meta+I"},{name:"underline",text:"Underline",action:"Underline",icon:"underline",shortcut:"Meta+U"},{name:"strikethrough",text:"Strikethrough",action:"Strikethrough",icon:"strike-through"},{name:"subscript",text:"Subscript",action:"Subscript",icon:"subscript"},{name:"superscript",text:"Superscript",action:"Superscript",icon:"superscript"},{name:"removeformat",text:"Clear formatting",action:"RemoveFormat",icon:"remove-formatting"},{name:"newdocument",text:"New document",action:"mceNewDocument",icon:"new-document"},{name:"cut",text:"Cut",action:"Cut",icon:"cut",shortcut:"Meta+X"},{name:"copy",text:"Copy",action:"Copy",icon:"copy",shortcut:"Meta+C"},{name:"paste",text:"Paste",action:"Paste",icon:"paste",shortcut:"Meta+V"},{name:"selectall",text:"Select all",action:"SelectAll",icon:"select-all",shortcut:"Meta+A"},{name:"print",text:"Print...",action:"mcePrint",icon:"print",shortcut:"Meta+P"},{name:"hr",text:"Horizontal line",action:"InsertHorizontalRule",icon:"horizontal-rule"}],(t=>{e.ui.registry.addMenuItem(t.name,{text:t.text,icon:t.icon,shortcut:t.shortcut,onAction:OM(e,t.action)})})),e.ui.registry.addMenuItem("codeformat",{text:"Code",icon:"sourcecode",onAction:YA(e,"code")})})(e)},ZA=(e,t)=>kM(e,"Undo Redo AddUndo TypingUndo ClearUndos SwitchMode",(o=>{o.setEnabled(!e.mode.isReadOnly()&&e.undoManager[t]())})),QA=e=>kM(e,"VisualAid",(t=>{t.setActive(e.hasVisual)})),eD=(e,t)=>{(e=>{L([{name:"alignleft",text:"Align left",cmd:"JustifyLeft",icon:"align-left"},{name:"aligncenter",text:"Align center",cmd:"JustifyCenter",icon:"align-center"},{name:"alignright",text:"Align right",cmd:"JustifyRight",icon:"align-right"},{name:"alignjustify",text:"Justify",cmd:"JustifyFull",icon:"align-justify"}],(t=>{e.ui.registry.addToggleButton(t.name,{tooltip:t.text,icon:t.icon,onAction:OM(e,t.cmd),onSetup:SM(e,t.name)})})),e.ui.registry.addButton("alignnone",{tooltip:"No alignment",icon:"align-none",onAction:OM(e,"JustifyNone")})})(e),JA(e),((e,t)=>{((e,t)=>{const o=TM(0,t,BM(e));e.ui.registry.addNestedMenuItem("align",{text:t.shared.providers.translate("Align"),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=TM(0,t,VM(e));e.ui.registry.addNestedMenuItem("fontfamily",{text:t.shared.providers.translate("Fonts"),getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o={type:"advanced",...t.styles},n=TM(0,t,WM(e,o));e.ui.registry.addNestedMenuItem("styles",{text:"Formats",getSubmenuItems:()=>n.items.validateItems(n.getStyleItems())})})(e,t),((e,t)=>{const o=TM(0,t,IM(e));e.ui.registry.addNestedMenuItem("blocks",{text:"Blocks",getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t),((e,t)=>{const o=TM(0,t,UM(e));e.ui.registry.addNestedMenuItem("fontsize",{text:"Font sizes",getSubmenuItems:()=>o.items.validateItems(o.getStyleItems())})})(e,t)})(e,t),(e=>{(e=>{e.ui.registry.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onSetup:ZA(e,"hasUndo"),onAction:OM(e,"undo")}),e.ui.registry.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onSetup:ZA(e,"hasRedo"),onAction:OM(e,"redo")})})(e),(e=>{e.ui.registry.addButton("undo",{tooltip:"Undo",icon:"undo",enabled:!1,onSetup:ZA(e,"hasUndo"),onAction:OM(e,"undo")}),e.ui.registry.addButton("redo",{tooltip:"Redo",icon:"redo",enabled:!1,onSetup:ZA(e,"hasRedo"),onAction:OM(e,"redo")})})(e)})(e),(e=>{(e=>{e.addCommand("mceApplyTextcolor",((t,o)=>{((e,t,o)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.apply(t,{value:o}),e.nodeChanged()}))})(e,t,o)})),e.addCommand("mceRemoveTextcolor",(t=>{((e,t)=>{e.undoManager.transact((()=>{e.focus(),e.formatter.remove(t,{value:null},void 0,!0),e.nodeChanged()}))})(e,t)}))})(e);const t=mx(e),o=gx(e),n=xr(t),r=xr(o);xx(e,"forecolor","forecolor","Text color",n),xx(e,"backcolor","hilitecolor","Background color",r),wx(e,"forecolor","forecolor","Text color"),wx(e,"backcolor","hilitecolor","Background color")})(e),(e=>{(e=>{e.ui.registry.addButton("visualaid",{tooltip:"Visual aids",text:"Visual aids",onAction:OM(e,"mceToggleVisualAid")})})(e),(e=>{e.ui.registry.addToggleMenuItem("visualaid",{text:"Visual aids",onSetup:QA(e),onAction:OM(e,"mceToggleVisualAid")})})(e)})(e),(e=>{(e=>{e.ui.registry.addButton("outdent",{tooltip:"Decrease indent",icon:"outdent",onSetup:XA(e),onAction:OM(e,"outdent")}),e.ui.registry.addButton("indent",{tooltip:"Increase indent",icon:"indent",onAction:OM(e,"indent")})})(e)})(e),(e=>{$A(e,qA),(e=>M.from(lf(e)).map((t=>({name:"language",text:"Language",icon:"language",getOptions:y(t),hash:e=>u(e.customCode)?e.code:`${e.code}/${e.customCode}`,display:e=>e.title,watcher:(e,t,o)=>{var n;return e.formatter.formatChanged("lang",o,!1,{value:t.code,customValue:null!==(n=t.customCode)&&void 0!==n?n:null}).unbind},getCurrent:e=>{const t=Ie(e.selection.getNode());return _r(t,(e=>M.some(e).filter(Pe).bind((e=>wt(e,"lang").map((t=>({code:t,customCode:wt(e,"data-mce-lang").getOrUndefined(),title:""})))))))},setCurrent:(e,t)=>e.execCommand("Lang",!1,t),onToolbarSetup:t=>{const o=Pl();return t.setActive(e.formatter.match("lang",{},void 0,!0)),o.set(e.formatter.formatChanged("lang",t.setActive,!0)),o.clear}}))))(e).each((t=>$A(e,t)))})(e),(e=>{const t=xr(Af(e)),o=()=>e.execCommand("mceTogglePlainTextPaste");e.ui.registry.addToggleButton("pastetext",{active:!1,icon:"paste-text",tooltip:"Paste as text",onAction:o,onSetup:KA(e,t)}),e.ui.registry.addToggleMenuItem("pastetext",{text:"Paste as text",icon:"paste-text",onAction:o,onSetup:KA(e,t)})})(e)},tD=e=>s(e)?e.split(/[ ,]/):e,oD=e=>t=>t.options.get(e),nD=oD("contextmenu_never_use_native"),rD=oD("contextmenu_avoid_overlap"),sD=e=>{const t=e.ui.registry.getAll().contextMenus,o=e.options.get("contextmenu");return e.options.isSet("contextmenu")?o:U(o,(e=>ve(t,e)))},aD=(e,t)=>({type:"makeshift",x:e,y:t}),iD=e=>"longpress"===e.type||0===e.type.indexOf("touch"),lD=(e,t)=>"contextmenu"===t.type||"longpress"===t.type?e.inline?(e=>{if(iD(e)){const t=e.touches[0];return aD(t.pageX,t.pageY)}return aD(e.pageX,e.pageY)})(t):((e,t)=>{const o=Gh.DOM.getPos(e);return((e,t,o)=>aD(e.x+t,e.y+o))(t,o.x,o.y)})(e.getContentAreaContainer(),(e=>{if(iD(e)){const t=e.touches[0];return aD(t.clientX,t.clientY)}return aD(e.clientX,e.clientY)})(t)):cD(e),cD=e=>({type:"selection",root:Ie(e.selection.getNode())}),dD=(e,t,o)=>{switch(o){case"node":return(e=>({type:"node",node:M.some(Ie(e.selection.getNode())),root:Ie(e.getBody())}))(e);case"point":return lD(e,t);case"selection":return cD(e)}},uD=(e,t,o,n,r,s)=>{const a=o(),i=dD(e,t,s);EC(a,Jf.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!1,search:M.none()}).map((e=>{t.preventDefault(),Th.showMenuAt(r,{anchor:i},{menu:{markers:ub("normal")},data:e})}))},mD={onLtr:()=>[Qi,Xi,Ki,Yi,Ji,Zi,PO,UO,LO,HO,zO,VO],onRtl:()=>[Qi,Ki,Xi,Ji,Yi,Zi,PO,UO,zO,VO,LO,HO]},gD={valignCentre:[],alignCentre:[],alignLeft:["tox-pop--align-left"],alignRight:["tox-pop--align-right"],right:["tox-pop--right"],left:["tox-pop--left"],bottom:["tox-pop--bottom"],top:["tox-pop--top"]},pD=(e,t,o,n,r,s)=>{const a=_o(),i=a.os.isiOS(),l=a.os.isMacOS(),c=a.os.isAndroid(),d=a.deviceType.isTouch(),u=()=>{const a=o();((e,t,o,n,r,s,a)=>{const i=((e,t,o)=>{const n=dD(e,t,o);return{bubble:oc(0,"point"===o?12:0,gD),layouts:mD,overrides:{maxWidthFunction:wE(),maxHeightFunction:Zl()},...n}})(e,t,s);EC(o,Jf.CLOSE_ON_EXECUTE,n,{isHorizontalMenu:!0,search:M.none()}).map((o=>{t.preventDefault();const l=a?Ch.HighlightMenuAndItem:Ch.HighlightNone;Th.showMenuWithinBounds(r,{anchor:i},{menu:{markers:ub("normal"),highlightOnOpen:l},data:o,type:"horizontal"},(()=>M.some(AA(e,n.shared,"node"===s?"node":"selection")))),e.dispatch(OA)}))})(e,t,a,n,r,s,!(c||i||l&&d))};if((l||i)&&"node"!==s){const o=()=>{(e=>{const t=e.selection.getRng(),o=()=>{Eh.setEditorTimeout(e,(()=>{e.selection.setRng(t)}),10),s()};e.once("touchend",o);const n=e=>{e.preventDefault(),e.stopImmediatePropagation()};e.on("mousedown",n,!0);const r=()=>s();e.once("longpresscancel",r);const s=()=>{e.off("touchend",o),e.off("longpresscancel",r),e.off("mousedown",n)}})(e),u()};((e,t)=>{const o=e.selection;if(o.isCollapsed()||t.touches.length<1)return!1;{const n=t.touches[0],r=o.getRng();return zc(e.getWin(),Mc.domRange(r)).exists((e=>e.left<=n.clientX&&e.right>=n.clientX&&e.top<=n.clientY&&e.bottom>=n.clientY))}})(e,t)?o():(e.once("selectionchange",o),e.once("touchend",(()=>e.off("selectionchange",o))))}else u()},hD=e=>s(e)?"|"===e:"separator"===e.type,fD={type:"separator"},bD=e=>{const t=e=>({text:e.text,icon:e.icon,enabled:e.enabled,shortcut:e.shortcut});if(s(e))return e;switch(e.type){case"separator":return fD;case"submenu":return{type:"nestedmenuitem",...t(e),getSubmenuItems:()=>{const t=e.getSubmenuItems();return s(t)?t:z(t,bD)}};default:const n=e;return{type:"menuitem",...t(n),onAction:(o=n.onAction,()=>o())}}var o},vD=(e,t)=>{if(0===t.length)return e;const o=ne(e).filter((e=>!hD(e))).fold((()=>[]),(e=>[fD]));return e.concat(o).concat(t).concat([fD])},yD=(e,t)=>!(e=>"longpress"===e.type||ve(e,"touches"))(t)&&(2!==t.button||t.target===e.getBody()&&""===t.pointerType),xD=(e,t)=>yD(e,t)?e.selection.getStart(!0):t.target,wD=(e,t,o)=>{const n=_o().deviceType.isTouch,r=Ka(Th.sketch({dom:{tag:"div"},lazySink:t,onEscape:()=>e.focus(),onShow:()=>o.setContextMenuState(!0),onHide:()=>o.setContextMenuState(!1),fireDismissalEventInstead:{},inlineBehaviours:gl([Vp("dismissContextMenu",[Fs(fs(),((t,o)=>{Nd.close(t),e.focus()}))])])})),a=()=>Th.hide(r),i=t=>{if(nD(e)&&t.preventDefault(),((e,t)=>t.ctrlKey&&!nD(e))(e,t)||(e=>0===sD(e).length)(e))return;const a=((e,t)=>{const o=rD(e),n=yD(e,t)?"selection":"point";if(Ee(o)){const r=xD(e,t);return mw(Ie(r),o)?"node":n}return n})(e,t);(n()?pD:uD)(e,t,(()=>{const o=xD(e,t),n=e.ui.registry.getAll(),r=sD(e);return((e,t,o)=>{const n=j(t,((t,n)=>be(e,n.toLowerCase()).map((e=>{const n=e.update(o);if(s(n))return vD(t,n.split(" "));if(n.length>0){const e=z(n,bD);return vD(t,e)}return t})).getOrThunk((()=>t.concat([n])))),[]);return n.length>0&&hD(n[n.length-1])&&n.pop(),n})(n.contextMenus,r,o)}),o,r,a)};e.on("init",(()=>{const t="ResizeEditor ScrollContent ScrollWindow longpresscancel"+(n()?"":" ResizeWindow");e.on(t,a),e.on("longpress contextmenu",i)}))},SD=wr([{offset:["x","y"]},{absolute:["x","y"]},{fixed:["x","y"]}]),kD=e=>t=>t.translate(-e.left,-e.top),CD=e=>t=>t.translate(e.left,e.top),OD=e=>(t,o)=>j(e,((e,t)=>t(e)),Pt(t,o)),_D=(e,t,o)=>e.fold(OD([CD(o),kD(t)]),OD([kD(t)]),OD([])),TD=(e,t,o)=>e.fold(OD([CD(o)]),OD([]),OD([CD(t)])),ED=(e,t,o)=>e.fold(OD([]),OD([kD(o)]),OD([CD(t),kD(o)])),MD=(e,t,o)=>{const n=e.fold(((e,t)=>({position:M.some("absolute"),left:M.some(e+"px"),top:M.some(t+"px")})),((e,t)=>({position:M.some("absolute"),left:M.some(e-o.left+"px"),top:M.some(t-o.top+"px")})),((e,t)=>({position:M.some("fixed"),left:M.some(e+"px"),top:M.some(t+"px")})));return{right:M.none(),bottom:M.none(),...n}},AD=(e,t,o,n)=>{const r=(e,r)=>(s,a)=>{const i=e(t,o,n);return r(s.getOr(i.left),a.getOr(i.top))};return e.fold(r(ED,DD),r(TD,BD),r(_D,FD))},DD=SD.offset,BD=SD.absolute,FD=SD.fixed,ID=(e,t)=>{const o=xt(e,t);return u(o)?NaN:parseInt(o,10)},RD=(e,t,o,n,r,s)=>{const a=((e,t,o,n)=>((e,t)=>{const o=e.element,n=ID(o,t.leftAttr),r=ID(o,t.topAttr);return isNaN(n)||isNaN(r)?M.none():M.some(Pt(n,r))})(e,t).fold((()=>o),(e=>FD(e.left+n.left,e.top+n.top))))(e,t,o,n),i=t.mustSnap?VD(e,t,a,r,s):HD(e,t,a,r,s),l=_D(a,r,s);return((e,t,o)=>{const n=e.element;vt(n,t.leftAttr,o.left+"px"),vt(n,t.topAttr,o.top+"px")})(e,t,l),i.fold((()=>({coord:FD(l.left,l.top),extra:M.none()})),(e=>({coord:e.output,extra:e.extra})))},ND=(e,t,o,n)=>se(e,(e=>{const r=e.sensor,s=((e,t,o,n,r,s)=>{const a=TD(e,r,s),i=TD(t,r,s);return Math.abs(a.left-i.left)<=o&&Math.abs(a.top-i.top)<=n})(t,r,e.range.left,e.range.top,o,n);return s?M.some({output:AD(e.output,t,o,n),extra:e.extra}):M.none()})),VD=(e,t,o,n,r)=>{const s=t.getSnapPoints(e);return ND(s,o,n,r).orThunk((()=>{const e=j(s,((e,t)=>{const s=t.sensor,a=((e,t,o,n,r,s)=>{const a=TD(e,r,s),i=TD(t,r,s),l=Math.abs(a.left-i.left),c=Math.abs(a.top-i.top);return Pt(l,c)})(o,s,t.range.left,t.range.top,n,r);return e.deltas.fold((()=>({deltas:M.some(a),snap:M.some(t)})),(o=>(a.left+a.top)/2<=(o.left+o.top)/2?{deltas:M.some(a),snap:M.some(t)}:e))}),{deltas:M.none(),snap:M.none()});return e.snap.map((e=>({output:AD(e.output,o,n,r),extra:e.extra})))}))},HD=(e,t,o,n,r)=>{const s=t.getSnapPoints(e);return ND(s,o,n,r)};var zD=Object.freeze({__proto__:null,snapTo:(e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const t=Ye(e.element),o=Vo(t),s=Q_(r),a=((e,t,o)=>({coord:AD(e.output,e.output,t,o),extra:e.extra}))(n,o,s),i=MD(a.coord,0,s);Et(r,i)}}});const LD="data-initial-z-index",PD=(e,t)=>{e.getSystem().addToGui(t),(e=>{et(e.element).filter(Pe).each((t=>{Dt(t,"z-index").each((e=>{vt(t,LD,e)})),_t(t,"z-index",Mt(e.element,"z-index"))}))})(t)},UD=e=>{(e=>{et(e.element).filter(Pe).each((e=>{wt(e,LD).fold((()=>It(e,"z-index")),(t=>_t(e,"z-index",t))),kt(e,LD)}))})(e),e.getSystem().removeFromGui(e)},WD=(e,t,o)=>e.getSystem().build(Sw.sketch({dom:{styles:{left:"0px",top:"0px",width:"100%",height:"100%",position:"fixed","z-index":"1000000000000000"},classes:[t]},events:o}));var jD=dr("snaps",[Xn("getSnapPoints"),wi("onSensor"),Xn("leftAttr"),Xn("topAttr"),ur("lazyViewport",Xo),ur("mustSnap",!1)]);const GD=[ur("useFixed",_),Xn("blockerClass"),ur("getTarget",x),ur("onDrag",b),ur("repositionTarget",!0),ur("onDrop",b),br("getBounds",Xo),jD],$D=(e,t)=>({bounds:e.getBounds(),height:zt(t.element),width:qt(t.element)}),qD=(e,t,o,n,r)=>{const s=o.update(n,r),a=o.getStartData().getOrThunk((()=>$D(t,e)));s.each((o=>{((e,t,o,n)=>{const r=t.getTarget(e.element);if(t.repositionTarget){const s=Ye(e.element),a=Vo(s),i=Q_(r),l=(e=>{return(t=Dt(e,"left"),o=Dt(e,"top"),n=Dt(e,"position"),r=(e,t,o)=>("fixed"===o?FD:DD)(parseInt(e,10),parseInt(t,10)),t.isSome()&&o.isSome()&&n.isSome()?M.some(r(t.getOrDie(),o.getOrDie(),n.getOrDie())):M.none()).getOrThunk((()=>{const t=Wt(e);return BD(t.left,t.top)}));var t,o,n,r})(r),c=((e,t,o,n,r,s,a)=>((e,t,o,n,r)=>{const s=r.bounds,a=TD(t,o,n),i=zi(a.left,s.x,s.x+s.width-r.width),l=zi(a.top,s.y,s.y+s.height-r.height),c=BD(i,l);return t.fold((()=>{const e=ED(c,o,n);return DD(e.left,e.top)}),y(c),(()=>{const e=_D(c,o,n);return FD(e.left,e.top)}))})(0,t.fold((()=>{const e=(t=o,a=s.left,i=s.top,t.fold(((e,t)=>DD(e+a,t+i)),((e,t)=>BD(e+a,t+i)),((e,t)=>FD(e+a,t+i))));var t,a,i;const l=_D(e,n,r);return FD(l.left,l.top)}),(t=>{const a=RD(e,t,o,s,n,r);return a.extra.each((o=>{t.onSensor(e,o)})),a.coord})),n,r,a))(e,t.snaps,l,a,i,n,o),d=MD(c,0,i);Et(r,d)}t.onDrag(e,r,n)})(e,t,a,o)}))},XD=(e,t,o,n)=>{t.each(UD),o.snaps.each((t=>{((e,t)=>{((e,t)=>{const o=e.element;kt(o,t.leftAttr),kt(o,t.topAttr)})(e,t)})(e,t)}));const r=o.getTarget(e.element);n.reset(),o.onDrop(e,r)},KD=e=>(t,o)=>{const n=e=>{o.setStartData($D(t,e))};return As([Fs(ms(),(e=>{o.getStartData().each((()=>n(e)))})),...e(t,o,n)])};var YD=Object.freeze({__proto__:null,getData:e=>M.from(Pt(e.x,e.y)),getDelta:(e,t)=>Pt(t.left-e.left,t.top-e.top)});const JD=(e,t,o)=>[Fs(Rr(),((n,r)=>{if(0!==r.event.raw.button)return;r.stop();const s=()=>XD(n,M.some(l),e,t),a=gw(s,200),i={drop:s,delayDrop:a.schedule,forceDrop:s,move:o=>{a.cancel(),qD(n,e,t,YD,o)}},l=WD(n,e.blockerClass,(e=>As([Fs(Rr(),e.forceDrop),Fs(Hr(),e.drop),Fs(Nr(),((t,o)=>{e.move(o.event)})),Fs(Vr(),e.delayDrop)]))(i));o(n),PD(n,l)}))],ZD=[...GD,Oi("dragger",{handlers:KD(JD)})];var QD=Object.freeze({__proto__:null,getData:e=>{const t=e.raw.touches;return 1===t.length?(e=>{const t=e[0];return M.some(Pt(t.clientX,t.clientY))})(t):M.none()},getDelta:(e,t)=>Pt(t.left-e.left,t.top-e.top)});const eB=(e,t,o)=>{const n=Ul(),r=o=>{XD(o,n.get(),e,t),n.clear()};return[Fs(Dr(),((s,a)=>{a.stop();const i=()=>r(s),l={drop:i,delayDrop:b,forceDrop:i,move:o=>{qD(s,e,t,QD,o)}},c=WD(s,e.blockerClass,(e=>As([Fs(Dr(),e.forceDrop),Fs(Fr(),e.drop),Fs(Ir(),e.drop),Fs(Br(),((t,o)=>{e.move(o.event)}))]))(l));n.set(c),o(s),PD(s,c)})),Fs(Br(),((o,n)=>{n.stop(),qD(o,e,t,QD,n.event)})),Fs(Fr(),((e,t)=>{t.stop(),r(e)})),Fs(Ir(),r)]},tB=ZD,oB=[...GD,Oi("dragger",{handlers:KD(eB)})],nB=[...GD,Oi("dragger",{handlers:KD(((e,t,o)=>[...JD(e,t,o),...eB(e,t,o)]))})];var rB=Object.freeze({__proto__:null,mouse:tB,touch:oB,mouseOrTouch:nB}),sB=Object.freeze({__proto__:null,init:()=>{let e=M.none(),t=M.none();const o=y({});return ba({readState:o,reset:()=>{e=M.none(),t=M.none()},update:(t,o)=>t.getData(o).bind((o=>((t,o)=>{const n=e.map((e=>t.getDelta(e,o)));return e=M.some(o),n})(t,o))),getStartData:()=>t,setStartData:e=>{t=M.some(e)}})}});const aB=bl({branchKey:"mode",branches:rB,name:"dragging",active:{events:(e,t)=>e.dragger.handlers(e,t)},extra:{snap:e=>({sensor:e.sensor,range:e.range,output:e.output,extra:M.from(e.extra)})},state:sB,apis:zD}),iB=(e,t,o,n,r,s)=>e.fold((()=>aB.snap({sensor:BD(o-20,n-20),range:Pt(r,s),output:BD(M.some(o),M.some(n)),extra:{td:t}})),(e=>{const r=o-20,s=n-20,a=e.element.dom.getBoundingClientRect();return aB.snap({sensor:BD(r,s),range:Pt(40,40),output:BD(M.some(o-a.width/2),M.some(n-a.height/2)),extra:{td:t}})})),lB=(e,t,o)=>({getSnapPoints:e,leftAttr:"data-drag-left",topAttr:"data-drag-top",onSensor:(e,n)=>{const r=n.td;((e,t)=>e.exists((e=>Xe(e,t))))(t.get(),r)||(t.set(r),o(r))},mustSnap:!0}),cB=e=>Ah(Mh.sketch({dom:{tag:"div",classes:["tox-selector"]},buttonBehaviours:gl([aB.config({mode:"mouseOrTouch",blockerClass:"blocker",snaps:e}),eS.config({})]),eventOrder:{mousedown:["dragging","alloy.base.behaviour"],touchstart:["dragging","alloy.base.behaviour"]}})),dB=(e,t)=>{const o=xr([]),n=xr([]),r=xr(!1),s=Ul(),a=Ul(),i=e=>{const o=qo(e);return iB(u.getOpt(t),e,o.x,o.y,o.width,o.height)},l=e=>{const o=qo(e);return iB(m.getOpt(t),e,o.right,o.bottom,o.width,o.height)},c=lB((()=>z(o.get(),(e=>i(e)))),s,(t=>{a.get().each((o=>{e.dispatch("TableSelectorChange",{start:t,finish:o})}))})),d=lB((()=>z(n.get(),(e=>l(e)))),a,(t=>{s.get().each((o=>{e.dispatch("TableSelectorChange",{start:o,finish:t})}))})),u=cB(c),m=cB(d),g=Ka(u.asSpec()),p=Ka(m.asSpec()),h=(t,o,n,r)=>{const s=n(o);aB.snapTo(t,s),((t,o,n,s)=>{const a=o.dom.getBoundingClientRect();It(t.element,"display");const i=Qe(Ie(e.getBody())).dom.innerHeight,l=a[r]<0,c=((e,t)=>e[r]>t)(a,i);(l||c)&&_t(t.element,"display","none")})(t,o)},f=e=>h(g,e,i,"top"),b=e=>h(p,e,l,"bottom");_o().deviceType.isTouch()&&(e.on("TableSelectionChange",(e=>{r.get()||(vd(t,g),vd(t,p),r.set(!0)),s.set(e.start),a.set(e.finish),e.otherCells.each((t=>{o.set(t.upOrLeftCells),n.set(t.downOrRightCells),f(e.start),b(e.finish)}))})),e.on("ResizeEditor ResizeWindow ScrollContent",(()=>{s.get().each(f),a.get().each(b)})),e.on("TableSelectionClear",(()=>{r.get()&&(wd(g),wd(p),r.set(!1)),s.clear(),a.clear()})))},uB=(e,t,o)=>{var n;const r=null!==(n=t.delimiter)&&void 0!==n?n:"\u203a";return{dom:{tag:"div",classes:["tox-statusbar__path"],attributes:{role:"navigation"}},behaviours:gl([Tp.config({mode:"flow",selector:"div[role=button]"}),km.config({disabled:o.isDisabled}),oy(),Mw.config({}),Np.config({}),Vp("elementPathEvents",[Ps(((t,n)=>{e.shortcuts.add("alt+F11","focus statusbar elementpath",(()=>Tp.focusIn(t))),e.on("NodeChange",(n=>{const s=(t=>{const o=[];let n=t.length;for(;n-- >0;){const s=t[n];if(1===s.nodeType&&"BR"!==(r=s).nodeName&&!r.getAttribute("data-mce-bogus")&&"bookmark"!==r.getAttribute("data-mce-type")){const t=Xy(e,s);if(t.isDefaultPrevented()||o.push({name:t.name,element:s}),t.isPropagationStopped())break}}var r;return o})(n.parents),a=s.length>0?j(s,((t,n,s)=>{const a=((t,n,r)=>Mh.sketch({dom:{tag:"div",classes:["tox-statusbar__path-item"],attributes:{"data-index":r,"aria-level":r+1}},components:[Ga(t)],action:t=>{e.focus(),e.selection.select(n),e.nodeChanged()},buttonBehaviours:gl([ny(o.isDisabled),oy()])}))(n.name,n.element,s);return 0===s?t.concat([a]):t.concat([{dom:{tag:"div",classes:["tox-statusbar__path-divider"],attributes:{"aria-hidden":!0}},components:[Ga(` ${r} `)]},a])}),[]):[];Np.set(t,a)}))}))])]),components:[]}};var mB;!function(e){e[e.None=0]="None",e[e.Both=1]="Both",e[e.Vertical=2]="Vertical"}(mB||(mB={}));const gB=(e,t,o)=>{const n=Ie(e.getContainer()),r=((e,t,o,n,r)=>{const s={height:yA(n+t.top,tf(e),nf(e))};return o===mB.Both&&(s.width=yA(r+t.left,ef(e),of(e))),s})(e,t,o,Ht(n),$t(n));le(r,((e,t)=>{h(e)&&_t(n,t,vA(e))})),(e=>{e.dispatch("ResizeEditor")})(e)},pB=(e,t,o,n)=>{const r=Pt(20*o,20*n);return gB(e,r,t),M.some(!0)},hB=(e,t)=>({dom:{tag:"div",classes:["tox-statusbar"]},components:(()=>{const o=(()=>{const o=[];return Tf(e)&&o.push(uB(e,{},t)),e.hasPlugin("wordcount")&&o.push(((e,t)=>{const o=(e,o,n)=>Np.set(e,[Ga(t.translate(["{0} "+n,o[n]]))]);return Mh.sketch({dom:{tag:"button",classes:["tox-statusbar__wordcount"]},components:[],buttonBehaviours:gl([ny(t.isDisabled),oy(),Mw.config({}),Np.config({}),ou.config({store:{mode:"memory",initialValue:{mode:"words",count:{words:0,characters:0}}}}),Vp("wordcount-events",[js((e=>{const t=ou.getValue(e),n="words"===t.mode?"characters":"words";ou.setValue(e,{mode:n,count:t.count}),o(e,t.count,n)})),Ps((t=>{e.on("wordCountUpdate",(e=>{const{mode:n}=ou.getValue(t);ou.setValue(t,{mode:n,count:e.wordCount}),o(t,e.wordCount,n)}))}))])]),eventOrder:{[ns()]:["disabling","alloy.base.behaviour","wordcount-events"]}})})(e,t)),Ef(e)&&o.push({dom:{tag:"span",classes:["tox-statusbar__branding"]},components:[{dom:{tag:"a",attributes:{href:"https://www.tiny.cloud/powered-by-tiny?utm_campaign=editor_referral&utm_medium=poweredby&utm_source=tinymce&utm_content=v6",rel:"noopener",target:"_blank","aria-label":Dh.translate(["Powered by {0}","Tiny"])},innerHtml:'<svg width="50px" height="16px" viewBox="0 0 50 16" xmlns="http://www.w3.org/2000/svg">\n  <path fill-rule="evenodd" clip-rule="evenodd" d="M10.143 0c2.608.015 5.186 2.178 5.186 5.331 0 0 .077 3.812-.084 4.87-.361 2.41-2.164 4.074-4.65 4.496-1.453.284-2.523.49-3.212.623-.373.071-.634.122-.785.152-.184.038-.997.145-1.35.145-2.732 0-5.21-2.04-5.248-5.33 0 0 0-3.514.03-4.442.093-2.4 1.758-4.342 4.926-4.963 0 0 3.875-.752 4.036-.782.368-.07.775-.1 1.15-.1Zm1.826 2.8L5.83 3.989v2.393l-2.455.475v5.968l6.137-1.189V9.243l2.456-.476V2.8ZM5.83 6.382l3.682-.713v3.574l-3.682.713V6.382Zm27.173-1.64-.084-1.066h-2.226v9.132h2.456V7.743c-.008-1.151.998-2.064 2.149-2.072 1.15-.008 1.987.92 1.995 2.072v5.065h2.455V7.359c-.015-2.18-1.657-3.929-3.837-3.913a3.993 3.993 0 0 0-2.908 1.296Zm-6.3-4.266L29.16 0v2.387l-2.456.475V.476Zm0 3.2v9.132h2.456V3.676h-2.456Zm18.179 11.787L49.11 3.676H46.58l-1.612 4.527-.46 1.382-.384-1.382-1.611-4.527H39.98l3.3 9.132L42.15 16l2.732-.537ZM22.867 9.738c0 .752.568 1.075.921 1.075.353 0 .668-.047.998-.154l.537 1.765c-.23.154-.92.537-2.225.537-1.305 0-2.655-.997-2.686-2.686a136.877 136.877 0 0 1 0-4.374H18.8V3.676h1.612v-1.98l2.455-.476v2.456h2.302V5.9h-2.302v3.837Z"/>\n</svg>\n'.trim()},behaviours:gl([Up.config({})])}]}),o.length>0?[{dom:{tag:"div",classes:["tox-statusbar__text-container"]},components:o}]:[]})(),n=((e,t)=>{const o=(e=>{const t=Mf(e);return!1===t?mB.None:"both"===t?mB.Both:mB.Vertical})(e);return o===mB.None?M.none():M.some(Lh("resize-handle",{tag:"div",classes:["tox-statusbar__resize-handle"],attributes:{title:t.translate("Resize")},behaviours:[aB.config({mode:"mouse",repositionTarget:!1,onDrag:(t,n,r)=>gB(e,r,o),blockerClass:"tox-blocker"}),Tp.config({mode:"special",onLeft:()=>pB(e,o,-1,0),onRight:()=>pB(e,o,1,0),onUp:()=>pB(e,o,0,-1),onDown:()=>pB(e,o,0,1)}),Mw.config({}),Up.config({})]},t.icons))})(e,t);return o.concat(n.toArray())})()}),fB=(e,t)=>t.get().getOrDie(`UI for ${e} has not been rendered`),bB=e=>{const t=e.inline,o=t?CA:fA,n=Gf(e)?OT:J_,r=(()=>{const e=Ul(),t=Ul(),o=Ul();return{dialogUi:e,popupUi:t,mainUi:o,getUiMotherships:()=>[...e.get().map((e=>e.mothership)).toArray()],setupDialogUi:t=>{e.set(t)},lazyGetInOuterOrDie:(e,t)=>()=>o.get().bind((e=>t(e.outerContainer))).getOrDie(`Could not find ${e} element in OuterContainer`)}})(),s=Ul(),a=Ul(),i=_o().deviceType.isTouch()?["tox-platform-touch"]:[],l=Lf(e),c=df(e),d=Ah({dom:{tag:"div",classes:["tox-anchorbar"]}}),u=()=>r.mainUi.get().map((e=>e.outerContainer)).bind(uM.getHeader),m=r.lazyGetInOuterOrDie("anchor bar",d.getOpt),g=r.lazyGetInOuterOrDie("toolbar",uM.getToolbar),p=r.lazyGetInOuterOrDie("throbber",uM.getThrobber),h=((e,t,o)=>{const n=xr(!1),r=(e=>{const t=xr(Lf(e)?"bottom":"top");return{isPositionedAtTop:()=>"top"===t.get(),getDockingMode:t.get,setDockingMode:t.set}})(t),s={icons:()=>t.ui.registry.getAll().icons,menuItems:()=>t.ui.registry.getAll().menuItems,translate:Dh.translate,isDisabled:()=>t.mode.isReadOnly()||!t.ui.isEnabled(),getOption:t.options.get},a=V_(t),i=(e=>{const t=t=>()=>e.formatter.match(t),o=t=>()=>{const o=e.formatter.get(t);return void 0!==o?M.some({tag:o.length>0&&(o[0].inline||o[0].block)||"div",styles:e.dom.parseStyle(e.formatter.getCssText(t))}):M.none()},n=xr([]),r=xr([]),s=xr(!1);return e.on("PreInit",(r=>{const s=d_(e),a=m_(e,s,t,o);n.set(a)})),e.on("addStyleModifications",(n=>{const a=m_(e,n.items,t,o);r.set(a),s.set(n.replace)})),{getData:()=>{const e=s.get()?[]:n.get(),t=r.get();return e.concat(t)}}})(t),l=(e=>({colorPicker:t_(e),hasCustomColors:o_(e),getColors:n_(e),getColorCols:r_(e)}))(t),c=(e=>({isDraggableModal:s_(e)}))(t),d={shared:{providers:s,anchors:e_(t,o,r.isPositionedAtTop),header:r},urlinput:a,styles:i,colorinput:l,dialog:c,isContextMenuOpen:()=>n.get(),setContextMenuState:e=>n.set(e)},u={...d,shared:{...d.shared,interpreter:e=>MO(e,{},u),getSink:e.popup}},m={...d,shared:{...d.shared,interpreter:e=>MO(e,{},m),getSink:e.dialog}};return{popup:u,dialog:m}})({popup:()=>Jo.fromOption(r.popupUi.get().map((e=>e.sink)),"(popup) UI has not been rendered"),dialog:()=>Jo.fromOption(r.dialogUi.get().map((e=>e.sink)),"UI has not been rendered")},e,m),f=x,b=()=>{const o=(()=>{const t={attributes:{[lc]:l?ic.BottomToTop:ic.TopToBottom}},o=uM.parts.menubar({dom:{tag:"div",classes:["tox-menubar"]},backstage:h.popup,onEscape:()=>{e.focus()}}),n=uM.parts.toolbar({dom:{tag:"div",classes:["tox-toolbar"]},getSink:h.popup.shared.getSink,providers:h.popup.shared.providers,onEscape:()=>{e.focus()},onToolbarToggled:t=>{((e,t)=>{e.dispatch("ToggleToolbarDrawer",{state:t})})(e,t)},type:c,lazyToolbar:g,lazyHeader:()=>u().getOrDie("Could not find header element"),...t}),r=uM.parts["multiple-toolbar"]({dom:{tag:"div",classes:["tox-toolbar-overlord"]},providers:h.popup.shared.providers,onEscape:()=>{e.focus()},type:c}),s=zf(e),a=Vf(e),i=If(e),m=Bf(e),p=uM.parts.promotion({dom:{tag:"div",classes:["tox-promotion"]}}),f=s||a||i,b=m?[p,o]:[o];return uM.parts.header({dom:{tag:"div",classes:["tox-editor-header"].concat(f?[]:["tox-editor-header--empty"]),...t},components:q([i?b:[],s?[r]:a?[n]:[],Uf(e)?[]:[d.asSpec()]]),sticky:Gf(e),editor:e,sharedBackstage:h.popup.shared})})(),n={dom:{tag:"div",classes:["tox-sidebar-wrap"]},components:[uM.parts.socket({dom:{tag:"div",classes:["tox-edit-area"]}}),uM.parts.sidebar({dom:{tag:"div",classes:["tox-sidebar"]}})]},r=uM.parts.throbber({dom:{tag:"div",classes:["tox-throbber"]},backstage:h.popup}),a=uM.parts.viewWrapper({backstage:h.popup}),m=_f(e)&&!t?M.some(hB(e,h.popup.shared.providers)):M.none(),p=q([l?[]:[o],t?[]:[n],l?[o]:[]]),f=uM.parts.editorContainer({components:q([p,t?[]:m.toArray()])}),b=jf(e),v={role:"application",...Dh.isRtl()?{dir:"rtl"}:{},...b?{"aria-hidden":"true"}:{}},y=Ka(uM.sketch({dom:{tag:"div",classes:["tox","tox-tinymce"].concat(t?["tox-tinymce-inline"]:[]).concat(l?["tox-tinymce--toolbar-bottom"]:[]).concat(i),styles:{visibility:"hidden",...b?{opacity:"0",border:"0"}:{}},attributes:v},components:[f,...t?[]:[a],r],behaviours:gl([oy(),km.config({disableClass:"tox-tinymce--disabled"}),Tp.config({mode:"cyclic",selector:".tox-menubar, .tox-toolbar, .tox-toolbar__primary, .tox-toolbar__overflow--open, .tox-sidebar__overflow--open, .tox-statusbar__path, .tox-statusbar__wordcount, .tox-statusbar__branding a, .tox-statusbar__resize-handle"})])})),x=kw(y);return s.set(x),{mothership:x,outerContainer:y}},v=t=>{const o=vA((e=>{const t=(e=>{const t=Zh(e),o=tf(e),n=nf(e);return bA(t).map((e=>yA(e,o,n)))})(e);return t.getOr(Zh(e))})(e)),n=vA((e=>xA(e).getOr(Qh(e)))(e));return e.inline||(Ft("div","width",n)&&_t(t.element,"width",n),Ft("div","height",o)?_t(t.element,"height",o):_t(t.element,"height","400px")),o};return{popups:{backstage:h.popup,getMothership:()=>fB("popups",a)},dialogs:{backstage:h.dialog,getMothership:()=>fB("dialogs",a)},renderUI:()=>{const t=b(),s=(()=>{const t=Wf(e),o=Xe(ht(),t)&&"grid"===Mt(t,"display"),r={dom:{tag:"div",classes:["tox","tox-silver-sink","tox-tinymce-aux"].concat(i),attributes:{...Dh.isRtl()?{dir:"rtl"}:{}}},behaviours:gl([ud.config({useFixed:()=>n.isDocked(u)})])},s={dom:{styles:{width:document.body.clientWidth+"px"}},events:As([Fs(gs(),(e=>{_t(e.element,"width",document.body.clientWidth+"px")}))])},l=Ka(cn(r,o?s:{})),c=kw(l);return a.set(c),{sink:l,mothership:c}})(),l=f(s);r.dialogUi.set(s),r.popupUi.set(l),r.mainUi.set(t);return(t=>{const{mainUi:r,popupUi:s,uiMotherships:a}=t;ce(uf(e),((t,o)=>{e.ui.registry.addGroupToolbarButton(o,t)}));const{buttons:i,menuItems:l,contextToolbars:d,sidebars:m,views:g}=e.ui.registry.getAll(),f=Hf(e),b={menuItems:l,menus:$f(e),menubar:bf(e),toolbar:f.getOrThunk((()=>vf(e))),allowToolbarGroups:c===Wh.floating,buttons:i,sidebar:m,views:g};var y;y=r.outerContainer,e.addShortcut("alt+F9","focus menubar",(()=>{uM.focusMenubar(y)})),e.addShortcut("alt+F10","focus toolbar",(()=>{uM.focusToolbar(y)})),e.addCommand("ToggleToolbarDrawer",(()=>{uM.toggleToolbarDrawer(y)})),e.addQueryStateHandler("ToggleToolbarDrawer",(()=>uM.isToolbarDrawerToggled(y))),((e,t,o)=>{const n=(e,n)=>{L([t,...o],(t=>{t.broadcastEvent(e,n)}))},r=(e,n)=>{L([t,...o],(t=>{t.broadcastOn([e],n)}))},s=e=>r(Vd(),{target:e.target}),a=Po(),i=jl(a,"touchstart",s),l=jl(a,"touchmove",(e=>n(ds(),e))),c=jl(a,"touchend",(e=>n(us(),e))),d=jl(a,"mousedown",s),u=jl(a,"mouseup",(e=>{0===e.raw.button&&r(zd(),{target:e.target})})),m=e=>r(Vd(),{target:Ie(e.target)}),g=e=>{0===e.button&&r(zd(),{target:Ie(e.target)})},p=()=>{L(e.editorManager.get(),(t=>{e!==t&&t.dispatch("DismissPopups",{relatedTarget:e})}))},h=e=>n(ms(),$l(e)),f=e=>{r(Hd(),{}),n(gs(),$l(e))},b=()=>r(Hd(),{}),v=t=>{t.state&&r(Vd(),{target:Ie(e.getContainer())})},y=e=>{r(Vd(),{target:Ie(e.relatedTarget.getContainer())})};e.on("PostRender",(()=>{e.on("click",m),e.on("tap",m),e.on("mouseup",g),e.on("mousedown",p),e.on("ScrollWindow",h),e.on("ResizeWindow",f),e.on("ResizeEditor",b),e.on("AfterProgressState",v),e.on("DismissPopups",y)})),e.on("remove",(()=>{e.off("click",m),e.off("tap",m),e.off("mouseup",g),e.off("mousedown",p),e.off("ScrollWindow",h),e.off("ResizeWindow",f),e.off("ResizeEditor",b),e.off("AfterProgressState",v),e.off("DismissPopups",y),d.unbind(),i.unbind(),l.unbind(),c.unbind(),u.unbind()})),e.on("detach",(()=>{L([t,...o],Od),L([t,...o],(e=>e.destroy()))}))})(e,r.mothership,a),n.setup(e,h.popup.shared,u),eD(e,h.popup),wD(e,h.popup.shared.getSink,h.popup),(e=>{const{sidebars:t}=e.ui.registry.getAll();L(ae(t),(o=>{const n=t[o],r=()=>xe(M.from(e.queryCommandValue("ToggleSidebar")),o);e.ui.registry.addToggleButton(o,{icon:n.icon,tooltip:n.tooltip,onAction:t=>{e.execCommand("ToggleSidebar",!1,o),t.setActive(r())},onSetup:t=>{t.setActive(r());const o=()=>t.setActive(r());return e.on("ToggleSidebar",o),()=>{e.off("ToggleSidebar",o)}}})}))})(e),mE(e,p,h.popup.shared),WA(e,d,s.sink,{backstage:h.popup}),dB(e,s.sink);const x={targetNode:e.getElement(),height:v(r.outerContainer)};return o.render(e,t,b,h.popup,x)})({popupUi:l,dialogUi:s,mainUi:t,uiMotherships:r.getUiMotherships()})}}},vB=y([Xn("lazySink"),nr("dragBlockClass"),br("getBounds",Xo),ur("useTabstopAt",T),ur("eventOrder",{}),nu("modalBehaviours",[Tp]),Si("onExecute"),Ci("onEscape")]),yB={sketch:x},xB=y([Bu({name:"draghandle",overrides:(e,t)=>({behaviours:gl([aB.config({mode:"mouse",getTarget:e=>oi(e,'[role="dialog"]').getOr(e),blockerClass:e.dragBlockClass.getOrDie(new Error("The drag blocker class was not specified for a dialog with a drag handle: \n"+JSON.stringify(t,null,2)).message),getBounds:e.getDragBounds})])})}),Au({schema:[Xn("dom")],name:"title"}),Au({factory:yB,schema:[Xn("dom")],name:"close"}),Au({factory:yB,schema:[Xn("dom")],name:"body"}),Bu({factory:yB,schema:[Xn("dom")],name:"footer"}),Du({factory:{sketch:(e,t)=>({...e,dom:t.dom,components:t.components})},schema:[ur("dom",{tag:"div",styles:{position:"fixed",left:"0px",top:"0px",right:"0px",bottom:"0px"}}),ur("components",[])],name:"blocker"})]),wB=sm({name:"ModalDialog",configFields:vB(),partFields:xB(),factory:(e,t,o,n)=>{const r=Ul(),s=Qs("modal-events"),a={...e.eventOrder,[ps()]:[s].concat(e.eventOrder["alloy.system.attached"]||[])};return{uid:e.uid,dom:e.dom,components:t,apis:{show:t=>{r.set(t);const o=e.lazySink(t).getOrDie(),s=n.blocker(),a=o.getSystem().build({...s,components:s.components.concat([Ya(t)]),behaviours:gl([Up.config({}),Vp("dialog-blocker-events",[Ls(Lr(),(()=>{Tp.focusIn(t)}))])])});vd(o,a),Tp.focusIn(t)},hide:e=>{r.clear(),et(e.element).each((t=>{e.getSystem().getByDom(t).each((e=>{wd(e)}))}))},getBody:t=>Gu(t,e,"body"),getFooter:t=>Gu(t,e,"footer"),setIdle:e=>{cE.unblock(e)},setBusy:(e,t)=>{cE.block(e,t)}},eventOrder:a,domModification:{attributes:{role:"dialog","aria-modal":"true"}},behaviours:su(e.modalBehaviours,[Np.config({}),Tp.config({mode:"cyclic",onEnter:e.onExecute,onEscape:e.onEscape,useTabstopAt:e.useTabstopAt}),cE.config({getRoot:r.get}),Vp(s,[Ps((t=>{((e,t)=>{const o=wt(e,"id").fold((()=>{const e=Qs("dialog-label");return vt(t,"id",e),e}),x);vt(e,"aria-labelledby",o)})(t.element,Gu(t,e,"title").element),((e,t)=>{const o=M.from(xt(e,"id")).fold((()=>{const e=Qs("dialog-describe");return vt(t,"id",e),e}),x);vt(e,"aria-describedby",o)})(t.element,Gu(t,e,"body").element)}))])])}},apis:{show:(e,t)=>{e.show(t)},hide:(e,t)=>{e.hide(t)},getBody:(e,t)=>e.getBody(t),getFooter:(e,t)=>e.getFooter(t),setBusy:(e,t,o)=>{e.setBusy(t,o)},setIdle:(e,t)=>{e.setIdle(t)}}}),SB=Cn([Nb,Vb].concat(Bv)),kB=Fn,CB=[cv("button"),Yb,hr("align","end",["start","end"]),rv,nv,ir("buttonType",["primary","secondary"])],OB=[...CB,zb],_B=[Zn("type",["submit","cancel","custom"]),...OB],TB=[Zn("type",["menu"]),Kb,Jb,Yb,or("items",SB),...CB],EB=jn("type",{submit:_B,cancel:_B,custom:_B,menu:TB}),MB=[Nb,zb,Zn("level",["info","warn","error","success"]),Pb,ur("url","")],AB=Cn(MB),DB=[Nb,zb,nv,cv("button"),Yb,ov,ir("buttonType",["primary","secondary","toolbar"]),rv],BB=Cn(DB),FB=[Nb,Vb],IB=FB.concat([Zb]),RB=FB.concat([Hb,nv]),NB=Cn(RB),VB=Fn,HB=IB.concat([sv("auto")]),zB=Cn(HB),LB=En([Ub,zb,Pb]),PB=IB.concat([pr("storageKey","default")]),UB=Cn(PB),WB=Bn,jB=Cn(IB),GB=Bn,$B=FB.concat([pr("tag","textarea"),Jn("scriptId"),Jn("scriptUrl"),mr("settings",void 0,Nn)]),qB=FB.concat([pr("tag","textarea"),Qn("init")]),XB=Hn((e=>Ln("customeditor.old",kn(qB),e).orThunk((()=>Ln("customeditor.new",kn($B),e))))),KB=Bn,YB=Cn(IB),JB=On(vn),ZB=e=>[Nb,Yn("columns"),e],QB=[Nb,Jn("html"),hr("presets","presentation",["presentation","document"])],eF=Cn(QB),tF=IB.concat([fr("sandboxed",!0),fr("transparent",!0)]),oF=Cn(tF),nF=Bn,rF=Cn(FB.concat([ar("height")])),sF=Cn([Jn("url"),sr("zoom"),sr("cachedWidth"),sr("cachedHeight")]),aF=IB.concat([ar("inputMode"),ar("placeholder"),fr("maximized",!1),nv]),iF=Cn(aF),lF=Bn,cF=e=>[Nb,Hb,e],dF=[zb,Ub],uF=[zb,or("items",((e,t)=>{const o=Xt(t);return{extract:(e,t)=>o().extract(e,t),toString:()=>o().toString()}})(0,(()=>mF)))],mF=_n([Cn(dF),Cn(uF)]),gF=IB.concat([or("items",mF),nv]),pF=Cn(gF),hF=Bn,fF=IB.concat([tr("items",[zb,Ub]),gr("size",1),nv]),bF=Cn(fF),vF=Bn,yF=IB.concat([fr("constrain",!0),nv]),xF=Cn(yF),wF=Cn([Jn("width"),Jn("height")]),SF=FB.concat([Hb,gr("min",0),gr("max",0)]),kF=Cn(SF),CF=Dn,OF=[Nb,or("header",Bn),or("cells",On(Bn))],_F=Cn(OF),TF=IB.concat([ar("placeholder"),fr("maximized",!1),nv]),EF=Cn(TF),MF=Bn,AF=IB.concat([hr("filetype","file",["image","media","file"]),nv]),DF=Cn(AF),BF=Cn([Ub,av]),FF=e=>Gn("items","items",{tag:"required",process:{}},On(Hn((t=>Ln(`Checking item of ${e}`,IF,t).fold((e=>Jo.error(Wn(e))),(e=>Jo.value(e))))))),IF=wn((()=>{return Vn("type",{alertbanner:AB,bar:Cn((e=FF("bar"),[Nb,e])),button:BB,checkbox:NB,colorinput:UB,colorpicker:jB,dropzone:YB,grid:Cn(ZB(FF("grid"))),iframe:oF,input:iF,listbox:pF,selectbox:bF,sizeinput:xF,slider:kF,textarea:EF,urlinput:DF,customeditor:XB,htmlpanel:eF,imagepreview:rF,collection:zB,label:Cn(cF(FF("label"))),table:_F,panel:NF});var e})),RF=[Nb,ur("classes",[]),or("items",IF)],NF=Cn(RF),VF=[cv("tab"),Lb,or("items",IF)],HF=[Nb,tr("tabs",VF)],zF=Cn(HF),LF=OB,PF=EB,UF=Cn([Jn("title"),Kn("body",Vn("type",{panel:NF,tabpanel:zF})),pr("size","normal"),or("buttons",PF),ur("initialData",{}),br("onAction",b),br("onChange",b),br("onSubmit",b),br("onClose",b),br("onCancel",b),br("onTabChange",b)]),WF=Cn([Zn("type",["cancel","custom"]),...LF]),jF=Cn([Jn("title"),Jn("url"),sr("height"),sr("width"),cr("buttons",WF),br("onAction",b),br("onCancel",b),br("onClose",b),br("onMessage",b)]),GF=e=>a(e)?[e].concat(X(fe(e),GF)):l(e)?X(e,GF):[],$F=e=>s(e.type)&&s(e.name),qF={checkbox:VB,colorinput:WB,colorpicker:GB,dropzone:JB,input:lF,iframe:nF,imagepreview:sF,selectbox:vF,sizeinput:wF,slider:CF,listbox:hF,size:wF,textarea:MF,urlinput:BF,customeditor:KB,collection:LB,togglemenuitem:kB},XF=e=>{const t=(e=>U(GF(e),$F))(e),o=X(t,(e=>(e=>M.from(qF[e.type]))(e).fold((()=>[]),(t=>[Kn(e.name,t)]))));return Cn(o)},KF=e=>{var t;return{internalDialog:Pn(Ln("dialog",UF,e)),dataValidator:XF(e),initialData:null!==(t=e.initialData)&&void 0!==t?t:{}}},YF={open:(e,t)=>{const o=KF(t);return e(o.internalDialog,o.initialData,o.dataValidator)},openUrl:(e,t)=>e(Pn(Ln("dialog",jF,t))),redial:e=>KF(e)},JF=e=>{const t=[],o={};return le(e,((e,n)=>{e.fold((()=>{t.push(n)}),(e=>{o[n]=e}))})),t.length>0?Jo.error(t):Jo.value(o)},ZF=(e,t,o)=>{const n=Ah(jk.sketch((n=>({dom:{tag:"div",classes:["tox-form"].concat(e.classes)},components:z(e.items,(e=>TO(n,e,t,o)))}))));return{dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[n.asSpec()]}],behaviours:gl([Tp.config({mode:"acyclic",useTabstopAt:k(hC)}),(r=n,cm.config({find:r.getOpt})),oC(n,{postprocess:e=>JF(e).fold((e=>(console.error(e),{})),x)})])};var r},QF=rm({name:"TabButton",configFields:[ur("uid",void 0),Xn("value"),Gn("dom","dom",gn((()=>({attributes:{role:"tab",id:Qs("aria"),"aria-selected":"false"}}))),Mn()),nr("action"),ur("domModification",{}),nu("tabButtonBehaviours",[Up,Tp,ou]),Xn("view")],factory:(e,t)=>({uid:e.uid,dom:e.dom,components:e.components,events:Zp(e.action),behaviours:su(e.tabButtonBehaviours,[Up.config({}),Tp.config({mode:"execution",useSpace:!0,useEnter:!0}),ou.config({store:{mode:"memory",initialValue:e.value}})]),domModification:e.domModification})}),eI=y([Xn("tabs"),Xn("dom"),ur("clickToDismiss",!1),nu("tabbarBehaviours",[Fm,Tp]),yi(["tabClass","selectedClass"])]),tI=Fu({factory:QF,name:"tabs",unit:"tab",overrides:e=>{const t=(e,t)=>{Fm.dehighlight(e,t),Os(e,ws(),{tabbar:e,button:t})},o=(e,t)=>{Fm.highlight(e,t),Os(e,xs(),{tabbar:e,button:t})};return{action:n=>{const r=n.getSystem().getByUid(e.uid).getOrDie(),s=Fm.isHighlighted(r,n);(s&&e.clickToDismiss?t:s?b:o)(r,n)},domModification:{classes:[e.markers.tabClass]}}}}),oI=y([tI]),nI=sm({name:"Tabbar",configFields:eI(),partFields:oI(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,components:t,"debug.sketcher":"Tabbar",domModification:{attributes:{role:"tablist"}},behaviours:su(e.tabbarBehaviours,[Fm.config({highlightClass:e.markers.selectedClass,itemClass:e.markers.tabClass,onHighlight:(e,t)=>{vt(t.element,"aria-selected","true")},onDehighlight:(e,t)=>{vt(t.element,"aria-selected","false")}}),Tp.config({mode:"flow",getInitial:e=>Fm.getHighlighted(e).map((e=>e.element)),selector:"."+e.markers.tabClass,executeOnMove:!0})])})}),rI=rm({name:"Tabview",configFields:[nu("tabviewBehaviours",[Np])],factory:(e,t)=>({uid:e.uid,dom:e.dom,behaviours:su(e.tabviewBehaviours,[Np.config({})]),domModification:{attributes:{role:"tabpanel"}}})}),sI=y([ur("selectFirst",!0),wi("onChangeTab"),wi("onDismissTab"),ur("tabs",[]),nu("tabSectionBehaviours",[])]),aI=Au({factory:nI,schema:[Xn("dom"),er("markers",[Xn("tabClass"),Xn("selectedClass")])],name:"tabbar",defaults:e=>({tabs:e.tabs})}),iI=Au({factory:rI,name:"tabview"}),lI=y([aI,iI]),cI=sm({name:"TabSection",configFields:sI(),partFields:lI(),factory:(e,t,o,n)=>{const r=(t,o)=>{ju(t,e,"tabbar").each((e=>{o(e).each(_s)}))};return{uid:e.uid,dom:e.dom,components:t,behaviours:ru(e.tabSectionBehaviours),events:As(q([e.selectFirst?[Ps(((e,t)=>{r(e,Fm.getFirst)}))]:[],[Fs(xs(),((t,o)=>{(t=>{const o=ou.getValue(t);ju(t,e,"tabview").each((n=>{G(e.tabs,(e=>e.value===o)).each((o=>{const r=o.view();wt(t.element,"id").each((e=>{vt(n.element,"aria-labelledby",e)})),Np.set(n,r),e.onChangeTab(n,t,r)}))}))})(o.event.button)})),Fs(ws(),((t,o)=>{const n=o.event.button;e.onDismissTab(t,n)}))]])),apis:{getViewItems:t=>ju(t,e,"tabview").map((e=>Np.contents(e))).getOr([]),showTab:(e,t)=>{r(e,(e=>{const o=Fm.getCandidates(e);return G(o,(e=>ou.getValue(e)===t)).filter((t=>!Fm.isHighlighted(e,t)))}))}}}},apis:{getViewItems:(e,t)=>e.getViewItems(t),showTab:(e,t,o)=>{e.showTab(t,o)}}}),dI=(e,t)=>{_t(e,"height",t+"px"),_t(e,"flex-basis",t+"px")},uI=(e,t,o)=>{oi(e,'[role="dialog"]').each((e=>{ri(e,'[role="tablist"]').each((n=>{o.get().map((o=>(_t(t,"height","0"),_t(t,"flex-basis","0"),Math.min(o,((e,t,o)=>{const n=Ze(e).dom,r=oi(e,".tox-dialog-wrap").getOr(e);let s;s="fixed"===Mt(r,"position")?Math.max(n.clientHeight,window.innerHeight):Math.max(n.offsetHeight,n.scrollHeight);const a=Ht(t),i=t.dom.offsetLeft>=o.dom.offsetLeft+$t(o)?Math.max(Ht(o),a):a,l=parseInt(Mt(e,"margin-top"),10)||0,c=parseInt(Mt(e,"margin-bottom"),10)||0;return s-(Ht(e)+l+c-i)})(e,t,n))))).each((e=>{dI(t,e)}))}))}))},mI=e=>ri(e,'[role="tabpanel"]'),gI="send-data-to-section",pI="send-data-to-view",hI=(e,t,o)=>{const n=xr({}),r=e=>{const t=ou.getValue(e),o=JF(t).getOr({}),r=n.get(),s=cn(r,o);n.set(s)},s=e=>{const t=n.get();ou.setValue(e,t)},a=xr(null),i=z(e.tabs,(e=>({value:e.name,dom:{tag:"div",classes:["tox-dialog__body-nav-item"]},components:[Ga(o.shared.providers.translate(e.title))],view:()=>[jk.sketch((n=>({dom:{tag:"div",classes:["tox-form"]},components:z(e.items,(e=>TO(n,e,t,o))),formBehaviours:gl([Tp.config({mode:"acyclic",useTabstopAt:k(hC)}),Vp("TabView.form.events",[Ps(s),Us(r)]),yl.config({channels:kr([{key:gI,value:{onReceive:r}},{key:pI,value:{onReceive:s}}])})])})))]}))),l=(e=>{const t=Ul(),o=[Ps((o=>{const n=o.element;mI(n).each((r=>{_t(r,"visibility","hidden"),o.getSystem().getByDom(r).toOptional().each((o=>{const n=((e,t,o)=>z(e,((n,r)=>{Np.set(o,e[r].view());const s=t.dom.getBoundingClientRect();return Np.set(o,[]),s.height})))(e,r,o),s=(e=>oe(ee(e,((e,t)=>e>t?-1:e<t?1:0))))(n);s.fold(t.clear,t.set)})),uI(n,r,t),It(r,"visibility"),((e,t)=>{oe(e).each((e=>cI.showTab(t,e.value)))})(e,o),requestAnimationFrame((()=>{uI(n,r,t)}))}))})),Fs(gs(),(e=>{const o=e.element;mI(o).each((e=>{uI(o,e,t)}))})),Fs(Ww,((e,o)=>{const n=e.element;mI(n).each((e=>{const o=kl(dt(e));_t(e,"visibility","hidden");const r=Dt(e,"height").map((e=>parseInt(e,10)));It(e,"height"),It(e,"flex-basis");const s=e.dom.getBoundingClientRect().height;r.forall((e=>s>e))?(t.set(s),uI(n,e,t)):r.each((t=>{dI(e,t)})),It(e,"visibility"),o.each(wl)}))}))];return{extraEvents:o,selectFirst:!1}})(i);return cI.sketch({dom:{tag:"div",classes:["tox-dialog__body"]},onChangeTab:(e,t,o)=>{const n=ou.getValue(t);Os(e,Uw,{name:n,oldName:a.get()}),a.set(n)},tabs:i,components:[cI.parts.tabbar({dom:{tag:"div",classes:["tox-dialog__body-nav"]},components:[nI.parts.tabs({})],markers:{tabClass:"tox-tab",selectedClass:"tox-dialog__body-nav-item--active"},tabbarBehaviours:gl([Mw.config({})])}),cI.parts.tabview({dom:{tag:"div",classes:["tox-dialog__body-content"]}})],selectFirst:l.selectFirst,tabSectionBehaviours:gl([Vp("tabpanel",l.extraEvents),Tp.config({mode:"acyclic"}),cm.config({find:e=>oe(cI.getViewItems(e))}),rC(M.none(),(e=>(e.getSystem().broadcastOn([gI],{}),n.get())),((e,t)=>{n.set(t),e.getSystem().broadcastOn([pI],{})}))])})},fI=Qs("update-dialog"),bI=Qs("update-title"),vI=Qs("update-body"),yI=Qs("update-footer"),xI=Qs("body-send-message"),wI=(e,t,o,n,r)=>({dom:{tag:"div",classes:["tox-dialog__content-js"],attributes:{...o.map((e=>({id:e}))).getOr({}),...r?{"aria-live":"polite"}:{}}},components:[],behaviours:gl([Zk(0),qM.config({channel:`${vI}-${t}`,updateState:(e,t)=>M.some({isTabPanel:()=>"tabpanel"===t.body.type}),renderComponents:e=>{const t=e.body;return"tabpanel"===t.type?[hI(t,e.initialData,n)]:[ZF(t,e.initialData,n)]},initialData:e})])});function SI(e){return SI="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},SI(e)}function kI(e,t){return kI=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},kI(e,t)}function CI(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function OI(e,t,o){return OI=CI()?Reflect.construct:function(e,t,o){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return o&&kI(r,o.prototype),r},OI.apply(null,arguments)}function _I(e){return function(e){if(Array.isArray(e))return TI(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return TI(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?TI(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function TI(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o<t;o++)n[o]=e[o];return n}var EI=Object.hasOwnProperty,MI=Object.setPrototypeOf,AI=Object.isFrozen,DI=Object.getPrototypeOf,BI=Object.getOwnPropertyDescriptor,FI=Object.freeze,II=Object.seal,RI=Object.create,NI="undefined"!=typeof Reflect&&Reflect,VI=NI.apply,HI=NI.construct;VI||(VI=function(e,t,o){return e.apply(t,o)}),FI||(FI=function(e){return e}),II||(II=function(e){return e}),HI||(HI=function(e,t){return OI(e,_I(t))});var zI,LI=YI(Array.prototype.forEach),PI=YI(Array.prototype.pop),UI=YI(Array.prototype.push),WI=YI(String.prototype.toLowerCase),jI=YI(String.prototype.match),GI=YI(String.prototype.replace),$I=YI(String.prototype.indexOf),qI=YI(String.prototype.trim),XI=YI(RegExp.prototype.test),KI=(zI=TypeError,function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return HI(zI,t)});function YI(e){return function(t){for(var o=arguments.length,n=new Array(o>1?o-1:0),r=1;r<o;r++)n[r-1]=arguments[r];return VI(e,t,n)}}function JI(e,t){MI&&MI(e,null);for(var o=t.length;o--;){var n=t[o];if("string"==typeof n){var r=WI(n);r!==n&&(AI(t)||(t[o]=r),n=r)}e[n]=!0}return e}function ZI(e){var t,o=RI(null);for(t in e)VI(EI,e,[t])&&(o[t]=e[t]);return o}function QI(e,t){for(;null!==e;){var o=BI(e,t);if(o){if(o.get)return YI(o.get);if("function"==typeof o.value)return YI(o.value)}e=DI(e)}return function(e){return console.warn("fallback value for",e),null}}var eR=FI(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),tR=FI(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),oR=FI(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),nR=FI(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),rR=FI(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),sR=FI(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),aR=FI(["#text"]),iR=FI(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),lR=FI(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),cR=FI(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),dR=FI(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),uR=II(/\{\{[\w\W]*|[\w\W]*\}\}/gm),mR=II(/<%[\w\W]*|[\w\W]*%>/gm),gR=II(/^data-[\-\w.\u00B7-\uFFFF]/),pR=II(/^aria-[\-\w]+$/),hR=II(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),fR=II(/^(?:\w+script|data):/i),bR=II(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),vR=II(/^html$/i),yR=function(){return"undefined"==typeof window?null:window},xR=function(e,t){if("object"!==SI(e)||"function"!=typeof e.createPolicy)return null;var o=null,n="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(n)&&(o=t.currentScript.getAttribute(n));var r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},wR=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yR(),o=function(t){return e(t)};if(o.version="2.3.8",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;var n=t.document,r=t.document,s=t.DocumentFragment,a=t.HTMLTemplateElement,i=t.Node,l=t.Element,c=t.NodeFilter,d=t.NamedNodeMap,u=void 0===d?t.NamedNodeMap||t.MozNamedAttrMap:d,m=t.HTMLFormElement,g=t.DOMParser,p=t.trustedTypes,h=l.prototype,f=QI(h,"cloneNode"),b=QI(h,"nextSibling"),v=QI(h,"childNodes"),y=QI(h,"parentNode");if("function"==typeof a){var x=r.createElement("template");x.content&&x.content.ownerDocument&&(r=x.content.ownerDocument)}var w=xR(p,n),S=w?w.createHTML(""):"",k=r,C=k.implementation,O=k.createNodeIterator,_=k.createDocumentFragment,T=k.getElementsByTagName,E=n.importNode,M={};try{M=ZI(r).documentMode?r.documentMode:{}}catch(e){}var A={};o.isSupported="function"==typeof y&&C&&void 0!==C.createHTMLDocument&&9!==M;var D,B,F=uR,I=mR,R=gR,N=pR,V=fR,H=bR,z=hR,L=null,P=JI({},[].concat(_I(eR),_I(tR),_I(oR),_I(rR),_I(aR))),U=null,W=JI({},[].concat(_I(iR),_I(lR),_I(cR),_I(dR))),j=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),G=null,$=null,q=!0,X=!0,K=!1,Y=!1,J=!1,Z=!1,Q=!1,ee=!1,te=!1,oe=!1,ne=!0,re=!0,se=!1,ae={},ie=null,le=JI({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ce=null,de=JI({},["audio","video","img","source","image","track"]),ue=null,me=JI({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ge="http://www.w3.org/1998/Math/MathML",pe="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml",fe=he,be=!1,ve=["application/xhtml+xml","text/html"],ye="text/html",xe=null,we=r.createElement("form"),Se=function(e){return e instanceof RegExp||e instanceof Function},ke=function(e){xe&&xe===e||(e&&"object"===SI(e)||(e={}),e=ZI(e),L="ALLOWED_TAGS"in e?JI({},e.ALLOWED_TAGS):P,U="ALLOWED_ATTR"in e?JI({},e.ALLOWED_ATTR):W,ue="ADD_URI_SAFE_ATTR"in e?JI(ZI(me),e.ADD_URI_SAFE_ATTR):me,ce="ADD_DATA_URI_TAGS"in e?JI(ZI(de),e.ADD_DATA_URI_TAGS):de,ie="FORBID_CONTENTS"in e?JI({},e.FORBID_CONTENTS):le,G="FORBID_TAGS"in e?JI({},e.FORBID_TAGS):{},$="FORBID_ATTR"in e?JI({},e.FORBID_ATTR):{},ae="USE_PROFILES"in e&&e.USE_PROFILES,q=!1!==e.ALLOW_ARIA_ATTR,X=!1!==e.ALLOW_DATA_ATTR,K=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Y=e.SAFE_FOR_TEMPLATES||!1,J=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,oe=e.RETURN_TRUSTED_TYPE||!1,Q=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=!1!==e.KEEP_CONTENT,se=e.IN_PLACE||!1,z=e.ALLOWED_URI_REGEXP||z,fe=e.NAMESPACE||he,e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Se(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(j.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),D=D=-1===ve.indexOf(e.PARSER_MEDIA_TYPE)?ye:e.PARSER_MEDIA_TYPE,B="application/xhtml+xml"===D?function(e){return e}:WI,Y&&(X=!1),te&&(ee=!0),ae&&(L=JI({},_I(aR)),U=[],!0===ae.html&&(JI(L,eR),JI(U,iR)),!0===ae.svg&&(JI(L,tR),JI(U,lR),JI(U,dR)),!0===ae.svgFilters&&(JI(L,oR),JI(U,lR),JI(U,dR)),!0===ae.mathMl&&(JI(L,rR),JI(U,cR),JI(U,dR))),e.ADD_TAGS&&(L===P&&(L=ZI(L)),JI(L,e.ADD_TAGS)),e.ADD_ATTR&&(U===W&&(U=ZI(U)),JI(U,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&JI(ue,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(ie===le&&(ie=ZI(ie)),JI(ie,e.FORBID_CONTENTS)),re&&(L["#text"]=!0),J&&JI(L,["html","head","body"]),L.table&&(JI(L,["tbody"]),delete G.tbody),FI&&FI(e),xe=e)},Ce=JI({},["mi","mo","mn","ms","mtext"]),Oe=JI({},["foreignobject","desc","title","annotation-xml"]),_e=JI({},["title","style","font","a","script"]),Te=JI({},tR);JI(Te,oR),JI(Te,nR);var Ee=JI({},rR);JI(Ee,sR);var Me=function(e){var t=y(e);t&&t.tagName||(t={namespaceURI:he,tagName:"template"});var o=WI(e.tagName),n=WI(t.tagName);return e.namespaceURI===pe?t.namespaceURI===he?"svg"===o:t.namespaceURI===ge?"svg"===o&&("annotation-xml"===n||Ce[n]):Boolean(Te[o]):e.namespaceURI===ge?t.namespaceURI===he?"math"===o:t.namespaceURI===pe?"math"===o&&Oe[n]:Boolean(Ee[o]):e.namespaceURI===he&&!(t.namespaceURI===pe&&!Oe[n])&&!(t.namespaceURI===ge&&!Ce[n])&&!Ee[o]&&(_e[o]||!Te[o])},Ae=function(e){UI(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=S}catch(t){e.remove()}}},De=function(e,t){try{UI(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){UI(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!U[e])if(ee||te)try{Ae(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Be=function(e){var t,o;if(Q)e="<remove></remove>"+e;else{var n=jI(e,/^[\r\n\t ]+/);o=n&&n[0]}"application/xhtml+xml"===D&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var s=w?w.createHTML(e):e;if(fe===he)try{t=(new g).parseFromString(s,D)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(fe,"template",null);try{t.documentElement.innerHTML=be?"":s}catch(e){}}var a=t.body||t.documentElement;return e&&o&&a.insertBefore(r.createTextNode(o),a.childNodes[0]||null),fe===he?T.call(t,J?"html":"body")[0]:J?t.documentElement:a},Fe=function(e){return O.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT,null,!1)},Ie=function(e){return e instanceof m&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},Re=function(e){return"object"===SI(i)?e instanceof i:e&&"object"===SI(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Ne=function(e,t,n){A[e]&&LI(A[e],(function(e){e.call(o,t,n,xe)}))},Ve=function(e){var t;if(Ne("beforeSanitizeElements",e,null),Ie(e))return Ae(e),!0;if(XI(/[\u0080-\uFFFF]/,e.nodeName))return Ae(e),!0;var n=B(e.nodeName);if(Ne("uponSanitizeElement",e,{tagName:n,allowedTags:L}),e.hasChildNodes()&&!Re(e.firstElementChild)&&(!Re(e.content)||!Re(e.content.firstElementChild))&&XI(/<[/\w]/g,e.innerHTML)&&XI(/<[/\w]/g,e.textContent))return Ae(e),!0;if("select"===n&&XI(/<template/i,e.innerHTML))return Ae(e),!0;if(!L[n]||G[n]){if(!G[n]&&ze(n)){if(j.tagNameCheck instanceof RegExp&&XI(j.tagNameCheck,n))return!1;if(j.tagNameCheck instanceof Function&&j.tagNameCheck(n))return!1}if(re&&!ie[n]){var r=y(e)||e.parentNode,s=v(e)||e.childNodes;if(s&&r)for(var a=s.length-1;a>=0;--a)r.insertBefore(f(s[a],!0),b(e))}return Ae(e),!0}return e instanceof l&&!Me(e)?(Ae(e),!0):"noscript"!==n&&"noembed"!==n||!XI(/<\/no(script|embed)/i,e.innerHTML)?(Y&&3===e.nodeType&&(t=e.textContent,t=GI(t,F," "),t=GI(t,I," "),e.textContent!==t&&(UI(o.removed,{element:e.cloneNode()}),e.textContent=t)),Ne("afterSanitizeElements",e,null),!1):(Ae(e),!0)},He=function(e,t,o){if(ne&&("id"===t||"name"===t)&&(o in r||o in we))return!1;if(X&&!$[t]&&XI(R,t));else if(q&&XI(N,t));else if(!U[t]||$[t]){if(!(ze(e)&&(j.tagNameCheck instanceof RegExp&&XI(j.tagNameCheck,e)||j.tagNameCheck instanceof Function&&j.tagNameCheck(e))&&(j.attributeNameCheck instanceof RegExp&&XI(j.attributeNameCheck,t)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(t))||"is"===t&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&XI(j.tagNameCheck,o)||j.tagNameCheck instanceof Function&&j.tagNameCheck(o))))return!1}else if(ue[t]);else if(XI(z,GI(o,H,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==$I(o,"data:")||!ce[e])if(K&&!XI(V,GI(o,H,"")));else if(o)return!1;return!0},ze=function(e){return e.indexOf("-")>0},Le=function(e){var t,o,n,r;Ne("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:U};for(r=s.length;r--;){var i=t=s[r],l=i.name,c=i.namespaceURI;o="value"===l?t.value:qI(t.value),n=B(l);var d=o;if(a.attrName=n,a.attrValue=o,a.keepAttr=!0,a.forceKeepAttr=void 0,Ne("uponSanitizeAttribute",e,a),o=a.attrValue,!a.forceKeepAttr)if(a.keepAttr)if(XI(/\/>/i,o))De(l,e);else{Y&&(o=GI(o,F," "),o=GI(o,I," "));var u=B(e.nodeName);if(He(u,n,o)){if(o!==d)try{c?e.setAttributeNS(c,l,o):e.setAttribute(l,o)}catch(t){De(l,e)}}else De(l,e)}else De(l,e)}Ne("afterSanitizeAttributes",e,null)}},Pe=function e(t){var o,n=Fe(t);for(Ne("beforeSanitizeShadowDOM",t,null);o=n.nextNode();)Ne("uponSanitizeShadowNode",o,null),Ve(o)||(o.content instanceof s&&e(o.content),Le(o));Ne("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e,r){var a,l,c,d,u;if((be=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Re(e)){if("function"!=typeof e.toString)throw KI("toString is not a function");if("string"!=typeof(e=e.toString()))throw KI("dirty is not a string, aborting")}if(!o.isSupported){if("object"===SI(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Re(e))return t.toStaticHTML(e.outerHTML)}return e}if(Z||ke(r),o.removed=[],"string"==typeof e&&(se=!1),se){if(e.nodeName){var m=B(e.nodeName);if(!L[m]||G[m])throw KI("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof i)1===(l=(a=Be("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?a=l:a.appendChild(l);else{if(!ee&&!Y&&!J&&-1===e.indexOf("<"))return w&&oe?w.createHTML(e):e;if(!(a=Be(e)))return ee?null:oe?S:""}a&&Q&&Ae(a.firstChild);for(var g=Fe(se?e:a);c=g.nextNode();)3===c.nodeType&&c===d||Ve(c)||(c.content instanceof s&&Pe(c.content),Le(c),d=c);if(d=null,se)return e;if(ee){if(te)for(u=_.call(a.ownerDocument);a.firstChild;)u.appendChild(a.firstChild);else u=a;return U.shadowroot&&(u=E.call(n,u,!0)),u}var p=J?a.outerHTML:a.innerHTML;return J&&L["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&XI(vR,a.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+p),Y&&(p=GI(p,F," "),p=GI(p,I," ")),w&&oe?w.createHTML(p):p},o.setConfig=function(e){ke(e),Z=!0},o.clearConfig=function(){xe=null,Z=!1},o.isValidAttribute=function(e,t,o){xe||ke({});var n=B(e),r=B(t);return He(n,r,o)},o.addHook=function(e,t){"function"==typeof t&&(A[e]=A[e]||[],UI(A[e],t))},o.removeHook=function(e){if(A[e])return PI(A[e])},o.removeHooks=function(e){A[e]&&(A[e]=[])},o.removeAllHooks=function(){A={}},o}();const SR=e=>wR().sanitize(e),kR=qh.deviceType.isTouch(),CR=(e,t)=>({dom:{tag:"div",styles:{display:"none"},classes:["tox-dialog__header"]},components:[e,t]}),OR=(e,t)=>wB.parts.close(Mh.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":t.translate("Close")}},action:e,buttonBehaviours:gl([Mw.config({})])})),_R=()=>wB.parts.title({dom:{tag:"div",classes:["tox-dialog__title"],innerHtml:"",styles:{display:"none"}}}),TR=(e,t)=>wB.parts.body({dom:{tag:"div",classes:["tox-dialog__body"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-content"]},components:[{dom:dE(`<p>${SR(t.translate(e))}</p>`)}]}]}),ER=e=>wB.parts.footer({dom:{tag:"div",classes:["tox-dialog__footer"]},components:e}),MR=(e,t)=>[Sw.sketch({dom:{tag:"div",classes:["tox-dialog__footer-start"]},components:e}),Sw.sketch({dom:{tag:"div",classes:["tox-dialog__footer-end"]},components:t})],AR=e=>{const t="tox-dialog",o=t+"-wrap",n=o+"__backdrop",r=t+"__disable-scroll";return wB.sketch({lazySink:e.lazySink,onEscape:t=>(e.onEscape(t),M.some(!0)),useTabstopAt:e=>!hC(e),dom:{tag:"div",classes:[t].concat(e.extraClasses),styles:{position:"relative",...e.extraStyles}},components:[e.header,e.body,...e.footer.toArray()],parts:{blocker:{dom:dE(`<div class="${o}"></div>`),components:[{dom:{tag:"div",classes:kR?[n,n+"--opaque"]:[n]}}]}},dragBlockClass:o,modalBehaviours:gl([Up.config({}),Vp("dialog-events",e.dialogEvents.concat([Ls(Lr(),((e,t)=>{Tp.focusIn(e)}))])),Vp("scroll-lock",[Ps((()=>{Da(ht(),r)})),Us((()=>{Ba(ht(),r)}))]),...e.extraBehaviours]),eventOrder:{[ns()]:["dialog-events"],[ps()]:["scroll-lock","dialog-events","alloy.base.behaviour"],[hs()]:["alloy.base.behaviour","dialog-events","scroll-lock"],...e.eventOrder}})},DR=e=>Mh.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":e.translate("Close"),title:e.translate("Close")}},components:[Lh("close",{tag:"div",classes:["tox-icon"]},e.icons)],action:e=>{Cs(e,Vw)}}),BR=(e,t,o,n)=>({dom:{tag:"div",classes:["tox-dialog__title"],attributes:{...o.map((e=>({id:e}))).getOr({})}},components:[],behaviours:gl([qM.config({channel:`${bI}-${t}`,initialData:e,renderComponents:e=>[Ga(n.translate(e.title))]})])}),FR=()=>({dom:dE('<div class="tox-dialog__draghandle"></div>')}),IR=(e,t,o)=>((e,t,o)=>{const n=wB.parts.title(BR(e,t,M.none(),o)),r=wB.parts.draghandle(FR()),s=wB.parts.close(DR(o)),a=[n].concat(e.draggable?[r]:[]).concat([s]);return Sw.sketch({dom:dE('<div class="tox-dialog__header"></div>'),components:a})})({title:o.shared.providers.translate(e),draggable:o.dialog.isDraggableModal()},t,o.shared.providers),RR=(e,t,o)=>({dom:{tag:"div",classes:["tox-dialog__busy-spinner"],attributes:{"aria-label":o.translate(e)},styles:{left:"0px",right:"0px",bottom:"0px",top:"0px",position:"absolute"}},behaviours:t,components:[{dom:dE('<div class="tox-spinner"><div></div><div></div><div></div></div>')}]}),NR=(e,t,o)=>({onClose:()=>o.closeWindow(),onBlock:o=>{wB.setBusy(e(),((e,n)=>RR(o.message,n,t)))},onUnblock:()=>{wB.setIdle(e())}}),VR=(e,t,o,n)=>Ka(AR({...e,lazySink:n.shared.getSink,extraBehaviours:[qM.config({channel:`${fI}-${e.id}`,updateState:(e,t)=>M.some(t),initialData:t}),sC({}),...e.extraBehaviours],onEscape:e=>{Cs(e,Vw)},dialogEvents:o,eventOrder:{[os()]:[qM.name(),yl.name()],[ps()]:["scroll-lock",qM.name(),"messages","dialog-events","alloy.base.behaviour"],[hs()]:["alloy.base.behaviour","dialog-events","messages",qM.name(),"scroll-lock"]}})),HR=e=>z(e,(e=>"menu"===e.type?(e=>{const t=z(e.items,(e=>({...e,storage:xr(!1)})));return{...e,items:t}})(e):e)),zR=e=>j(e,((e,t)=>"menu"===t.type?j(t.items,((e,t)=>(e[t.name]=t.storage,e)),e):e),{}),LR=(e,t)=>[Vs(Lr(),pC),e(Nw,((e,o)=>{t.onClose(),o.onClose()})),e(Vw,((e,t,o,n)=>{t.onCancel(e),Cs(n,Nw)})),Fs(Pw,((e,o)=>t.onUnblock())),Fs(Lw,((e,o)=>t.onBlock(o.event)))],PR=(e,t,o)=>{const n=(t,o)=>Fs(t,((t,n)=>{r(t,((r,s)=>{o(e(),r,n.event,t)}))})),r=(e,t)=>{qM.getState(e).get().each((o=>{t(o.internalDialog,e)}))};return[...LR(n,t),n(zw,((e,t)=>t.onSubmit(e))),n(Rw,((e,t,o)=>{t.onChange(e,{name:o.name})})),n(Hw,((e,t,n,r)=>{const s=()=>Tp.focusIn(r),a=e=>St(e,"disabled")||wt(e,"aria-disabled").exists((e=>"true"===e)),i=dt(r.element),l=kl(i);t.onAction(e,{name:n.name,value:n.value}),kl(i).fold(s,(e=>{a(e)||l.exists((t=>Ke(e,t)&&a(t)))?s():o().toOptional().filter((t=>!Ke(t.element,e))).each(s)}))})),n(Uw,((e,t,o)=>{t.onTabChange(e,{newTabName:o.name,oldTabName:o.oldName})})),Us((t=>{const o=e();ou.setValue(t,o.getData())}))]},UR=(e,t)=>{const o=t.map((e=>e.footerButtons)).getOr([]),n=P(o,(e=>"start"===e.align)),r=(e,t)=>Sw.sketch({dom:{tag:"div",classes:[`tox-dialog__footer-${e}`]},components:z(t,(e=>e.memento.asSpec()))});return[r("start",n.pass),r("end",n.fail)]},WR=(e,t,o)=>({dom:dE('<div class="tox-dialog__footer"></div>'),components:[],behaviours:gl([qM.config({channel:`${yI}-${t}`,initialData:e,updateState:(e,t)=>{const n=z(t.buttons,(e=>{const t=Ah(((e,t)=>uO(e,e.type,t))(e,o));return{name:e.name,align:e.align,memento:t}}));return M.some({lookupByName:t=>((e,t,o)=>G(t,(e=>e.name===o)).bind((t=>t.memento.getOpt(e))))(e,n,t),footerButtons:n})},renderComponents:UR})])}),jR=(e,t,o)=>wB.parts.footer(WR(e,t,o)),GR=(e,t)=>{if(e.getRoot().getSystem().isConnected()){const o=cm.getCurrent(e.getFormWrapper()).getOr(e.getFormWrapper());return jk.getField(o,t).orThunk((()=>{const o=e.getFooter();return qM.getState(o).get().bind((e=>e.lookupByName(t)))}))}return M.none()},$R=(e,t,o)=>{const n=t=>{const o=e.getRoot();o.getSystem().isConnected()&&t(o)},r={getData:()=>{const t=e.getRoot(),n=t.getSystem().isConnected()?e.getFormWrapper():t;return{...ou.getValue(n),...ce(o,(e=>e.get()))}},setData:t=>{n((n=>{const s=r.getData(),a=cn(s,t),i=((e,t)=>{const o=e.getRoot();return qM.getState(o).get().map((e=>Pn(Ln("data",e.dataValidator,t)))).getOr(t)})(e,a),l=e.getFormWrapper();ou.setValue(l,i),le(o,((e,t)=>{ve(a,t)&&e.set(a[t])}))}))},setEnabled:(t,o)=>{GR(e,t).each(o?km.enable:km.disable)},focus:t=>{GR(e,t).each(Up.focus)},block:e=>{if(!s(e))throw new Error("The dialogInstanceAPI.block function should be passed a blocking message of type string as an argument");n((t=>{Os(t,Lw,{message:e})}))},unblock:()=>{n((e=>{Cs(e,Pw)}))},showTab:t=>{n((o=>{const n=e.getBody();qM.getState(n).get().exists((e=>e.isTabPanel()))&&cm.getCurrent(n).each((e=>{cI.showTab(e,t)}))}))},redial:o=>{n((n=>{const s=e.getId(),a=t(o);n.getSystem().broadcastOn([`${fI}-${s}`],a),n.getSystem().broadcastOn([`${bI}-${s}`],a.internalDialog),n.getSystem().broadcastOn([`${vI}-${s}`],a.internalDialog),n.getSystem().broadcastOn([`${yI}-${s}`],a.internalDialog),r.setData(a.initialData)}))},close:()=>{n((e=>{Cs(e,Nw)}))}};return r};var qR=tinymce.util.Tools.resolve("tinymce.util.URI");const XR=["insertContent","setContent","execCommand","close","block","unblock"],KR=e=>a(e)&&-1!==XR.indexOf(e.mceAction),YR=(e,t,o,n)=>{const r=Qs("dialog"),i=IR(e.title,r,n),l=(e=>{const t={dom:{tag:"div",classes:["tox-dialog__content-js"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-iframe"]},components:[mC({dom:{tag:"iframe",attributes:{src:e.url}},behaviours:gl([Mw.config({}),Up.config({})])})]}],behaviours:gl([Tp.config({mode:"acyclic",useTabstopAt:k(hC)})])};return wB.parts.body(t)})(e),c=e.buttons.bind((e=>0===e.length?M.none():M.some(jR({buttons:e},r,n)))),u=((e,t)=>{const o=(t,o)=>Fs(t,((t,r)=>{n(t,((n,s)=>{o(e(),n,r.event,t)}))})),n=(e,t)=>{qM.getState(e).get().each((o=>{t(o,e)}))};return[...LR(o,t),o(Hw,((e,t,o)=>{t.onAction(e,{name:o.name})}))]})((()=>x),NR((()=>y),n.shared.providers,t)),m={...e.height.fold((()=>({})),(e=>({height:e+"px","max-height":e+"px"}))),...e.width.fold((()=>({})),(e=>({width:e+"px","max-width":e+"px"})))},p=e.width.isNone()&&e.height.isNone()?["tox-dialog--width-lg"]:[],h=new qR(e.url,{base_uri:new qR(window.location.href)}),f=`${h.protocol}://${h.host}${h.port?":"+h.port:""}`,b=Pl(),v=[Vp("messages",[Ps((()=>{const t=jl(Ie(window),"message",(t=>{if(h.isSameOrigin(new qR(t.raw.origin))){const n=t.raw.data;KR(n)?((e,t,o)=>{switch(o.mceAction){case"insertContent":e.insertContent(o.content);break;case"setContent":e.setContent(o.content);break;case"execCommand":const n=!!d(o.ui)&&o.ui;e.execCommand(o.cmd,n,o.value);break;case"close":t.close();break;case"block":t.block(o.message);break;case"unblock":t.unblock()}})(o,x,n):(e=>!KR(e)&&a(e)&&ve(e,"mceAction"))(n)&&e.onMessage(x,n)}}));b.set(t)})),Us(b.clear)]),yl.config({channels:{[xI]:{onReceive:(e,t)=>{ri(e.element,"iframe").each((e=>{const o=e.dom.contentWindow;g(o)&&o.postMessage(t,f)}))}}}})],y=VR({id:r,header:i,body:l,footer:c,extraClasses:p,extraBehaviours:v,extraStyles:m},e,u,n),x=(e=>{const t=t=>{e.getSystem().isConnected()&&t(e)};return{block:e=>{if(!s(e))throw new Error("The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument");t((t=>{Os(t,Lw,{message:e})}))},unblock:()=>{t((e=>{Cs(e,Pw)}))},close:()=>{t((e=>{Cs(e,Nw)}))},sendMessage:e=>{t((t=>{t.getSystem().broadcastOn([xI],e)}))}}})(y);return{dialog:y,instanceApi:x}},JR=(e,t,o)=>t&&o?[]:[hT.config({contextual:{lazyContext:()=>M.some($o(Ie(e.getContentAreaContainer()))),fadeInClass:"tox-dialog-dock-fadein",fadeOutClass:"tox-dialog-dock-fadeout",transitionClass:"tox-dialog-dock-transition"},modes:["top"]})],ZR=e=>{const t=e.editor,o=Gf(t),n=(e=>{const t=e.shared;return{open:(o,n)=>{const r=()=>{wB.hide(l),n()},s=Ah(uO({name:"close-alert",text:"OK",primary:!0,buttonType:M.some("primary"),align:"end",enabled:!0,icon:M.none()},"cancel",e)),a=_R(),i=OR(r,t.providers),l=Ka(AR({lazySink:()=>t.getSink(),header:CR(a,i),body:TR(o,t.providers),footer:M.some(ER(MR([],[s.asSpec()]))),onEscape:r,extraClasses:["tox-alert-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Fs(Vw,r)],eventOrder:{}}));wB.show(l);const c=s.get(l);Up.focus(c)}}})(e.backstages.dialog),r=(e=>{const t=e.shared;return{open:(o,n)=>{const r=e=>{wB.hide(c),n(e)},s=Ah(uO({name:"yes",text:"Yes",primary:!0,buttonType:M.some("primary"),align:"end",enabled:!0,icon:M.none()},"submit",e)),a=uO({name:"no",text:"No",primary:!1,buttonType:M.some("secondary"),align:"end",enabled:!0,icon:M.none()},"cancel",e),i=_R(),l=OR((()=>r(!1)),t.providers),c=Ka(AR({lazySink:()=>t.getSink(),header:CR(i,l),body:TR(o,t.providers),footer:M.some(ER(MR([],[a,s.asSpec()]))),onEscape:()=>r(!1),extraClasses:["tox-confirm-dialog"],extraBehaviours:[],extraStyles:{},dialogEvents:[Fs(Vw,(()=>r(!1))),Fs(zw,(()=>r(!0)))],eventOrder:{}}));wB.show(c);const d=s.get(c);Up.focus(d)}}})(e.backstages.dialog),s=(t,o)=>YF.open(((t,n,r)=>{const s=n,a=((e,t,o)=>{const n=Qs("dialog"),r=e.internalDialog,s=IR(r.title,n,o),a=((e,t,o)=>{const n=wI(e,t,M.none(),o,!1);return wB.parts.body(n)})({body:r.body,initialData:r.initialData},n,o),i=HR(r.buttons),l=zR(i),c=jR({buttons:i},n,o),d=PR((()=>h),NR((()=>g),o.shared.providers,t),o.shared.getSink),u=(e=>{switch(e){case"large":return["tox-dialog--width-lg"];case"medium":return["tox-dialog--width-md"];default:return[]}})(r.size),m={id:n,header:s,body:a,footer:M.some(c),extraClasses:u,extraBehaviours:[],extraStyles:{}},g=VR(m,e,d,o),p={getId:y(n),getRoot:y(g),getBody:()=>wB.getBody(g),getFooter:()=>wB.getFooter(g),getFormWrapper:()=>{const e=wB.getBody(g);return cm.getCurrent(e).getOr(e)}},h=$R(p,t.redial,l);return{dialog:g,instanceApi:h}})({dataValidator:r,initialData:s,internalDialog:t},{redial:YF.redial,closeWindow:()=>{wB.hide(a.dialog),o(a.instanceApi)}},e.backstages.dialog);return wB.show(a.dialog),a.instanceApi.setData(s),a.instanceApi}),t),a=(n,r,s,a=!1)=>YF.open(((n,i,l)=>{const c=Pn(Ln("data",l,i)),d=Ul(),u=e.backstages.popup.shared.header.isPositionedAtTop(),m=()=>d.on((e=>{Th.reposition(e),hT.refresh(e)})),g=((e,t,o,n)=>{const r=Qs("dialog"),s=Qs("dialog-label"),a=Qs("dialog-content"),i=e.internalDialog,l=Ah(((e,t,o,n)=>Sw.sketch({dom:dE('<div class="tox-dialog__header"></div>'),components:[BR(e,t,M.some(o),n),FR(),DR(n)],containerBehaviours:gl([aB.config({mode:"mouse",blockerClass:"blocker",getTarget:e=>si(e,'[role="dialog"]').getOrDie(),snaps:{getSnapPoints:()=>[],leftAttr:"data-drag-left",topAttr:"data-drag-top"}})])}))({title:i.title,draggable:!0},r,s,o.shared.providers)),c=Ah(((e,t,o,n,r)=>wI(e,t,M.some(o),n,r))({body:i.body,initialData:i.initialData},r,a,o,n)),d=HR(i.buttons),u=zR(d),m=Ah(((e,t,o)=>WR(e,t,o))({buttons:d},r,o)),g=PR((()=>h),{onBlock:e=>{cE.block(p,((t,n)=>RR(e.message,n,o.shared.providers)))},onUnblock:()=>{cE.unblock(p)},onClose:()=>t.closeWindow()},o.shared.getSink),p=Ka({dom:{tag:"div",classes:["tox-dialog","tox-dialog-inline"],attributes:{role:"dialog","aria-labelledby":s,"aria-describedby":a}},eventOrder:{[os()]:[qM.name(),yl.name()],[ns()]:["execute-on-form"],[ps()]:["reflecting","execute-on-form"]},behaviours:gl([Tp.config({mode:"cyclic",onEscape:e=>(Cs(e,Nw),M.some(!0)),useTabstopAt:e=>!hC(e)&&("button"!==ze(e)||"disabled"!==xt(e,"disabled"))}),qM.config({channel:`${fI}-${r}`,updateState:(e,t)=>M.some(t),initialData:e}),Up.config({}),Vp("execute-on-form",g.concat([Ls(Lr(),((e,t)=>{Tp.focusIn(e)}))])),cE.config({getRoot:()=>M.some(p)}),Np.config({}),sC({})]),components:[l.asSpec(),c.asSpec(),m.asSpec()]}),h=$R({getId:y(r),getRoot:y(p),getFooter:()=>m.get(p),getBody:()=>c.get(p),getFormWrapper:()=>{const e=c.get(p);return cm.getCurrent(e).getOr(e)}},t.redial,u);return{dialog:p,instanceApi:h}})({dataValidator:l,initialData:c,internalDialog:n},{redial:YF.redial,closeWindow:()=>{d.on(Th.hide),t.off("ResizeEditor",m),d.clear(),s(g.instanceApi)}},e.backstages.popup,a),p=Ka(Th.sketch({lazySink:e.backstages.popup.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:{},...u?{}:{fireRepositionEventInstead:{}},inlineBehaviours:gl([Vp("window-manager-inline-events",[Fs(fs(),((e,t)=>{Cs(g.dialog,Vw)}))]),...JR(t,o,u)]),isExtraPart:(e,t)=>(e=>mw(e,".tox-alert-dialog")||mw(e,".tox-confirm-dialog"))(t)}));return d.set(p),Th.showWithin(p,Ya(g.dialog),{anchor:r},M.some(ht())),o&&u||(hT.refresh(p),t.on("ResizeEditor",m)),g.instanceApi.setData(c),Tp.focusIn(g.dialog),g.instanceApi}),n);return{open:(t,o,n)=>void 0!==o&&"toolbar"===o.inline?a(t,e.backstages.popup.shared.anchors.inlineDialog(),n,o.ariaAttrs):void 0!==o&&"cursor"===o.inline?a(t,e.backstages.popup.shared.anchors.cursor(),n,o.ariaAttrs):s(t,n),openUrl:(o,n)=>((o,n)=>YF.openUrl((o=>{const r=YR(o,{closeWindow:()=>{wB.hide(r.dialog),n(r.instanceApi)}},t,e.backstages.dialog);return wB.show(r.dialog),r.instanceApi}),o))(o,n),alert:(e,t)=>{n.open(e,t)},close:e=>{e.close()},confirm:(e,t)=>{r.open(e,t)}}};E.add("silver",(e=>{(e=>{Yh(e),(e=>{const t=e.options.register,o=e=>f(e,s)?{value:ax(e),valid:!0}:{valid:!1,message:"Must be an array of strings."};t("color_map",{processor:o,default:["#BFEDD2","Light Green","#FBEEB8","Light Yellow","#F8CAC6","Light Red","#ECCAFA","Light Purple","#C2E0F4","Light Blue","#2DC26B","Green","#F1C40F","Yellow","#E03E2D","Red","#B96AD9","Purple","#3598DB","Blue","#169179","Dark Turquoise","#E67E23","Orange","#BA372A","Dark Red","#843FA1","Dark Purple","#236FA1","Dark Blue","#ECF0F1","Light Gray","#CED4D9","Medium Gray","#95A5A6","Gray","#7E8C8D","Dark Gray","#34495E","Navy Blue","#000000","Black","#ffffff","White"]}),t("color_map_background",{processor:o}),t("color_map_foreground",{processor:o}),t("color_cols",{processor:"number",default:sx(ux(e,"default").length)}),t("color_cols_foreground",{processor:"number",default:sx(ux(e,nx).length)}),t("color_cols_background",{processor:"number",default:sx(ux(e,rx).length)}),t("custom_colors",{processor:"boolean",default:!0}),t("color_default_foreground",{processor:"string",default:lx}),t("color_default_background",{processor:"string",default:lx})})(e),(e=>{const t=e.options.register;t("contextmenu_avoid_overlap",{processor:"string",default:""}),t("contextmenu_never_use_native",{processor:"boolean",default:!1}),t("contextmenu",{processor:e=>!1===e?{value:[],valid:!0}:s(e)||f(e,s)?{value:tD(e),valid:!0}:{valid:!1,message:"Must be false or a string."},default:"link linkchecker image editimage table spellchecker configurepermanentpen"})})(e)})(e);const{dialogs:t,popups:o,renderUI:n}=bB(e);uw(e,o.backstage.shared);const r=ZR({editor:e,backstages:{popup:o.backstage,dialog:t.backstage}});return{renderUI:n,getWindowManagerImpl:y(r),getNotificationManagerImpl:()=>((e,t,o)=>{const n=t.backstage.shared,r=()=>{const t=$o(Ie(e.getContentAreaContainer())),o=Xo(),n=zi(o.x,t.x,t.right),r=zi(o.y,t.y,t.bottom),s=Math.max(t.right,o.right),a=Math.max(t.bottom,o.bottom);return M.some(Go(n,r,s-n,a-r))};return{open:(t,s)=>{const a=()=>{s(),Th.hide(l)},i=Ka(Uh.sketch({text:t.text,level:R(["success","error","warning","warn","info"],t.type)?t.type:void 0,progress:!0===t.progressBar,icon:t.icon,closeButton:t.closeButton,onAction:a,iconProvider:n.providers.icons,translationProvider:n.providers.translate})),l=Ka(Th.sketch({dom:{tag:"div",classes:["tox-notifications-container"]},lazySink:n.getSink,fireDismissalEventInstead:{},...n.header.isPositionedAtTop()?{}:{fireRepositionEventInstead:{}}}));o.add(l),h(t.timeout)&&t.timeout>0&&Eh.setEditorTimeout(e,(()=>{a()}),t.timeout);const c={close:a,reposition:()=>{const t=Ya(i),o={maxHeightFunction:Zl()},s=e.notificationManager.getNotifications();if(s[0]===c){const e={...n.anchors.banner(),overrides:o};Th.showWithinBounds(l,t,{anchor:e},r)}else I(s,c).each((e=>{const n=s[e-1].getEl(),a={type:"node",root:ht(),node:M.some(Ie(n)),overrides:o,layouts:{onRtl:()=>[Qi],onLtr:()=>[Qi]}};Th.showWithinBounds(l,t,{anchor:a},r)}))},text:e=>{Uh.updateText(i,e)},settings:t,getEl:()=>i.element.dom,progressBar:{value:e=>{Uh.updateProgress(i,e)}}};return c},close:e=>{e.close()},getArgs:e=>e.settings}})(e,{backstage:o.backstage},o.getMothership())}}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(t,e,r)=>{const s="UL"===e?"InsertUnorderedList":"InsertOrderedList";t.execCommand(s,!1,!1===r?null:{"list-style-type":r})},r=t=>e=>e.options.get(t),s=r("advlist_number_styles"),n=r("advlist_bullet_styles"),l=t=>null==t,i=t=>!l(t);var o=tinymce.util.Tools.resolve("tinymce.util.Tools");class a{constructor(t,e){this.tag=t,this.value=e}static some(t){return new a(!0,t)}static none(){return a.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?a.some(t(this.value)):a.none()}bind(t){return this.tag?t(this.value):a.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:a.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return i(t)?a.some(t):a.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}a.singletonNone=new a(!1);const u=t=>i(t)&&/^(TH|TD)$/.test(t.nodeName),d=t=>l(t)||"default"===t?"":t,g=(t,e)=>r=>{const s=s=>{r.setActive(((t,e,r)=>{const s=((t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r]))return r;return-1})(e.parents,u),n=-1!==s?e.parents.slice(0,s):e.parents,l=o.grep(n,(t=>e=>i(e)&&/^(OL|UL|DL)$/.test(e.nodeName)&&((t,e)=>t.dom.isChildOf(e,t.getBody()))(t,e))(t));return l.length>0&&l[0].nodeName===r})(t,s,e)),r.setEnabled(!((t,e)=>{const r=t.dom.getParent(e,"ol,ul,dl");return((t,e)=>null!==e&&"false"===t.dom.getContentEditableParent(e))(t,r)})(t,s.element))};return t.on("NodeChange",s),()=>t.off("NodeChange",s)},h=(t,r,s,n,l,i)=>{i.length>1?((t,r,s,n,l,i)=>{t.ui.registry.addSplitButton(r,{tooltip:s,icon:"OL"===l?"ordered-list":"unordered-list",presets:"listpreview",columns:3,fetch:t=>{t(o.map(i,(t=>{const e="OL"===l?"num":"bull",r="disc"===t||"decimal"===t?"default":t,s=d(t),n=(t=>t.replace(/\-/g," ").replace(/\b\w/g,(t=>t.toUpperCase())))(t);return{type:"choiceitem",value:s,icon:"list-"+e+"-"+r,text:n}})))},onAction:()=>t.execCommand(n),onItemAction:(r,s)=>{e(t,l,s)},select:e=>{const r=(t=>{const e=t.dom.getParent(t.selection.getNode(),"ol,ul"),r=t.dom.getStyle(e,"listStyleType");return a.from(r)})(t);return r.map((t=>e===t)).getOr(!1)},onSetup:g(t,l)})})(t,r,s,n,l,i):((t,r,s,n,l,i)=>{t.ui.registry.addToggleButton(r,{active:!1,tooltip:s,icon:"OL"===l?"ordered-list":"unordered-list",onSetup:g(t,l),onAction:()=>t.queryCommandState(n)||""===i?t.execCommand(n):e(t,l,i)})})(t,r,s,n,l,d(i[0]))};t.add("advlist",(t=>{t.hasPlugin("lists")?((t=>{const e=t.options.register;e("advlist_number_styles",{processor:"string[]",default:"default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman".split(",")}),e("advlist_bullet_styles",{processor:"string[]",default:"default,circle,square".split(",")})})(t),(t=>{h(t,"numlist","Numbered list","InsertOrderedList","OL",s(t)),h(t,"bullist","Bullet list","InsertUnorderedList","UL",n(t))})(t),(t=>{t.addCommand("ApplyUnorderedListStyle",((r,s)=>{e(t,"UL",s["list-style-type"])})),t.addCommand("ApplyOrderedListStyle",((r,s)=>{e(t,"OL",s["list-style-type"])}))})(t)):console.error("Please use the Lists plugin together with the Advanced List plugin.")}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),o=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=("allow_html_in_named_anchor",e=>e.options.get("allow_html_in_named_anchor"));const a="a:not([href])",r=e=>!e,i=e=>e.getAttribute("id")||e.getAttribute("name")||"",l=e=>(e=>"a"===e.nodeName.toLowerCase())(e)&&!e.getAttribute("href")&&""!==i(e),s=e=>e.dom.getParent(e.selection.getStart(),a),d=(e,a)=>{const r=s(e);r?((e,t,o)=>{o.removeAttribute("name"),o.id=t,e.addVisual(),e.undoManager.add()})(e,a,r):((e,a)=>{e.undoManager.transact((()=>{n(e)||e.selection.collapse(!0),e.selection.isCollapsed()?e.insertContent(e.dom.createHTML("a",{id:a})):((e=>{const n=e.dom;t(n).walk(e.selection.getRng(),(e=>{o.each(e,(e=>{var t;l(t=e)&&!t.firstChild&&n.remove(e,!1)}))}))})(e),e.formatter.remove("namedAnchor",void 0,void 0,!0),e.formatter.apply("namedAnchor",{value:a}),e.addVisual())}))})(e,a),e.focus()},c=e=>(e=>r(e.attr("href"))&&!r(e.attr("id")||e.attr("name")))(e)&&!e.firstChild,m=e=>t=>{for(let o=0;o<t.length;o++){const n=t[o];c(n)&&n.attr("contenteditable",e)}};e.add("anchor",(e=>{(e=>{(0,e.options.register)("allow_html_in_named_anchor",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreInit",(()=>{e.parser.addNodeFilter("a",m("false")),e.serializer.addNodeFilter("a",m(null))}))})(e),(e=>{e.addCommand("mceAnchor",(()=>{(e=>{const t=(e=>{const t=s(e);return t?i(t):""})(e);e.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:t},onSubmit:t=>{((e,t)=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)?(d(e,t),!0):(e.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1))(e,t.getData().id)&&t.close()}})})(e)}))})(e),(e=>{const t=()=>e.execCommand("mceAnchor");e.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:t,onSetup:t=>e.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind}),e.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:t})})(e),e.on("PreInit",(()=>{(e=>{e.formatter.register("namedAnchor",{inline:"a",selector:a,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(e,t,o)=>l(e)})})(e)}))}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>t.options.get(e),n=t("autolink_pattern"),o=t("link_default_target"),r=t("link_default_protocol"),a=t("allow_unsafe_link_target"),s=("string",e=>"string"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=o=e,(r=String).prototype.isPrototypeOf(n)||(null===(a=o.constructor)||void 0===a?void 0:a.name)===r.name)?"string":t;var n,o,r,a})(e));const l=(void 0,e=>undefined===e);const i=e=>!(e=>null==e)(e),c=Object.hasOwnProperty,d=e=>"\ufeff"===e;var u=tinymce.util.Tools.resolve("tinymce.dom.TextSeeker");const f=e=>/^[(\[{ \u00a0]$/.test(e),g=(e,t,n)=>{for(let o=t-1;o>=0;o--){const t=e.charAt(o);if(!d(t)&&n(t))return o}return-1},m=(e,t)=>{var o;const a=e.schema.getVoidElements(),s=n(e),{dom:i,selection:d}=e;if(null!==i.getParent(d.getNode(),"a[href]"))return null;const m=d.getRng(),k=u(i,(e=>{return i.isBlock(e)||(t=a,n=e.nodeName.toLowerCase(),c.call(t,n))||"false"===i.getContentEditable(e);var t,n})),{container:p,offset:y}=((e,t)=>{let n=e,o=t;for(;1===n.nodeType&&n.childNodes[o];)n=n.childNodes[o],o=3===n.nodeType?n.data.length:n.childNodes.length;return{container:n,offset:o}})(m.endContainer,m.endOffset),h=null!==(o=i.getParent(p,i.isBlock))&&void 0!==o?o:i.getRoot(),w=k.backwards(p,y+t,((e,t)=>{const n=e.data,o=g(n,t,(r=f,e=>!r(e)));var r,a;return-1===o||(a=n[o],/[?!,.;:]/.test(a))?o:o+1}),h);if(!w)return null;let v=w.container;const _=k.backwards(w.container,w.offset,((e,t)=>{v=e;const n=g(e.data,t,f);return-1===n?n:n+1}),h),A=i.createRng();_?A.setStart(_.container,_.offset):A.setStart(v,0),A.setEnd(w.container,w.offset);const C=A.toString().replace(/\uFEFF/g,"").match(s);if(C){let t=C[0];return $="www.",(b=t).length>=$.length&&b.substr(0,0+$.length)===$?t=r(e)+"://"+t:((e,t,n=0,o)=>{const r=e.indexOf(t,n);return-1!==r&&(!!l(o)||r+t.length<=o)})(t,"@")&&!(e=>/^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(e))(t)&&(t="mailto:"+t),{rng:A,url:t}}var b,$;return null},k=(e,t)=>{const{dom:n,selection:r}=e,{rng:l,url:i}=t,c=r.getBookmark();r.setRng(l);const d="createlink",u={command:d,ui:!1,value:i};if(!e.dispatch("BeforeExecCommand",u).isDefaultPrevented()){e.getDoc().execCommand(d,!1,i),e.dispatch("ExecCommand",u);const t=o(e);if(s(t)){const o=r.getNode();n.setAttrib(o,"target",t),"_blank"!==t||a(e)||n.setAttrib(o,"rel","noopener")}}r.moveToBookmark(c),e.nodeChanged()},p=e=>{const t=m(e,-1);i(t)&&k(e,t)},y=p;e.add("autolink",(e=>{(e=>{const t=e.options.register;t("autolink_pattern",{processor:"regexp",default:new RegExp("^"+/(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-.~*+=!;:'%@$(),\/\w]*[-~*+=%@$()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g.source+"$","i")}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"})})(e),(e=>{e.on("keydown",(t=>{13!==t.keyCode||t.isDefaultPrevented()||(e=>{const t=m(e,0);i(t)&&k(e,t)})(e)})),e.on("keyup",(t=>{32===t.keyCode?p(e):(48===t.keyCode&&t.shiftKey||221===t.keyCode)&&y(e)}))})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.Env");const o=e=>t=>t.options.get(e),n=o("min_height"),s=o("max_height"),i=o("autoresize_overflow_padding"),r=o("autoresize_bottom_margin"),l=(e,t)=>{const o=e.getBody();o&&(o.style.overflowY=t?"":"hidden",t||(o.scrollTop=0))},a=(e,t,o,n)=>{var s;const i=parseInt(null!==(s=e.getStyle(t,o,n))&&void 0!==s?s:"",10);return isNaN(i)?0:i},g=(e,o,i)=>{var c;const u=e.dom,d=e.getDoc();if(!d)return;if((e=>e.plugins.fullscreen&&e.plugins.fullscreen.isFullscreen())(e))return void l(e,!0);const f=d.documentElement,m=r(e),p=null!==(c=n(e))&&void 0!==c?c:e.getElement().offsetHeight;let h=p;const v=a(u,f,"margin-top",!0),y=a(u,f,"margin-bottom",!0);let C=f.offsetHeight+v+y+m;C<0&&(C=0);const S=e.getContainer().offsetHeight-e.getContentAreaContainer().offsetHeight;C+S>p&&(h=C+S);const z=s(e);if(z&&h>z?(h=z,l(e,!0)):l(e,!1),h!==o.get()){const n=h-o.get();if(u.setStyle(e.getContainer(),"height",h+"px"),o.set(h),(e=>{e.dispatch("ResizeEditor")})(e),t.browser.isSafari()&&(t.os.isMacOS()||t.os.isiOS())){const t=e.getWin();t.scrollTo(t.pageXOffset,t.pageYOffset)}e.hasFocus()&&(e=>{if("setcontent"===(null==e?void 0:e.type.toLowerCase())){const t=e;return!0===t.selection||!0===t.paste}return!1})(i)&&e.selection.scrollIntoView(),(t.browser.isSafari()||t.browser.isChromium())&&n<0&&g(e,o,i)}};e.add("autoresize",(e=>{if((e=>{const t=e.options.register;t("autoresize_overflow_padding",{processor:"number",default:1}),t("autoresize_bottom_margin",{processor:"number",default:50})})(e),e.options.isSet("resize")||e.options.set("resize",!1),!e.inline){const t=(e=>{let t=0;return{get:()=>t,set:e=>{t=e}}})();((e,t)=>{e.addCommand("mceAutoResize",(()=>{g(e,t)}))})(e,t),((e,t)=>{e.on("init",(()=>{const t=i(e),o=e.dom;o.setStyles(e.getDoc().documentElement,{height:"auto"}),o.setStyles(e.getBody(),{paddingLeft:t,paddingRight:t,"min-height":0})})),e.on("NodeChange SetContent keyup FullscreenStateChanged ResizeContent",(o=>{g(e,t,o)}))})(e,t)}}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=("string",t=>"string"===(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&(r=o=t,(a=String).prototype.isPrototypeOf(r)||(null===(s=o.constructor)||void 0===s?void 0:s.name)===a.name)?"string":e;var r,o,a,s})(t));const r=(void 0,t=>undefined===t);var o=tinymce.util.Tools.resolve("tinymce.util.Delay"),a=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),s=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=t=>{const e=/^(\d+)([ms]?)$/.exec(t);return(e&&e[2]?{s:1e3,m:6e4}[e[2]]:1)*parseInt(t,10)},i=t=>e=>e.options.get(t),u=i("autosave_ask_before_unload"),l=i("autosave_restore_when_empty"),c=i("autosave_interval"),d=i("autosave_retention"),m=t=>{const e=document.location;return t.options.get("autosave_prefix").replace(/{path}/g,e.pathname).replace(/{query}/g,e.search).replace(/{hash}/g,e.hash).replace(/{id}/g,t.id)},v=(t,e)=>{if(r(e))return t.dom.isEmpty(t.getBody());{const r=s.trim(e);if(""===r)return!0;{const e=(new DOMParser).parseFromString(r,"text/html");return t.dom.isEmpty(e)}}},f=t=>{var e;const r=parseInt(null!==(e=a.getItem(m(t)+"time"))&&void 0!==e?e:"0",10)||0;return!((new Date).getTime()-r>d(t)&&(p(t,!1),1))},p=(t,e)=>{const r=m(t);a.removeItem(r+"draft"),a.removeItem(r+"time"),!1!==e&&(t=>{t.dispatch("RemoveDraft")})(t)},g=t=>{const e=m(t);!v(t)&&t.isDirty()&&(a.setItem(e+"draft",t.getContent({format:"raw",no_events:!0})),a.setItem(e+"time",(new Date).getTime().toString()),(t=>{t.dispatch("StoreDraft")})(t))},y=t=>{var e;const r=m(t);f(t)&&(t.setContent(null!==(e=a.getItem(r+"draft"))&&void 0!==e?e:"",{format:"raw"}),(t=>{t.dispatch("RestoreDraft")})(t))};var D=tinymce.util.Tools.resolve("tinymce.EditorManager");const h=t=>e=>{e.setEnabled(f(t));const r=()=>e.setEnabled(f(t));return t.on("StoreDraft RestoreDraft RemoveDraft",r),()=>t.off("StoreDraft RestoreDraft RemoveDraft",r)};t.add("autosave",(t=>((t=>{const r=t.options.register,o=t=>{const r=e(t);return r?{value:n(t),valid:r}:{valid:!1,message:"Must be a string."}};r("autosave_ask_before_unload",{processor:"boolean",default:!0}),r("autosave_prefix",{processor:"string",default:"tinymce-autosave-{path}{query}{hash}-{id}-"}),r("autosave_restore_when_empty",{processor:"boolean",default:!1}),r("autosave_interval",{processor:o,default:"30s"}),r("autosave_retention",{processor:o,default:"20m"})})(t),(t=>{t.editorManager.on("BeforeUnload",(t=>{let e;s.each(D.get(),(t=>{t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&u(t)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))})),e&&(t.preventDefault(),t.returnValue=e)}))})(t),(t=>{(t=>{const e=c(t);o.setEditorInterval(t,(()=>{g(t)}),e)})(t);const e=()=>{(t=>{t.undoManager.transact((()=>{y(t),p(t)})),t.focus()})(t)};t.ui.registry.addButton("restoredraft",{tooltip:"Restore last draft",icon:"restore-draft",onAction:e,onSetup:h(t)}),t.ui.registry.addMenuItem("restoredraft",{text:"Restore last draft",icon:"restore-draft",onAction:e,onSetup:h(t)})})(t),t.on("init",(()=>{l(t)&&t.dom.isEmpty(t.getBody())&&y(t)})),(t=>({hasDraft:()=>f(t),storeDraft:()=>g(t),restoreDraft:()=>y(t),removeDraft:e=>p(t,e),isEmpty:e=>v(t,e)}))(t))))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(e,t)=>{const r=((e,t)=>e.dispatch("insertCustomChar",{chr:t}))(e,t).chr;e.execCommand("mceInsertContent",!1,r)},r=e=>t=>e===t,a=("array",e=>"array"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(r=a=e,(n=String).prototype.isPrototypeOf(r)||(null===(i=a.constructor)||void 0===i?void 0:i.name)===n.name)?"string":t;var r,a,n,i})(e));const n=r(null),i=r(void 0),o=e=>"function"==typeof e,s=(!1,()=>false);class l{constructor(e,t){this.tag=e,this.value=t}static some(e){return new l(!0,e)}static none(){return l.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?l.some(e(this.value)):l.none()}bind(e){return this.tag?e(this.value):l.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:l.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return null==e?l.none():l.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}l.singletonNone=new l(!1);const c=Array.prototype.push,u=(e,t)=>{const r=e.length,a=new Array(r);for(let n=0;n<r;n++){const r=e[n];a[n]=t(r,n)}return a};var g=tinymce.util.Tools.resolve("tinymce.util.Tools");const h=e=>t=>t.options.get(e),m=h("charmap"),p=h("charmap_append"),d=g.isArray,f="User Defined",y=e=>{return d(e)?(t=e,g.grep(t,(e=>d(e)&&2===e.length))):"function"==typeof e?e():[];var t},w=e=>{const t=((e,t)=>{const r=m(e);r&&(t=[{name:f,characters:y(r)}]);const a=p(e);if(a){const e=g.grep(t,(e=>e.name===f));return e.length?(e[0].characters=[...e[0].characters,...y(a)],t):t.concat({name:f,characters:y(a)})}return t})(e,[{name:"Currency",characters:[[36,"dollar sign"],[162,"cent sign"],[8364,"euro sign"],[163,"pound sign"],[165,"yen sign"],[164,"currency sign"],[8352,"euro-currency sign"],[8353,"colon sign"],[8354,"cruzeiro sign"],[8355,"french franc sign"],[8356,"lira sign"],[8357,"mill sign"],[8358,"naira sign"],[8359,"peseta sign"],[8360,"rupee sign"],[8361,"won sign"],[8362,"new sheqel sign"],[8363,"dong sign"],[8365,"kip sign"],[8366,"tugrik sign"],[8367,"drachma sign"],[8368,"german penny symbol"],[8369,"peso sign"],[8370,"guarani sign"],[8371,"austral sign"],[8372,"hryvnia sign"],[8373,"cedi sign"],[8374,"livre tournois sign"],[8375,"spesmilo sign"],[8376,"tenge sign"],[8377,"indian rupee sign"],[8378,"turkish lira sign"],[8379,"nordic mark sign"],[8380,"manat sign"],[8381,"ruble sign"],[20870,"yen character"],[20803,"yuan character"],[22291,"yuan character, in hong kong and taiwan"],[22278,"yen/yuan character variant one"]]},{name:"Text",characters:[[169,"copyright sign"],[174,"registered sign"],[8482,"trade mark sign"],[8240,"per mille sign"],[181,"micro sign"],[183,"middle dot"],[8226,"bullet"],[8230,"three dot leader"],[8242,"minutes / feet"],[8243,"seconds / inches"],[167,"section sign"],[182,"paragraph sign"],[223,"sharp s / ess-zed"]]},{name:"Quotations",characters:[[8249,"single left-pointing angle quotation mark"],[8250,"single right-pointing angle quotation mark"],[171,"left pointing guillemet"],[187,"right pointing guillemet"],[8216,"left single quotation mark"],[8217,"right single quotation mark"],[8220,"left double quotation mark"],[8221,"right double quotation mark"],[8218,"single low-9 quotation mark"],[8222,"double low-9 quotation mark"],[60,"less-than sign"],[62,"greater-than sign"],[8804,"less-than or equal to"],[8805,"greater-than or equal to"],[8211,"en dash"],[8212,"em dash"],[175,"macron"],[8254,"overline"],[164,"currency sign"],[166,"broken bar"],[168,"diaeresis"],[161,"inverted exclamation mark"],[191,"turned question mark"],[710,"circumflex accent"],[732,"small tilde"],[176,"degree sign"],[8722,"minus sign"],[177,"plus-minus sign"],[247,"division sign"],[8260,"fraction slash"],[215,"multiplication sign"],[185,"superscript one"],[178,"superscript two"],[179,"superscript three"],[188,"fraction one quarter"],[189,"fraction one half"],[190,"fraction three quarters"]]},{name:"Mathematical",characters:[[402,"function / florin"],[8747,"integral"],[8721,"n-ary sumation"],[8734,"infinity"],[8730,"square root"],[8764,"similar to"],[8773,"approximately equal to"],[8776,"almost equal to"],[8800,"not equal to"],[8801,"identical to"],[8712,"element of"],[8713,"not an element of"],[8715,"contains as member"],[8719,"n-ary product"],[8743,"logical and"],[8744,"logical or"],[172,"not sign"],[8745,"intersection"],[8746,"union"],[8706,"partial differential"],[8704,"for all"],[8707,"there exists"],[8709,"diameter"],[8711,"backward difference"],[8727,"asterisk operator"],[8733,"proportional to"],[8736,"angle"]]},{name:"Extended Latin",characters:[[192,"A - grave"],[193,"A - acute"],[194,"A - circumflex"],[195,"A - tilde"],[196,"A - diaeresis"],[197,"A - ring above"],[256,"A - macron"],[198,"ligature AE"],[199,"C - cedilla"],[200,"E - grave"],[201,"E - acute"],[202,"E - circumflex"],[203,"E - diaeresis"],[274,"E - macron"],[204,"I - grave"],[205,"I - acute"],[206,"I - circumflex"],[207,"I - diaeresis"],[298,"I - macron"],[208,"ETH"],[209,"N - tilde"],[210,"O - grave"],[211,"O - acute"],[212,"O - circumflex"],[213,"O - tilde"],[214,"O - diaeresis"],[216,"O - slash"],[332,"O - macron"],[338,"ligature OE"],[352,"S - caron"],[217,"U - grave"],[218,"U - acute"],[219,"U - circumflex"],[220,"U - diaeresis"],[362,"U - macron"],[221,"Y - acute"],[376,"Y - diaeresis"],[562,"Y - macron"],[222,"THORN"],[224,"a - grave"],[225,"a - acute"],[226,"a - circumflex"],[227,"a - tilde"],[228,"a - diaeresis"],[229,"a - ring above"],[257,"a - macron"],[230,"ligature ae"],[231,"c - cedilla"],[232,"e - grave"],[233,"e - acute"],[234,"e - circumflex"],[235,"e - diaeresis"],[275,"e - macron"],[236,"i - grave"],[237,"i - acute"],[238,"i - circumflex"],[239,"i - diaeresis"],[299,"i - macron"],[240,"eth"],[241,"n - tilde"],[242,"o - grave"],[243,"o - acute"],[244,"o - circumflex"],[245,"o - tilde"],[246,"o - diaeresis"],[248,"o slash"],[333,"o macron"],[339,"ligature oe"],[353,"s - caron"],[249,"u - grave"],[250,"u - acute"],[251,"u - circumflex"],[252,"u - diaeresis"],[363,"u - macron"],[253,"y - acute"],[254,"thorn"],[255,"y - diaeresis"],[563,"y - macron"],[913,"Alpha"],[914,"Beta"],[915,"Gamma"],[916,"Delta"],[917,"Epsilon"],[918,"Zeta"],[919,"Eta"],[920,"Theta"],[921,"Iota"],[922,"Kappa"],[923,"Lambda"],[924,"Mu"],[925,"Nu"],[926,"Xi"],[927,"Omicron"],[928,"Pi"],[929,"Rho"],[931,"Sigma"],[932,"Tau"],[933,"Upsilon"],[934,"Phi"],[935,"Chi"],[936,"Psi"],[937,"Omega"],[945,"alpha"],[946,"beta"],[947,"gamma"],[948,"delta"],[949,"epsilon"],[950,"zeta"],[951,"eta"],[952,"theta"],[953,"iota"],[954,"kappa"],[955,"lambda"],[956,"mu"],[957,"nu"],[958,"xi"],[959,"omicron"],[960,"pi"],[961,"rho"],[962,"final sigma"],[963,"sigma"],[964,"tau"],[965,"upsilon"],[966,"phi"],[967,"chi"],[968,"psi"],[969,"omega"]]},{name:"Symbols",characters:[[8501,"alef symbol"],[982,"pi symbol"],[8476,"real part symbol"],[978,"upsilon - hook symbol"],[8472,"Weierstrass p"],[8465,"imaginary part"]]},{name:"Arrows",characters:[[8592,"leftwards arrow"],[8593,"upwards arrow"],[8594,"rightwards arrow"],[8595,"downwards arrow"],[8596,"left right arrow"],[8629,"carriage return"],[8656,"leftwards double arrow"],[8657,"upwards double arrow"],[8658,"rightwards double arrow"],[8659,"downwards double arrow"],[8660,"left right double arrow"],[8756,"therefore"],[8834,"subset of"],[8835,"superset of"],[8836,"not a subset of"],[8838,"subset of or equal to"],[8839,"superset of or equal to"],[8853,"circled plus"],[8855,"circled times"],[8869,"perpendicular"],[8901,"dot operator"],[8968,"left ceiling"],[8969,"right ceiling"],[8970,"left floor"],[8971,"right floor"],[9001,"left-pointing angle bracket"],[9002,"right-pointing angle bracket"],[9674,"lozenge"],[9824,"black spade suit"],[9827,"black club suit"],[9829,"black heart suit"],[9830,"black diamond suit"],[8194,"en space"],[8195,"em space"],[8201,"thin space"],[8204,"zero width non-joiner"],[8205,"zero width joiner"],[8206,"left-to-right mark"],[8207,"right-to-left mark"]]}]);return t.length>1?[{name:"All",characters:(r=t,n=e=>e.characters,(e=>{const t=[];for(let r=0,n=e.length;r<n;++r){if(!a(e[r]))throw new Error("Arr.flatten item "+r+" was not an array, input: "+e);c.apply(t,e[r])}return t})(u(r,n)))}].concat(t):t;var r,n},v=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},b=(e,t,r=0,a)=>{const n=e.indexOf(t,r);return-1!==n&&(!!i(a)||n+t.length<=a)},k=String.fromCodePoint,C=(e,t)=>{const r=[],a=t.toLowerCase();return((e,t)=>{for(let t=0,i=e.length;t<i;t++)((e,t,r)=>!!b(k(e).toLowerCase(),r)||b(t.toLowerCase(),r)||b(t.toLowerCase().replace(/\s+/g,""),r))((n=e[t])[0],n[1],a)&&r.push(n);var n})(e.characters),u(r,(e=>({text:e[1],value:k(e[0]),icon:k(e[0])})))},x="pattern",A=(e,r)=>{const a=()=>[{label:"Search",type:"input",name:x},{type:"collection",name:"results"}],i=1===r.length?v(f):v("All"),o=((e,t)=>{let r=null;const a=()=>{n(r)||(clearTimeout(r),r=null)};return{cancel:a,throttle:(...t)=>{a(),r=setTimeout((()=>{r=null,e.apply(null,t)}),40)}}})((e=>{const t=e.getData().pattern;((e,t)=>{var a,n;(a=r,n=e=>e.name===i.get(),((e,t,r)=>{for(let a=0,n=e.length;a<n;a++){const n=e[a];if(t(n,a))return l.some(n);if(r(n,a))break}return l.none()})(a,n,s)).each((r=>{const a=C(r,t);e.setData({results:a})}))})(e,t)})),c={title:"Special Character",size:"normal",body:1===r.length?{type:"panel",items:a()}:{type:"tabpanel",tabs:u(r,(e=>({title:e.name,name:e.name,items:a()})))},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}],initialData:{pattern:"",results:C(r[0],"")},onAction:(r,a)=>{"results"===a.name&&(t(e,a.value),r.close())},onTabChange:(e,t)=>{i.set(t.newTabName),o.throttle(e)},onChange:(e,t)=>{t.name===x&&o.throttle(e)}};e.windowManager.open(c).focus(x)};e.add("charmap",(e=>{(e=>{const t=e.options.register,r=e=>o(e)||a(e);t("charmap",{processor:r}),t("charmap_append",{processor:r})})(e);const r=w(e);return((e,t)=>{e.addCommand("mceShowCharmap",(()=>{A(e,t)}))})(e,r),(e=>{const t=()=>e.execCommand("mceShowCharmap");e.ui.registry.addButton("charmap",{icon:"insert-character",tooltip:"Special character",onAction:t}),e.ui.registry.addMenuItem("charmap",{icon:"insert-character",text:"Special character...",onAction:t})})(e),((e,t)=>{e.ui.registry.addAutocompleter("charmap",{trigger:":",columns:"auto",minChars:2,fetch:(e,r)=>new Promise(((r,a)=>{r(C(t,e))})),onAction:(t,r,a)=>{e.selection.setRng(r),e.insertContent(a),t.hide()}})})(e,r[0]),(e=>({getCharMap:()=>w(e),insertChar:r=>{t(e,r)}}))(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";tinymce.util.Tools.resolve("tinymce.PluginManager").add("code",(e=>((e=>{e.addCommand("mceCodeEditor",(()=>{(e=>{const o=(e=>e.getContent({source_view:!0}))(e);e.windowManager.open({title:"Source Code",size:"large",body:{type:"panel",items:[{type:"textarea",name:"code"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{code:o},onSubmit:o=>{((e,o)=>{e.focus(),e.undoManager.transact((()=>{e.setContent(o)})),e.selection.setCursorLocation(),e.nodeChanged()})(e,o.getData().code),o.close()}})})(e)}))})(e),(e=>{const o=()=>e.execCommand("mceCodeEditor");e.ui.registry.addButton("code",{icon:"sourcecode",tooltip:"Source code",onAction:o}),e.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:o})})(e),{})))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>!(e=>null==e)(e);class n{constructor(e,t){this.tag=e,this.value=t}static some(e){return new n(!0,e)}static none(){return n.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?n.some(e(this.value)):n.none()}bind(e){return this.tag?e(this.value):n.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:n.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return t(e)?n.some(e):n.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}n.singletonNone=new n(!1);var a=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");const s="undefined"!=typeof window?window:Function("return this;")(),r=function(e,t,n){const a=window.Prism;window.Prism={manual:!0};var s=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,a={},s={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof r?new r(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++n}),e.__id},clone:function e(t,n){var a,r;switch(n=n||{},s.util.type(t)){case"Object":if(r=s.util.objId(t),n[r])return n[r];for(var i in a={},n[r]=a,t)t.hasOwnProperty(i)&&(a[i]=e(t[i],n));return a;case"Array":return r=s.util.objId(t),n[r]?n[r]:(a=[],n[r]=a,t.forEach((function(t,s){a[s]=e(t,n)})),a);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return"none"},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,"gi"),""),e.classList.add("language-"+n)},currentScript:function(){if("undefined"==typeof document)return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(a){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(a.stack)||[])[1];if(e){var t=document.getElementsByTagName("script");for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var a="no-"+t;e;){var s=e.classList;if(s.contains(t))return!0;if(s.contains(a))return!1;e=e.parentElement}return!!n}},languages:{plain:a,plaintext:a,text:a,txt:a,extend:function(e,t){var n=s.util.clone(s.languages[e]);for(var a in t)n[a]=t[a];return n},insertBefore:function(e,t,n,a){var r=(a=a||s.languages)[e],i={};for(var o in r)if(r.hasOwnProperty(o)){if(o==t)for(var l in n)n.hasOwnProperty(l)&&(i[l]=n[l]);n.hasOwnProperty(o)||(i[o]=r[o])}var u=a[e];return a[e]=i,s.languages.DFS(s.languages,(function(t,n){n===u&&t!=e&&(this[t]=i)})),i},DFS:function e(t,n,a,r){r=r||{};var i=s.util.objId;for(var o in t)if(t.hasOwnProperty(o)){n.call(t,o,t[o],a||o);var l=t[o],u=s.util.type(l);"Object"!==u||r[i(l)]?"Array"!==u||r[i(l)]||(r[i(l)]=!0,e(l,n,o,r)):(r[i(l)]=!0,e(l,n,null,r))}}},plugins:{},highlightAll:function(e,t){s.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var a={callback:n,container:e,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};s.hooks.run("before-highlightall",a),a.elements=Array.prototype.slice.apply(a.container.querySelectorAll(a.selector)),s.hooks.run("before-all-elements-highlight",a);for(var r,i=0;r=a.elements[i++];)s.highlightElement(r,!0===t,a.callback)},highlightElement:function(t,n,a){var r=s.util.getLanguage(t),i=s.languages[r];s.util.setLanguage(t,r);var o=t.parentElement;o&&"pre"===o.nodeName.toLowerCase()&&s.util.setLanguage(o,r);var l={element:t,language:r,grammar:i,code:t.textContent};function u(e){l.highlightedCode=e,s.hooks.run("before-insert",l),l.element.innerHTML=l.highlightedCode,s.hooks.run("after-highlight",l),s.hooks.run("complete",l),a&&a.call(l.element)}if(s.hooks.run("before-sanity-check",l),(o=l.element.parentElement)&&"pre"===o.nodeName.toLowerCase()&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","0"),!l.code)return s.hooks.run("complete",l),void(a&&a.call(l.element));if(s.hooks.run("before-highlight",l),l.grammar)if(n&&e.Worker){var c=new Worker(s.filename);c.onmessage=function(e){u(e.data)},c.postMessage(JSON.stringify({language:l.language,code:l.code,immediateClose:!0}))}else u(s.highlight(l.code,l.grammar,l.language));else u(s.util.encode(l.code))},highlight:function(e,t,n){var a={code:e,grammar:t,language:n};if(s.hooks.run("before-tokenize",a),!a.grammar)throw new Error('The language "'+a.language+'" has no grammar.');return a.tokens=s.tokenize(a.code,a.grammar),s.hooks.run("after-tokenize",a),r.stringify(s.util.encode(a.tokens),a.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var a in n)t[a]=n[a];delete t.rest}var s=new l;return u(s,s.head,e),o(e,s,t,s.head,0),function(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}(s)},hooks:{all:{},add:function(e,t){var n=s.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=s.hooks.all[e];if(n&&n.length)for(var a,r=0;a=n[r++];)a(t)}},Token:r};function r(e,t,n,a){this.type=e,this.content=t,this.alias=n,this.length=0|(a||"").length}function i(e,t,n,a){e.lastIndex=t;var s=e.exec(n);if(s&&a&&s[1]){var r=s[1].length;s.index+=r,s[0]=s[0].slice(r)}return s}function o(e,t,n,a,l,d){for(var g in n)if(n.hasOwnProperty(g)&&n[g]){var p=n[g];p=Array.isArray(p)?p:[p];for(var b=0;b<p.length;++b){if(d&&d.cause==g+","+b)return;var h=p[b],f=h.inside,m=!!h.lookbehind,y=!!h.greedy,w=h.alias;if(y&&!h.pattern.global){var k=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,k+"g")}for(var v=h.pattern||h,_=a.next,x=l;_!==t.tail&&!(d&&x>=d.reach);x+=_.value.length,_=_.next){var F=_.value;if(t.length>e.length)return;if(!(F instanceof r)){var A,S=1;if(y){if(!(A=i(v,x,e,m))||A.index>=e.length)break;var $=A.index,z=A.index+A[0].length,E=x;for(E+=_.value.length;$>=E;)E+=(_=_.next).value.length;if(x=E-=_.value.length,_.value instanceof r)continue;for(var C=_;C!==t.tail&&(E<z||"string"==typeof C.value);C=C.next)S++,E+=C.value.length;S--,F=e.slice(x,E),A.index-=x}else if(!(A=i(v,0,F,m)))continue;$=A.index;var j=A[0],B=F.slice(0,$),T=F.slice($+j.length),O=x+F.length;d&&O>d.reach&&(d.reach=O);var P=_.prev;if(B&&(P=u(t,P,B),x+=B.length),c(t,P,S),_=u(t,P,new r(g,f?s.tokenize(j,f):j,w,j)),T&&u(t,_,T),S>1){var N={cause:g+","+b,reach:O};o(e,t,n,_.prev,x,N),d&&N.reach>d.reach&&(d.reach=N.reach)}}}}}}function l(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function u(e,t,n){var a=t.next,s={value:n,prev:t,next:a};return t.next=s,a.prev=s,e.length++,s}function c(e,t,n){for(var a=t.next,s=0;s<n&&a!==e.tail;s++)a=a.next;t.next=a,a.prev=t,e.length-=s}if(e.Prism=s,r.stringify=function e(t,n){if("string"==typeof t)return t;if(Array.isArray(t)){var a="";return t.forEach((function(t){a+=e(t,n)})),a}var r={type:t.type,content:e(t.content,n),tag:"span",classes:["token",t.type],attributes:{},language:n},i=t.alias;i&&(Array.isArray(i)?Array.prototype.push.apply(r.classes,i):r.classes.push(i)),s.hooks.run("wrap",r);var o="";for(var l in r.attributes)o+=" "+l+'="'+(r.attributes[l]||"").replace(/"/g,"&quot;")+'"';return"<"+r.tag+' class="'+r.classes.join(" ")+'"'+o+">"+r.content+"</"+r.tag+">"},!e.document)return e.addEventListener?(s.disableWorkerMessageHandler||e.addEventListener("message",(function(t){var n=JSON.parse(t.data),a=n.language,r=n.code,i=n.immediateClose;e.postMessage(s.highlight(r,s.languages[a],a)),i&&e.close()}),!1),s):s;var d=s.util.currentScript();function g(){s.manual||s.highlightAll()}if(d&&(s.filename=d.src,d.hasAttribute("data-manual")&&(s.manual=!0)),!s.manual){var p=document.readyState;"loading"===p||"interactive"===p&&d&&d.defer?document.addEventListener("DOMContentLoaded",g):window.requestAnimationFrame?window.requestAnimationFrame(g):window.setTimeout(g,16)}return s}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{});return s.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,a,s,r){if(n.language===a){var i=n.tokenStack=[];n.code=n.code.replace(s,(function(e){if("function"==typeof r&&!r(e))return e;for(var s,o=i.length;-1!==n.code.indexOf(s=t(a,o));)++o;return i[o]=e,s})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,a){if(n.language===a&&n.tokenStack){n.grammar=e.languages[a];var s=0,r=Object.keys(n.tokenStack);!function i(o){for(var l=0;l<o.length&&!(s>=r.length);l++){var u=o[l];if("string"==typeof u||u.content&&"string"==typeof u.content){var c=r[s],d=n.tokenStack[c],g="string"==typeof u?u:u.content,p=t(a,c),b=g.indexOf(p);if(b>-1){++s;var h=g.substring(0,b),f=new e.Token(a,e.tokenize(d,n.grammar),"language-"+a,d),m=g.substring(b+p.length),y=[];h&&y.push.apply(y,i([h])),y.push(f),m&&y.push.apply(y,i([m])),"string"==typeof u?o.splice.apply(o,[l,1].concat(y)):u.content=y}}else u.content&&i(u.content)}return o}(n.tokens)}}}})}(s),s.languages.c=s.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),s.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),s.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},s.languages.c.string],char:s.languages.c.char,comment:s.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:s.languages.c}}}}),s.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete s.languages.c.boolean,function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=/\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g,(function(){return t.source}));e.languages.cpp=e.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g,(function(){return t.source}))),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g,(function(){return n}))+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),e.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e.languages.cpp}}}}),e.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),e.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend("cpp",{})}}),e.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp["base-clause"])}(s),function(e){function t(e,t){return e.replace(/<<(\d+)>>/g,(function(e,n){return"(?:"+t[+n]+")"}))}function n(e,n,a){return RegExp(t(e,n),a||"")}function a(e,t){for(var n=0;n<t;n++)e=e.replace(/<<self>>/g,(function(){return"(?:"+e+")"}));return e.replace(/<<self>>/g,"[^\\s\\S]")}var s="bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void",r="class enum interface record struct",i="add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)",o="abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield";function l(e){return"\\b(?:"+e.trim().replace(/ /g,"|")+")\\b"}var u=l(r),c=RegExp(l(s+" "+r+" "+i+" "+o)),d=l(r+" "+i+" "+o),g=l(s+" "+r+" "+o),p=a(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source,2),b=a(/\((?:[^()]|<<self>>)*\)/.source,2),h=/@?\b[A-Za-z_]\w*\b/.source,f=t(/<<0>>(?:\s*<<1>>)?/.source,[h,p]),m=t(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source,[d,f]),y=/\[\s*(?:,\s*)*\]/.source,w=t(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source,[m,y]),k=t(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source,[p,b,y]),v=t(/\(<<0>>+(?:,<<0>>+)+\)/.source,[k]),_=t(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source,[v,m,y]),x={keyword:c,punctuation:/[<>()?,.:[\]]/},F=/'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source,A=/"(?:\\.|[^\\"\r\n])*"/.source,S=/@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;e.languages.csharp=e.languages.extend("clike",{string:[{pattern:n(/(^|[^$\\])<<0>>/.source,[S]),lookbehind:!0,greedy:!0},{pattern:n(/(^|[^@$\\])<<0>>/.source,[A]),lookbehind:!0,greedy:!0}],"class-name":[{pattern:n(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source,[m]),lookbehind:!0,inside:x},{pattern:n(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source,[h,_]),lookbehind:!0,inside:x},{pattern:n(/(\busing\s+)<<0>>(?=\s*=)/.source,[h]),lookbehind:!0},{pattern:n(/(\b<<0>>\s+)<<1>>/.source,[u,f]),lookbehind:!0,inside:x},{pattern:n(/(\bcatch\s*\(\s*)<<0>>/.source,[m]),lookbehind:!0,inside:x},{pattern:n(/(\bwhere\s+)<<0>>/.source,[h]),lookbehind:!0},{pattern:n(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source,[w]),lookbehind:!0,inside:x},{pattern:n(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source,[_,g,h]),inside:x}],keyword:c,number:/(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,operator:/>>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,punctuation:/\?\.?|::|[{}[\];(),.:]/}),e.languages.insertBefore("csharp","number",{range:{pattern:/\.\./,alias:"operator"}}),e.languages.insertBefore("csharp","punctuation",{"named-parameter":{pattern:n(/([(,]\s*)<<0>>(?=\s*:)/.source,[h]),lookbehind:!0,alias:"punctuation"}}),e.languages.insertBefore("csharp","class-name",{namespace:{pattern:n(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source,[h]),lookbehind:!0,inside:{punctuation:/\./}},"type-expression":{pattern:n(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source,[b]),lookbehind:!0,alias:"class-name",inside:x},"return-type":{pattern:n(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source,[_,m]),inside:x,alias:"class-name"},"constructor-invocation":{pattern:n(/(\bnew\s+)<<0>>(?=\s*[[({])/.source,[_]),lookbehind:!0,inside:x,alias:"class-name"},"generic-method":{pattern:n(/<<0>>\s*<<1>>(?=\s*\()/.source,[h,p]),inside:{function:n(/^<<0>>/.source,[h]),generic:{pattern:RegExp(p),alias:"class-name",inside:x}}},"type-list":{pattern:n(/\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source,[u,f,h,_,c.source,b,/\bnew\s*\(\s*\)/.source]),lookbehind:!0,inside:{"record-arguments":{pattern:n(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source,[f,b]),lookbehind:!0,greedy:!0,inside:e.languages.csharp},keyword:c,"class-name":{pattern:RegExp(_),greedy:!0,inside:x},punctuation:/[,()]/}},preprocessor:{pattern:/(^[\t ]*)#.*/m,lookbehind:!0,alias:"property",inside:{directive:{pattern:/(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,lookbehind:!0,alias:"keyword"}}}});var $=A+"|"+F,z=t(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source,[$]),E=a(t(/[^"'/()]|<<0>>|\(<<self>>*\)/.source,[z]),2),C=/\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source,j=t(/<<0>>(?:\s*\(<<1>>*\))?/.source,[m,E]);e.languages.insertBefore("csharp","class-name",{attribute:{pattern:n(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source,[C,j]),lookbehind:!0,greedy:!0,inside:{target:{pattern:n(/^<<0>>(?=\s*:)/.source,[C]),alias:"keyword"},"attribute-arguments":{pattern:n(/\(<<0>>*\)/.source,[E]),inside:e.languages.csharp},"class-name":{pattern:RegExp(m),inside:{punctuation:/\./}},punctuation:/[:,]/}}});var B=/:[^}\r\n]+/.source,T=a(t(/[^"'/()]|<<0>>|\(<<self>>*\)/.source,[z]),2),O=t(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[T,B]),P=a(t(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source,[$]),2),N=t(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source,[P,B]);function R(t,a){return{interpolation:{pattern:n(/((?:^|[^{])(?:\{\{)*)<<0>>/.source,[t]),lookbehind:!0,inside:{"format-string":{pattern:n(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source,[a,B]),lookbehind:!0,inside:{punctuation:/^:/}},punctuation:/^\{|\}$/,expression:{pattern:/[\s\S]+/,alias:"language-csharp",inside:e.languages.csharp}}},string:/[\s\S]+/}}e.languages.insertBefore("csharp","string",{"interpolation-string":[{pattern:n(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source,[O]),lookbehind:!0,greedy:!0,inside:R(O,T)},{pattern:n(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source,[N]),lookbehind:!0,greedy:!0,inside:R(N,P)}],char:{pattern:RegExp(F),greedy:!0}}),e.languages.dotnet=e.languages.cs=e.languages.csharp}(s),function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|"+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(s),function(e){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,a={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};e.languages.java=e.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[a,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:a.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:a.inside}],keyword:t,function:[e.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0}}),e.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),e.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":a,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:a.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:a.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g,(function(){return t.source}))),lookbehind:!0,inside:{punctuation:/\./}}})}(s),s.languages.javascript=s.languages.extend("clike",{"class-name":[s.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),s.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,s.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:s.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:s.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:s.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:s.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:s.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),s.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:s.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),s.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),s.languages.markup&&(s.languages.markup.tag.addInlined("script","javascript"),s.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),s.languages.js=s.languages.javascript,s.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},s.languages.markup.tag.inside["attr-value"].inside.entity=s.languages.markup.entity,s.languages.markup.doctype.inside["internal-subset"].inside=s.languages.markup,s.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&amp;/,"&"))})),Object.defineProperty(s.languages.markup.tag,"addInlined",{value:function(e,t){var n={};n["language-"+t]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:s.languages[t]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};a["language-"+t]={pattern:/[\s\S]+/,inside:s.languages[t]};var r={};r[e]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,(function(){return e})),"i"),lookbehind:!0,greedy:!0,inside:a},s.languages.insertBefore("markup","cdata",r)}}),Object.defineProperty(s.languages.markup.tag,"addAttribute",{value:function(e,t){s.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:s.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),s.languages.html=s.languages.markup,s.languages.mathml=s.languages.markup,s.languages.svg=s.languages.markup,s.languages.xml=s.languages.extend("markup",{}),s.languages.ssml=s.languages.xml,s.languages.atom=s.languages.xml,s.languages.rss=s.languages.xml,function(e){var t=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,n=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],a=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,s=/<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,r=/[{}\[\](),:;]/;e.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:t,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:a,operator:s,punctuation:r};var i={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:e.languages.php},o=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:i}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:i}}];e.languages.insertBefore("php","variable",{string:o,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:t,string:o,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,number:a,operator:s,punctuation:r}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),e.hooks.add("before-tokenize",(function(t){/<\?/.test(t.code)&&e.languages["markup-templating"].buildPlaceholders(t,"php",/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g)})),e.hooks.add("after-tokenize",(function(t){e.languages["markup-templating"].tokenizePlaceholders(t,"php")}))}(s),s.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},s.languages.python["string-interpolation"].inside.interpolation.inside.rest=s.languages.python,s.languages.py=s.languages.python,function(e){e.languages.ruby=e.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),e.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var t={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:e.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete e.languages.ruby.function;var n="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",a=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;e.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+n+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+a),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+a+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),e.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+n),greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+n),greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete e.languages.ruby.string,e.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),e.languages.rb=e.languages.ruby}(s),window.Prism=a,s}(),i=e=>t=>t.options.get(e),o=i("codesample_languages"),l=i("codesample_global_prismjs"),u=e=>s.Prism&&l(e)?s.Prism:r,c=e=>t(e)&&"PRE"===e.nodeName&&-1!==e.className.indexOf("language-"),d=e=>{const t=e.selection?e.selection.getNode():null;return c(t)?n.some(t):n.none()},g=e=>{const t=(e=>o(e)||[{text:"HTML/XML",value:"markup"},{text:"JavaScript",value:"javascript"},{text:"CSS",value:"css"},{text:"PHP",value:"php"},{text:"Ruby",value:"ruby"},{text:"Python",value:"python"},{text:"Java",value:"java"},{text:"C",value:"c"},{text:"C#",value:"csharp"},{text:"C++",value:"cpp"}])(e),s=(r=t,((e,t)=>0<e.length?n.some(e[0]):n.none())(r)).fold(("",()=>""),(e=>e.value));var r;const i=((e,t)=>d(e).fold((()=>t),(e=>{const n=e.className.match(/language-(\w+)/);return n?n[1]:t})))(e,s),l=(e=>d(e).bind((e=>n.from(e.textContent))).getOr(""))(e);e.windowManager.open({title:"Insert/Edit Code Sample",size:"large",body:{type:"panel",items:[{type:"selectbox",name:"language",label:"Language",items:t},{type:"textarea",name:"code",label:"Code view"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{language:i,code:l},onSubmit:t=>{const n=t.getData();((e,t,n)=>{const s=e.dom;e.undoManager.transact((()=>{const r=d(e);return n=a.DOM.encode(n),r.fold((()=>{e.insertContent('<pre id="__new" class="language-'+t+'">'+n+"</pre>");const a=s.select("#__new")[0];s.setAttrib(a,"id",null),e.selection.select(a)}),(a=>{s.setAttrib(a,"class","language-"+t),a.innerHTML=n,u(e).highlightElement(a),e.selection.select(a)}))}))})(e,n.language,n.code),t.close()}})},p=(b=/^\s+|\s+$/g,e=>e.replace(b,""));var b,h=tinymce.util.Tools.resolve("tinymce.util.Tools");e.add("codesample",(e=>{(e=>{const t=e.options.register;t("codesample_languages",{processor:"object[]"}),t("codesample_global_prismjs",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreProcess",(t=>{const n=e.dom,a=n.select("pre[contenteditable=false]",t.node);h.each(h.grep(a,c),(e=>{const t=e.textContent;let a;for(n.setAttrib(e,"class",p(n.getAttrib(e,"class"))),n.setAttrib(e,"contentEditable",null),n.setAttrib(e,"data-mce-highlighted",null);a=e.firstChild;)e.removeChild(a);n.add(e,"code").textContent=t}))})),e.on("SetContent",(()=>{const t=e.dom,n=h.grep(t.select("pre"),(e=>c(e)&&"true"!==t.getAttrib(e,"data-mce-highlighted")));n.length&&e.undoManager.transact((()=>{h.each(n,(n=>{var a;h.each(t.select("br",n),(n=>{t.replace(e.getDoc().createTextNode("\n"),n)})),n.innerHTML=t.encode(null!==(a=n.textContent)&&void 0!==a?a:""),u(e).highlightElement(n),t.setAttrib(n,"data-mce-highlighted",!0),n.className=p(n.className)}))}))})),e.on("PreInit",(()=>{e.parser.addNodeFilter("pre",(e=>{var t;for(let n=0,a=e.length;n<a;n++){const a=e[n];-1!==(null!==(t=a.attr("class"))&&void 0!==t?t:"").indexOf("language-")&&(a.attr("contenteditable","false"),a.attr("data-mce-highlighted","false"))}}))}))})(e),(e=>{const t=()=>e.execCommand("codesample");e.ui.registry.addToggleButton("codesample",{icon:"code-sample",tooltip:"Insert/edit code sample",onAction:t,onSetup:t=>{const n=()=>{t.setActive((e=>{const t=e.selection.getStart();return e.dom.is(t,'pre[class*="language-"]')})(e))};return e.on("NodeChange",n),()=>e.off("NodeChange",n)}}),e.ui.registry.addMenuItem("codesample",{text:"Code sample...",icon:"code-sample",onAction:t})})(e),(e=>{e.addCommand("codesample",(()=>{const t=e.selection.getNode();e.selection.isCollapsed()||c(t)?g(e):e.formatter.toggle("code")}))})(e),e.on("dblclick",(t=>{c(t.target)&&g(e)}))}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=t=>e=>typeof e===t,o=t=>"string"===(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&(o=r=t,(n=String).prototype.isPrototypeOf(o)||(null===(i=r.constructor)||void 0===i?void 0:i.name)===n.name)?"string":e;var o,r,n,i})(t),r=e("boolean"),n=t=>!(t=>null==t)(t),i=e("function"),s=e("number"),l=(!1,()=>false);class a{constructor(t,e){this.tag=t,this.value=e}static some(t){return new a(!0,t)}static none(){return a.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?a.some(t(this.value)):a.none()}bind(t){return this.tag?t(this.value):a.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:a.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return n(t)?a.some(t):a.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}a.singletonNone=new a(!1);const u=(t,e)=>{for(let o=0,r=t.length;o<r;o++)e(t[o],o)},c=t=>{if(null==t)throw new Error("Node cannot be null or undefined");return{dom:t}},d=c,h=(t,e)=>{const o=t.dom;if(1!==o.nodeType)return!1;{const t=o;if(void 0!==t.matches)return t.matches(e);if(void 0!==t.msMatchesSelector)return t.msMatchesSelector(e);if(void 0!==t.webkitMatchesSelector)return t.webkitMatchesSelector(e);if(void 0!==t.mozMatchesSelector)return t.mozMatchesSelector(e);throw new Error("Browser lacks native selectors")}};"undefined"!=typeof window?window:Function("return this;")();const m=t=>e=>(t=>t.dom.nodeType)(e)===t,g=m(1),f=m(3),v=m(9),p=m(11),y=(t,e)=>{t.dom.removeAttribute(e)},w=i(Element.prototype.attachShadow)&&i(Node.prototype.getRootNode)?t=>d(t.dom.getRootNode()):t=>v(t)?t:d(t.dom.ownerDocument),N=t=>d(t.dom.host),b=t=>{const e=f(t)?t.dom.parentNode:t.dom;if(null==e||null===e.ownerDocument)return!1;const o=e.ownerDocument;return(t=>{const e=w(t);return p(o=e)&&n(o.dom.host)?a.some(e):a.none();var o})(d(e)).fold((()=>o.body.contains(e)),(r=b,i=N,t=>r(i(t))));var r,i},S=t=>"rtl"===((t,e)=>{const o=t.dom,r=window.getComputedStyle(o).getPropertyValue(e);return""!==r||b(t)?r:((t,e)=>(t=>void 0!==t.style&&i(t.style.getPropertyValue))(t)?t.style.getPropertyValue(e):"")(o,e)})(t,"direction")?"rtl":"ltr",A=(t,e)=>((t,o)=>((t,e)=>{const o=[];for(let r=0,n=t.length;r<n;r++){const n=t[r];e(n,r)&&o.push(n)}return o})(((t,e)=>{const o=t.length,r=new Array(o);for(let n=0;n<o;n++){const o=t[n];r[n]=e(o,n)}return r})(t.dom.childNodes,d),(t=>h(t,e))))(t),T=("li",t=>g(t)&&"li"===t.dom.nodeName.toLowerCase());const C=(t,e)=>{const n=t.selection.getSelectedBlocks();n.length>0&&(u(n,(t=>{const n=d(t),c=T(n),m=((t,e)=>{return(e?(o=t,r="ol,ul",((t,e,o)=>{let n=t.dom;const s=i(o)?o:l;for(;n.parentNode;){n=n.parentNode;const t=d(n);if(h(t,r))return a.some(t);if(s(t))break}return a.none()})(o,0,n)):a.some(t)).getOr(t);var o,r,n})(n,c);var f;(f=m,(t=>a.from(t.dom.parentNode).map(d))(f).filter(g)).each((t=>{if(S(t)!==e?((t,e,n)=>{((t,e,n)=>{if(!(o(n)||r(n)||s(n)))throw console.error("Invalid call to Attribute.set. Key ",e,":: Value ",n,":: Element ",t),new Error("Attribute value was not simple");t.setAttribute(e,n+"")})(t.dom,e,n)})(m,"dir",e):S(m)!==e&&y(m,"dir"),c){const t=A(m,"li[dir]");u(t,(t=>y(t,"dir")))}}))})),t.nodeChanged())},D=(t,e)=>o=>{const r=t=>{const r=d(t.element);o.setActive(S(r)===e)};return t.on("NodeChange",r),()=>t.off("NodeChange",r)};t.add("directionality",(t=>{(t=>{t.addCommand("mceDirectionLTR",(()=>{C(t,"ltr")})),t.addCommand("mceDirectionRTL",(()=>{C(t,"rtl")}))})(t),(t=>{t.ui.registry.addToggleButton("ltr",{tooltip:"Left to right",icon:"ltr",onAction:()=>t.execCommand("mceDirectionLTR"),onSetup:D(t,"ltr")}),t.ui.registry.addToggleButton("rtl",{tooltip:"Right to left",icon:"rtl",onAction:()=>t.execCommand("mceDirectionRTL"),onSetup:D(t,"rtl")})})(t)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=t=>e=>t===e,o=e(null),n=e(void 0),s=()=>{},r=()=>!1;class a{constructor(t,e){this.tag=t,this.value=e}static some(t){return new a(!0,t)}static none(){return a.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?a.some(t(this.value)):a.none()}bind(t){return this.tag?t(this.value):a.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:a.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return null==t?a.none():a.some(t)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}a.singletonNone=new a(!1);const i=(t,e)=>{const o=t.length,n=new Array(o);for(let s=0;s<o;s++){const o=t[s];n[s]=e(o,s)}return n},l=t=>{let e=t;return{get:()=>e,set:t=>{e=t}}},c=Object.keys,u=Object.hasOwnProperty,g=(t,e)=>{const o=c(t);for(let n=0,s=o.length;n<s;n++){const s=o[n];e(t[s],s)}},m=(t,e)=>u.call(t,e),h=(d=(t,e)=>e,(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const e={};for(let o=0;o<t.length;o++){const n=t[o];for(const t in n)m(n,t)&&(e[t]=d(e[t],n[t]))}return e});var d;const p=()=>{const t=(t=>{const e=l(a.none()),o=()=>e.get().each(t);return{clear:()=>{o(),e.set(a.none())},isSet:()=>e.get().isSome(),get:()=>e.get(),set:t=>{o(),e.set(a.some(t))}}})(s);return{...t,on:e=>t.get().each(e)}},v=(t,e,o=0,s)=>{const r=t.indexOf(e,o);return-1!==r&&(!!n(s)||r+e.length<=s)};var y=tinymce.util.Tools.resolve("tinymce.Resource");const f=t=>e=>e.options.get(t),b=f("emoticons_database"),w=f("emoticons_database_url"),_=f("emoticons_database_id"),j=f("emoticons_append"),C=f("emoticons_images_url"),k="All",A={symbols:"Symbols",people:"People",animals_and_nature:"Animals and Nature",food_and_drink:"Food and Drink",activity:"Activity",travel_and_places:"Travel and Places",objects:"Objects",flags:"Flags",user:"User Defined"},O=(t,e)=>m(t,e)?t[e]:e,x=t=>{const e=j(t);return o=t=>({keywords:[],category:"user",...t}),((t,e)=>{const o={};return g(t,((t,n)=>{const s=e(t,n);o[s.k]=s.v})),o})(e,((t,e)=>({k:e,v:o(t)})));var o},L=(t,e)=>v(t.title.toLowerCase(),e)||((t,o)=>{for(let o=0,s=t.length;o<s;o++)if(n=t[o],v(n.toLowerCase(),e))return!0;var n;return!1})(t.keywords),T=(t,e,o)=>{const n=[],s=e.toLowerCase(),a=o.fold((()=>r),(t=>e=>e>=t));for(let o=0;o<t.length&&(0!==e.length&&!L(t[o],s)||(n.push({value:t[o].char,text:t[o].title,icon:t[o].char}),!a(n.length)));o++);return n},D="pattern",E=(t,e)=>{const n={pattern:"",results:T(e.listAll(),"",a.some(300))},s=l(k),r=((t,e)=>{let n=null;const s=()=>{o(n)||(clearTimeout(n),n=null)};return{cancel:s,throttle:(...e)=>{s(),n=setTimeout((()=>{n=null,t.apply(null,e)}),200)}}})((t=>{(t=>{const o=t.getData(),n=s.get(),r=e.listCategory(n),i=T(r,o.pattern,n===k?a.some(300):a.none());t.setData({results:i})})(t)})),c={label:"Search",type:"input",name:D},u={type:"collection",name:"results"},g=()=>({title:"Emojis",size:"normal",body:{type:"tabpanel",tabs:i(e.listCategories(),(t=>({title:t,name:t,items:[c,u]})))},initialData:n,onTabChange:(t,e)=>{s.set(e.newTabName),r.throttle(t)},onChange:r.throttle,onAction:(e,o)=>{"results"===o.name&&(((t,e)=>{t.insertContent(e)})(t,o.value),e.close())},buttons:[{type:"cancel",text:"Close",primary:!0}]}),m=t.windowManager.open(g());m.focus(D),e.hasLoaded()||(m.block("Loading emojis..."),e.waitForLoad().then((()=>{m.redial(g()),r.throttle(m),m.focus(D),m.unblock()})).catch((t=>{m.redial({title:"Emojis",body:{type:"panel",items:[{type:"alertbanner",level:"error",icon:"warning",text:"Could not load emojis"}]},buttons:[{type:"cancel",text:"Close",primary:!0}],initialData:{pattern:"",results:[]}}),m.focus(D),m.unblock()})))};t.add("emoticons",((t,e)=>{((t,e)=>{const o=t.options.register;o("emoticons_database",{processor:"string",default:"emojis"}),o("emoticons_database_url",{processor:"string",default:`${e}/js/${b(t)}${t.suffix}.js`}),o("emoticons_database_id",{processor:"string",default:"tinymce.plugins.emoticons"}),o("emoticons_append",{processor:"object",default:{}}),o("emoticons_images_url",{processor:"string",default:"https://twemoji.maxcdn.com/v/13.0.1/72x72/"})})(t,e);const o=((t,e,o)=>{const n=p(),s=p(),r=C(t),i=t=>{return o="<img",(e=t.char).length>=o.length&&e.substr(0,0+o.length)===o?t.char.replace(/src="([^"]+)"/,((t,e)=>`src="${r}${e}"`)):t.char;var e,o};t.on("init",(()=>{y.load(o,e).then((e=>{const o=x(t);(t=>{const e={},o=[];g(t,((t,n)=>{const s={title:n,keywords:t.keywords,char:i(t),category:O(A,t.category)},r=void 0!==e[s.category]?e[s.category]:[];e[s.category]=r.concat([s]),o.push(s)})),n.set(e),s.set(o)})(h(e,o))}),(t=>{console.log(`Failed to load emojis: ${t}`),n.set({}),s.set([])}))}));const l=()=>s.get().getOr([]),u=()=>n.isSet()&&s.isSet();return{listCategories:()=>[k].concat(c(n.get().getOr({}))),hasLoaded:u,waitForLoad:()=>u()?Promise.resolve(!0):new Promise(((t,o)=>{let n=15;const s=setInterval((()=>{u()?(clearInterval(s),t(!0)):(n--,n<0&&(console.log("Could not load emojis from url: "+e),clearInterval(s),o(!1)))}),100)})),listAll:l,listCategory:t=>t===k?l():n.get().bind((e=>a.from(e[t]))).getOr([])}})(t,w(t),_(t));((t,e)=>{t.addCommand("mceEmoticons",(()=>E(t,e)))})(t,o),(t=>{const e=()=>t.execCommand("mceEmoticons");t.ui.registry.addButton("emoticons",{tooltip:"Emojis",icon:"emoji",onAction:e}),t.ui.registry.addMenuItem("emoticons",{text:"Emojis...",icon:"emoji",onAction:e})})(t),((t,e)=>{t.ui.registry.addAutocompleter("emoticons",{trigger:":",columns:"auto",minChars:2,fetch:(t,o)=>e.waitForLoad().then((()=>{const n=e.listAll();return T(n,t,a.some(o))})),onAction:(e,o,n)=>{t.selection.setRng(o),t.insertContent(n),e.hide()}})})(t,o),(t=>{t.on("PreInit",(()=>{t.parser.addAttributeFilter("data-emoticon",(t=>{((t,e)=>{for(let e=0,n=t.length;e<n;e++)(o=t[e]).attr("data-mce-resize","false"),o.attr("data-mce-placeholder","1");var o})(t)}))}))})(t)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";const e=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}};var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const n=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=r=e,(o=String).prototype.isPrototypeOf(n)||(null===(s=r.constructor)||void 0===s?void 0:s.name)===o.name)?"string":t;var n,r,o,s})(t)===e,r=e=>t=>typeof t===e,o=e=>t=>e===t,s=n("string"),i=n("array"),l=o(null),a=r("boolean"),c=o(void 0),u=e=>!(e=>null==e)(e),d=r("function"),m=r("number"),h=()=>{},g=e=>()=>e;function p(e,...t){return(...n)=>{const r=t.concat(n);return e.apply(null,r)}}const f=g(!1),v=g(!0);class w{constructor(e,t){this.tag=e,this.value=t}static some(e){return new w(!0,e)}static none(){return w.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?w.some(e(this.value)):w.none()}bind(e){return this.tag?e(this.value):w.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:w.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return u(e)?w.some(e):w.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}w.singletonNone=new w(!1);const y=t=>{const n=e(w.none()),r=()=>n.get().each(t);return{clear:()=>{r(),n.set(w.none())},isSet:()=>n.get().isSome(),get:()=>n.get(),set:e=>{r(),n.set(w.some(e))}}},b=()=>y((e=>e.unbind())),S=Array.prototype.push,x=(e,t)=>{const n=e.length,r=new Array(n);for(let o=0;o<n;o++){const n=e[o];r[o]=t(n,o)}return r},E=(e,t)=>{for(let n=0,r=e.length;n<r;n++)t(e[n],n)},F=(e,t)=>{const n=[];for(let r=0,o=e.length;r<o;r++){const o=e[r];t(o,r)&&n.push(o)}return n},O=(e,t)=>((e,t,n)=>{for(let r=0,o=e.length;r<o;r++){const o=e[r];if(t(o,r))return w.some(o);if(n(o,r))break}return w.none()})(e,t,f),T=Object.keys,k=(e,t,n=0,r)=>{const o=e.indexOf(t,n);return-1!==o&&(!!c(r)||o+t.length<=r)},C=e=>void 0!==e.style&&d(e.style.getPropertyValue),A=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},R=A;"undefined"!=typeof window?window:Function("return this;")();const L=e=>t=>(e=>e.dom.nodeType)(t)===e,M=L(1),N=L(3),P=L(9),D=L(11),W=(e,t)=>{const n=e.dom;if(1!==n.nodeType)return!1;{const e=n;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},q=e=>R(e.dom.ownerDocument),H=e=>x(e.dom.childNodes,R),I=d(Element.prototype.attachShadow)&&d(Node.prototype.getRootNode),B=g(I),V=I?e=>R(e.dom.getRootNode()):e=>P(e)?e:q(e),_=e=>{const t=V(e);return D(n=t)&&u(n.dom.host)?w.some(t):w.none();var n},j=e=>R(e.dom.host),z=e=>{const t=N(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const n=t.ownerDocument;return _(R(t)).fold((()=>n.body.contains(t)),(r=z,o=j,e=>r(o(e))));var r,o},$=(e,t)=>{const n=e.dom.getAttribute(t);return null===n?void 0:n},U=(e,t)=>{e.dom.removeAttribute(t)},K=(e,t)=>{const n=e.dom;((e,t)=>{const n=T(e);for(let r=0,o=n.length;r<o;r++){const o=n[r];t(e[o],o)}})(t,((e,t)=>{((e,t,n)=>{if(!s(n))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",n,":: Element ",e),new Error("CSS value must be a string: "+n);C(e)&&e.style.setProperty(t,n)})(n,t,e)}))},X=e=>{const t=R((e=>{if(B()&&u(e.target)){const t=R(e.target);if(M(t)&&u(t.dom.shadowRoot)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return((e,t)=>0<e.length?w.some(e[0]):w.none())(t)}}return w.from(e.target)})(e).getOr(e.target)),n=()=>e.stopPropagation(),r=()=>e.preventDefault(),o=(s=r,i=n,(...e)=>s(i.apply(null,e)));var s,i;return((e,t,n,r,o,s,i)=>({target:e,x:t,y:n,stop:r,prevent:o,kill:s,raw:i}))(t,e.clientX,e.clientY,n,r,o,e)},Y=(e,t,n,r)=>{e.dom.removeEventListener(t,n,r)},G=v,J=(e,t,n)=>((e,t,n,r)=>((e,t,n,r,o)=>{const s=((e,t)=>n=>{e(n)&&t(X(n))})(n,r);return e.dom.addEventListener(t,s,o),{unbind:p(Y,e,t,s,o)}})(e,t,n,r,!1))(e,t,G,n),Q=()=>Z(0,0),Z=(e,t)=>({major:e,minor:t}),ee={nu:Z,detect:(e,t)=>{const n=String(t).toLowerCase();return 0===e.length?Q():((e,t)=>{const n=((e,t)=>{for(let n=0;n<e.length;n++){const r=e[n];if(r.test(t))return r}})(e,t);if(!n)return{major:0,minor:0};const r=e=>Number(t.replace(n,"$"+e));return Z(r(1),r(2))})(e,n)},unknown:Q},te=(e,t)=>{const n=String(t).toLowerCase();return O(e,(e=>e.search(n)))},ne=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,re=e=>t=>k(t,e),oe=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>k(e,"edge/")&&k(e,"chrome")&&k(e,"safari")&&k(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ne],search:e=>k(e,"chrome")&&!k(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>k(e,"msie")||k(e,"trident")},{name:"Opera",versionRegexes:[ne,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:re("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:re("firefox")},{name:"Safari",versionRegexes:[ne,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(k(e,"safari")||k(e,"mobile/"))&&k(e,"applewebkit")}],se=[{name:"Windows",search:re("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>k(e,"iphone")||k(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:re("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:re("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:re("linux"),versionRegexes:[]},{name:"Solaris",search:re("sunos"),versionRegexes:[]},{name:"FreeBSD",search:re("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:re("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],ie={browsers:g(oe),oses:g(se)},le="Edge",ae="Chromium",ce="Opera",ue="Firefox",de="Safari",me=e=>{const t=e.current,n=e.version,r=e=>()=>t===e;return{current:t,version:n,isEdge:r(le),isChromium:r(ae),isIE:r("IE"),isOpera:r(ce),isFirefox:r(ue),isSafari:r(de)}},he=()=>me({current:void 0,version:ee.unknown()}),ge=me,pe=(g(le),g(ae),g("IE"),g(ce),g(ue),g(de),"Windows"),fe="Android",ve="Linux",we="macOS",ye="Solaris",be="FreeBSD",Se="ChromeOS",xe=e=>{const t=e.current,n=e.version,r=e=>()=>t===e;return{current:t,version:n,isWindows:r(pe),isiOS:r("iOS"),isAndroid:r(fe),isMacOS:r(we),isLinux:r(ve),isSolaris:r(ye),isFreeBSD:r(be),isChromeOS:r(Se)}},Ee=()=>xe({current:void 0,version:ee.unknown()}),Fe=xe,Oe=(g(pe),g("iOS"),g(fe),g(ve),g(we),g(ye),g(be),g(Se),(e,t,n)=>{const r=ie.browsers(),o=ie.oses(),s=t.bind((e=>((e,t)=>((e,t)=>{for(let n=0;n<e.length;n++){const r=t(e[n]);if(r.isSome())return r}return w.none()})(t.brands,(t=>{const n=t.brand.toLowerCase();return O(e,(e=>{var t;return n===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:ee.nu(parseInt(t.version,10),0)})))})))(r,e))).orThunk((()=>((e,t)=>te(e,t).map((e=>{const n=ee.detect(e.versionRegexes,t);return{current:e.name,version:n}})))(r,e))).fold(he,ge),i=((e,t)=>te(e,t).map((e=>{const n=ee.detect(e.versionRegexes,t);return{current:e.name,version:n}})))(o,e).fold(Ee,Fe),l=((e,t,n,r)=>{const o=e.isiOS()&&!0===/ipad/i.test(n),s=e.isiOS()&&!o,i=e.isiOS()||e.isAndroid(),l=i||r("(pointer:coarse)"),a=o||!s&&i&&r("(min-device-width:768px)"),c=s||i&&!a,u=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(n),d=!c&&!a&&!u;return{isiPad:g(o),isiPhone:g(s),isTablet:g(a),isPhone:g(c),isTouch:g(l),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:g(u),isDesktop:g(d)}})(i,s,e,n);return{browser:s,os:i,deviceType:l}}),Te=e=>window.matchMedia(e).matches;let ke=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e.apply(null,r)),t)})((()=>Oe(navigator.userAgent,w.from(navigator.userAgentData),Te)));const Ce=(e,t)=>({left:e,top:t,translate:(n,r)=>Ce(e+n,t+r)}),Ae=Ce,Re=e=>{const t=void 0===e?window:e;return ke().browser.isFirefox()?w.none():w.from(t.visualViewport)},Le=(e,t,n,r)=>({x:e,y:t,width:n,height:r,right:e+n,bottom:t+r}),Me=e=>{const t=void 0===e?window:e,n=t.document,r=(e=>{const t=void 0!==e?e.dom:document,n=t.body.scrollLeft||t.documentElement.scrollLeft,r=t.body.scrollTop||t.documentElement.scrollTop;return Ae(n,r)})(R(n));return Re(t).fold((()=>{const e=t.document.documentElement,n=e.clientWidth,o=e.clientHeight;return Le(r.left,r.top,n,o)}),(e=>Le(Math.max(e.pageLeft,r.left),Math.max(e.pageTop,r.top),e.width,e.height)))},Ne=(e,t,n)=>Re(n).map((n=>{const r=e=>t(X(e));return n.addEventListener(e,r),{unbind:()=>n.removeEventListener(e,r)}})).getOrThunk((()=>({unbind:h})));var Pe=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),De=tinymce.util.Tools.resolve("tinymce.Env");const We=(e,t)=>{e.dispatch("FullscreenStateChanged",{state:t}),e.dispatch("ResizeEditor")},qe=("fullscreen_native",e=>e.options.get("fullscreen_native"));const He=e=>{return e.dom===(void 0!==(t=q(e).dom).fullscreenElement?t.fullscreenElement:void 0!==t.msFullscreenElement?t.msFullscreenElement:void 0!==t.webkitFullscreenElement?t.webkitFullscreenElement:null);var t},Ie=(e,t,n)=>((e,t,n)=>F(((e,t)=>{const n=d(t)?t:f;let r=e.dom;const o=[];for(;null!==r.parentNode&&void 0!==r.parentNode;){const e=r.parentNode,t=R(e);if(o.push(t),!0===n(t))break;r=e}return o})(e,n),t))(e,(e=>W(e,t)),n),Be=(e,t)=>((e,n)=>{return F((e=>w.from(e.dom.parentNode).map(R))(r=e).map(H).map((e=>F(e,(e=>{return t=e,!(r.dom===t.dom);var t})))).getOr([]),(e=>W(e,t)));var r})(e),Ve="data-ephox-mobile-fullscreen-style",_e="position:absolute!important;",je="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;",ze=De.os.isAndroid(),$e=e=>{const t=((e,t)=>{const n=e.dom,r=window.getComputedStyle(n).getPropertyValue(t);return""!==r||z(e)?r:((e,t)=>C(e)?e.style.getPropertyValue(t):"")(n,t)})(e,"background-color");return void 0!==t&&""!==t?"background-color:"+t+"!important":"background-color:rgb(255,255,255)!important;"},Ue=Pe.DOM,Ke=Re().fold((()=>({bind:h,unbind:h})),(e=>{const t=(()=>{const e=y(h);return{...e,on:t=>e.get().each(t)}})(),n=b(),r=b(),o=((e,t)=>{let n=null;return{cancel:()=>{l(n)||(clearTimeout(n),n=null)},throttle:(...t)=>{l(n)&&(n=setTimeout((()=>{n=null,e.apply(null,t)}),50))}}})((()=>{document.body.scrollTop=0,document.documentElement.scrollTop=0,window.requestAnimationFrame((()=>{t.on((t=>K(t,{top:e.offsetTop+"px",left:e.offsetLeft+"px",height:e.height+"px",width:e.width+"px"})))}))}));return{bind:e=>{t.set(e),o.throttle(),n.set(Ne("resize",o.throttle)),r.set(Ne("scroll",o.throttle))},unbind:()=>{t.on((()=>{n.clear(),r.clear()})),t.clear()}}})),Xe=(e,t)=>{const n=document.body,r=document.documentElement,o=e.getContainer(),l=R(o),c=(e=>{const t=R(e.getElement());return _(t).map(j).getOrThunk((()=>(e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return R(t)})(q(t))))})(e),u=t.get(),d=R(e.getBody()),h=De.deviceType.isTouch(),g=o.style,p=e.iframeElement,f=null==p?void 0:p.style,v=e=>{e(n,"tox-fullscreen"),e(r,"tox-fullscreen"),e(o,"tox-fullscreen"),_(l).map((e=>j(e).dom)).each((t=>{e(t,"tox-fullscreen"),e(t,"tox-shadowhost")}))},y=()=>{h&&(e=>{const t=((e,t)=>{const n=document;return 1!==(r=n).nodeType&&9!==r.nodeType&&11!==r.nodeType||0===r.childElementCount?[]:x(n.querySelectorAll(e),R);var r})("["+Ve+"]");E(t,(t=>{const n=$(t,Ve);n&&"no-styles"!==n?K(t,e.parseStyle(n)):U(t,"style"),U(t,Ve)}))})(e.dom),v(Ue.removeClass),Ke.unbind(),w.from(t.get()).each((e=>e.fullscreenChangeHandler.unbind()))};if(u)u.fullscreenChangeHandler.unbind(),qe(e)&&He(c)&&(e=>{const t=e.dom;t.exitFullscreen?t.exitFullscreen():t.msExitFullscreen?t.msExitFullscreen():t.webkitCancelFullScreen&&t.webkitCancelFullScreen()})(q(c)),f.width=u.iframeWidth,f.height=u.iframeHeight,g.width=u.containerWidth,g.height=u.containerHeight,g.top=u.containerTop,g.left=u.containerLeft,y(),b=u.scrollPos,window.scrollTo(b.x,b.y),t.set(null),We(e,!1),e.off("remove",y);else{const n=J(q(c),void 0!==document.fullscreenElement?"fullscreenchange":void 0!==document.msFullscreenElement?"MSFullscreenChange":void 0!==document.webkitFullscreenElement?"webkitfullscreenchange":"fullscreenchange",(n=>{qe(e)&&(He(c)||null===t.get()||Xe(e,t))})),r={scrollPos:Me(window),containerWidth:g.width,containerHeight:g.height,containerTop:g.top,containerLeft:g.left,iframeWidth:f.width,iframeHeight:f.height,fullscreenChangeHandler:n};h&&((e,t,n)=>{const r=t=>n=>{const r=$(n,"style"),o=void 0===r?"no-styles":r.trim();o!==t&&(((e,t,n)=>{((e,t,n)=>{if(!(s(n)||a(n)||m(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")})(e.dom,t,n)})(n,Ve,o),K(n,e.parseStyle(t)))},o=Ie(t,"*"),l=(e=>{const t=[];for(let n=0,r=e.length;n<r;++n){if(!i(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);S.apply(t,e[n])}return t})(x(o,(e=>Be(e,"*:not(.tox-silver-sink)")))),c=$e(n);E(l,r("display:none!important;")),E(o,r(_e+je+c)),r((!0===ze?"":_e)+je+c)(t)})(e.dom,l,d),f.width=f.height="100%",g.width=g.height="",v(Ue.addClass),Ke.bind(l),e.on("remove",y),t.set(r),qe(e)&&(e=>{const t=e.dom;t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.webkitRequestFullScreen&&t.webkitRequestFullScreen()})(c),We(e,!0)}var b},Ye=(e,t)=>n=>{n.setActive(null!==t.get());const r=e=>n.setActive(e.state);return e.on("FullscreenStateChanged",r),()=>e.off("FullscreenStateChanged",r)};t.add("fullscreen",(t=>{const n=e(null);return t.inline||((e=>{(0,e.options.register)("fullscreen_native",{processor:"boolean",default:!1})})(t),((e,t)=>{e.addCommand("mceFullScreen",(()=>{Xe(e,t)}))})(t,n),((e,t)=>{const n=()=>e.execCommand("mceFullScreen");e.ui.registry.addToggleMenuItem("fullscreen",{text:"Fullscreen",icon:"fullscreen",shortcut:"Meta+Shift+F",onAction:n,onSetup:Ye(e,t)}),e.ui.registry.addToggleButton("fullscreen",{tooltip:"Fullscreen",icon:"fullscreen",onAction:n,onSetup:Ye(e,t)})})(t,n),t.addShortcut("Meta+Shift+F","","mceFullScreen")),(e=>({isFullscreen:()=>null!==e.get()}))(n)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");let t=0;const n=e=>{const n=(new Date).getTime(),a=Math.floor(1e9*Math.random());return t++,e+"_"+a+t+String(n)},a=e=>t=>t.options.get(e),o=a("help_tabs"),i=a("forced_plugins"),r=("string",e=>"string"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=a=e,(o=String).prototype.isPrototypeOf(n)||(null===(i=a.constructor)||void 0===i?void 0:i.name)===o.name)?"string":t;var n,a,o,i})(e));const s=(void 0,e=>undefined===e);const l=e=>"function"==typeof e,c=(!1,()=>false);class u{constructor(e,t){this.tag=e,this.value=t}static some(e){return new u(!0,e)}static none(){return u.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?u.some(e(this.value)):u.none()}bind(e){return this.tag?e(this.value):u.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:u.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return null==e?u.none():u.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}u.singletonNone=new u(!1);const m=Array.prototype.slice,h=Array.prototype.indexOf,p=(e,t)=>{const n=e.length,a=new Array(n);for(let o=0;o<n;o++){const n=e[o];a[o]=t(n,o)}return a},d=(e,t)=>{const n=[];for(let a=0,o=e.length;a<o;a++){const o=e[a];t(o,a)&&n.push(o)}return n},g=(e,t)=>{const n=m.call(e,0);return n.sort(t),n},y=Object.keys,b=Object.hasOwnProperty,k=(e,t)=>b.call(e,t);var v=tinymce.util.Tools.resolve("tinymce.Env");const f=e=>{const t=v.os.isMacOS()||v.os.isiOS(),n=t?{alt:"&#x2325;",ctrl:"&#x2303;",shift:"&#x21E7;",meta:"&#x2318;",access:"&#x2303;&#x2325;"}:{meta:"Ctrl ",access:"Shift + Alt "},a=e.split("+"),o=p(a,(e=>{const t=e.toLowerCase().trim();return k(n,t)?n[t]:e}));return t?o.join("").replace(/\s/,""):o.join("+")},w=[{shortcuts:["Meta + B"],action:"Bold"},{shortcuts:["Meta + I"],action:"Italic"},{shortcuts:["Meta + U"],action:"Underline"},{shortcuts:["Meta + A"],action:"Select all"},{shortcuts:["Meta + Y","Meta + Shift + Z"],action:"Redo"},{shortcuts:["Meta + Z"],action:"Undo"},{shortcuts:["Access + 1"],action:"Heading 1"},{shortcuts:["Access + 2"],action:"Heading 2"},{shortcuts:["Access + 3"],action:"Heading 3"},{shortcuts:["Access + 4"],action:"Heading 4"},{shortcuts:["Access + 5"],action:"Heading 5"},{shortcuts:["Access + 6"],action:"Heading 6"},{shortcuts:["Access + 7"],action:"Paragraph"},{shortcuts:["Access + 8"],action:"Div"},{shortcuts:["Access + 9"],action:"Address"},{shortcuts:["Alt + 0"],action:"Open help dialog"},{shortcuts:["Alt + F9"],action:"Focus to menubar"},{shortcuts:["Alt + F10"],action:"Focus to toolbar"},{shortcuts:["Alt + F11"],action:"Focus to element path"},{shortcuts:["Ctrl + F9"],action:"Focus to contextual toolbar"},{shortcuts:["Shift + Enter"],action:"Open popup menu for split buttons"},{shortcuts:["Meta + K"],action:"Insert link (if link plugin activated)"},{shortcuts:["Meta + S"],action:"Save (if save plugin activated)"},{shortcuts:["Meta + F"],action:"Find (if searchreplace plugin activated)"},{shortcuts:["Meta + Shift + F"],action:"Switch to or from fullscreen mode"}],A=()=>({name:"shortcuts",title:"Handy Shortcuts",items:[{type:"table",header:["Action","Shortcut"],cells:p(w,(e=>{const t=p(e.shortcuts,f).join(" or ");return[e.action,t]}))}]});var x=tinymce.util.Tools.resolve("tinymce.util.I18n");const T=p([{key:"advlist",name:"Advanced List"},{key:"anchor",name:"Anchor"},{key:"autolink",name:"Autolink"},{key:"autoresize",name:"Autoresize"},{key:"autosave",name:"Autosave"},{key:"charmap",name:"Character Map"},{key:"code",name:"Code"},{key:"codesample",name:"Code Sample"},{key:"colorpicker",name:"Color Picker"},{key:"directionality",name:"Directionality"},{key:"emoticons",name:"Emoticons"},{key:"fullscreen",name:"Full Screen"},{key:"help",name:"Help"},{key:"image",name:"Image"},{key:"importcss",name:"Import CSS"},{key:"insertdatetime",name:"Insert Date/Time"},{key:"link",name:"Link"},{key:"lists",name:"Lists"},{key:"media",name:"Media"},{key:"nonbreaking",name:"Nonbreaking"},{key:"pagebreak",name:"Page Break"},{key:"preview",name:"Preview"},{key:"quickbars",name:"Quick Toolbars"},{key:"save",name:"Save"},{key:"searchreplace",name:"Search and Replace"},{key:"table",name:"Table"},{key:"template",name:"Template"},{key:"textcolor",name:"Text Color"},{key:"visualblocks",name:"Visual Blocks"},{key:"visualchars",name:"Visual Characters"},{key:"wordcount",name:"Word Count"},{key:"a11ychecker",name:"Accessibility Checker",type:"premium"},{key:"advcode",name:"Advanced Code Editor",type:"premium"},{key:"advtable",name:"Advanced Tables",type:"premium"},{key:"casechange",name:"Case Change",type:"premium"},{key:"checklist",name:"Checklist",type:"premium"},{key:"editimage",name:"Enhanced Image Editing",type:"premium"},{key:"footnotes",name:"Footnotes",type:"premium"},{key:"typography",name:"Advanced Typography",type:"premium"},{key:"mediaembed",name:"Enhanced Media Embed",type:"premium",slug:"introduction-to-mediaembed"},{key:"export",name:"Export",type:"premium"},{key:"formatpainter",name:"Format Painter",type:"premium"},{key:"inlinecss",name:"Inline CSS",type:"premium"},{key:"linkchecker",name:"Link Checker",type:"premium"},{key:"mentions",name:"Mentions",type:"premium"},{key:"mergetags",name:"Merge Tags",type:"premium"},{key:"pageembed",name:"Page Embed",type:"premium"},{key:"permanentpen",name:"Permanent Pen",type:"premium"},{key:"powerpaste",name:"PowerPaste",type:"premium",slug:"introduction-to-powerpaste"},{key:"rtc",name:"Real-Time Collaboration",type:"premium",slug:"rtc-introduction"},{key:"tinymcespellchecker",name:"Spell Checker Pro",type:"premium",slug:"introduction-to-tiny-spellchecker"},{key:"autocorrect",name:"Spelling Autocorrect",type:"premium"},{key:"tableofcontents",name:"Table of Contents",type:"premium"},{key:"tinycomments",name:"Tiny Comments",type:"premium",slug:"introduction-to-tiny-comments"},{key:"tinydrive",name:"Tiny Drive",type:"premium",slug:"tinydrive-introduction"}],(e=>({...e,type:e.type||"opensource",slug:e.slug||e.key}))),C=e=>{const t=e=>`<a href="${e.url}" target="_blank" rel="noopener">${e.name}</a>`,n=(e,n)=>{return(a=T,o=e=>e.key===n,((e,t,n)=>{for(let a=0,o=e.length;a<o;a++){const o=e[a];if(t(o,a))return u.some(o);if(n(o,a))break}return u.none()})(a,o,c)).fold((()=>((e,n)=>{const a=e.plugins[n].getMetadata;if(l(a)){const e=a();return{name:e.name,html:t(e)}}return{name:n,html:n}})(e,n)),(e=>{const n="premium"===e.type?`${e.name}*`:e.name;return{name:n,html:t({name:n,url:`https://www.tiny.cloud/docs/tinymce/6/${e.slug}/`})}}));var a,o},a=e=>{const t=(e=>{const t=y(e.plugins),n=i(e);return s(n)?t:d(t,(e=>!(((e,t)=>h.call(e,t))(n,e)>-1)))})(e),a=g(p(t,(t=>n(e,t))),((e,t)=>e.name.localeCompare(t.name))),o=p(a,(e=>"<li>"+e.html+"</li>")),r=o.length,l=o.join("");return"<p><b>"+x.translate(["Plugins installed ({0}):",r])+"</b></p><ul>"+l+"</ul>"},o={type:"htmlpanel",presets:"document",html:[(e=>null==e?"":'<div data-mce-tabstop="1" tabindex="-1">'+a(e)+"</div>")(e),(()=>{const e=d(T,(({type:e})=>"premium"===e)),t=g(p(e,(e=>e.name)),((e,t)=>e.localeCompare(t))),n=p(t,(e=>`<li>${e}</li>`)).join("");return'<div data-mce-tabstop="1" tabindex="-1"><p><b>'+x.translate("Premium plugins:")+"</b></p><ul>"+n+'<li class="tox-help__more-link" "><a href="https://www.tiny.cloud/pricing/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" rel="noopener" target="_blank">'+x.translate("Learn more...")+"</a></li></ul></div>"})()].join("")};return{name:"plugins",title:"Plugins",items:[o]}};var M=tinymce.util.Tools.resolve("tinymce.EditorManager");const S=(e,t)=>()=>{const{tabs:a,names:i}=((e,t)=>{const a=A(),i={name:"keyboardnav",title:"Keyboard Navigation",items:[{type:"htmlpanel",presets:"document",html:"<h1>Editor UI keyboard navigation</h1>\n\n<h2>Activating keyboard navigation</h2>\n\n<p>The sections of the outer UI of the editor - the menubar, toolbar, sidebar and footer - are all keyboard navigable. As such, there are multiple ways to activate keyboard navigation:</p>\n<ul>\n  <li>Focus the menubar: Alt + F9 (Windows) or &#x2325;F9 (MacOS)</li>\n  <li>Focus the toolbar: Alt + F10 (Windows) or &#x2325;F10 (MacOS)</li>\n  <li>Focus the footer: Alt + F11 (Windows) or &#x2325;F11 (MacOS)</li>\n</ul>\n\n<p>Focusing the menubar or toolbar will start keyboard navigation at the first item in the menubar or toolbar, which will be highlighted with a gray background. Focusing the footer will start keyboard navigation at the first item in the element path, which will be highlighted with an underline. </p>\n\n<h2>Moving between UI sections</h2>\n\n<p>When keyboard navigation is active, pressing tab will move the focus to the next major section of the UI, where applicable. These sections are:</p>\n<ul>\n  <li>the menubar</li>\n  <li>each group of the toolbar </li>\n  <li>the sidebar</li>\n  <li>the element path in the footer </li>\n  <li>the wordcount toggle button in the footer </li>\n  <li>the branding link in the footer </li>\n  <li>the editor resize handle in the footer</li>\n</ul>\n\n<p>Pressing shift + tab will move backwards through the same sections, except when moving from the footer to the toolbar. Focusing the element path then pressing shift + tab will move focus to the first toolbar group, not the last.</p>\n\n<h2>Moving within UI sections</h2>\n\n<p>Keyboard navigation within UI sections can usually be achieved using the left and right arrow keys. This includes:</p>\n<ul>\n  <li>moving between menus in the menubar</li>\n  <li>moving between buttons in a toolbar group</li>\n  <li>moving between items in the element path</li>\n</ul>\n\n<p>In all these UI sections, keyboard navigation will cycle within the section. For example, focusing the last button in a toolbar group then pressing right arrow will move focus to the first item in the same toolbar group. </p>\n\n<h1>Executing buttons</h1>\n\n<p>To execute a button, navigate the selection to the desired button and hit space or enter.</p>\n\n<h1>Opening, navigating and closing menus</h1>\n\n<p>When focusing a menubar button or a toolbar button with a menu, pressing space, enter or down arrow will open the menu. When the menu opens the first item will be selected. To move up or down the menu, press the up or down arrow key respectively. This is the same for submenus, which can also be opened and closed using the left and right arrow keys.</p>\n\n<p>To close any active menu, hit the escape key. When a menu is closed the selection will be restored to its previous selection. This also works for closing submenus.</p>\n\n<h1>Context toolbars and menus</h1>\n\n<p>To focus an open context toolbar such as the table context toolbar, press Ctrl + F9 (Windows) or &#x2303;F9 (MacOS).</p>\n\n<p>Context toolbar navigation is the same as toolbar navigation, and context menu navigation is the same as standard menu navigation.</p>\n\n<h1>Dialog navigation</h1>\n\n<p>There are two types of dialog UIs in TinyMCE: tabbed dialogs and non-tabbed dialogs.</p>\n\n<p>When a non-tabbed dialog is opened, the first interactive component in the dialog will be focused. Users can navigate between interactive components by pressing tab. This includes any footer buttons. Navigation will cycle back to the first dialog component if tab is pressed while focusing the last component in the dialog. Pressing shift + tab will navigate backwards.</p>\n\n<p>When a tabbed dialog is opened, the first button in the tab menu is focused. Pressing tab will navigate to the first interactive component in that tab, and will cycle through the tab\u2019s components, the footer buttons, then back to the tab button. To switch to another tab, focus the tab button for the current tab, then use the arrow keys to cycle through the tab buttons.</p>"}]},s=C(e),l=(()=>{var e,t;const n='<a href="https://www.tiny.cloud/docs/tinymce/6/changelog/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" rel="noopener" target="_blank">TinyMCE '+(e=M.majorVersion,t=M.minorVersion,(0===e.indexOf("@")?"X.X.X":e+"."+t)+"</a>");return{name:"versions",title:"Version",items:[{type:"htmlpanel",html:"<p>"+x.translate(["You are using {0}",n])+"</p>",presets:"document"}]}})(),c={[a.name]:a,[i.name]:i,[s.name]:s,[l.name]:l,...t.get()};return u.from(o(e)).fold((()=>(e=>{const t=y(e),n=t.indexOf("versions");return-1!==n&&(t.splice(n,1),t.push("versions")),{tabs:e,names:t}})(c)),(e=>((e,t)=>{const a={},o=p(e,(e=>{var o;if(r(e))return k(t,e)&&(a[e]=t[e]),e;{const t=null!==(o=e.name)&&void 0!==o?o:n("tab-name");return a[t]=e,t}}));return{tabs:a,names:o}})(e,c)))})(e,t),s={type:"tabpanel",tabs:(e=>{const t=[],n=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(n);return t})(p(i,(e=>{return k(t=a,n=e)?u.from(t[n]):u.none();var t,n})))};e.windowManager.open({title:"Help",size:"medium",body:s,buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}],initialData:{}})};e.add("help",(e=>{const t=(e=>{let t={};return{get:()=>t,set:e=>{t=e}}})(),a=(e=>({addTab:t=>{var a;const o=null!==(a=t.name)&&void 0!==a?a:n("tab-name"),i=e.get();i[o]=t,e.set(i)}}))(t);(e=>{(0,e.options.register)("help_tabs",{processor:"array"})})(e);const o=S(e,t);return((e,t)=>{e.ui.registry.addButton("help",{icon:"help",tooltip:"Help",onAction:t}),e.ui.registry.addMenuItem("help",{text:"Help",icon:"help",shortcut:"Alt+0",onAction:t})})(e,o),((e,t)=>{e.addCommand("mceHelp",t)})(e,o),e.shortcuts.add("Alt+0","Open help dialog","mceHelp"),a}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=Object.getPrototypeOf,a=(e,t,a)=>{var i;return!!a(e,t.prototype)||(null===(i=e.constructor)||void 0===i?void 0:i.name)===t.name},i=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&a(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":t})(t)===e,s=e=>t=>typeof t===e,r=i("string"),o=i("object"),n=e=>((e,i)=>o(e)&&a(e,i,((e,a)=>t(e)===a)))(e,Object),l=i("array"),c=(null,e=>null===e);const m=s("boolean"),d=e=>!(e=>null==e)(e),g=s("function"),u=s("number"),p=()=>{};class h{constructor(e,t){this.tag=e,this.value=t}static some(e){return new h(!0,e)}static none(){return h.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?h.some(e(this.value)):h.none()}bind(e){return this.tag?e(this.value):h.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:h.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return d(e)?h.some(e):h.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}h.singletonNone=new h(!1);const b=Object.keys,v=Object.hasOwnProperty,y=(e,t)=>v.call(e,t),f=Array.prototype.push,w=e=>{const t=[];for(let a=0,i=e.length;a<i;++a){if(!l(e[a]))throw new Error("Arr.flatten item "+a+" was not an array, input: "+e);f.apply(t,e[a])}return t};"undefined"!=typeof window?window:Function("return this;")();const A=(e,t,a)=>{((e,t,a)=>{if(!(r(a)||m(a)||u(a)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",a,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,a+"")})(e.dom,t,a)},D=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},_=D;var C=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),I=tinymce.util.Tools.resolve("tinymce.util.URI");const U=e=>e.length>0,x=e=>t=>t.options.get(e),S=x("image_dimensions"),N=x("image_advtab"),T=x("image_uploadtab"),O=x("image_prepend_url"),L=x("image_class_list"),E=x("image_description"),j=x("image_title"),M=x("image_caption"),R=x("image_list"),k=x("a11y_advanced_options"),z=x("automatic_uploads"),P=(e,t)=>Math.max(parseInt(e,10),parseInt(t,10)),B=e=>(e&&(e=e.replace(/px$/,"")),e),F=e=>(e.length>0&&/^[0-9]+$/.test(e)&&(e+="px"),e),H=e=>"IMG"===e.nodeName&&(e.hasAttribute("data-mce-object")||e.hasAttribute("data-mce-placeholder")),G=(e,t)=>{const a=e.options.get;return I.isDomSafe(t,"img",{allow_html_data_urls:a("allow_html_data_urls"),allow_script_urls:a("allow_script_urls"),allow_svg_data_urls:a("allow_svg_data_urls")})},W=C.DOM,$=e=>e.style.marginLeft&&e.style.marginRight&&e.style.marginLeft===e.style.marginRight?B(e.style.marginLeft):"",V=e=>e.style.marginTop&&e.style.marginBottom&&e.style.marginTop===e.style.marginBottom?B(e.style.marginTop):"",K=e=>e.style.borderWidth?B(e.style.borderWidth):"",Z=(e,t)=>{var a;return e.hasAttribute(t)&&null!==(a=e.getAttribute(t))&&void 0!==a?a:""},q=e=>null!==e.parentNode&&"FIGURE"===e.parentNode.nodeName,J=(e,t,a)=>{""===a||null===a?e.removeAttribute(t):e.setAttribute(t,a)},Q=(e,t)=>{const a=e.getAttribute("style"),i=t(null!==a?a:"");i.length>0?(e.setAttribute("style",i),e.setAttribute("data-mce-style",i)):e.removeAttribute("style")},X=(e,t)=>(e,a,i)=>{const s=e.style;s[a]?(s[a]=F(i),Q(e,t)):J(e,a,i)},Y=(e,t)=>e.style[t]?B(e.style[t]):Z(e,t),ee=(e,t)=>{const a=F(t);e.style.marginLeft=a,e.style.marginRight=a},te=(e,t)=>{const a=F(t);e.style.marginTop=a,e.style.marginBottom=a},ae=(e,t)=>{const a=F(t);e.style.borderWidth=a},ie=(e,t)=>{e.style.borderStyle=t},se=e=>{var t;return null!==(t=e.style.borderStyle)&&void 0!==t?t:""},re=e=>d(e)&&"FIGURE"===e.nodeName,oe=e=>0===W.getAttrib(e,"alt").length&&"presentation"===W.getAttrib(e,"role"),ne=e=>oe(e)?"":Z(e,"alt"),le=(e,t)=>{var a;const i=document.createElement("img");return J(i,"style",t.style),($(i)||""!==t.hspace)&&ee(i,t.hspace),(V(i)||""!==t.vspace)&&te(i,t.vspace),(K(i)||""!==t.border)&&ae(i,t.border),(se(i)||""!==t.borderStyle)&&ie(i,t.borderStyle),e(null!==(a=i.getAttribute("style"))&&void 0!==a?a:"")},ce=(e,t)=>({src:Z(t,"src"),alt:ne(t),title:Z(t,"title"),width:Y(t,"width"),height:Y(t,"height"),class:Z(t,"class"),style:e(Z(t,"style")),caption:q(t),hspace:$(t),vspace:V(t),border:K(t),borderStyle:se(t),isDecorative:oe(t)}),me=(e,t,a,i,s)=>{a[i]!==t[i]&&s(e,i,String(a[i]))},de=(e,t,a)=>{if(a){W.setAttrib(e,"role","presentation");const t=_(e);A(t,"alt","")}else{if(c(t)){"alt",_(e).dom.removeAttribute("alt")}else{const a=_(e);A(a,"alt",t)}"presentation"===W.getAttrib(e,"role")&&W.setAttrib(e,"role","")}},ge=(e,t)=>(a,i,s)=>{e(a,s),Q(a,t)},ue=(e,t,a)=>{const i=ce(e,a);me(a,i,t,"caption",((e,t,a)=>(e=>{q(e)?(e=>{const t=e.parentNode;d(t)&&(W.insertAfter(e,t),W.remove(t))})(e):(e=>{const t=W.create("figure",{class:"image"});W.insertAfter(t,e),t.appendChild(e),t.appendChild(W.create("figcaption",{contentEditable:"true"},"Caption")),t.contentEditable="false"})(e)})(e))),me(a,i,t,"src",J),me(a,i,t,"title",J),me(a,i,t,"width",X(0,e)),me(a,i,t,"height",X(0,e)),me(a,i,t,"class",J),me(a,i,t,"style",ge(((e,t)=>J(e,"style",t)),e)),me(a,i,t,"hspace",ge(ee,e)),me(a,i,t,"vspace",ge(te,e)),me(a,i,t,"border",ge(ae,e)),me(a,i,t,"borderStyle",ge(ie,e)),((e,t,a)=>{a.alt===t.alt&&a.isDecorative===t.isDecorative||de(e,a.alt,a.isDecorative)})(a,i,t)},pe=(e,t)=>{const a=(e=>{if(e.margin){const t=String(e.margin).split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e})(e.dom.styles.parse(t)),i=e.dom.styles.parse(e.dom.styles.serialize(a));return e.dom.styles.serialize(i)},he=e=>{const t=e.selection.getNode(),a=e.dom.getParent(t,"figure.image");return a?e.dom.select("img",a)[0]:t&&("IMG"!==t.nodeName||H(t))?null:t},be=(e,t)=>{var a;const i=e.dom,s=((t,a)=>{const i={};var s;return((e,t,a,i)=>{((e,t)=>{const a=b(e);for(let i=0,s=a.length;i<s;i++){const s=a[i];t(e[s],s)}})(e,((e,s)=>{(t(e,s)?a:i)(e,s)}))})(t,((t,a)=>!e.schema.isValidChild(a,"figure")),(s=i,(e,t)=>{s[t]=e}),p),i})(e.schema.getTextBlockElements()),r=i.getParent(t.parentNode,(e=>{return t=s,a=e.nodeName,y(t,a)&&void 0!==t[a]&&null!==t[a];var t,a}),e.getBody());return r&&null!==(a=i.split(r,t))&&void 0!==a?a:t},ve=(e,t)=>{const a=((t,a)=>{const i=document.createElement("img");if(ue((t=>pe(e,t)),{...a,caption:!1},i),de(i,a.alt,a.isDecorative),a.caption){const e=W.create("figure",{class:"image"});return e.appendChild(i),e.appendChild(W.create("figcaption",{contentEditable:"true"},"Caption")),e.contentEditable="false",e}return i})(0,t);e.dom.setAttrib(a,"data-mce-id","__mcenew"),e.focus(),e.selection.setContent(a.outerHTML);const i=e.dom.select('*[data-mce-id="__mcenew"]')[0];if(e.dom.setAttrib(i,"data-mce-id",null),re(i)){const t=be(e,i);e.selection.select(t)}else e.selection.select(i)},ye=(e,t)=>{const a=he(e);if(a){const i={...ce((t=>pe(e,t)),a),...t},s=((e,t)=>{const a=t.src;return{...t,src:G(e,a)?a:""}})(e,i);i.src?((e,t)=>{const a=he(e);if(a)if(ue((t=>pe(e,t)),t,a),((e,t)=>{e.dom.setAttrib(t,"src",t.getAttribute("src"))})(e,a),re(a.parentNode)){const t=a.parentNode;be(e,t),e.selection.select(a.parentNode)}else e.selection.select(a),((e,t,a)=>{const i=()=>{a.onload=a.onerror=null,e.selection&&(e.selection.select(a),e.nodeChanged())};a.onload=()=>{t.width||t.height||!S(e)||e.dom.setAttribs(a,{width:String(a.clientWidth),height:String(a.clientHeight)}),i()},a.onerror=i})(e,t,a)})(e,s):((e,t)=>{if(t){const a=e.dom.is(t.parentNode,"figure.image")?t.parentNode:t;e.dom.remove(a),e.focus(),e.nodeChanged(),e.dom.isEmpty(e.getBody())&&(e.setContent(""),e.selection.setCursorLocation())}})(e,a)}else t.src&&ve(e,{src:"",alt:"",title:"",width:"",height:"",class:"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:"",isDecorative:!1,...t})},fe=(we=(e,t)=>n(e)&&n(t)?fe(e,t):t,(...e)=>{if(0===e.length)throw new Error("Can't merge zero objects");const t={};for(let a=0;a<e.length;a++){const i=e[a];for(const e in i)y(i,e)&&(t[e]=we(t[e],i[e]))}return t});var we,Ae=tinymce.util.Tools.resolve("tinymce.util.ImageUploader"),De=tinymce.util.Tools.resolve("tinymce.util.Tools");const _e=e=>r(e.value)?e.value:"",Ce=(e,t)=>{const a=[];return De.each(e,(e=>{const i=(e=>r(e.text)?e.text:r(e.title)?e.title:"")(e);if(void 0!==e.menu){const s=Ce(e.menu,t);a.push({text:i,items:s})}else{const s=t(e);a.push({text:i,value:s})}})),a},Ie=(e=_e)=>t=>t?h.from(t).map((t=>Ce(t,e))):h.none(),Ue=(e,t)=>((e,a)=>{for(let a=0;a<e.length;a++){const s=(e=>y(e,"items"))(i=e[a])?Ue(i.items,t):i.value===t?h.some(i):h.none();if(s.isSome())return s}var i;return h.none()})(e),xe=Ie,Se=(e,t)=>e.bind((e=>Ue(e,t))),Ne=e=>{const t=xe((t=>e.convertURL(t.value||t.url||"","src"))),a=new Promise((a=>{((e,t)=>{const a=R(e);r(a)?fetch(a).then((e=>{e.ok&&e.json().then(t)})):g(a)?a(t):t(a)})(e,(e=>{a(t(e).map((e=>w([[{text:"None",value:""}],e]))))}))})),i=(A=L(e),Ie(_e)(A)),s=N(e),o=T(e),n=(e=>U(e.options.get("images_upload_url")))(e),l=(e=>d(e.options.get("images_upload_handler")))(e),c=(e=>{const t=he(e);return t?ce((t=>pe(e,t)),t):{src:"",alt:"",title:"",width:"",height:"",class:"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:"",isDecorative:!1}})(e),m=E(e),u=j(e),p=S(e),b=M(e),v=k(e),y=z(e),f=h.some(O(e)).filter((e=>r(e)&&e.length>0));var A;return a.then((e=>({image:c,imageList:e,classList:i,hasAdvTab:s,hasUploadTab:o,hasUploadUrl:n,hasUploadHandler:l,hasDescription:m,hasImageTitle:u,hasDimensions:p,hasImageCaption:b,prependURL:f,hasAccessibilityOptions:v,automaticUploads:y})))},Te=e=>{const t=e.imageList.map((e=>({name:"images",type:"listbox",label:"Image list",items:e}))),a={name:"alt",type:"input",label:"Alternative description",enabled:!(e.hasAccessibilityOptions&&e.image.isDecorative)},i=e.classList.map((e=>({name:"classes",type:"listbox",label:"Class",items:e})));return w([[{name:"src",type:"urlinput",filetype:"image",label:"Source"}],t.toArray(),e.hasAccessibilityOptions&&e.hasDescription?[{type:"label",label:"Accessibility",items:[{name:"isDecorative",type:"checkbox",label:"Image is decorative"}]}]:[],e.hasDescription?[a]:[],e.hasImageTitle?[{name:"title",type:"input",label:"Image title"}]:[],e.hasDimensions?[{name:"dimensions",type:"sizeinput"}]:[],[{...(s=e.classList.isSome()&&e.hasImageCaption,s?{type:"grid",columns:2}:{type:"panel"}),items:w([i.toArray(),e.hasImageCaption?[{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[]])}]]);var s},Oe=e=>({title:"General",name:"general",items:Te(e)}),Le=Te,Ee=e=>({src:{value:e.src,meta:{}},images:e.src,alt:e.alt,title:e.title,dimensions:{width:e.width,height:e.height},classes:e.class,caption:e.caption,style:e.style,vspace:e.vspace,border:e.border,hspace:e.hspace,borderstyle:e.borderStyle,fileinput:[],isDecorative:e.isDecorative}),je=(e,t)=>({src:e.src.value,alt:null!==e.alt&&0!==e.alt.length||!t?e.alt:null,title:e.title,width:e.dimensions.width,height:e.dimensions.height,class:e.classes,style:e.style,caption:e.caption,hspace:e.hspace,vspace:e.vspace,border:e.border,borderStyle:e.borderstyle,isDecorative:e.isDecorative}),Me=(e,t,a,i)=>{((e,t)=>{const a=t.getData();((e,t)=>/^(?:[a-zA-Z]+:)?\/\//.test(t)?h.none():e.prependURL.bind((e=>t.substring(0,e.length)!==e?h.some(e+t):h.none())))(e,a.src.value).each((e=>{t.setData({src:{value:e,meta:a.src.meta}})}))})(t,i),((e,t)=>{const a=t.getData(),i=a.src.meta;if(void 0!==i){const s=fe({},a);((e,t,a)=>{e.hasDescription&&r(a.alt)&&(t.alt=a.alt),e.hasAccessibilityOptions&&(t.isDecorative=a.isDecorative||t.isDecorative||!1),e.hasImageTitle&&r(a.title)&&(t.title=a.title),e.hasDimensions&&(r(a.width)&&(t.dimensions.width=a.width),r(a.height)&&(t.dimensions.height=a.height)),r(a.class)&&Se(e.classList,a.class).each((e=>{t.classes=e.value})),e.hasImageCaption&&m(a.caption)&&(t.caption=a.caption),e.hasAdvTab&&(r(a.style)&&(t.style=a.style),r(a.vspace)&&(t.vspace=a.vspace),r(a.border)&&(t.border=a.border),r(a.hspace)&&(t.hspace=a.hspace),r(a.borderstyle)&&(t.borderstyle=a.borderstyle))})(e,s,i),t.setData(s)}})(t,i),((e,t,a,i)=>{const s=i.getData(),r=s.src.value,o=s.src.meta||{};o.width||o.height||!t.hasDimensions||(U(r)?e.imageSize(r).then((e=>{a.open&&i.setData({dimensions:e})})).catch((e=>console.error(e))):i.setData({dimensions:{width:"",height:""}}))})(e,t,a,i),((e,t,a)=>{const i=a.getData(),s=Se(e.imageList,i.src.value);t.prevImage=s,a.setData({images:s.map((e=>e.value)).getOr("")})})(t,a,i)},Re=(e,t,a,i)=>{const s=i.getData();var r;i.block("Uploading image"),(r=s.fileinput,((e,t)=>0<e.length?h.some(e[0]):h.none())(r)).fold((()=>{i.unblock()}),(s=>{const r=URL.createObjectURL(s),o=()=>{i.unblock(),URL.revokeObjectURL(r)},n=s=>{i.setData({src:{value:s,meta:{}}}),i.showTab("general"),Me(e,t,a,i)};var l;(l=s,new Promise(((e,t)=>{const a=new FileReader;a.onload=()=>{e(a.result)},a.onerror=()=>{var e;t(null===(e=a.error)||void 0===e?void 0:e.message)},a.readAsDataURL(l)}))).then((a=>{const l=e.createBlobCache(s,r,a);t.automaticUploads?e.uploadImage(l).then((e=>{n(e.url),o()})).catch((t=>{o(),e.alertErr(t)})):(e.addToBlobCache(l),n(l.blobUri()),i.unblock())}))}))},ke=(e,t,a)=>(i,s)=>{"src"===s.name?Me(e,t,a,i):"images"===s.name?((e,t,a,i)=>{const s=i.getData(),r=Se(t.imageList,s.images);r.each((e=>{const t=""===s.alt||a.prevImage.map((e=>e.text===s.alt)).getOr(!1);t?""===e.value?i.setData({src:e,alt:a.prevAlt}):i.setData({src:e,alt:e.text}):i.setData({src:e})})),a.prevImage=r,Me(e,t,a,i)})(e,t,a,i):"alt"===s.name?a.prevAlt=i.getData().alt:"fileinput"===s.name?Re(e,t,a,i):"isDecorative"===s.name&&i.setEnabled("alt",!i.getData().isDecorative)},ze=e=>()=>{e.open=!1},Pe=e=>e.hasAdvTab||e.hasUploadUrl||e.hasUploadHandler?{type:"tabpanel",tabs:w([[Oe(e)],e.hasAdvTab?[{title:"Advanced",name:"advanced",items:[{type:"grid",columns:2,items:[{type:"input",label:"Vertical space",name:"vspace",inputMode:"numeric"},{type:"input",label:"Horizontal space",name:"hspace",inputMode:"numeric"},{type:"input",label:"Border width",name:"border",inputMode:"numeric"},{type:"listbox",name:"borderstyle",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"}]}]}]}]:[],e.hasUploadTab&&(e.hasUploadUrl||e.hasUploadHandler)?[{title:"Upload",name:"upload",items:[{type:"dropzone",name:"fileinput"}]}]:[]])}:{type:"panel",items:Le(e)},Be=(e,t,a)=>i=>{const s=fe(Ee(t.image),i.getData()),r={...s,style:le(a.normalizeCss,je(s,!1))};e.execCommand("mceUpdateImage",!1,je(r,t.hasAccessibilityOptions)),e.editorUpload.uploadImagesAuto(),i.close()},Fe=e=>t=>G(e,t)?(e=>new Promise((t=>{const a=document.createElement("img"),i=e=>{a.onload=a.onerror=null,a.parentNode&&a.parentNode.removeChild(a),t(e)};a.onload=()=>{const e={width:P(a.width,a.clientWidth),height:P(a.height,a.clientHeight)};i(Promise.resolve(e))},a.onerror=()=>{i(Promise.reject(`Failed to get image dimensions for: ${e}`))};const s=a.style;s.visibility="hidden",s.position="fixed",s.bottom=s.left="0px",s.width=s.height="auto",document.body.appendChild(a),a.src=e})))(e.documentBaseURI.toAbsolute(t)).then((e=>({width:String(e.width),height:String(e.height)}))):Promise.resolve({width:"",height:""}),He=e=>(t,a,i)=>{var s;return e.editorUpload.blobCache.create({blob:t,blobUri:a,name:null===(s=t.name)||void 0===s?void 0:s.replace(/\.[^\.]+$/,""),filename:t.name,base64:i.split(",")[1]})},Ge=e=>t=>{e.editorUpload.blobCache.add(t)},We=e=>t=>{e.windowManager.alert(t)},$e=e=>t=>pe(e,t),Ve=e=>t=>e.dom.parseStyle(t),Ke=e=>(t,a)=>e.dom.serializeStyle(t,a),Ze=e=>t=>Ae(e).upload([t],!1).then((e=>{var t;return 0===e.length?Promise.reject("Failed to upload image"):!1===e[0].status?Promise.reject(null===(t=e[0].error)||void 0===t?void 0:t.message):e[0]})),qe=e=>{const t={imageSize:Fe(e),addToBlobCache:Ge(e),createBlobCache:He(e),alertErr:We(e),normalizeCss:$e(e),parseStyle:Ve(e),serializeStyle:Ke(e),uploadImage:Ze(e)};return{open:()=>{Ne(e).then((a=>{const i=(e=>({prevImage:Se(e.imageList,e.image.src),prevAlt:e.image.alt,open:!0}))(a);return{title:"Insert/Edit Image",size:"normal",body:Pe(a),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:Ee(a.image),onSubmit:Be(e,a,t),onChange:ke(t,a,i),onClose:ze(i)}})).then(e.windowManager.open)}}},Je=e=>{const t=e.attr("class");return d(t)&&/\bimage\b/.test(t)},Qe=e=>t=>{let a=t.length;const i=t=>{t.attr("contenteditable",e?"true":null)};for(;a--;){const s=t[a];Je(s)&&(s.attr("contenteditable",e?"false":null),De.each(s.getAll("figcaption"),i))}};e.add("image",(e=>{(e=>{const t=e.options.register;t("image_dimensions",{processor:"boolean",default:!0}),t("image_advtab",{processor:"boolean",default:!1}),t("image_uploadtab",{processor:"boolean",default:!0}),t("image_prepend_url",{processor:"string",default:""}),t("image_class_list",{processor:"object[]"}),t("image_description",{processor:"boolean",default:!0}),t("image_title",{processor:"boolean",default:!1}),t("image_caption",{processor:"boolean",default:!1}),t("image_list",{processor:e=>{const t=!1===e||r(e)||((e,t)=>{if(l(e)){for(let a=0,i=e.length;a<i;++a)if(!t(e[a]))return!1;return!0}return!1})(e,o)||g(e);return t?{value:e,valid:t}:{valid:!1,message:"Must be false, a string, an array or a function."}},default:!1})})(e),(e=>{e.on("PreInit",(()=>{e.parser.addNodeFilter("figure",Qe(!0)),e.serializer.addNodeFilter("figure",Qe(!1))}))})(e),(e=>{e.ui.registry.addToggleButton("image",{icon:"image",tooltip:"Insert/edit image",onAction:qe(e).open,onSetup:t=>(t.setActive(d(he(e))),e.selection.selectorChangedWithUnbind("img:not([data-mce-object]):not([data-mce-placeholder]),figure.image",t.setActive).unbind)}),e.ui.registry.addMenuItem("image",{icon:"image",text:"Image...",onAction:qe(e).open}),e.ui.registry.addContextMenu("image",{update:e=>re(e)||"IMG"===e.nodeName&&!H(e)?["image"]:[]})})(e),(e=>{e.addCommand("mceImage",qe(e).open),e.addCommand("mceUpdateImage",((t,a)=>{e.undoManager.transact((()=>ye(e,a)))}))})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(s=r=e,(o=String).prototype.isPrototypeOf(s)||(null===(n=r.constructor)||void 0===n?void 0:n.name)===o.name)?"string":t;var s,r,o,n})(t)===e,s=t("string"),r=t("object"),o=t("array"),n=("function",e=>"function"==typeof e);var c=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),i=tinymce.util.Tools.resolve("tinymce.EditorManager"),l=tinymce.util.Tools.resolve("tinymce.Env"),a=tinymce.util.Tools.resolve("tinymce.util.Tools");const p=e=>t=>t.options.get(e),u=p("importcss_merge_classes"),m=p("importcss_exclusive"),f=p("importcss_selector_converter"),y=p("importcss_selector_filter"),d=p("importcss_groups"),h=p("importcss_append"),_=p("importcss_file_filter"),g=p("skin"),v=p("skin_url"),b=Array.prototype.push,x=/^\.(?:ephox|tiny-pageembed|mce)(?:[.-]+\w+)+$/,T=e=>s(e)?t=>-1!==t.indexOf(e):e instanceof RegExp?t=>e.test(t):e,S=(e,t)=>{let s={};const r=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(t);if(!r)return;const o=r[1],n=r[2].substr(1).split(".").join(" "),c=a.makeMap("a,img");return r[1]?(s={title:t},e.schema.getTextBlockElements()[o]?s.block=o:e.schema.getBlockElements()[o]||c[o.toLowerCase()]?s.selector=o:s.inline=o):r[2]&&(s={inline:"span",title:t.substr(1),classes:n}),u(e)?s.classes=n:s.attributes={class:n},s},k=(e,t)=>null===t||m(e),w=e=>{e.on("init",(()=>{const t=(()=>{const e=[],t=[],s={};return{addItemToGroup:(e,r)=>{s[e]?s[e].push(r):(t.push(e),s[e]=[r])},addItem:t=>{e.push(t)},toFormats:()=>{return(r=t,n=e=>{const t=s[e];return 0===t.length?[]:[{title:e,items:t}]},(e=>{const t=[];for(let s=0,r=e.length;s<r;++s){if(!o(e[s]))throw new Error("Arr.flatten item "+s+" was not an array, input: "+e);b.apply(t,e[s])}return t})(((e,t)=>{const s=e.length,r=new Array(s);for(let o=0;o<s;o++){const s=e[o];r[o]=t(s,o)}return r})(r,n))).concat(e);var r,n}}})(),r={},n=T(y(e)),p=(e=>a.map(e,(e=>a.extend({},e,{original:e,selectors:{},filter:T(e.filter)}))))(d(e)),u=(t,s)=>{if(((e,t,s,r)=>!(k(e,s)?t in r:t in s.selectors))(e,t,s,r)){((e,t,s,r)=>{k(e,s)?r[t]=!0:s.selectors[t]=!0})(e,t,s,r);const o=((e,t,s,r)=>{let o;const n=f(e);return o=r&&r.selector_converter?r.selector_converter:n||(()=>S(e,s)),o.call(t,s,r)})(e,e.plugins.importcss,t,s);if(o){const t=o.name||c.DOM.uniqueId();return e.formatter.register(t,o),{title:o.title,format:t}}}return null};a.each(((e,t,r)=>{const o=[],n={},c=(t,n)=>{let p,u=t.href;if(u=(e=>{const t=l.cacheSuffix;return s(e)&&(e=e.replace("?"+t,"").replace("&"+t,"")),e})(u),u&&(!r||r(u,n))&&!((e,t)=>{const s=g(e);if(s){const r=v(e),o=r?e.documentBaseURI.toAbsolute(r):i.baseURL+"/skins/ui/"+s,n=i.baseURL+"/skins/content/";return t===o+"/content"+(e.inline?".inline":"")+".min.css"||-1!==t.indexOf(n)}return!1})(e,u)){a.each(t.imports,(e=>{c(e,!0)}));try{p=t.cssRules||t.rules}catch(e){}a.each(p,(e=>{e.styleSheet?c(e.styleSheet,!0):e.selectorText&&a.each(e.selectorText.split(","),(e=>{o.push(a.trim(e))}))}))}};a.each(e.contentCSS,(e=>{n[e]=!0})),r||(r=(e,t)=>t||n[e]);try{a.each(t.styleSheets,(e=>{c(e)}))}catch(e){}return o})(e,e.getDoc(),T(_(e))),(e=>{if(!x.test(e)&&(!n||n(e))){const s=((e,t)=>a.grep(e,(e=>!e.filter||e.filter(t))))(p,e);if(s.length>0)a.each(s,(s=>{const r=u(e,s);r&&t.addItemToGroup(s.title,r)}));else{const s=u(e,null);s&&t.addItem(s)}}}));const m=t.toFormats();e.dispatch("addStyleModifications",{items:m,replace:!h(e)})}))};e.add("importcss",(e=>((e=>{const t=e.options.register,o=e=>s(e)||n(e)||r(e);t("importcss_merge_classes",{processor:"boolean",default:!0}),t("importcss_exclusive",{processor:"boolean",default:!0}),t("importcss_selector_converter",{processor:"function"}),t("importcss_selector_filter",{processor:o}),t("importcss_file_filter",{processor:o}),t("importcss_groups",{processor:"object[]"}),t("importcss_append",{processor:"boolean",default:!1})})(e),w(e),(e=>({convertSelectorToFormat:t=>S(e,t)}))(e))))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>t.options.get(e),a=t("insertdatetime_dateformat"),r=t("insertdatetime_timeformat"),n=t("insertdatetime_formats"),s=t("insertdatetime_element"),i="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),o="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),l="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),m="January February March April May June July August September October November December".split(" "),c=(e,t)=>{if((e=""+e).length<t)for(let a=0;a<t-e.length;a++)e="0"+e;return e},d=(e,t,a=new Date)=>(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("%D","%m/%d/%Y")).replace("%r","%I:%M:%S %p")).replace("%Y",""+a.getFullYear())).replace("%y",""+a.getYear())).replace("%m",c(a.getMonth()+1,2))).replace("%d",c(a.getDate(),2))).replace("%H",""+c(a.getHours(),2))).replace("%M",""+c(a.getMinutes(),2))).replace("%S",""+c(a.getSeconds(),2))).replace("%I",""+((a.getHours()+11)%12+1))).replace("%p",a.getHours()<12?"AM":"PM")).replace("%B",""+e.translate(m[a.getMonth()]))).replace("%b",""+e.translate(l[a.getMonth()]))).replace("%A",""+e.translate(o[a.getDay()]))).replace("%a",""+e.translate(i[a.getDay()]))).replace("%%","%"),u=(e,t)=>{if(s(e)){const a=d(e,t);let r;r=/%[HMSIp]/.test(t)?d(e,"%Y-%m-%dT%H:%M"):d(e,"%Y-%m-%d");const n=e.dom.getParent(e.selection.getStart(),"time");n?((e,t,a,r)=>{const n=e.dom.create("time",{datetime:a},r);e.dom.replace(n,t),e.selection.select(n,!0),e.selection.collapse(!1)})(e,n,r,a):e.insertContent('<time datetime="'+r+'">'+a+"</time>")}else e.insertContent(d(e,t))};var p=tinymce.util.Tools.resolve("tinymce.util.Tools");e.add("insertdatetime",(e=>{(e=>{const t=e.options.register;t("insertdatetime_dateformat",{processor:"string",default:e.translate("%Y-%m-%d")}),t("insertdatetime_timeformat",{processor:"string",default:e.translate("%H:%M:%S")}),t("insertdatetime_formats",{processor:"string[]",default:["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"]}),t("insertdatetime_element",{processor:"boolean",default:!1})})(e),(e=>{e.addCommand("mceInsertDate",((t,r)=>{u(e,null!=r?r:a(e))})),e.addCommand("mceInsertTime",((t,a)=>{u(e,null!=a?a:r(e))}))})(e),(e=>{const t=n(e),a=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})((e=>{const t=n(e);return t.length>0?t[0]:r(e)})(e)),s=t=>e.execCommand("mceInsertDate",!1,t);e.ui.registry.addSplitButton("insertdatetime",{icon:"insert-time",tooltip:"Insert date/time",select:e=>e===a.get(),fetch:a=>{a(p.map(t,(t=>({type:"choiceitem",text:d(e,t),value:t}))))},onAction:e=>{s(a.get())},onItemAction:(e,t)=>{a.set(t),s(t)}});const i=e=>()=>{a.set(e),s(e)};e.ui.registry.addNestedMenuItem("insertdatetime",{icon:"insert-time",text:"Date/time",getSubmenuItems:()=>p.map(t,(t=>({type:"menuitem",text:d(e,t),onAction:i(t)})))})})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=o=e,(r=String).prototype.isPrototypeOf(n)||(null===(l=o.constructor)||void 0===l?void 0:l.name)===r.name)?"string":t;var n,o,r,l})(t)===e,n=e=>t=>typeof t===e,o=t("string"),r=t("object"),l=t("array"),a=(null,e=>null===e);const i=n("boolean"),s=e=>!(e=>null==e)(e),c=n("function"),u=(e,t)=>{if(l(e)){for(let n=0,o=e.length;n<o;++n)if(!t(e[n]))return!1;return!0}return!1},g=()=>{},d=(e,t)=>e===t;class m{constructor(e,t){this.tag=e,this.value=t}static some(e){return new m(!0,e)}static none(){return m.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?m.some(e(this.value)):m.none()}bind(e){return this.tag?e(this.value):m.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:m.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return s(e)?m.some(e):m.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}m.singletonNone=new m(!1);const h=Array.prototype.indexOf,f=Array.prototype.push,p=e=>{const t=[];for(let n=0,o=e.length;n<o;++n){if(!l(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);f.apply(t,e[n])}return t},k=(e,t)=>{for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o.isSome())return o}return m.none()},v=(e,t,n=d)=>e.exists((e=>n(e,t))),y=e=>{const t=[],n=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(n);return t},x=(e,t)=>e?m.some(t):m.none(),b=e=>t=>t.options.get(e),_=b("link_assume_external_targets"),w=b("link_context_toolbar"),C=b("link_list"),O=b("link_default_target"),N=b("link_default_protocol"),A=b("link_target_list"),S=b("link_rel_list"),T=b("link_class_list"),E=b("link_title"),P=b("allow_unsafe_link_target"),R=b("link_quicklink");var L=tinymce.util.Tools.resolve("tinymce.util.Tools");const M=e=>o(e.value)?e.value:"",D=(e,t)=>{const n=[];return L.each(e,(e=>{const r=(e=>o(e.text)?e.text:o(e.title)?e.title:"")(e);if(void 0!==e.menu){const o=D(e.menu,t);n.push({text:r,items:o})}else{const o=t(e);n.push({text:r,value:o})}})),n},B=(e=M)=>t=>m.from(t).map((t=>D(t,e))),I=e=>B(M)(e),j=B,K=(e,t)=>n=>({name:e,type:"listbox",label:t,items:n}),U=M,q=Object.keys,F=Object.hasOwnProperty,V=(e,t)=>F.call(e,t);var $=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),z=tinymce.util.Tools.resolve("tinymce.util.URI");const G=e=>s(e)&&"a"===e.nodeName.toLowerCase(),H=e=>G(e)&&!!Q(e),J=(e,t)=>{if(e.collapsed)return[];{const n=e.cloneContents(),o=n.firstChild,r=new $(o,n),l=[];let a=o;do{t(a)&&l.push(a)}while(a=r.next());return l}},W=e=>/^\w+:/i.test(e),Q=e=>{var t,n;return null!==(n=null!==(t=e.getAttribute("data-mce-href"))&&void 0!==t?t:e.getAttribute("href"))&&void 0!==n?n:""},X=(e,t)=>{const n=["noopener"],o=e?e.split(/\s+/):[],r=e=>e.filter((e=>-1===L.inArray(n,e))),l=t?(e=>(e=r(e)).length>0?e.concat(n):n)(o):r(o);return l.length>0?(e=>L.trim(e.sort().join(" ")))(l):""},Y=(e,t)=>(t=t||e.selection.getNode(),oe(t)?m.from(e.dom.select("a[href]",t)[0]):m.from(e.dom.getParent(t,"a[href]"))),Z=(e,t)=>Y(e,t).isSome(),ee=(e,t)=>t.fold((()=>e.getContent({format:"text"})),(e=>e.innerText||e.textContent||"")).replace(/\uFEFF/g,""),te=e=>L.grep(e,H).length>0,ne=e=>{const t=e.schema.getTextInlineElements();if(Y(e).exists((e=>e.hasAttribute("data-mce-block"))))return!1;const n=e.selection.getRng();return!!n.collapsed||0===J(n,(e=>1===e.nodeType&&!G(e)&&!V(t,e.nodeName.toLowerCase()))).length},oe=e=>s(e)&&"FIGURE"===e.nodeName&&/\bimage\b/i.test(e.className),re=(e,t,n)=>{const o=e.selection.getNode(),r=Y(e,o),l=((e,t)=>{const n={...t};if(0===S(e).length&&!P(e)){const e=X(n.rel,"_blank"===n.target);n.rel=e||null}return m.from(n.target).isNone()&&!1===A(e)&&(n.target=O(e)),n.href=((e,t)=>"http"!==t&&"https"!==t||W(e)?e:t+"://"+e)(n.href,_(e)),n})(e,(e=>{return t=["title","rel","class","target"],n=(t,n)=>(e[n].each((e=>{t[n]=e.length>0?e:null})),t),o={href:e.href},((e,t)=>{for(let n=0,o=e.length;n<o;n++)t(e[n],n)})(t,((e,t)=>{o=n(o,e)})),o;var t,n,o})(n));e.undoManager.transact((()=>{n.href===t.href&&t.attach(),r.fold((()=>{((e,t,n,o)=>{const r=e.dom;oe(t)?ce(r,t,o):n.fold((()=>{e.execCommand("mceInsertLink",!1,o)}),(t=>{e.insertContent(r.createHTML("a",o,r.encode(t)))}))})(e,o,n.text,l)}),(t=>{e.focus(),((e,t,n,o)=>{n.each((e=>{V(t,"innerText")?t.innerText=e:t.textContent=e})),e.dom.setAttribs(t,o),e.selection.select(t)})(e,t,n.text,l)}))}))},le=e=>{const{class:t,href:n,rel:o,target:r,text:l,title:i}=e;return((e,t)=>{const n={};var o;return((e,t,n,o)=>{((e,t)=>{const n=q(e);for(let o=0,r=n.length;o<r;o++){const r=n[o];t(e[r],r)}})(e,((e,r)=>{(t(e,r)?n:o)(e,r)}))})(e,((e,t)=>!1===a(e)),(o=n,(e,t)=>{o[t]=e}),g),n})({class:t.getOrNull(),href:n,rel:o.getOrNull(),target:r.getOrNull(),text:l.getOrNull(),title:i.getOrNull()})},ae=(e,t,n)=>{const o=((e,t)=>{const n=e.options.get,o={allow_html_data_urls:n("allow_html_data_urls"),allow_script_urls:n("allow_script_urls"),allow_svg_data_urls:n("allow_svg_data_urls")},r=t.href;return{...t,href:z.isDomSafe(r,"a",o)?r:""}})(e,n);e.hasPlugin("rtc",!0)?e.execCommand("createlink",!1,le(o)):re(e,t,o)},ie=e=>{e.hasPlugin("rtc",!0)?e.execCommand("unlink"):(e=>{e.undoManager.transact((()=>{const t=e.selection.getNode();oe(t)?se(e,t):(e=>{const t=e.dom,n=e.selection,o=n.getBookmark(),r=n.getRng().cloneRange(),l=t.getParent(r.startContainer,"a[href]",e.getBody()),a=t.getParent(r.endContainer,"a[href]",e.getBody());l&&r.setStartBefore(l),a&&r.setEndAfter(a),n.setRng(r),e.execCommand("unlink"),n.moveToBookmark(o)})(e),e.focus()}))})(e)},se=(e,t)=>{var n;const o=e.dom.select("img",t)[0];if(o){const r=e.dom.getParents(o,"a[href]",t)[0];r&&(null===(n=r.parentNode)||void 0===n||n.insertBefore(o,r),e.dom.remove(r))}},ce=(e,t,n)=>{var o;const r=e.select("img",t)[0];if(r){const t=e.create("a",n);null===(o=r.parentNode)||void 0===o||o.insertBefore(t,r),t.appendChild(r)}},ue=(e,t)=>k(t,(t=>(e=>{return V(t=e,n="items")&&void 0!==t[n]&&null!==t[n];var t,n})(t)?ue(e,t.items):x(t.value===e,t))),ge=(e,t)=>{const n={text:e.text,title:e.title},o=(e,o)=>{const r=(l=t,a=o,"link"===a?l.link:"anchor"===a?l.anchor:m.none()).getOr([]);var l,a;return((e,t,n,o)=>{const r=o[t],l=e.length>0;return void 0!==r?ue(r,n).map((t=>({url:{value:t.value,meta:{text:l?e:t.text,attach:g}},text:l?e:t.text}))):m.none()})(n.text,o,r,e)};return{onChange:(e,t)=>{const r=t.name;return"url"===r?(e=>{const t=(o=e.url,x(n.text.length<=0,m.from(null===(r=o.meta)||void 0===r?void 0:r.text).getOr(o.value)));var o,r;const l=(e=>{var t;return x(n.title.length<=0,m.from(null===(t=e.meta)||void 0===t?void 0:t.title).getOr(""))})(e.url);return t.isSome()||l.isSome()?m.some({...t.map((e=>({text:e}))).getOr({}),...l.map((e=>({title:e}))).getOr({})}):m.none()})(e()):((e,t)=>h.call(e,t))(["anchor","link"],r)>-1?o(e(),r):"text"===r||"title"===r?(n[r]=e()[r],m.none()):m.none()}}};var de=tinymce.util.Tools.resolve("tinymce.util.Delay");const me=e=>{const t=e.href;return t.indexOf("@")>0&&-1===t.indexOf("/")&&-1===t.indexOf("mailto:")?m.some({message:"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",preprocess:e=>({...e,href:"mailto:"+t})}):m.none()},he=(e,t)=>n=>{const o=n.href;return 1===e&&!W(o)||0===e&&/^\s*www(\.|\d\.)/i.test(o)?m.some({message:`The URL you entered seems to be an external link. Do you want to add the required ${t}:// prefix?`,preprocess:e=>({...e,href:t+"://"+o})}):m.none()},fe=e=>{const t=e.dom.select("a:not([href])"),n=p(((e,t)=>{const n=e.length,o=new Array(n);for(let r=0;r<n;r++){const n=e[r];o[r]=t(n,r)}return o})(t,(e=>{const t=e.name||e.id;return t?[{text:t,value:"#"+t}]:[]})));return n.length>0?m.some([{text:"None",value:""}].concat(n)):m.none()},pe=e=>{const t=T(e);return t.length>0?I(t):m.none()},ke=e=>{try{return m.some(JSON.parse(e))}catch(e){return m.none()}},ve=(e,t)=>{const n=S(e);if(n.length>0){const o=v(t,"_blank"),r=e=>X(U(e),o);return(!1===P(e)?j(r):I)(n)}return m.none()},ye=[{text:"Current window",value:""},{text:"New window",value:"_blank"}],xe=e=>{const t=A(e);return l(t)?I(t).orThunk((()=>m.some(ye))):!1===t?m.none():m.some(ye)},be=(e,t,n)=>{const o=e.getAttrib(t,n);return null!==o&&o.length>0?m.some(o):m.none()},_e=(e,t)=>(e=>{const t=t=>e.convertURL(t.value||t.url||"","href"),n=C(e);return new Promise((e=>{o(n)?fetch(n).then((e=>e.ok?e.text().then(ke):Promise.reject())).then(e,(()=>e(m.none()))):c(n)?n((t=>e(m.some(t)))):e(m.from(n))})).then((e=>e.bind(j(t)).map((e=>e.length>0?[{text:"None",value:""}].concat(e):e))))})(e).then((n=>{const o=((e,t)=>{const n=e.dom,o=ne(e)?m.some(ee(e.selection,t)):m.none(),r=t.bind((e=>m.from(n.getAttrib(e,"href")))),l=t.bind((e=>m.from(n.getAttrib(e,"target")))),a=t.bind((e=>be(n,e,"rel"))),i=t.bind((e=>be(n,e,"class")));return{url:r,text:o,title:t.bind((e=>be(n,e,"title"))),target:l,rel:a,linkClass:i}})(e,t);return{anchor:o,catalogs:{targets:xe(e),rels:ve(e,o.target),classes:pe(e),anchor:fe(e),link:n},optNode:t,flags:{titleEnabled:E(e)}}})),we=e=>{const t=(e=>{const t=Y(e);return _e(e,t)})(e);t.then((t=>{const n=((e,t)=>n=>{const o=n.getData();if(!o.url.value)return ie(e),void n.close();const r=e=>m.from(o[e]).filter((n=>!v(t.anchor[e],n))),l={href:o.url.value,text:r("text"),target:r("target"),rel:r("rel"),class:r("linkClass"),title:r("title")},a={href:o.url.value,attach:void 0!==o.url.meta&&o.url.meta.attach?o.url.meta.attach:g};((e,t)=>k([me,he(_(e),N(e))],(e=>e(t))).fold((()=>Promise.resolve(t)),(n=>new Promise((o=>{((e,t,n)=>{const o=e.selection.getRng();de.setEditorTimeout(e,(()=>{e.windowManager.confirm(t,(t=>{e.selection.setRng(o),n(t)}))}))})(e,n.message,(e=>{o(e?n.preprocess(t):t)}))})))))(e,l).then((t=>{ae(e,a,t)})),n.close()})(e,t);return((e,t,n)=>{const o=e.anchor.text.map((()=>({name:"text",type:"input",label:"Text to display"}))).toArray(),r=e.flags.titleEnabled?[{name:"title",type:"input",label:"Title"}]:[],l=((e,t)=>{const n=e.anchor,o=n.url.getOr("");return{url:{value:o,meta:{original:{value:o}}},text:n.text.getOr(""),title:n.title.getOr(""),anchor:o,link:o,rel:n.rel.getOr(""),target:n.target.or(t).getOr(""),linkClass:n.linkClass.getOr("")}})(e,m.from(O(n))),a=e.catalogs,i=ge(l,a);return{title:"Insert/Edit Link",size:"normal",body:{type:"panel",items:p([[{name:"url",type:"urlinput",filetype:"file",label:"URL"}],o,r,y([a.anchor.map(K("anchor","Anchors")),a.rels.map(K("rel","Rel")),a.targets.map(K("target","Open link in...")),a.link.map(K("link","Link list")),a.classes.map(K("linkClass","Class"))])])},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:l,onChange:(e,{name:t})=>{i.onChange(e.getData,{name:t}).each((t=>{e.setData(t)}))},onSubmit:t}})(t,n,e)})).then((t=>{e.windowManager.open(t)}))};var Ce=tinymce.util.Tools.resolve("tinymce.util.VK");const Oe=(e,t)=>e.dom.getParent(t,"a[href]"),Ne=e=>Oe(e,e.selection.getStart()),Ae=(e,t)=>{if(t){const n=Q(t);if(/^#/.test(n)){const t=e.dom.select(n);t.length&&e.selection.scrollIntoView(t[0],!0)}else(e=>{const t=document.createElement("a");t.target="_blank",t.href=e,t.rel="noreferrer noopener";const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),((e,t)=>{document.body.appendChild(e),e.dispatchEvent(t),document.body.removeChild(e)})(t,n)})(t.href)}},Se=e=>()=>{e.execCommand("mceLink",!1,{dialog:!0})},Te=e=>()=>{Ae(e,Ne(e))},Ee=(e,t)=>(e.on("NodeChange",t),()=>e.off("NodeChange",t)),Pe=e=>t=>{const n=()=>t.setActive(!e.mode.isReadOnly()&&Z(e,e.selection.getNode()));return n(),Ee(e,n)},Re=e=>t=>{const n=()=>t.setEnabled(Z(e,e.selection.getNode()));return n(),Ee(e,n)},Le=e=>t=>{const n=t=>{return te(t)||(n=e.selection.getRng(),J(n,H).length>0);var n},o=e.dom.getParents(e.selection.getStart());return t.setEnabled(n(o)),Ee(e,(e=>t.setEnabled(n(e.parents))))};e.add("link",(e=>{(e=>{const t=e.options.register;t("link_assume_external_targets",{processor:e=>{const t=o(e)||i(e);return t?!0===e?{value:1,valid:t}:"http"===e||"https"===e?{value:e,valid:t}:{value:0,valid:t}:{valid:!1,message:"Must be a string or a boolean."}},default:!1}),t("link_context_toolbar",{processor:"boolean",default:!1}),t("link_list",{processor:e=>o(e)||c(e)||u(e,r)}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"}),t("link_target_list",{processor:e=>i(e)||u(e,r),default:!0}),t("link_rel_list",{processor:"object[]",default:[]}),t("link_class_list",{processor:"object[]",default:[]}),t("link_title",{processor:"boolean",default:!0}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("link_quicklink",{processor:"boolean",default:!1})})(e),(e=>{e.ui.registry.addToggleButton("link",{icon:"link",tooltip:"Insert/edit link",onAction:Se(e),onSetup:Pe(e)}),e.ui.registry.addButton("openlink",{icon:"new-tab",tooltip:"Open link",onAction:Te(e),onSetup:Re(e)}),e.ui.registry.addButton("unlink",{icon:"unlink",tooltip:"Remove link",onAction:()=>ie(e),onSetup:Le(e)})})(e),(e=>{e.ui.registry.addMenuItem("openlink",{text:"Open link",icon:"new-tab",onAction:Te(e),onSetup:Re(e)}),e.ui.registry.addMenuItem("link",{icon:"link",text:"Link...",shortcut:"Meta+K",onAction:Se(e)}),e.ui.registry.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onAction:()=>ie(e),onSetup:Le(e)})})(e),(e=>{e.ui.registry.addContextMenu("link",{update:t=>te(e.dom.getParents(t,"a"))?"link unlink openlink":"link"})})(e),(e=>{const t=t=>{const n=e.selection.getNode();return t.setEnabled(Z(e,n)),g};e.ui.registry.addContextForm("quicklink",{launch:{type:"contextformtogglebutton",icon:"link",tooltip:"Link",onSetup:Pe(e)},label:"Link",predicate:t=>w(e)&&Z(e,t),initValue:()=>Y(e).fold((()=>""),Q),commands:[{type:"contextformtogglebutton",icon:"link",tooltip:"Link",primary:!0,onSetup:t=>{const n=e.selection.getNode();return t.setActive(Z(e,n)),Pe(e)(t)},onAction:t=>{const n=t.getValue(),o=(t=>{const n=Y(e),o=ne(e);if(n.isNone()&&o){const o=ee(e.selection,n);return m.some(o.length>0?o:t)}return m.none()})(n);ae(e,{href:n,attach:g},{href:n,text:o,title:m.none(),rel:m.none(),target:m.none(),class:m.none()}),(e=>{e.selection.collapse(!1)})(e),t.hide()}},{type:"contextformbutton",icon:"unlink",tooltip:"Remove link",onSetup:t,onAction:t=>{ie(e),t.hide()}},{type:"contextformbutton",icon:"new-tab",tooltip:"Open link",onSetup:t,onAction:t=>{Te(e)(),t.hide()}}]})})(e),(e=>{e.on("click",(t=>{const n=Oe(e,t.target);n&&Ce.metaKeyPressed(t)&&(t.preventDefault(),Ae(e,n))})),e.on("keydown",(t=>{if(!t.isDefaultPrevented()&&13===t.keyCode&&(e=>!0===e.altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey)(t)){const n=Ne(e);n&&(t.preventDefault(),Ae(e,n))}}))})(e),(e=>{e.addCommand("mceLink",((t,n)=>{!0!==(null==n?void 0:n.dialog)&&R(e)?e.dispatch("contexttoolbar-show",{toolbarKey:"quicklink"}):we(e)}))})(e),(e=>{e.addShortcut("Meta+K","",(()=>{e.execCommand("mceLink")}))})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=t=>e=>(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&(n=r=t,(o=String).prototype.isPrototypeOf(n)||(null===(s=r.constructor)||void 0===s?void 0:s.name)===o.name)?"string":e;var n,r,o,s})(e)===t,n=t=>e=>typeof e===t,r=e("string"),o=e("object"),s=e("array"),i=n("boolean"),a=t=>!(t=>null==t)(t),l=n("function"),d=n("number"),c=()=>{},u=(t,e)=>t===e,m=t=>e=>!t(e),p=(!1,()=>false);class g{constructor(t,e){this.tag=t,this.value=e}static some(t){return new g(!0,t)}static none(){return g.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?g.some(t(this.value)):g.none()}bind(t){return this.tag?t(this.value):g.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:g.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return a(t)?g.some(t):g.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}g.singletonNone=new g(!1);const h=Array.prototype.slice,f=Array.prototype.indexOf,y=Array.prototype.push,v=(t,e)=>{return n=t,r=e,f.call(n,r)>-1;var n,r},C=(t,e)=>{for(let n=0,r=t.length;n<r;n++)if(e(t[n],n))return!0;return!1},b=(t,e)=>{const n=t.length,r=new Array(n);for(let o=0;o<n;o++){const n=t[o];r[o]=e(n,o)}return r},S=(t,e)=>{for(let n=0,r=t.length;n<r;n++)e(t[n],n)},N=(t,e)=>{const n=[];for(let r=0,o=t.length;r<o;r++){const o=t[r];e(o,r)&&n.push(o)}return n},L=(t,e,n)=>(S(t,((t,r)=>{n=e(n,t,r)})),n),O=(t,e,n)=>{for(let r=0,o=t.length;r<o;r++){const o=t[r];if(e(o,r))return g.some(o);if(n(o,r))break}return g.none()},k=(t,e)=>O(t,e,p),T=(t,e)=>(t=>{const e=[];for(let n=0,r=t.length;n<r;++n){if(!s(t[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+t);y.apply(e,t[n])}return e})(b(t,e)),A=t=>{const e=h.call(t,0);return e.reverse(),e},w=(t,e)=>e>=0&&e<t.length?g.some(t[e]):g.none(),D=t=>w(t,0),E=t=>w(t,t.length-1),B=(t,e)=>{const n=[],r=l(e)?t=>C(n,(n=>e(n,t))):t=>v(n,t);for(let e=0,o=t.length;e<o;e++){const o=t[e];r(o)||n.push(o)}return n},x=(t,e,n=u)=>t.exists((t=>n(t,e))),I=(t,e,n)=>t.isSome()&&e.isSome()?g.some(n(t.getOrDie(),e.getOrDie())):g.none(),P=t=>{if(null==t)throw new Error("Node cannot be null or undefined");return{dom:t}},M=(t,e)=>{const n=(e||document).createElement(t);return P(n)},R=P,U=(t,e)=>t.dom===e.dom;"undefined"!=typeof window?window:Function("return this;")();const $=t=>t.dom.nodeName.toLowerCase(),_=(1,t=>1===(t=>t.dom.nodeType)(t));const H=t=>e=>_(e)&&$(e)===t,j=t=>g.from(t.dom.parentNode).map(R),F=t=>b(t.dom.childNodes,R),K=(t,e)=>{const n=t.dom.childNodes;return g.from(n[e]).map(R)},V=t=>K(t,0),z=t=>K(t,t.dom.childNodes.length-1),Q=(t,e,n)=>{let r=t.dom;const o=l(n)?n:p;for(;r.parentNode;){r=r.parentNode;const t=R(r);if(e(t))return g.some(t);if(o(t))break}return g.none()},q=(t,e,n)=>((t,e,n,r,o)=>r(n)?g.some(n):l(o)&&o(n)?g.none():e(n,r,o))(0,Q,t,e,n),W=(t,e)=>{j(t).each((n=>{n.dom.insertBefore(e.dom,t.dom)}))},Z=(t,e)=>{t.dom.appendChild(e.dom)},G=(t,e)=>{S(e,(e=>{Z(t,e)}))},J=t=>{t.dom.textContent="",S(F(t),(t=>{X(t)}))},X=t=>{const e=t.dom;null!==e.parentNode&&e.parentNode.removeChild(e)};var Y=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),tt=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),et=tinymce.util.Tools.resolve("tinymce.util.VK");const nt=t=>b(t,R),rt=Object.keys,ot=(t,e)=>{const n=rt(t);for(let r=0,o=n.length;r<o;r++){const o=n[r];e(t[o],o)}},st=(t,e)=>{const n=t.dom;ot(e,((t,e)=>{((t,e,n)=>{if(!(r(n)||i(n)||d(n)))throw console.error("Invalid call to Attribute.set. Key ",e,":: Value ",n,":: Element ",t),new Error("Attribute value was not simple");t.setAttribute(e,n+"")})(n,e,t)}))},it=t=>L(t.dom.attributes,((t,e)=>(t[e.name]=e.value,t)),{}),at=t=>((t,e)=>R(t.dom.cloneNode(!0)))(t),lt=(t,e)=>{const n=((t,e)=>{const n=M(e),r=it(t);return st(n,r),n})(t,e);((t,e)=>{const n=(t=>g.from(t.dom.nextSibling).map(R))(t);n.fold((()=>{j(t).each((t=>{Z(t,e)}))}),(t=>{W(t,e)}))})(t,n);const r=F(t);return G(n,r),X(t),n};var dt=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),ct=tinymce.util.Tools.resolve("tinymce.util.Tools");const ut=t=>e=>a(e)&&e.nodeName.toLowerCase()===t,mt=t=>e=>a(e)&&t.test(e.nodeName),pt=t=>a(t)&&3===t.nodeType,gt=t=>a(t)&&1===t.nodeType,ht=mt(/^(OL|UL|DL)$/),ft=mt(/^(OL|UL)$/),yt=ut("ol"),vt=mt(/^(LI|DT|DD)$/),Ct=mt(/^(DT|DD)$/),bt=mt(/^(TH|TD)$/),St=ut("br"),Nt=(t,e)=>a(e)&&e.nodeName in t.schema.getTextBlockElements(),Lt=(t,e)=>a(t)&&t.nodeName in e,Ot=(t,e,n)=>{const r=t.isEmpty(e);return!(n&&t.select("span[data-mce-type=bookmark]",e).length>0)&&r},kt=(t,e)=>t.isChildOf(e,t.getRoot()),Tt=t=>e=>e.options.get(t),At=Tt("lists_indent_on_tab"),wt=Tt("forced_root_block"),Dt=Tt("forced_root_block_attrs"),Et=(t,e)=>{const n=t.dom,r=t.schema.getBlockElements(),o=n.createFragment(),s=wt(t),i=Dt(t);let a,l,d=!1;for(l=n.create(s,i),Lt(e.firstChild,r)||o.appendChild(l);a=e.firstChild;){const t=a.nodeName;d||"SPAN"===t&&"bookmark"===a.getAttribute("data-mce-type")||(d=!0),Lt(a,r)?(o.appendChild(a),l=null):(l||(l=n.create(s,i),o.appendChild(l)),l.appendChild(a))}return!d&&l&&l.appendChild(n.create("br",{"data-mce-bogus":"1"})),o},Bt=dt.DOM,xt=H("dd"),It=H("dt"),Pt=(t,e)=>{var n;xt(e)?lt(e,"dt"):It(e)&&(n=e,g.from(n.dom.parentElement).map(R)).each((n=>((t,e,n)=>{const r=Bt.select('span[data-mce-type="bookmark"]',e),o=Et(t,n),s=Bt.createRng();s.setStartAfter(n),s.setEndAfter(e);const i=s.extractContents();for(let e=i.firstChild;e;e=e.firstChild)if("LI"===e.nodeName&&t.dom.isEmpty(e)){Bt.remove(e);break}t.dom.isEmpty(i)||Bt.insertAfter(i,e),Bt.insertAfter(o,e);const a=n.parentElement;a&&Ot(t.dom,a)&&(t=>{const e=t.parentNode;e&&ct.each(r,(t=>{e.insertBefore(t,n.parentNode)})),Bt.remove(t)})(a),Bt.remove(n),Ot(t.dom,e)&&Bt.remove(e)})(t,n.dom,e.dom)))},Mt=t=>{It(t)&&lt(t,"dd")},Rt=(t,e)=>{if(pt(t))return{container:t,offset:e};const n=Y.getNode(t,e);return pt(n)?{container:n,offset:e>=t.childNodes.length?n.data.length:0}:n.previousSibling&&pt(n.previousSibling)?{container:n.previousSibling,offset:n.previousSibling.data.length}:n.nextSibling&&pt(n.nextSibling)?{container:n.nextSibling,offset:0}:{container:t,offset:e}},Ut=t=>{const e=t.cloneRange(),n=Rt(t.startContainer,t.startOffset);e.setStart(n.container,n.offset);const r=Rt(t.endContainer,t.endOffset);return e.setEnd(r.container,r.offset),e},$t=["OL","UL","DL"],_t=$t.join(","),Ht=(t,e)=>{const n=e||t.selection.getStart(!0);return t.dom.getParent(n,_t,Kt(t,n))},jt=t=>{const e=t.selection.getSelectedBlocks();return N(((t,e)=>{const n=ct.map(e,(e=>t.dom.getParent(e,"li,dd,dt",Kt(t,e))||e));return B(n)})(t,e),vt)},Ft=(t,e)=>{const n=t.dom.getParents(e,"TD,TH");return n.length>0?n[0]:t.getBody()},Kt=(t,e)=>{const n=t.dom.getParents(e,t.dom.isBlock),r=k(n,(e=>{return n=t.schema,!ht(r=e)&&!vt(r)&&C($t,(t=>n.isValidChild(r.nodeName,t)));var n,r}));return r.getOr(t.getBody())},Vt=(t,e)=>{const n=t.dom.getParents(e,"ol,ul",Kt(t,e));return E(n)},zt=(t,e)=>{const n=b(e,(e=>Vt(t,e).getOr(e)));return B(n)},Qt=t=>/\btox\-/.test(t.className),qt=(t,e)=>O(t,ht,bt).exists((t=>t.nodeName===e&&!Qt(t))),Wt=(t,e)=>null!==e&&"false"===t.dom.getContentEditableParent(e),Zt=(t,e)=>{const n=t.dom.getParent(e,"ol,ul,dl");return Wt(t,n)},Gt=(t,e)=>{const n=t.selection.getNode();return e({parents:t.dom.getParents(n),element:n}),t.on("NodeChange",e),()=>t.off("NodeChange",e)},Jt=(t,e,n)=>t.dispatch("ListMutation",{action:e,element:n}),Xt=(Yt=/^\s+|\s+$/g,t=>t.replace(Yt,""));var Yt;const te=(t,e,n)=>{((t,e,n)=>{if(!r(n))throw console.error("Invalid call to CSS.set. Property ",e,":: Value ",n,":: Element ",t),new Error("CSS value must be a string: "+n);(t=>void 0!==t.style&&l(t.style.getPropertyValue))(t)&&t.style.setProperty(e,n)})(t.dom,e,n)},ee=(t,e)=>{Z(t.item,e.list)},ne=(t,e)=>{const n={list:M(e,t),item:M("li",t)};return Z(n.list,n.item),n},re=t=>((t,e)=>{const n=t.dom;if(1!==n.nodeType)return!1;{const t=n;if(void 0!==t.matches)return t.matches(e);if(void 0!==t.msMatchesSelector)return t.msMatchesSelector(e);if(void 0!==t.webkitMatchesSelector)return t.webkitMatchesSelector(e);if(void 0!==t.mozMatchesSelector)return t.mozMatchesSelector(e);throw new Error("Browser lacks native selectors")}})(t,"OL,UL"),oe=t=>V(t).exists(re),se=t=>t.depth>0,ie=t=>t.isSelected,ae=t=>{const e=F(t),n=z(t).exists(re)?e.slice(0,-1):e;return b(n,at)},le=t=>(S(t,((e,n)=>{((t,e)=>{const n=t[e].depth,r=t=>t.depth===n&&!t.dirty,o=t=>t.depth<n;return O(A(t.slice(0,e)),r,o).orThunk((()=>O(t.slice(e+1),r,o)))})(t,n).fold((()=>{e.dirty&&(t=>{t.listAttributes=((t,e)=>{const n={};var r;return((t,e,n,r)=>{ot(t,((t,o)=>{(e(t,o)?n:r)(t,o)}))})(t,e,(r=n,(t,e)=>{r[e]=t}),c),n})(t.listAttributes,((t,e)=>"start"!==e))})(e)}),(t=>{return r=t,(n=e).listType=r.listType,void(n.listAttributes={...r.listAttributes});var n,r}))})),t),de=(t,e,n,r)=>V(r).filter(re).fold((()=>{e.each((t=>{U(t.start,r)&&n.set(!0)}));const o=((t,e,n)=>j(t).filter(_).map((r=>({depth:e,dirty:!1,isSelected:n,content:ae(t),itemAttributes:it(t),listAttributes:it(r),listType:$(r)}))))(r,t,n.get());e.each((t=>{U(t.end,r)&&n.set(!1)}));const s=z(r).filter(re).map((r=>ce(t,e,n,r))).getOr([]);return o.toArray().concat(s)}),(r=>ce(t,e,n,r))),ce=(t,e,n,r)=>T(F(r),(r=>(re(r)?ce:de)(t+1,e,n,r))),ue=(t,e)=>{const n=le(e);return((t,e)=>{const n=L(e,((e,n)=>n.depth>e.length?((t,e,n)=>{const r=((t,e,n)=>{const r=[];for(let o=0;o<n;o++)r.push(ne(t,e.listType));return r})(t,n,n.depth-e.length);var o;return(t=>{for(let e=1;e<t.length;e++)ee(t[e-1],t[e])})(r),((t,e)=>{for(let e=0;e<t.length-1;e++)te(t[e].item,"list-style-type","none");E(t).each((t=>{st(t.list,e.listAttributes),st(t.item,e.itemAttributes),G(t.item,e.content)}))})(r,n),o=r,I(E(e),D(o),ee),e.concat(r)})(t,e,n):((t,e,n)=>{const r=e.slice(0,n.depth);return E(r).each((e=>{const r=((t,e,n)=>{const r=M("li",t);return st(r,e),G(r,n),r})(t,n.itemAttributes,n.content);((t,e)=>{Z(t.list,e),t.item=e})(e,r),((t,e)=>{$(t.list)!==e.listType&&(t.list=lt(t.list,e.listType)),st(t.list,e.listAttributes)})(e,n)})),r})(t,e,n)),[]);return D(n).map((t=>t.list))})(t.contentDocument,n).toArray()},me=(t,e,n)=>{const r=((t,e)=>{const n=(t=>{let e=!1;return{get:()=>e,set:t=>{e=t}}})();return b(t,(t=>({sourceList:t,entries:ce(0,e,n,t)})))})(e,(t=>{const e=b(jt(t),R);return I(k(e,m(oe)),k(A(e),m(oe)),((t,e)=>({start:t,end:e})))})(t));S(r,(e=>{((t,e)=>{S(N(t,ie),(t=>((t,e)=>{switch(t){case"Indent":e.depth++;break;case"Outdent":e.depth--;break;case"Flatten":e.depth=0}e.dirty=!0})(e,t)))})(e.entries,n);const r=((t,e)=>T(((t,e)=>{if(0===t.length)return[];{let n=e(t[0]);const r=[];let o=[];for(let s=0,i=t.length;s<i;s++){const i=t[s],a=e(i);a!==n&&(r.push(o),o=[]),n=a,o.push(i)}return 0!==o.length&&r.push(o),r}})(e,se),(e=>D(e).exists(se)?ue(t,e):((t,e)=>{const n=le(e);return b(n,(e=>{const n=((t,e)=>{const n=document.createDocumentFragment();return S(t,(t=>{n.appendChild(t.dom)})),R(n)})(e.content);return R(Et(t,n.dom))}))})(t,e))))(t,e.entries);var o;S(r,(e=>{Jt(t,"Indent"===n?"IndentList":"OutdentList",e.dom)})),o=e.sourceList,S(r,(t=>{W(o,t)})),X(e.sourceList)}))},pe=(t,e)=>{const n=nt((t=>{const e=(t=>{const e=Vt(t,t.selection.getStart()),n=N(t.selection.getSelectedBlocks(),ft);return e.toArray().concat(n)})(t);return zt(t,e)})(t)),r=nt((t=>N(jt(t),Ct))(t));let o=!1;if(n.length||r.length){const s=t.selection.getBookmark();me(t,n,e),((t,e,n)=>{S(n,"Indent"===e?Mt:e=>Pt(t,e))})(t,e,r),t.selection.moveToBookmark(s),t.selection.setRng(Ut(t.selection.getRng())),t.nodeChanged(),o=!0}return o},ge=(t,e)=>!(t=>{const e=Ht(t);return Wt(t,e)})(t)&&pe(t,e),he=t=>ge(t,"Indent"),fe=t=>ge(t,"Outdent"),ye=t=>ge(t,"Flatten");var ve=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager");const Ce=dt.DOM,be=t=>{const e={},n=n=>{let r=t[n?"startContainer":"endContainer"],o=t[n?"startOffset":"endOffset"];if(gt(r)){const t=Ce.create("span",{"data-mce-type":"bookmark"});r.hasChildNodes()?(o=Math.min(o,r.childNodes.length-1),n?r.insertBefore(t,r.childNodes[o]):Ce.insertAfter(t,r.childNodes[o])):r.appendChild(t),r=t,o=0}e[n?"startContainer":"endContainer"]=r,e[n?"startOffset":"endOffset"]=o};return n(!0),t.collapsed||n(),e},Se=t=>{const e=e=>{let n=t[e?"startContainer":"endContainer"],r=t[e?"startOffset":"endOffset"];if(n){if(gt(n)&&n.parentNode){const t=n;r=(t=>{var e;let n=null===(e=t.parentNode)||void 0===e?void 0:e.firstChild,r=0;for(;n;){if(n===t)return r;gt(n)&&"bookmark"===n.getAttribute("data-mce-type")||r++,n=n.nextSibling}return-1})(n),n=n.parentNode,Ce.remove(t),!n.hasChildNodes()&&Ce.isBlock(n)&&n.appendChild(Ce.create("br"))}t[e?"startContainer":"endContainer"]=n,t[e?"startOffset":"endOffset"]=r}};e(!0),e();const n=Ce.createRng();return n.setStart(t.startContainer,t.startOffset),t.endContainer&&n.setEnd(t.endContainer,t.endOffset),Ut(n)},Ne=t=>{switch(t){case"UL":return"ToggleUlList";case"OL":return"ToggleOlList";case"DL":return"ToggleDLList"}},Le=(t,e)=>{ct.each(e,((e,n)=>{t.setAttribute(n,e)}))},Oe=(t,e,n)=>{((t,e,n)=>{const r=n["list-style-type"]?n["list-style-type"]:null;t.setStyle(e,"list-style-type",r)})(t,e,n),((t,e,n)=>{Le(e,n["list-attributes"]),ct.each(t.select("li",e),(t=>{Le(t,n["list-item-attributes"])}))})(t,e,n)},ke=(t,e,n,r)=>{let o=e[n?"startContainer":"endContainer"];const s=e[n?"startOffset":"endOffset"];for(gt(o)&&(o=o.childNodes[Math.min(s,o.childNodes.length-1)]||o),!n&&St(o.nextSibling)&&(o=o.nextSibling);o.parentNode!==r;){const e=o.parentNode;if(Nt(t,o))return o;if(/^(TD|TH)$/.test(e.nodeName))return o;o=e}return o},Te=(t,e,n)=>{const r=t.selection.getRng();let o="LI";const s=Kt(t,t.selection.getStart(!0)),i=t.dom;if("false"===i.getContentEditable(t.selection.getNode()))return;"DL"===(e=e.toUpperCase())&&(o="DT");const a=be(r),l=((t,e,n)=>{const r=[],o=t.dom,s=ke(t,e,!0,n),i=ke(t,e,!1,n);let a;const l=[];for(let t=s;t&&(l.push(t),t!==i);t=t.nextSibling);return ct.each(l,(e=>{var s;if(Nt(t,e))return r.push(e),void(a=null);if(o.isBlock(e)||St(e))return St(e)&&o.remove(e),void(a=null);const i=e.nextSibling;ve.isBookmarkNode(e)&&(ht(i)||Nt(t,i)||!i&&e.parentNode===n)?a=null:(a||(a=o.create("p"),null===(s=e.parentNode)||void 0===s||s.insertBefore(a,e),r.push(a)),a.appendChild(e))})),r})(t,r,s);ct.each(l,(r=>{let s;const a=r.previousSibling,l=r.parentNode;vt(l)||(a&&ht(a)&&a.nodeName===e&&((t,e,n)=>{const r=t.getStyle(e,"list-style-type");let o=n?n["list-style-type"]:"";return o=null===o?"":o,r===o})(i,a,n)?(s=a,r=i.rename(r,o),a.appendChild(r)):(s=i.create(e),l.insertBefore(s,r),s.appendChild(r),r=i.rename(r,o)),((t,e,n)=>{ct.each(["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"],(n=>t.setStyle(e,n,"")))})(i,r),Oe(i,s,n),we(t.dom,s))})),t.selection.setRng(Se(a))},Ae=(t,e,n)=>{return((t,e)=>ht(t)&&t.nodeName===(null==e?void 0:e.nodeName))(e,n)&&((t,e,n)=>t.getStyle(e,"list-style-type",!0)===t.getStyle(n,"list-style-type",!0))(t,e,n)&&(r=n,e.className===r.className);var r},we=(t,e)=>{let n,r=e.nextSibling;if(Ae(t,e,r)){const o=r;for(;n=o.firstChild;)e.appendChild(n);t.remove(o)}if(r=e.previousSibling,Ae(t,e,r)){const o=r;for(;n=o.lastChild;)e.insertBefore(n,e.firstChild);t.remove(o)}},De=t=>"list-style-type"in t,Ee=(t,e,n)=>{const r=Ht(t);if(Zt(t,r))return;const s=(t=>{const e=Ht(t),n=t.selection.getSelectedBlocks();return((t,e)=>a(t)&&1===e.length&&e[0]===t)(e,n)?(t=>N(t.querySelectorAll(_t),ht))(e):N(n,(t=>ht(t)&&e!==t))})(t),i=o(n)?n:{};s.length>0?((t,e,n,r,o)=>{const s=ht(e);if(s&&e.nodeName===r&&!De(o))ye(t);else{Te(t,r,o);const i=be(t.selection.getRng()),a=s?[e,...n]:n;ct.each(a,(e=>{((t,e,n,r)=>{if(e.nodeName!==n){const o=t.dom.rename(e,n);Oe(t.dom,o,r),Jt(t,Ne(n),o)}else Oe(t.dom,e,r),Jt(t,Ne(n),e)})(t,e,r,o)})),t.selection.setRng(Se(i))}})(t,r,s,e,i):((t,e,n,r)=>{if(e!==t.getBody())if(e)if(e.nodeName!==n||De(r)||Qt(e)){const o=be(t.selection.getRng());Oe(t.dom,e,r);const s=t.dom.rename(e,n);we(t.dom,s),t.selection.setRng(Se(o)),Te(t,n,r),Jt(t,Ne(n),s)}else ye(t);else Te(t,n,r),Jt(t,Ne(n),e)})(t,r,e,i)},Be=dt.DOM,xe=(t,e)=>{const n=ct.grep(t.select("ol,ul",e));ct.each(n,(e=>{((t,e)=>{const n=e.parentElement;if(n&&"LI"===n.nodeName&&n.firstChild===e){const r=n.previousSibling;r&&"LI"===r.nodeName?(r.appendChild(e),Ot(t,n)&&Be.remove(n)):Be.setStyle(n,"listStyleType","none")}if(ht(n)){const t=n.previousSibling;t&&"LI"===t.nodeName&&t.appendChild(e)}})(t,e)}))},Ie=(t,e,n,r)=>{let o=e.startContainer;const s=e.startOffset;if(pt(o)&&(n?s<o.data.length:s>0))return o;const i=t.schema.getNonEmptyElements();gt(o)&&(o=Y.getNode(o,s));const a=new tt(o,r);n&&((t,e)=>!!St(e)&&t.isBlock(e.nextSibling)&&!St(e.previousSibling))(t.dom,o)&&a.next();const l=n?a.next.bind(a):a.prev2.bind(a);for(;o=l();){if("LI"===o.nodeName&&!o.hasChildNodes())return o;if(i[o.nodeName])return o;if(pt(o)&&o.data.length>0)return o}return null},Pe=(t,e)=>{const n=e.childNodes;return 1===n.length&&!ht(n[0])&&t.isBlock(n[0])},Me=(t,e,n)=>{let r;const o=e.parentNode;if(!kt(t,e)||!kt(t,n))return;ht(n.lastChild)&&(r=n.lastChild),o===n.lastChild&&St(o.previousSibling)&&t.remove(o.previousSibling);const s=n.lastChild;s&&St(s)&&e.hasChildNodes()&&t.remove(s),Ot(t,n,!0)&&J(R(n)),((t,e,n)=>{let r;const o=Pe(t,n)?n.firstChild:n;if(((t,e)=>{Pe(t,e)&&t.remove(e.firstChild,!0)})(t,e),!Ot(t,e,!0))for(;r=e.firstChild;)o.appendChild(r)})(t,e,n),r&&n.appendChild(r);const i=((t,e)=>{const n=t.dom,r=e.dom;return n!==r&&n.contains(r)})(R(n),R(e))?t.getParents(e,ht,n):[];t.remove(e),S(i,(e=>{Ot(t,e)&&e!==t.getRoot()&&t.remove(e)}))},Re=(t,e)=>{const n=t.dom,r=t.selection,o=r.getStart(),s=Ft(t,o),i=n.getParent(r.getStart(),"LI",s);if(i){const o=i.parentElement;if(o===t.getBody()&&Ot(n,o))return!0;const a=Ut(r.getRng()),l=n.getParent(Ie(t,a,e,s),"LI",s);if(l&&l!==i)return t.undoManager.transact((()=>{var n,r;e?((t,e,n,r)=>{const o=t.dom;if(o.isEmpty(r))((t,e,n)=>{J(R(n)),Me(t.dom,e,n),t.selection.setCursorLocation(n,0)})(t,n,r);else{const s=be(e);Me(o,n,r),t.selection.setRng(Se(s))}})(t,a,l,i):(null===(r=(n=i).parentNode)||void 0===r?void 0:r.firstChild)===n?fe(t):((t,e,n,r)=>{const o=be(e);Me(t.dom,n,r);const s=Se(o);t.selection.setRng(s)})(t,a,i,l)})),!0;if(!l&&!e&&0===a.startOffset&&0===a.endOffset)return t.undoManager.transact((()=>{ye(t)})),!0}return!1},Ue=t=>{const e=t.selection.getStart(),n=Ft(t,e);return t.dom.getParent(e,"LI,DT,DD",n)||jt(t).length>0},$e=(t,e)=>{const n=t.selection;return!Zt(t,n.getNode())&&(n.isCollapsed()?((t,e)=>Re(t,e)||((t,e)=>{const n=t.dom,r=t.selection.getStart(),o=Ft(t,r),s=n.getParent(r,n.isBlock,o);if(s&&n.isEmpty(s)){const r=Ut(t.selection.getRng()),i=n.getParent(Ie(t,r,e,o),"LI",o);if(i){const a=t=>v(["td","th","caption"],$(t)),l=t=>t.dom===o;return!!((t,e,n=u)=>I(t,e,n).getOr(t.isNone()&&e.isNone()))(q(R(i),a,l),q(R(r.startContainer),a,l),U)&&(t.undoManager.transact((()=>{((t,e,n)=>{const r=t.getParent(e.parentNode,t.isBlock,n);t.remove(e),r&&t.isEmpty(r)&&t.remove(r)})(n,s,o),we(n,i.parentNode),t.selection.select(i,!0),t.selection.collapse(e)})),!0)}}return!1})(t,e))(t,e):(t=>!!Ue(t)&&(t.undoManager.transact((()=>{t.execCommand("Delete"),xe(t.dom,t.getBody())})),!0))(t))},_e=t=>{const e=A(Xt(t).split("")),n=b(e,((t,e)=>{const n=t.toUpperCase().charCodeAt(0)-"A".charCodeAt(0)+1;return Math.pow(26,e)*n}));return L(n,((t,e)=>t+e),0)},He=t=>{if(--t<0)return"";{const e=t%26,n=Math.floor(t/26);return He(n)+String.fromCharCode("A".charCodeAt(0)+e)}},je=t=>{const e=parseInt(t.start,10);return x(t.listStyleType,"upper-alpha")?He(e):x(t.listStyleType,"lower-alpha")?He(e).toLowerCase():t.start},Fe=(t,e)=>()=>{const n=Ht(t);return a(n)&&n.nodeName===e},Ke=t=>{t.addCommand("mceListProps",(()=>{(t=>{const e=Ht(t);yt(e)&&!Zt(t,e)&&t.windowManager.open({title:"List Properties",body:{type:"panel",items:[{type:"input",name:"start",label:"Start list at number",inputMode:"numeric"}]},initialData:{start:je({start:t.dom.getAttrib(e,"start","1"),listStyleType:g.from(t.dom.getStyle(e,"list-style-type"))})},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:e=>{(t=>{switch((t=>/^[0-9]+$/.test(t)?2:/^[A-Z]+$/.test(t)?0:/^[a-z]+$/.test(t)?1:t.length>0?4:3)(t)){case 2:return g.some({listStyleType:g.none(),start:t});case 0:return g.some({listStyleType:g.some("upper-alpha"),start:_e(t).toString()});case 1:return g.some({listStyleType:g.some("lower-alpha"),start:_e(t).toString()});case 3:return g.some({listStyleType:g.none(),start:""});case 4:return g.none()}})(e.getData().start).each((e=>{t.execCommand("mceListUpdate",!1,{attrs:{start:"1"===e.start?"":e.start},styles:{"list-style-type":e.listStyleType.getOr("")}})})),e.close()}})})(t)}))},Ve=(t,e)=>n=>Gt(t,(r=>{n.setActive(qt(r.parents,e)),n.setEnabled(!Zt(t,r.element))})),ze=(t,e)=>n=>Gt(t,(r=>n.setEnabled(qt(r.parents,e)&&!Zt(t,r.element))));t.add("lists",(t=>((t=>{(0,t.options.register)("lists_indent_on_tab",{processor:"boolean",default:!0})})(t),t.hasPlugin("rtc",!0)?Ke(t):((t=>{At(t)&&(t=>{t.on("keydown",(e=>{e.keyCode!==et.TAB||et.metaKeyPressed(e)||t.undoManager.transact((()=>{(e.shiftKey?fe(t):he(t))&&e.preventDefault()}))}))})(t),(t=>{t.on("ExecCommand",(e=>{const n=e.command.toLowerCase();"delete"!==n&&"forwarddelete"!==n||!Ue(t)||xe(t.dom,t.getBody())})),t.on("keydown",(e=>{e.keyCode===et.BACKSPACE?$e(t,!1)&&e.preventDefault():e.keyCode===et.DELETE&&$e(t,!0)&&e.preventDefault()}))})(t)})(t),(t=>{t.on("BeforeExecCommand",(e=>{const n=e.command.toLowerCase();"indent"===n?he(t):"outdent"===n&&fe(t)})),t.addCommand("InsertUnorderedList",((e,n)=>{Ee(t,"UL",n)})),t.addCommand("InsertOrderedList",((e,n)=>{Ee(t,"OL",n)})),t.addCommand("InsertDefinitionList",((e,n)=>{Ee(t,"DL",n)})),t.addCommand("RemoveList",(()=>{ye(t)})),Ke(t),t.addCommand("mceListUpdate",((e,n)=>{o(n)&&((t,e)=>{const n=Ht(t);null===n||Zt(t,n)||t.undoManager.transact((()=>{o(e.styles)&&t.dom.setStyles(n,e.styles),o(e.attrs)&&ot(e.attrs,((e,r)=>t.dom.setAttrib(n,r,e)))}))})(t,n)})),t.addQueryStateHandler("InsertUnorderedList",Fe(t,"UL")),t.addQueryStateHandler("InsertOrderedList",Fe(t,"OL")),t.addQueryStateHandler("InsertDefinitionList",Fe(t,"DL"))})(t)),(t=>{const e=e=>()=>t.execCommand(e);t.hasPlugin("advlist")||(t.ui.registry.addToggleButton("numlist",{icon:"ordered-list",active:!1,tooltip:"Numbered list",onAction:e("InsertOrderedList"),onSetup:Ve(t,"OL")}),t.ui.registry.addToggleButton("bullist",{icon:"unordered-list",active:!1,tooltip:"Bullet list",onAction:e("InsertUnorderedList"),onSetup:Ve(t,"UL")}))})(t),(t=>{const e={text:"List properties...",icon:"ordered-list",onAction:()=>t.execCommand("mceListProps"),onSetup:ze(t,"OL")};t.ui.registry.addMenuItem("listprops",e),t.ui.registry.addContextMenu("lists",{update:e=>{const n=Ht(t,e);return yt(n)?["listprops"]:[]}})})(t),(t=>({backspaceDelete:e=>{$e(t,e)}}))(t))))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(r=a=e,(o=String).prototype.isPrototypeOf(r)||(null===(s=a.constructor)||void 0===s?void 0:s.name)===o.name)?"string":t;var r,a,o,s})(t)===e,r=t("string"),a=t("object"),o=t("array"),s=e=>!(e=>null==e)(e);class i{constructor(e,t){this.tag=e,this.value=t}static some(e){return new i(!0,e)}static none(){return i.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?i.some(e(this.value)):i.none()}bind(e){return this.tag?e(this.value):i.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:i.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return s(e)?i.some(e):i.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}i.singletonNone=new i(!1);const n=Array.prototype.push,c=(e,t)=>{for(let r=0,a=e.length;r<a;r++)t(e[r],r)},l=e=>{const t=[];for(let r=0,a=e.length;r<a;++r){if(!o(e[r]))throw new Error("Arr.flatten item "+r+" was not an array, input: "+e);n.apply(t,e[r])}return t},m=Object.keys,u=Object.hasOwnProperty,d=(e,t)=>h(e,t)?i.from(e[t]):i.none(),h=(e,t)=>u.call(e,t),p=e=>t=>t.options.get(e),g=p("audio_template_callback"),b=p("video_template_callback"),w=p("iframe_template_callback"),v=p("media_live_embeds"),f=p("media_filter_html"),y=p("media_url_resolver"),x=p("media_alt_source"),_=p("media_poster"),j=p("media_dimensions");var k=tinymce.util.Tools.resolve("tinymce.util.Tools"),O=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),A=tinymce.util.Tools.resolve("tinymce.html.DomParser");const S=O.DOM,C=e=>e.replace(/px$/,""),D=e=>{const t=e.attr("style"),r=t?S.parseStyle(t):{};return{type:"ephox-embed-iri",source:e.attr("data-ephox-embed-iri"),altsource:"",poster:"",width:d(r,"max-width").map(C).getOr(""),height:d(r,"max-height").map(C).getOr("")}},T=(e,t)=>{let r={};for(let a=A({validate:!1,forced_root_block:!1},t).parse(e);a;a=a.walk())if(1===a.type){const e=a.name;if(a.attr("data-ephox-embed-iri")){r=D(a);break}r.source||"param"!==e||(r.source=a.attr("movie")),"iframe"!==e&&"object"!==e&&"embed"!==e&&"video"!==e&&"audio"!==e||(r.type||(r.type=e),r=k.extend(a.attributes.map,r)),"script"===e&&(r={type:"script",source:a.attr("src")}),"source"===e&&(r.source?r.altsource||(r.altsource=a.attr("src")):r.source=a.attr("src")),"img"!==e||r.poster||(r.poster=a.attr("src"))}return r.source=r.source||r.src||"",r.altsource=r.altsource||"",r.poster=r.poster||"",r},$=e=>{var t;const r=null!==(t=e.toLowerCase().split(".").pop())&&void 0!==t?t:"";return d({mp3:"audio/mpeg",m4a:"audio/x-m4a",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"},r).getOr("")};var z=tinymce.util.Tools.resolve("tinymce.html.Node"),M=tinymce.util.Tools.resolve("tinymce.html.Serializer");const F=(e,t={})=>A({forced_root_block:!1,validate:!1,allow_conditional_comments:!0,...t},e),N=O.DOM,R=e=>/^[0-9.]+$/.test(e)?e+"px":e,U=(e,t)=>{const r=t.attr("style"),a=r?N.parseStyle(r):{};s(e.width)&&(a["max-width"]=R(e.width)),s(e.height)&&(a["max-height"]=R(e.height)),t.attr("style",N.serializeStyle(a))},P=["source","altsource"],E=(e,t,r,a)=>{let o=0,s=0;const i=F(a);i.addNodeFilter("source",(e=>o=e.length));const n=i.parse(e);for(let e=n;e;e=e.walk())if(1===e.type){const a=e.name;if(e.attr("data-ephox-embed-iri")){U(t,e);break}switch(a){case"video":case"object":case"embed":case"img":case"iframe":void 0!==t.height&&void 0!==t.width&&(e.attr("width",t.width),e.attr("height",t.height))}if(r)switch(a){case"video":e.attr("poster",t.poster),e.attr("src",null);for(let r=o;r<2;r++)if(t[P[r]]){const a=new z("source",1);a.attr("src",t[P[r]]),a.attr("type",t[P[r]+"mime"]||null),e.append(a)}break;case"iframe":e.attr("src",t.source);break;case"object":const r=e.getAll("img").length>0;if(t.poster&&!r){e.attr("src",t.poster);const r=new z("img",1);r.attr("src",t.poster),r.attr("width",t.width),r.attr("height",t.height),e.append(r)}break;case"source":if(s<2&&(e.attr("src",t[P[s]]),e.attr("type",t[P[s]+"mime"]||null),!t[P[s]])){e.remove();continue}s++;break;case"img":t.poster||e.remove()}}return M({},a).serialize(n)},L=[{regex:/youtu\.be\/([\w\-_\?&=.]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$2?$4",allowFullscreen:!0},{regex:/youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?title=0&amp;byline=0",allowFullscreen:!0},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'maps.google.com/maps/ms?msid=$2&output=embed"',allowFullscreen:!1},{regex:/dailymotion\.com\/video\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0},{regex:/dai\.ly\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0}],I=(e,t)=>{const r=(e=>{const t=e.match(/^(https?:\/\/|www\.)(.+)$/i);return t&&t.length>1?"www."===t[1]?"https://":t[1]:"https://"})(t),a=e.regex.exec(t);let o=r+e.url;if(s(a))for(let e=0;e<a.length;e++)o=o.replace("$"+e,(()=>a[e]?a[e]:""));return o.replace(/\?$/,"")},B=(e,t)=>{var r;const a=k.extend({},t);if(!a.source&&(k.extend(a,T(null!==(r=a.embed)&&void 0!==r?r:"",e.schema)),!a.source))return"";a.altsource||(a.altsource=""),a.poster||(a.poster=""),a.source=e.convertURL(a.source,"source"),a.altsource=e.convertURL(a.altsource,"source"),a.sourcemime=$(a.source),a.altsourcemime=$(a.altsource),a.poster=e.convertURL(a.poster,"poster");const o=(e=>{const t=L.filter((t=>t.regex.test(e)));return t.length>0?k.extend({},t[0],{url:I(t[0],e)}):null})(a.source);if(o&&(a.source=o.url,a.type=o.type,a.allowfullscreen=o.allowFullscreen,a.width=a.width||String(o.w),a.height=a.height||String(o.h)),a.embed)return E(a.embed,a,!0,e.schema);{const t=g(e),r=b(e),o=w(e);return a.width=a.width||"300",a.height=a.height||"150",k.each(a,((t,r)=>{a[r]=e.dom.encode(""+t)})),"iframe"===a.type?((e,t)=>{if(t)return t(e);{const t=e.allowfullscreen?' allowFullscreen="1"':"";return'<iframe src="'+e.source+'" width="'+e.width+'" height="'+e.height+'"'+t+"></iframe>"}})(a,o):"application/x-shockwave-flash"===a.sourcemime?(e=>{let t='<object data="'+e.source+'" width="'+e.width+'" height="'+e.height+'" type="application/x-shockwave-flash">';return e.poster&&(t+='<img src="'+e.poster+'" width="'+e.width+'" height="'+e.height+'" />'),t+="</object>",t})(a):-1!==a.sourcemime.indexOf("audio")?((e,t)=>t?t(e):'<audio controls="controls" src="'+e.source+'">'+(e.altsource?'\n<source src="'+e.altsource+'"'+(e.altsourcemime?' type="'+e.altsourcemime+'"':"")+" />\n":"")+"</audio>")(a,t):"script"===a.type?(e=>'<script src="'+e.source+'"><\/script>')(a):((e,t)=>t?t(e):'<video width="'+e.width+'" height="'+e.height+'"'+(e.poster?' poster="'+e.poster+'"':"")+' controls="controls">\n<source src="'+e.source+'"'+(e.sourcemime?' type="'+e.sourcemime+'"':"")+" />\n"+(e.altsource?'<source src="'+e.altsource+'"'+(e.altsourcemime?' type="'+e.altsourcemime+'"':"")+" />\n":"")+"</video>")(a,r)}},G=e=>e.hasAttribute("data-mce-object")||e.hasAttribute("data-ephox-embed-iri"),W={},q=e=>t=>B(e,t),H=(e,t)=>{const r=y(e);return r?((e,t,r)=>new Promise(((a,o)=>{const s=r=>(r.html&&(W[e.source]=r),a({url:e.source,html:r.html?r.html:t(e)}));W[e.source]?s(W[e.source]):r({url:e.source},s,o)})))(t,q(e),r):((e,t)=>Promise.resolve({html:t(e),url:e.source}))(t,q(e))},J=(e,t)=>{const r={};return d(e,"dimensions").each((e=>{c(["width","height"],(a=>{d(t,a).orThunk((()=>d(e,a))).each((e=>r[a]=e))}))})),r},K=(e,t)=>{const r=t&&"dimensions"!==t?((e,t)=>d(t,e).bind((e=>d(e,"meta"))))(t,e).getOr({}):{},o=((e,t,r)=>o=>{const s=()=>d(e,o),n=()=>d(t,o),c=e=>d(e,"value").bind((e=>e.length>0?i.some(e):i.none()));return{[o]:(o===r?s().bind((e=>a(e)?c(e).orThunk(n):n().orThunk((()=>i.from(e))))):n().orThunk((()=>s().bind((e=>a(e)?c(e):i.from(e)))))).getOr("")}})(e,r,t);return{...o("source"),...o("altsource"),...o("poster"),...o("embed"),...J(e,r)}},Q=e=>{const t={...e,source:{value:d(e,"source").getOr("")},altsource:{value:d(e,"altsource").getOr("")},poster:{value:d(e,"poster").getOr("")}};return c(["width","height"],(r=>{d(e,r).each((e=>{const a=t.dimensions||{};a[r]=e,t.dimensions=a}))})),t},V=e=>t=>{const r=t&&t.msg?"Media embed handler error: "+t.msg:"Media embed handler threw unknown error.";e.notificationManager.open({type:"error",text:r})},X=(e,t)=>a=>{if(r(a.url)&&a.url.trim().length>0){const r=a.html,o={...T(r,t.schema),source:a.url,embed:r};e.setData(Q(o))}},Y=(e,t)=>{const r=e.dom.select("*[data-mce-object]");e.insertContent(t),((e,t)=>{const r=e.dom.select("*[data-mce-object]");for(let e=0;e<t.length;e++)for(let a=r.length-1;a>=0;a--)t[e]===r[a]&&r.splice(a,1);e.selection.select(r[0])})(e,r),e.nodeChanged()},Z=e=>{const t=(e=>{const t=e.selection.getNode(),r=G(t)?e.serializer.serialize(t,{selection:!0}):"";return{embed:r,...T(r,e.schema)}})(e),r=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})(t),a=Q(t),o=j(e)?[{type:"sizeinput",name:"dimensions",label:"Constrain proportions",constrain:!0}]:[],s={title:"General",name:"general",items:l([[{name:"source",type:"urlinput",filetype:"media",label:"Source"}],o])},i=[];x(e)&&i.push({name:"altsource",type:"urlinput",filetype:"media",label:"Alternative source URL"}),_(e)&&i.push({name:"poster",type:"urlinput",filetype:"image",label:"Media poster (Image URL)"});const n={title:"Advanced",name:"advanced",items:i},c=[s,{title:"Embed",items:[{type:"textarea",name:"embed",label:"Paste your embed code below:"}]}];i.length>0&&c.push(n);const m={type:"tabpanel",tabs:c},u=e.windowManager.open({title:"Insert/Edit Media",size:"normal",body:m,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{const a=K(t.getData());((e,t,r)=>{var a,o;t.embed=E(null!==(a=t.embed)&&void 0!==a?a:"",t,!1,r.schema),t.embed&&(e.source===t.source||(o=t.source,h(W,o)))?Y(r,t.embed):H(r,t).then((e=>{Y(r,e.html)})).catch(V(r))})(r.get(),a,e),t.close()},onChange:(t,a)=>{switch(a.name){case"source":((t,r)=>{const a=K(r.getData(),"source");t.source!==a.source&&(X(u,e)({url:a.source,html:""}),H(e,a).then(X(u,e)).catch(V(e)))})(r.get(),t);break;case"embed":(t=>{var r;const a=K(t.getData()),o=T(null!==(r=a.embed)&&void 0!==r?r:"",e.schema);t.setData(Q(o))})(t);break;case"dimensions":case"altsource":case"poster":((t,r)=>{const a=K(t.getData(),r),o=B(e,a);t.setData(Q({...a,embed:o}))})(t,a.name)}r.set(K(t.getData()))},initialData:a})};var ee=tinymce.util.Tools.resolve("tinymce.Env");const te=e=>{const t=e.name;return"iframe"===t||"video"===t||"audio"===t},re=(e,t,r,a=null)=>{const o=e.attr(r);return s(o)?o:h(t,r)?null:a},ae=(e,t,r)=>{const a="img"===t.name||"video"===e.name,o=a?"300":null,s="audio"===e.name?"30":"150",i=a?s:null;t.attr({width:re(e,r,"width",o),height:re(e,r,"height",i)})},oe=(e,t)=>{const r=t.name,a=new z("img",1);return ie(e,t,a),ae(t,a,{}),a.attr({style:t.attr("style"),src:ee.transparentSrc,"data-mce-object":r,class:"mce-object mce-object-"+r}),a},se=(e,t)=>{var r;const a=t.name,o=new z("span",1);o.attr({contentEditable:"false",style:t.attr("style"),"data-mce-object":a,class:"mce-preview-object mce-object-"+a}),ie(e,t,o);const i=e.dom.parseStyle(null!==(r=t.attr("style"))&&void 0!==r?r:""),n=new z(a,1);if(ae(t,n,i),n.attr({src:t.attr("src"),style:t.attr("style"),class:t.attr("class")}),"iframe"===a)n.attr({allowfullscreen:t.attr("allowfullscreen"),frameborder:"0"});else{c(["controls","crossorigin","currentTime","loop","muted","poster","preload"],(e=>{n.attr(e,t.attr(e))}));const r=o.attr("data-mce-html");s(r)&&((e,t,r,a)=>{const o=F(e.schema).parse(a,{context:t});for(;o.firstChild;)r.append(o.firstChild)})(e,a,n,unescape(r))}const l=new z("span",1);return l.attr("class","mce-shim"),o.append(n),o.append(l),o},ie=(e,t,r)=>{var a;const o=null!==(a=t.attributes)&&void 0!==a?a:[];let s=o.length;for(;s--;){const t=o[s].name;let a=o[s].value;"width"===t||"height"===t||"style"===t||(n="data-mce-",(i=t).length>=n.length&&i.substr(0,0+n.length)===n)||("data"!==t&&"src"!==t||(a=e.convertURL(a,t)),r.attr("data-mce-p-"+t,a))}var i,n;const l=M({inner:!0},e.schema),m=new z("div",1);c(t.children(),(e=>m.append(e)));const u=l.serialize(m);u&&(r.attr("data-mce-html",escape(u)),r.empty())},ne=e=>{const t=e.attr("class");return r(t)&&/\btiny-pageembed\b/.test(t)},ce=e=>{let t=e;for(;t=t.parent;)if(t.attr("data-ephox-embed-iri")||ne(t))return!0;return!1},le=(e,t,r)=>{const a=f(e);return F(e.schema,{validate:a}).parse(r,{context:t})};e.add("media",(e=>((e=>{const t=e.options.register;t("audio_template_callback",{processor:"function"}),t("video_template_callback",{processor:"function"}),t("iframe_template_callback",{processor:"function"}),t("media_live_embeds",{processor:"boolean",default:!0}),t("media_filter_html",{processor:"boolean",default:!0}),t("media_url_resolver",{processor:"function"}),t("media_alt_source",{processor:"boolean",default:!0}),t("media_poster",{processor:"boolean",default:!0}),t("media_dimensions",{processor:"boolean",default:!0})})(e),(e=>{e.addCommand("mceMedia",(()=>{Z(e)}))})(e),(e=>{const t=()=>e.execCommand("mceMedia");e.ui.registry.addToggleButton("media",{tooltip:"Insert/edit media",icon:"embed",onAction:t,onSetup:t=>{const r=e.selection;return t.setActive(G(r.getNode())),r.selectorChangedWithUnbind("img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]",t.setActive).unbind}}),e.ui.registry.addMenuItem("media",{icon:"embed",text:"Media...",onAction:t})})(e),(e=>{e.on("ResolveName",(e=>{let t;1===e.target.nodeType&&(t=e.target.getAttribute("data-mce-object"))&&(e.name=t)}))})(e),(e=>{e.on("PreInit",(()=>{const{schema:t,serializer:r,parser:a}=e,o=t.getBoolAttrs();c("webkitallowfullscreen mozallowfullscreen".split(" "),(e=>{o[e]={}})),((e,t)=>{const r=m(e);for(let a=0,o=r.length;a<o;a++){const o=r[a];t(e[o],o)}})({embed:["wmode"]},((e,r)=>{const a=t.getElementRule(r);a&&c(e,(e=>{a.attributes[e]={},a.attributesOrder.push(e)}))})),a.addNodeFilter("iframe,video,audio,object,embed,script",(e=>t=>{let r,a=t.length;for(;a--;)r=t[a],r.parent&&(r.parent.attr("data-mce-object")||(te(r)&&v(e)?ce(r)||r.replace(se(e,r)):ce(r)||r.replace(oe(e,r))))})(e)),r.addAttributeFilter("data-mce-object",((t,r)=>{var a;let o=t.length;for(;o--;){const s=t[o];if(!s.parent)continue;const i=s.attr(r),n=new z(i,1);if("audio"!==i&&"script"!==i){const e=s.attr("class");e&&-1!==e.indexOf("mce-preview-object")&&s.firstChild?n.attr({width:s.firstChild.attr("width"),height:s.firstChild.attr("height")}):n.attr({width:s.attr("width"),height:s.attr("height")})}n.attr({style:s.attr("style")});const l=null!==(a=s.attributes)&&void 0!==a?a:[];let m=l.length;for(;m--;){const e=l[m].name;0===e.indexOf("data-mce-p-")&&n.attr(e.substr(11),l[m].value)}"script"===i&&n.attr("type","text/javascript");const u=s.attr("data-mce-html");if(u){const t=le(e,i,unescape(u));c(t.children(),(e=>n.append(e)))}s.replace(n)}}))})),e.on("SetContent",(()=>{const t=e.dom;c(t.select("span.mce-preview-object"),(e=>{0===t.select("span.mce-shim",e).length&&t.add(e,"span",{class:"mce-shim"})}))}))})(e),(e=>{e.on("click keyup touchend",(()=>{const t=e.selection.getNode();t&&e.dom.hasClass(t,"mce-preview-object")&&e.dom.getAttrib(t,"data-mce-selected")&&t.setAttribute("data-mce-selected","2")})),e.on("ObjectSelected",(e=>{"script"===e.target.getAttribute("data-mce-object")&&e.preventDefault()})),e.on("ObjectResized",(t=>{const r=t.target;if(r.getAttribute("data-mce-object")){let a=r.getAttribute("data-mce-html");a&&(a=unescape(a),r.setAttribute("data-mce-html",escape(E(a,{width:String(t.width),height:String(t.height)},!1,e.schema))))}}))})(e),(e=>({showDialog:()=>{Z(e)}}))(e))))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=n=>e=>typeof e===n,a=e("boolean"),o=e("number"),t=n=>e=>e.options.get(n),i=t("nonbreaking_force_tab"),r=t("nonbreaking_wrap"),s=(n,e)=>{let a="";for(let o=0;o<e;o++)a+=n;return a},c=(n,e)=>{const a=r(n)||n.plugins.visualchars?`<span class="${(n=>!!n.plugins.visualchars&&n.plugins.visualchars.isEnabled())(n)?"mce-nbsp-wrap mce-nbsp":"mce-nbsp-wrap"}" contenteditable="false">${s("&nbsp;",e)}</span>`:s("&nbsp;",e);n.undoManager.transact((()=>n.insertContent(a)))};var l=tinymce.util.Tools.resolve("tinymce.util.VK");n.add("nonbreaking",(n=>{(n=>{const e=n.options.register;e("nonbreaking_force_tab",{processor:n=>a(n)?{value:n?3:0,valid:!0}:o(n)?{value:n,valid:!0}:{valid:!1,message:"Must be a boolean or number."},default:!1}),e("nonbreaking_wrap",{processor:"boolean",default:!0})})(n),(n=>{n.addCommand("mceNonBreaking",(()=>{c(n,1)}))})(n),(n=>{const e=()=>n.execCommand("mceNonBreaking");n.ui.registry.addButton("nonbreaking",{icon:"non-breaking",tooltip:"Nonbreaking space",onAction:e}),n.ui.registry.addMenuItem("nonbreaking",{icon:"non-breaking",text:"Nonbreaking space",onAction:e})})(n),(n=>{const e=i(n);e>0&&n.on("keydown",(a=>{if(a.keyCode===l.TAB&&!a.isDefaultPrevented()){if(a.shiftKey)return;a.preventDefault(),a.stopImmediatePropagation(),c(n,e)}}))})(n)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=tinymce.util.Tools.resolve("tinymce.Env");const t=e=>a=>a.options.get(e),r=t("pagebreak_separator"),n=t("pagebreak_split_block"),o="mce-pagebreak",s=e=>{const t=`<img src="${a.transparentSrc}" class="mce-pagebreak" data-mce-resize="false" data-mce-placeholder />`;return e?`<p>${t}</p>`:t};e.add("pagebreak",(e=>{(e=>{const a=e.options.register;a("pagebreak_separator",{processor:"string",default:"\x3c!-- pagebreak --\x3e"}),a("pagebreak_split_block",{processor:"boolean",default:!1})})(e),(e=>{e.addCommand("mcePageBreak",(()=>{e.insertContent(s(n(e)))}))})(e),(e=>{const a=()=>e.execCommand("mcePageBreak");e.ui.registry.addButton("pagebreak",{icon:"page-break",tooltip:"Page break",onAction:a}),e.ui.registry.addMenuItem("pagebreak",{text:"Page break",icon:"page-break",onAction:a})})(e),(e=>{const a=r(e),t=()=>n(e),c=new RegExp(a.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,(e=>"\\"+e)),"gi");e.on("BeforeSetContent",(e=>{e.content=e.content.replace(c,s(t()))})),e.on("PreInit",(()=>{e.serializer.addNodeFilter("img",(r=>{let n,s,c=r.length;for(;c--;)if(n=r[c],s=n.attr("class"),s&&-1!==s.indexOf(o)){const r=n.parent;if(r&&e.schema.getBlockElements()[r.name]&&t()){r.type=3,r.value=a,r.raw=!0,n.remove();continue}n.type=3,n.value=a,n.raw=!0}}))}))})(e),(e=>{e.on("ResolveName",(a=>{"IMG"===a.target.nodeName&&e.dom.hasClass(a.target,o)&&(a.name="pagebreak")}))})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.Env"),o=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=e=>t=>t.options.get(e),i=n("content_style"),s=n("content_css_cors"),c=n("body_class"),r=n("body_id");e.add("preview",(e=>{(e=>{e.addCommand("mcePreview",(()=>{(e=>{const n=(e=>{var n;let l="";const a=e.dom.encode,d=null!==(n=i(e))&&void 0!==n?n:"";l+='<base href="'+a(e.documentBaseURI.getURI())+'">';const m=s(e)?' crossorigin="anonymous"':"";o.each(e.contentCSS,(t=>{l+='<link type="text/css" rel="stylesheet" href="'+a(e.documentBaseURI.toAbsolute(t))+'"'+m+">"})),d&&(l+='<style type="text/css">'+d+"</style>");const y=r(e),u=c(e),v='<script>document.addEventListener && document.addEventListener("click", function(e) {for (var elm = e.target; elm; elm = elm.parentNode) {if (elm.nodeName === "A" && !('+(t.os.isMacOS()||t.os.isiOS()?"e.metaKey":"e.ctrlKey && !e.altKey")+")) {e.preventDefault();}}}, false);<\/script> ",p=e.getBody().dir,w=p?' dir="'+a(p)+'"':"";return"<!DOCTYPE html><html><head>"+l+'</head><body id="'+a(y)+'" class="mce-content-body '+a(u)+'"'+w+">"+e.getContent()+v+"</body></html>"})(e);e.windowManager.open({title:"Preview",size:"large",body:{type:"panel",items:[{name:"preview",type:"iframe",sandboxed:!0,transparent:!1}]},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}],initialData:{preview:n}}).focus("close")})(e)}))})(e),(e=>{const t=()=>e.execCommand("mcePreview");e.ui.registry.addButton("preview",{icon:"preview",tooltip:"Preview",onAction:t}),e.ui.registry.addMenuItem("preview",{icon:"preview",text:"Preview",onAction:t})})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>typeof t===e,o=("string",e=>"string"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(i=n.constructor)||void 0===i?void 0:i.name)===r.name)?"string":t;var o,n,r,i})(e));const n=t("boolean"),r=t("function"),i=e=>t=>t.options.get(e),s=i("quickbars_selection_toolbar"),a=i("quickbars_insert_toolbar"),l=i("quickbars_image_toolbar");let c=0;var u=tinymce.util.Tools.resolve("tinymce.Env"),d=tinymce.util.Tools.resolve("tinymce.util.Delay");const m=e=>{e.ui.registry.addButton("quickimage",{icon:"image",tooltip:"Insert image",onAction:()=>{(e=>new Promise((t=>{const o=document.createElement("input");o.type="file",o.accept="image/*",o.style.position="fixed",o.style.left="0",o.style.top="0",o.style.opacity="0.001",document.body.appendChild(o),o.addEventListener("change",(e=>{t(Array.prototype.slice.call(e.target.files))}));const n=r=>{const i=()=>{var e;t([]),null===(e=o.parentNode)||void 0===e||e.removeChild(o)};u.os.isAndroid()&&"remove"!==r.type?d.setEditorTimeout(e,i,0):i(),e.off("focusin remove",n)};e.on("focusin remove",n),o.click()})))(e).then((t=>{if(t.length>0){const o=t[0];(e=>new Promise((t=>{const o=new FileReader;o.onloadend=()=>{t(o.result.split(",")[1])},o.readAsDataURL(e)})))(o).then((t=>{((e,t,o)=>{const n=e.editorUpload.blobCache,r=n.create((e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return c++,"mceu_"+o+c+String(t)})(),o,t);n.add(r),e.insertContent(e.dom.createHTML("img",{src:r.blobUri()}))})(e,t,o)}))}}))}}),e.ui.registry.addButton("quicktable",{icon:"table",tooltip:"Insert table",onAction:()=>{((e,t,o)=>{e.execCommand("mceInsertTable",!1,{rows:2,columns:2})})(e)}})},g=(!1,()=>false);class h{constructor(e,t){this.tag=e,this.value=t}static some(e){return new h(!0,e)}static none(){return h.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?h.some(e(this.value)):h.none()}bind(e){return this.tag?e(this.value):h.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:h.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return null==e?h.none():h.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}h.singletonNone=new h(!1),"undefined"!=typeof window?window:Function("return this;")();var b=(e,t,o,n,i)=>e(o,n)?h.some(o):r(i)&&i(o)?h.none():t(o,n,i);const v=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},p=v,f=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},y=(e,t,o)=>{let n=e.dom;const i=r(o)?o:g;for(;n.parentNode;){n=n.parentNode;const e=p(n);if(t(e))return h.some(e);if(i(e))break}return h.none()},k=(e,t,o)=>y(e,(e=>f(e,t)),o),w=e=>{const t=a(e);t.length>0&&e.ui.registry.addContextToolbar("quickblock",{predicate:t=>{const o=p(t),n=e.schema.getTextBlockElements(),r=t=>t.dom===e.getBody();return!((e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute("data-mce-bogus")})(o)&&((e,t,o)=>b(((e,t)=>f(e,t)),k,e,'table,[data-mce-bogus="all"]',o))(o,0,r).fold((()=>((e,t,o)=>((e,t,o)=>b(((e,t)=>t(e)),y,e,t,o))(e,t,o).isSome())(o,(t=>t.dom.nodeName.toLowerCase()in n&&e.dom.isEmpty(t.dom)),r)),g)},items:t,position:"line",scope:"editor"})};e.add("quickbars",(e=>{(e=>{const t=e.options.register,r=e=>t=>{const r=n(t)||o(t);return r?n(t)?{value:t?e:"",valid:r}:{value:t.trim(),valid:r}:{valid:!1,message:"Must be a boolean or string."}},i="bold italic | quicklink h2 h3 blockquote";t("quickbars_selection_toolbar",{processor:r(i),default:i});const s="quickimage quicktable";t("quickbars_insert_toolbar",{processor:r(s),default:s});const a="alignleft aligncenter alignright";t("quickbars_image_toolbar",{processor:r(a),default:a})})(e),m(e),w(e),(e=>{const t=e=>"IMG"===e.nodeName||"FIGURE"===e.nodeName&&/image/i.test(e.className),o=l(e);o.length>0&&e.ui.registry.addContextToolbar("imageselection",{predicate:t,items:o,position:"node"});const n=s(e);n.length>0&&e.ui.registry.addContextToolbar("textselection",{predicate:o=>!t(o)&&!e.selection.isCollapsed()&&(t=>"false"!==e.dom.getContentEditableParent(t))(o),items:n,position:"selection",scope:"editor"})})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const n=("function",e=>"function"==typeof e);var o=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),t=tinymce.util.Tools.resolve("tinymce.util.Tools");const a=e=>n=>n.options.get(e),c=a("save_enablewhendirty"),i=a("save_onsavecallback"),s=a("save_oncancelcallback"),r=(e,n)=>{e.notificationManager.open({text:n,type:"error"})},l=e=>n=>{const o=()=>{n.setEnabled(!c(e)||e.isDirty())};return o(),e.on("NodeChange dirty",o),()=>e.off("NodeChange dirty",o)};e.add("save",(e=>{(e=>{const n=e.options.register;n("save_enablewhendirty",{processor:"boolean",default:!0}),n("save_onsavecallback",{processor:"function"}),n("save_oncancelcallback",{processor:"function"})})(e),(e=>{e.ui.registry.addButton("save",{icon:"save",tooltip:"Save",enabled:!1,onAction:()=>e.execCommand("mceSave"),onSetup:l(e)}),e.ui.registry.addButton("cancel",{icon:"cancel",tooltip:"Cancel",enabled:!1,onAction:()=>e.execCommand("mceCancel"),onSetup:l(e)}),e.addShortcut("Meta+S","","mceSave")})(e),(e=>{e.addCommand("mceSave",(()=>{(e=>{const t=o.DOM.getParent(e.id,"form");if(c(e)&&!e.isDirty())return;e.save();const a=i(e);if(n(a))return a.call(e,e),void e.nodeChanged();t?(e.setDirty(!1),t.onsubmit&&!t.onsubmit()||("function"==typeof t.submit?t.submit():r(e,"Error: Form submit field collision.")),e.nodeChanged()):r(e,"Error: No form element found.")})(e)})),e.addCommand("mceCancel",(()=>{(e=>{const o=t.trim(e.startContent),a=s(e);n(a)?a.call(e,e):e.resetContent(o)})(e)}))})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";const e=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}};var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const n=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=o=e,(r=String).prototype.isPrototypeOf(n)||(null===(s=o.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var n,o,r,s})(t)===e,o=e=>t=>typeof t===e,r=n("string"),s=n("array"),a=o("boolean"),l=o("number"),i=()=>{},c=e=>()=>e,d=c(!0),u=c("[!-#%-*,-\\/:;?@\\[-\\]_{}\xa1\xab\xb7\xbb\xbf;\xb7\u055a-\u055f\u0589\u058a\u05be\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1361-\u1368\u1400\u166d\u166e\u169b\u169c\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cd3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205e\u207d\u207e\u208d\u208e\u3008\u3009\u2768-\u2775\u27c5\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc\u29fd\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e2e\u2e30\u2e31\u3001-\u3003\u3008-\u3011\u3014-\u301f\u3030\u303d\u30a0\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uabeb\ufd3e\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a\uff1b\uff1f\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]");class m{constructor(e,t){this.tag=e,this.value=t}static some(e){return new m(!0,e)}static none(){return m.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?m.some(e(this.value)):m.none()}bind(e){return this.tag?e(this.value):m.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:m.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return null==e?m.none():m.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}m.singletonNone=new m(!1);const h=u;var g=tinymce.util.Tools.resolve("tinymce.Env"),f=tinymce.util.Tools.resolve("tinymce.util.Tools");const p=Array.prototype.slice,x=Array.prototype.push,y=(e,t)=>{const n=e.length,o=new Array(n);for(let r=0;r<n;r++){const n=e[r];o[r]=t(n,r)}return o},w=(e,t)=>{for(let n=0,o=e.length;n<o;n++)t(e[n],n)},b=(e,t)=>{for(let n=e.length-1;n>=0;n--)t(e[n],n)},v=(e,t)=>(e=>{const t=[];for(let n=0,o=e.length;n<o;++n){if(!s(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);x.apply(t,e[n])}return t})(y(e,t)),C=Object.hasOwnProperty,E=(e,t)=>C.call(e,t);"undefined"!=typeof window?window:Function("return this;")();const O=(3,e=>3===(e=>e.dom.nodeType)(e));const N=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},T=N,k=(e,t)=>({element:e,offset:t}),A=(e,t)=>{((e,t)=>{const n=(e=>m.from(e.dom.parentNode).map(T))(e);n.each((n=>{n.dom.insertBefore(t.dom,e.dom)}))})(e,t),((e,t)=>{e.dom.appendChild(t.dom)})(t,e)},S=((e,t)=>{const n=t=>e(t)?m.from(t.dom.nodeValue):m.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return n(t).getOr("")},getOption:n,set:(t,n)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=n}}})(O),B=e=>S.get(e);var F=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");const I=(e,t)=>e.isBlock(t)||E(e.schema.getVoidElements(),t.nodeName),M=(e,t)=>"false"===e.getContentEditable(t),R=(e,t)=>!e.isBlock(t)&&E(e.schema.getWhitespaceElements(),t.nodeName),P=(e,t)=>((e,t)=>{const n=(e=>y(e.dom.childNodes,T))(e);return n.length>0&&t<n.length?k(n[t],0):k(e,t)})(T(e),t),D=(e,t,n,o,r,s=!0)=>{let a=s?t(!1):n;for(;a;){const n=M(e,a);if(n||R(e,a)){if(n?o.cef(a):o.boundary(a))break;a=t(!0)}else{if(I(e,a)){if(o.boundary(a))break}else 3===a.nodeType&&o.text(a);if(a===r)break;a=t(!1)}}},W=(e,t,n,o,r)=>{var s;if(((e,t)=>I(e,t)||M(e,t)||R(e,t)||((e,t)=>"true"===e.getContentEditable(t)&&t.parentNode&&"false"===e.getContentEditableParent(t.parentNode))(e,t))(e,n))return;const a=null!==(s=e.getParent(o,e.isBlock))&&void 0!==s?s:e.getRoot(),l=new F(n,a),i=r?l.next.bind(l):l.prev.bind(l);D(e,i,n,{boundary:d,cef:d,text:e=>{r?t.fOffset+=e.length:t.sOffset+=e.length,t.elements.push(T(e))}})},$=(e,t,n,o,r,s=!0)=>{const a=new F(n,t),l=[];let i={sOffset:0,fOffset:0,elements:[]};W(e,i,n,t,!1);const c=()=>(i.elements.length>0&&(l.push(i),i={sOffset:0,fOffset:0,elements:[]}),!1);return D(e,a.next.bind(a),n,{boundary:c,cef:e=>(c(),r&&l.push(...r.cef(e)),!1),text:e=>{i.elements.push(T(e)),r&&r.text(e,i)}},o,s),o&&W(e,i,o,t,!0),c(),l},V=(e,t)=>{const n=P(t.startContainer,t.startOffset),o=n.element.dom,r=P(t.endContainer,t.endOffset),s=r.element.dom;return $(e,t.commonAncestorContainer,o,s,{text:(e,t)=>{e===s?t.fOffset+=e.length-r.offset:e===o&&(t.sOffset+=n.offset)},cef:t=>{return((e,t)=>{const n=p.call(e,0);return n.sort(((e,t)=>((e,t)=>((e,t,n)=>0!=(e.compareDocumentPosition(t)&n))(e,t,Node.DOCUMENT_POSITION_PRECEDING))(e.elements[0].dom,t.elements[0].dom)?1:-1)),n})(v((n=T(t),((e,t)=>{const n=void 0===t?document:t.dom;return 1!==(o=n).nodeType&&9!==o.nodeType&&11!==o.nodeType||0===o.childElementCount?[]:y(n.querySelectorAll(e),T);var o})("*[contenteditable=true]",n)),(t=>{const n=t.dom;return $(e,n,n)})));var n}},!1)},j=(e,t)=>t.collapsed?[]:V(e,t),_=(e,t)=>{const n=e.createRng();return n.selectNode(t),j(e,n)},z=(e,t)=>v(t,(t=>{const n=t.elements,o=y(n,B).join(""),r=((e,t,n=0,o=e.length)=>{const r=t.regex;r.lastIndex=n;const s=[];let a;for(;a=r.exec(e);){const e=a[t.matchIndex],n=a.index+a[0].indexOf(e),l=n+e.length;if(l>o)break;s.push({start:n,finish:l}),r.lastIndex=l}return s})(o,e,t.sOffset,o.length-t.fOffset);return((e,t)=>{const n=(o=e,r=(e,n)=>{const o=B(n),r=e.last,s=r+o.length,a=v(t,((e,t)=>e.start<s&&e.finish>r?[{element:n,start:Math.max(r,e.start)-r,finish:Math.min(s,e.finish)-r,matchId:t}]:[]));return{results:e.results.concat(a),last:s}},s={results:[],last:0},w(o,((e,t)=>{s=r(s,e)})),s).results;var o,r,s;return((e,t)=>{if(0===e.length)return[];{let n=t(e[0]);const o=[];let r=[];for(let s=0,a=e.length;s<a;s++){const a=e[s],l=t(a);l!==n&&(o.push(r),r=[]),n=l,r.push(a)}return 0!==r.length&&o.push(r),o}})(n,(e=>e.matchId))})(n,r)})),U=(e,t)=>{b(e,((e,n)=>{b(e,(e=>{const o=T(t.cloneNode(!1));((e,t,n)=>{((e,t,n)=>{if(!(r(n)||a(n)||l(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")})(e.dom,t,n)})(o,"data-mce-index",n);const s=e.element.dom;if(s.length===e.finish&&0===e.start)A(e.element,o);else{s.length!==e.finish&&s.splitText(e.finish);const t=s.splitText(e.start);A(T(t),o)}}))}))},q=e=>e.getAttribute("data-mce-index"),G=(e,t,n,o)=>{const r=e.dom.create("span",{"data-mce-bogus":1});r.className="mce-match-marker";const s=e.getBody();return te(e,t,!1),o?((e,t,n,o)=>{const r=n.getBookmark(),s=e.select("td[data-mce-selected],th[data-mce-selected]"),a=s.length>0?((e,t)=>v(t,(t=>_(e,t))))(e,s):j(e,n.getRng()),l=z(t,a);return U(l,o),n.moveToBookmark(r),l.length})(e.dom,n,e.selection,r):((e,t,n,o)=>{const r=_(e,n),s=z(t,r);return U(s,o),s.length})(e.dom,n,s,r)},K=e=>{var t;const n=e.parentNode;e.firstChild&&n.insertBefore(e.firstChild,e),null===(t=e.parentNode)||void 0===t||t.removeChild(e)},H=(e,t)=>{const n=[],o=f.toArray(e.getBody().getElementsByTagName("span"));if(o.length)for(let e=0;e<o.length;e++){const r=q(o[e]);null!==r&&r.length&&r===t.toString()&&n.push(o[e])}return n},J=(e,t,n)=>{const o=t.get();let r=o.index;const s=e.dom;n?r+1===o.count?r=0:r++:r-1==-1?r=o.count-1:r--,s.removeClass(H(e,o.index),"mce-match-marker-selected");const a=H(e,r);return a.length?(s.addClass(H(e,r),"mce-match-marker-selected"),e.selection.scrollIntoView(a[0]),r):-1},L=(e,t)=>{const n=t.parentNode;e.remove(t),n&&e.isEmpty(n)&&e.remove(n)},Q=(e,t,n,o,r,s)=>{const a=e.selection,l=((e,t)=>{const n="("+e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&").replace(/\s/g,"[^\\S\\r\\n\\uFEFF]")+")";return t?`(?:^|\\s|${h()})`+n+`(?=$|\\s|${h()})`:n})(n,r),i=a.isForward(),c={regex:new RegExp(l,o?"g":"gi"),matchIndex:1},d=G(e,t,c,s);if(g.browser.isSafari()&&a.setRng(a.getRng(),i),d){const a=J(e,t,!0);t.set({index:a,count:d,text:n,matchCase:o,wholeWord:r,inSelection:s})}return d},X=(e,t)=>{const n=J(e,t,!0);t.set({...t.get(),index:n})},Y=(e,t)=>{const n=J(e,t,!1);t.set({...t.get(),index:n})},Z=e=>{const t=q(e);return null!==t&&t.length>0},ee=(e,t,n,o,r)=>{const s=t.get(),a=s.index;let l,i=a;o=!1!==o;const c=e.getBody(),d=f.grep(f.toArray(c.getElementsByTagName("span")),Z);for(let t=0;t<d.length;t++){const c=q(d[t]);let u=l=parseInt(c,10);if(r||u===s.index){for(n.length?(d[t].innerText=n,K(d[t])):L(e.dom,d[t]);d[++t];){if(u=parseInt(q(d[t]),10),u!==l){t--;break}L(e.dom,d[t])}o&&i--}else l>a&&d[t].setAttribute("data-mce-index",String(l-1))}return t.set({...s,count:r?0:s.count-1,index:i}),o?X(e,t):Y(e,t),!r&&t.get().count>0},te=(e,t,n)=>{let o,r;const s=t.get(),a=f.toArray(e.getBody().getElementsByTagName("span"));for(let e=0;e<a.length;e++){const t=q(a[e]);null!==t&&t.length&&(t===s.index.toString()&&(o||(o=a[e].firstChild),r=a[e].firstChild),K(a[e]))}if(t.set({...s,index:-1,count:0,text:""}),o&&r){const t=e.dom.createRng();return t.setStart(o,0),t.setEnd(r,r.data.length),!1!==n&&e.selection.setRng(t),t}},ne=(t,n)=>{const o=(()=>{const t=(t=>{const n=e(m.none()),o=()=>n.get().each(t);return{clear:()=>{o(),n.set(m.none())},isSet:()=>n.get().isSome(),get:()=>n.get(),set:e=>{o(),n.set(m.some(e))}}})(i);return{...t,on:e=>t.get().each(e)}})();t.undoManager.add();const r=f.trim(t.selection.getContent({format:"text"})),s=e=>{e.setEnabled("next",((e,t)=>t.get().count>1)(0,n)),e.setEnabled("prev",((e,t)=>t.get().count>1)(0,n))},a=(e,t)=>{w(["replace","replaceall","prev","next"],(n=>e.setEnabled(n,!t)))},l=(e,t)=>{g.browser.isSafari()&&g.deviceType.isTouch()&&("find"===t||"replace"===t||"replaceall"===t)&&e.focus(t)},c=e=>{te(t,n,!1),a(e,!0),s(e)},d=e=>{const o=e.getData(),r=n.get();if(o.findtext.length){if(r.text===o.findtext&&r.matchCase===o.matchcase&&r.wholeWord===o.wholewords)X(t,n);else{const r=Q(t,n,o.findtext,o.matchcase,o.wholewords,o.inselection);r<=0&&(e=>{t.windowManager.alert("Could not find the specified string.",(()=>{e.focus("findtext")}))})(e),a(e,0===r)}s(e)}else c(e)},u=n.get(),h={title:"Find and Replace",size:"normal",body:{type:"panel",items:[{type:"bar",items:[{type:"input",name:"findtext",placeholder:"Find",maximized:!0,inputMode:"search"},{type:"button",name:"prev",text:"Previous",icon:"action-prev",enabled:!1,borderless:!0},{type:"button",name:"next",text:"Next",icon:"action-next",enabled:!1,borderless:!0}]},{type:"input",name:"replacetext",placeholder:"Replace with",inputMode:"search"}]},buttons:[{type:"menu",name:"options",icon:"preferences",tooltip:"Preferences",align:"start",items:[{type:"togglemenuitem",name:"matchcase",text:"Match case"},{type:"togglemenuitem",name:"wholewords",text:"Find whole words only"},{type:"togglemenuitem",name:"inselection",text:"Find in selection"}]},{type:"custom",name:"find",text:"Find",primary:!0},{type:"custom",name:"replace",text:"Replace",enabled:!1},{type:"custom",name:"replaceall",text:"Replace all",enabled:!1}],initialData:{findtext:r,replacetext:"",wholewords:u.wholeWord,matchcase:u.matchCase,inselection:u.inSelection},onChange:(e,t)=>{"findtext"===t.name&&n.get().count>0&&c(e)},onAction:(e,o)=>{const r=e.getData();switch(o.name){case"find":d(e);break;case"replace":ee(t,n,r.replacetext)?s(e):c(e);break;case"replaceall":ee(t,n,r.replacetext,!0,!0),c(e);break;case"prev":Y(t,n),s(e);break;case"next":X(t,n),s(e);break;case"matchcase":case"wholewords":case"inselection":(e=>{const t=e.getData(),o=n.get();n.set({...o,matchCase:t.matchcase,wholeWord:t.wholewords,inSelection:t.inselection})})(e),c(e)}l(e,o.name)},onSubmit:e=>{d(e),l(e,"find")},onClose:()=>{t.focus(),te(t,n),t.undoManager.add()}};o.set(t.windowManager.open(h,{inline:"toolbar"}))},oe=(e,t)=>()=>{ne(e,t)};t.add("searchreplace",(t=>{const n=e({index:-1,count:0,text:"",matchCase:!1,wholeWord:!1,inSelection:!1});return((e,t)=>{e.addCommand("SearchReplace",(()=>{ne(e,t)}))})(t,n),((e,t)=>{e.ui.registry.addMenuItem("searchreplace",{text:"Find and replace...",shortcut:"Meta+F",onAction:oe(e,t),icon:"search"}),e.ui.registry.addButton("searchreplace",{tooltip:"Find and replace",onAction:oe(e,t),icon:"search"}),e.shortcuts.add("Meta+F","",oe(e,t))})(t,n),((e,t)=>({done:n=>te(e,t,n),find:(n,o,r,s=!1)=>Q(e,t,n,o,r,s),next:()=>X(e,t),prev:()=>Y(e,t),replace:(n,o,r)=>ee(e,t,n,o,r)}))(t,n)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=l=e,(n=String).prototype.isPrototypeOf(o)||(null===(r=l.constructor)||void 0===r?void 0:r.name)===n.name)?"string":t;var o,l,n,r})(t)===e,o=e=>t=>typeof t===e,l=t("string"),n=t("array"),r=o("boolean"),a=(void 0,e=>undefined===e);const s=e=>!(e=>null==e)(e),c=o("function"),i=o("number"),m=()=>{},d=e=>()=>e,u=e=>e,p=(e,t)=>e===t;function b(e,...t){return(...o)=>{const l=t.concat(o);return e.apply(null,l)}}const g=e=>{e()},h=d(!1),f=d(!0);class y{constructor(e,t){this.tag=e,this.value=t}static some(e){return new y(!0,e)}static none(){return y.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?y.some(e(this.value)):y.none()}bind(e){return this.tag?e(this.value):y.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:y.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return s(e)?y.some(e):y.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}y.singletonNone=new y(!1);const w=Object.keys,S=Object.hasOwnProperty,C=(e,t)=>{const o=w(e);for(let l=0,n=o.length;l<n;l++){const n=o[l];t(e[n],n)}},v=(e,t)=>{const o={};var l;return((e,t,o,l)=>{C(e,((e,n)=>{(t(e,n)?o:l)(e,n)}))})(e,t,(l=o,(e,t)=>{l[t]=e}),m),o},T=e=>w(e).length,x=(e,t)=>A(e,t)?y.from(e[t]):y.none(),A=(e,t)=>S.call(e,t),R=(e,t)=>A(e,t)&&void 0!==e[t]&&null!==e[t],O=Array.prototype.indexOf,_=Array.prototype.push,D=(e,t)=>((e,t)=>O.call(e,t))(e,t)>-1,I=(e,t)=>{for(let o=0,l=e.length;o<l;o++)if(t(e[o],o))return!0;return!1},M=(e,t)=>{const o=[];for(let l=0;l<e;l++)o.push(t(l));return o},N=(e,t)=>{const o=e.length,l=new Array(o);for(let n=0;n<o;n++){const o=e[n];l[n]=t(o,n)}return l},P=(e,t)=>{for(let o=0,l=e.length;o<l;o++)t(e[o],o)},k=(e,t)=>{const o=[];for(let l=0,n=e.length;l<n;l++){const n=e[l];t(n,l)&&o.push(n)}return o},B=(e,t,o)=>(P(e,((e,l)=>{o=t(o,e,l)})),o),E=(e,t)=>((e,t,o)=>{for(let l=0,n=e.length;l<n;l++){const n=e[l];if(t(n,l))return y.some(n);if(o(n,l))break}return y.none()})(e,t,h),F=(e,t)=>(e=>{const t=[];for(let o=0,l=e.length;o<l;++o){if(!n(e[o]))throw new Error("Arr.flatten item "+o+" was not an array, input: "+e);_.apply(t,e[o])}return t})(N(e,t)),q=(e,t)=>{for(let o=0,l=e.length;o<l;++o)if(!0!==t(e[o],o))return!1;return!0},L=(e,t)=>t>=0&&t<e.length?y.some(e[t]):y.none(),H=(e,t)=>{for(let o=0;o<e.length;o++){const l=t(e[o],o);if(l.isSome())return l}return y.none()},j=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},V={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return j(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return j(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return j(o)},fromDom:j,fromPoint:(e,t,o)=>y.from(e.dom.elementFromPoint(t,o)).map(j)};"undefined"!=typeof window?window:Function("return this;")();const z=e=>e.dom.nodeName.toLowerCase(),W=e=>e.dom.nodeType,$=e=>t=>W(t)===e,U=$(1),G=$(3),K=$(9),J=$(11),Q=e=>t=>U(t)&&z(t)===e,X=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Y=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Z=(e,t)=>e.dom===t.dom,ee=X,te=e=>K(e)?e:V.fromDom(e.dom.ownerDocument),oe=e=>y.from(e.dom.parentNode).map(V.fromDom),le=e=>y.from(e.dom.nextSibling).map(V.fromDom),ne=e=>N(e.dom.childNodes,V.fromDom),re=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?e=>V.fromDom(e.dom.getRootNode()):te,ae=e=>V.fromDom(e.dom.host),se=e=>{const t=G(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=re(e);return J(o=t)&&s(o.dom.host)?y.some(t):y.none();var o})(V.fromDom(t)).fold((()=>o.body.contains(t)),(l=se,n=ae,e=>l(n(e))));var l,n},ce=(e,t)=>{let o=[];return P(ne(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(ce(e,t))})),o},ie=(e,t)=>((e,o)=>k(ne(e),(e=>X(e,t))))(e),me=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Y(o)?[]:N(o.querySelectorAll(e),V.fromDom)})(t,e),de=(e,t,o)=>{let l=e.dom;const n=c(o)?o:h;for(;l.parentNode;){l=l.parentNode;const e=V.fromDom(l);if(t(e))return y.some(e);if(n(e))break}return y.none()},ue=(e,t,o)=>de(e,(e=>X(e,t)),o),pe=(e,t)=>((e,o)=>E(e.dom.childNodes,(e=>{return o=V.fromDom(e),X(o,t);var o})).map(V.fromDom))(e),be=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Y(o)?y.none():y.from(o.querySelector(e)).map(V.fromDom)})(t,e),ge=(e,t,o)=>((e,t,o,l,n)=>((e,t)=>X(e,t))(o,l)?y.some(o):c(n)&&n(o)?y.none():t(o,l,n))(0,ue,e,t,o),he=(e,t,o)=>{if(!(l(o)||r(o)||i(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},fe=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},ye=(e,t)=>y.from(fe(e,t)),we=(e,t)=>{e.dom.removeAttribute(t)},Se=(e,t,o=p)=>e.exists((e=>o(e,t))),Ce=(e,t,o)=>e.isSome()&&t.isSome()?y.some(o(e.getOrDie(),t.getOrDie())):y.none(),ve=(e,t)=>((e,t,o)=>""===t||e.length>=t.length&&e.substr(0,0+t.length)===t)(e,t),Te=(xe=/^\s+|\s+$/g,e=>e.replace(xe,""));var xe;const Ae=e=>e.length>0,Re=(e,t=10)=>{const o=parseInt(e,t);return isNaN(o)?y.none():y.some(o)},Oe=e=>void 0!==e.style&&c(e.style.getPropertyValue),_e=(e,t)=>{const o=e.dom,l=window.getComputedStyle(o).getPropertyValue(t);return""!==l||se(e)?l:De(o,t)},De=(e,t)=>Oe(e)?e.style.getPropertyValue(t):"",Ie=(e,t)=>{const o=e.dom,l=De(o,t);return y.from(l).filter((e=>e.length>0))},Me=(e,t,o=0)=>ye(e,t).map((e=>parseInt(e,10))).getOr(o),Ne=(e,t)=>Pe(e,t,f),Pe=(e,t,o)=>F(ne(e),(e=>X(e,t)?o(e)?[e]:[]:Pe(e,t,o))),ke=["tfoot","thead","tbody","colgroup"],Be=(e,t,o)=>({element:e,rowspan:t,colspan:o}),Ee=(e,t,o)=>({element:e,cells:t,section:o}),Fe=(e,t)=>ge(e,"table",t),qe=e=>Ne(e,"tr"),Le=e=>Fe(e).fold(d([]),(e=>ie(e,"colgroup"))),He=e=>oe(e).map((e=>{const t=z(e);return(e=>D(ke,e))(t)?t:"tbody"})).getOr("tbody"),je=e=>ye(e,"data-snooker-locked-cols").bind((e=>y.from(e.match(/\d+/g)))).map((e=>((e,t)=>{const o={};for(let l=0,n=e.length;l<n;l++){const n=e[l];o[String(n)]=t(n,l)}return o})(e,f))),Ve=(e,t)=>e+","+t,ze=e=>{const t={},o=[];var l;const n=(l=e,L(l,0)).map((e=>e.element)).bind(Fe).bind(je).getOr({});let r=0,a=0,s=0;const{pass:c,fail:i}=((e,t)=>{const o=[],l=[];for(let t=0,r=e.length;t<r;t++){const r=e[t];(n=r,"colgroup"===n.section?o:l).push(r)}var n;return{pass:o,fail:l}})(e);P(i,(e=>{const l=[];P(e.cells,(e=>{let o=0;for(;void 0!==t[Ve(s,o)];)o++;const r=R(n,o.toString()),c=((e,t,o,l,n,r)=>({element:e,rowspan:t,colspan:o,row:l,column:n,isLocked:r}))(e.element,e.rowspan,e.colspan,s,o,r);for(let l=0;l<e.colspan;l++)for(let n=0;n<e.rowspan;n++){const e=o+l,r=Ve(s+n,e);t[r]=c,a=Math.max(a,e+1)}l.push(c)})),r++,o.push(Ee(e.element,l,e.section)),s++}));const{columns:m,colgroups:d}=(e=>L(e,e.length-1))(c).map((e=>{const t=(e=>{const t={};let o=0;return P(e.cells,(e=>{const l=e.colspan;M(l,(n=>{const r=o+n;t[r]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,l,r)})),o+=l})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,((e,t)=>{const o=[];return C(e,((e,l)=>{o.push(t(e,l))})),o})(t,u));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),p=((e,t)=>({rows:e,columns:t}))(r,a);return{grid:p,access:t,all:o,columns:m,colgroups:d}},We=e=>{const t=(e=>{const t=qe(e);return((e,t)=>N(e,(e=>{if("colgroup"===z(e)){const t=N((e=>X(e,"colgroup")?ie(e,"col"):F(Le(e),(e=>ie(e,"col"))))(e),(e=>{const t=Me(e,"span",1);return Be(e,1,t)}));return Ee(e,t,"colgroup")}{const o=N((e=>Ne(e,"th,td"))(e),(e=>{const t=Me(e,"rowspan",1),o=Me(e,"colspan",1);return Be(e,t,o)}));return Ee(e,o,t(e))}})))([...Le(e),...t],He)})(e);return ze(t)},$e=(e,t,o)=>y.from(e.access[Ve(t,o)]),Ue=(e,t,o)=>{const l=((e,t)=>{const o=F(e.all,(e=>e.cells));return k(o,t)})(e,(e=>o(t,e.element)));return l.length>0?y.some(l[0]):y.none()},Ge=(e,t)=>y.from(e.columns[t]);var Ke=tinymce.util.Tools.resolve("tinymce.util.Tools");const Je=(e,t,o)=>{const l=e.select("td,th",t);let n;for(let t=0;t<l.length;t++){const r=e.getStyle(l[t],o);if(a(n)&&(n=r),n!==r)return""}return n},Qe=(e,t,o)=>{Ke.each("left center right".split(" "),(l=>{l!==o&&e.formatter.remove("align"+l,{},t)})),o&&e.formatter.apply("align"+o,{},t)},Xe=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},Ye=(e,t,o)=>((e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?y.none():y.some(t)})(e).getOr(t))(_e(e,t),o),Ze=e=>((e,t)=>{const o=e.dom,l=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?l:((e,t,o,l)=>t-Ye(e,"padding-left",0)-Ye(e,"padding-right",0)-Ye(e,"border-left-width",0)-Ye(e,"border-right-width",0))(e,l)})(e,"content-box");var et=tinymce.util.Tools.resolve("tinymce.Env");const tt=M(5,(e=>{const t=`${e+1}px`;return{title:t,value:t}})),ot=N(["Solid","Dotted","Dashed","Double","Groove","Ridge","Inset","Outset","None","Hidden"],(e=>({title:e,value:e.toLowerCase()}))),lt="100%",nt=e=>{var t;const o=e.dom,l=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return Ze(V.fromDom(l))+"px"},rt=e=>t=>t.options.get(e),at=rt("table_sizing_mode"),st=rt("table_border_widths"),ct=rt("table_border_styles"),it=rt("table_cell_advtab"),mt=rt("table_row_advtab"),dt=rt("table_advtab"),ut=rt("table_appearance_options"),pt=rt("table_grid"),bt=rt("table_style_by_css"),gt=rt("table_cell_class_list"),ht=rt("table_row_class_list"),ft=rt("table_class_list"),yt=rt("table_toolbar"),wt=rt("table_background_color_map"),St=rt("table_border_color_map"),Ct=e=>"fixed"===at(e),vt=e=>"responsive"===at(e),Tt=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>vt(e)||!bt(e)?t:Ct(e)?{...t,width:nt(e)}:{...t,width:lt})(e,o)},xt=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>vt(e)||bt(e)?t:Ct(e)?{...t,width:nt(e)}:{...t,width:lt})(e,o)},At=e=>t=>Z(t,(e=>V.fromDom(e.getBody()))(e)),Rt=e=>/^\d+(\.\d+)?$/.test(e)?e+"px":e,Ot=e=>V.fromDom(e.selection.getStart()),_t=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,Dt=(e,t,o)=>((e,t,o)=>{const l=Ue(e,t,Z),n=Ue(e,o,Z);return l.bind((e=>n.map((t=>{return o=e,l=t,{startRow:Math.min(o.row,l.row),startCol:Math.min(o.column,l.column),finishRow:Math.max(o.row+o.rowspan-1,l.row+l.rowspan-1),finishCol:Math.max(o.column+o.colspan-1,l.column+l.colspan-1)};var o,l}))))})(e,t,o).bind((t=>((e,t)=>{let o=!0;const l=b(_t,t);for(let n=t.startRow;n<=t.finishRow;n++)for(let r=t.startCol;r<=t.finishCol;r++)o=o&&$e(e,n,r).exists(l);return o?y.some(t):y.none()})(e,t))),It=We,Mt=(e,t)=>{oe(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Nt=(e,t)=>{le(e).fold((()=>{oe(e).each((e=>{Pt(e,t)}))}),(e=>{Mt(e,t)}))},Pt=(e,t)=>{e.dom.appendChild(t.dom)},kt=(e,t)=>{P(t,((o,l)=>{const n=0===l?e:t[l-1];Nt(n,o)}))},Bt=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Et=((e,t)=>{const o=t=>e(t)?y.from(t.dom.nodeValue):y.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return o(t).getOr("")},getOption:o,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(G);var Ft=["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"];const qt=(e,t,o,l)=>{const n=t(e,o);return r=(o,l)=>{const n=t(e,l);return Lt(e,o,n)},a=n,((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(l,((e,t)=>{a=r(a,e)})),a;var r,a},Lt=(e,t,o)=>t.bind((t=>o.filter(b(e.eq,t)))),Ht={up:d({selector:ue,closest:ge,predicate:de,all:(e,t)=>{const o=c(t)?t:h;let l=e.dom;const n=[];for(;null!==l.parentNode&&void 0!==l.parentNode;){const e=l.parentNode,t=V.fromDom(e);if(n.push(t),!0===o(t))break;l=e}return n}}),down:d({selector:me,predicate:ce}),styles:d({get:_e,getRaw:Ie,set:(e,t,o)=>{((e,t,o)=>{if(!l(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Oe(e)&&e.style.setProperty(t,o)})(e.dom,t,o)},remove:(e,t)=>{((e,t)=>{Oe(e)&&e.style.removeProperty(t)})(e.dom,t),Se(ye(e,"style").map(Te),"")&&we(e,"style")}}),attrs:d({get:fe,set:(e,t,o)=>{he(e.dom,t,o)},remove:we,copyTo:(e,t)=>{((e,t)=>{const o=e.dom;C(t,((e,t)=>{he(o,t,e)}))})(t,B(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))}}),insert:d({before:Mt,after:Nt,afterAll:kt,append:Pt,appendAll:(e,t)=>{P(t,(t=>{Pt(e,t)}))},prepend:(e,t)=>{(e=>((e,t)=>{const o=e.dom.childNodes;return y.from(o[0]).map(V.fromDom)})(e))(e).fold((()=>{Pt(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},wrap:(e,t)=>{Mt(e,t),Pt(t,e)}}),remove:d({unwrap:e=>{const t=ne(e);t.length>0&&kt(e,t),Bt(e)},remove:Bt}),create:d({nu:V.fromTag,clone:e=>V.fromDom(e.dom.cloneNode(!1)),text:V.fromText}),query:d({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:e=>y.from(e.dom.previousSibling).map(V.fromDom),nextSibling:le}),property:d({children:ne,name:z,parent:oe,document:e=>te(e).dom,isText:G,isComment:e=>8===W(e)||"#comment"===z(e),isElement:U,isSpecial:e=>{const t=z(e);return D(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>U(e)?ye(e,"lang"):y.none(),getText:e=>Et.get(e),setText:(e,t)=>Et.set(e,t),isBoundary:e=>!!U(e)&&("body"===z(e)||D(Ft,z(e))),isEmptyTag:e=>!!U(e)&&D(["br","img","hr","input"],z(e)),isNonEditable:e=>U(e)&&"false"===fe(e,"contenteditable")}),eq:Z,is:ee},jt=e=>ue(e,"table"),Vt=(e,t,o)=>be(e,t).bind((t=>be(e,o).bind((e=>{return(o=jt,l=[t,e],((e,t,o)=>o.length>0?((e,t,o,l)=>l(e,t,o[0],o.slice(1)))(e,t,o,qt):y.none())(Ht,((e,t)=>o(t)),l)).map((o=>({first:t,last:e,table:o})));var o,l})))),zt=e=>N(e,V.fromDom),Wt={selected:"data-mce-selected",selectedSelector:"td[data-mce-selected],th[data-mce-selected]",firstSelected:"data-mce-first-selected",firstSelectedSelector:"td[data-mce-first-selected],th[data-mce-first-selected]",lastSelected:"data-mce-last-selected",lastSelectedSelector:"td[data-mce-last-selected],th[data-mce-last-selected]"},$t=e=>(t,o)=>{const l=z(t),n="col"===l||"colgroup"===l?Fe(r=t).bind((e=>((e,t)=>((e,t)=>{const o=me(e,t);return o.length>0?y.some(o):y.none()})(e,t))(e,Wt.firstSelectedSelector))).fold(d(r),(e=>e[0])):t;var r;return ge(n,e,o)},Ut=$t("th,td,caption"),Gt=$t("th,td"),Kt=e=>zt(e.model.table.getSelectedCells()),Jt=(e,t)=>{const o=Gt(e),l=o.bind((e=>Fe(e))).map((e=>qe(e)));return Ce(o,l,((e,o)=>k(o,(o=>I(zt(o.dom.cells),(o=>"1"===fe(o,t)||Z(o,e))))))).getOr([])},Qt=[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}],Xt=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Yt=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Zt=e=>{return(t=e,"#",ve(t,"#")?((e,t)=>e.substring(t))(t,"#".length):t).toUpperCase();var t},eo=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},to=e=>({value:eo(e.red)+eo(e.green)+eo(e.blue)}),oo=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,lo=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,no=(e,t,o,l)=>({red:e,green:t,blue:o,alpha:l}),ro=(e,t,o,l)=>{const n=parseInt(e,10),r=parseInt(t,10),a=parseInt(o,10),s=parseFloat(l);return no(n,r,a,s)},ao=e=>{if("transparent"===e)return y.some(no(0,0,0,0));const t=oo.exec(e);if(null!==t)return y.some(ro(t[1],t[2],t[3],"1"));const o=lo.exec(e);return null!==o?y.some(ro(o[1],o[2],o[3],o[4])):y.none()},so=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},co=(e,t,o)=>l=>{const n=(e=>{const t=so(y.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(y.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(y.some(e))}}})((e=>e.unbind())),r=!Ae(o),a=()=>{const a=Kt(e),s=l=>e.formatter.match(t,{value:o},l.dom,r);r?(l.setActive(!I(a,s)),n.set(e.formatter.formatChanged(t,(e=>l.setActive(!e)),!0))):(l.setActive(q(a,s)),n.set(e.formatter.formatChanged(t,l.setActive,!1,{value:o})))};return e.initialized?a():e.on("init",a),n.clear},io=e=>R(e,"menu"),mo=e=>N(e,(e=>{const t=e.text||e.title||"";return io(e)?{text:t,items:mo(e.menu)}:{text:t,value:e.value}})),uo=(e,t,o,l)=>N(t,(t=>{const n=t.text||t.title;return io(t)?{type:"nestedmenuitem",text:n,getSubmenuItems:()=>uo(e,t.menu,o,l)}:{text:n,type:"togglemenuitem",onAction:()=>l(t.value),onSetup:co(e,o,t.value)}})),po=(e,t)=>o=>{e.execCommand("mceTableApplyCellStyle",!1,{[t]:o})},bo=e=>F(e,(e=>io(e)?[{...e,menu:bo(e.menu)}]:Ae(e.value)?[e]:[])),go=(e,t,o,l)=>n=>n(uo(e,t,o,l)),ho=(e,t,o)=>{const l=N(t,(e=>{return{text:e.title,value:"#"+(o=e.value,(t=o,(e=>Xt.test(e)||Yt.test(e))(t)?y.some({value:Zt(t)}):y.none()).orThunk((()=>ao(o).map(to))).getOrThunk((()=>{const e=document.createElement("canvas");e.height=1,e.width=1;const t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),t.fillStyle="#FFFFFF",t.fillStyle=o,t.fillRect(0,0,1,1);const l=t.getImageData(0,0,1,1).data,n=l[0],r=l[1],a=l[2],s=l[3];return to(no(n,r,a,s))}))).value,type:"choiceitem"};var t,o}));return[{type:"fancymenuitem",fancytype:"colorswatch",initData:{colors:l.length>0?l:void 0,allowCustomColors:!1},onAction:t=>{const l="remove"===t.value?"":t.value;e.execCommand("mceTableApplyCellStyle",!1,{[o]:l})}}]},fo=e=>()=>{const t="header"===e.queryCommandValue("mceTableRowType")?"body":"header";e.execCommand("mceTableRowType",!1,{type:t})},yo=e=>()=>{const t="th"===e.queryCommandValue("mceTableColType")?"td":"th";e.execCommand("mceTableColType",!1,{type:t})},wo=[{name:"width",type:"input",label:"Width"},{name:"height",type:"input",label:"Height"},{name:"celltype",type:"listbox",label:"Cell type",items:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{name:"scope",type:"listbox",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:"listbox",label:"Horizontal align",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"valign",type:"listbox",label:"Vertical align",items:Qt}],So=e=>wo.concat((e=>{const t=mo(gt(e));return t.length>0?y.some({name:"class",type:"listbox",label:"Class",items:t}):y.none()})(e).toArray()),Co=(e,t)=>{const o=[{name:"borderstyle",type:"listbox",label:"Border style",items:[{text:"Select...",value:""}].concat(mo(ct(e)))},{name:"bordercolor",type:"colorinput",label:"Border color"},{name:"backgroundcolor",type:"colorinput",label:"Background color"}];return{title:"Advanced",name:"advanced",items:"cell"===t?[{name:"borderwidth",type:"input",label:"Border width"}].concat(o):o}},vo=(e,t)=>{const o=e.dom;return{setAttrib:(e,l)=>{o.setAttrib(t,e,l)},setStyle:(e,l)=>{o.setStyle(t,e,l)},setFormat:(o,l)=>{""===l?e.formatter.remove(o,{value:null},t,!0):e.formatter.apply(o,{value:l},t)}}},To=Q("th"),xo=(e,t)=>e&&t?"sectionCells":e?"section":"cells",Ao=e=>{const t=N(e,(e=>(e=>{const t="thead"===e.section,o=Se((e=>{const t=k(e,(e=>To(e.element)));return 0===t.length?y.some("td"):t.length===e.length?y.some("th"):y.none()})(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:xo(t,o)}:{type:"body"}})(e).type)),o=D(t,"header"),l=D(t,"footer");if(o||l){const e=D(t,"body");return!o||e||l?o||e||!l?y.none():y.some("footer"):y.some("header")}return y.some("body")},Ro=(e,t)=>H(e.all,(e=>E(e.cells,(e=>Z(t,e.element))))),Oo=(e,t,o)=>{const l=(e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(o);return t})(N(t.selection,(t=>{return(l=t,((e,t,o=h)=>o(t)?y.none():D(e,z(t))?y.some(t):ue(t,e.join(","),(e=>X(e,"table")||o(e))))(["td","th"],l,n)).bind((t=>Ro(e,t))).filter(o);var l,n})));return n=l,l.length>0?y.some(n):y.none();var n},_o=(e,t)=>Oo(e,t,f),Do=(e,t)=>q(t,(t=>((e,t)=>Ro(e,t).exists((e=>!e.isLocked)))(e,t))),Io=(e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>Do(e,t.cells))),Mo=(e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>Do(e,t))),No=((e=>{if(!n(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};P(e,((l,r)=>{const a=w(l);if(1!==a.length)throw new Error("one and only one name per case");const s=a[0],c=l[s];if(void 0!==o[s])throw new Error("duplicate key detected:"+s);if("cata"===s)throw new Error("cannot have a case named cata (sorry)");if(!n(c))throw new Error("case arguments must be an array");t.push(s),o[s]=(...o)=>{const l=o.length;if(l!==c.length)throw new Error("Wrong number of arguments to case "+s+". Expected "+c.length+" ("+c+"), got "+l);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const l=w(e);if(t.length!==l.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+l.join(","));if(!q(t,(e=>D(l,e))))throw new Error("Not all branches were specified when using match. Specified: "+l.join(", ")+"\nRequired: "+t.join(", "));return e[s].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:s,params:o})}}}}))})([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}]),(e,t)=>{const o=We(e);return _o(o,t).bind((e=>{const t=e[e.length-1],l=e[0].row,n=t.row+t.rowspan,r=o.all.slice(l,n);return Ao(r)})).getOr("")}),Po=e=>{return ve(e,"rgb")?ao(t=e).map(to).map((e=>"#"+e.value)).getOr(t):e;var t},ko=e=>{const t=V.fromDom(e);return{borderwidth:Ie(t,"border-width").getOr(""),borderstyle:Ie(t,"border-style").getOr(""),bordercolor:Ie(t,"border-color").map(Po).getOr(""),backgroundcolor:Ie(t,"background-color").map(Po).getOr("")}},Bo=e=>{const t=e[0],o=e.slice(1);return P(o,(e=>{P(w(t),(o=>{C(e,((e,l)=>{const n=t[o];""!==n&&o===l&&n!==e&&(t[o]="")}))}))})),t},Eo=(e,t,o,l)=>E(e,(e=>!a(o.formatter.matchNode(l,t+e)))).getOr(""),Fo=b(Eo,["left","center","right"],"align"),qo=b(Eo,["top","middle","bottom"],"valign"),Lo=e=>Fe(V.fromDom(e)).map((t=>{const o={selection:zt(e.cells)};return No(t,o)})).getOr(""),Ho=(e,t)=>{const o=We(e),l=(e=>F(e.all,(e=>e.cells)))(o),n=k(l,(e=>I(t,(t=>Z(e.element,t)))));return N(n,(e=>({element:e.element.dom,column:Ge(o,e.column).map((e=>e.element.dom))})))},jo=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact((()=>{((e,t,o,l)=>{const n=v(l,((e,t)=>o[t]!==e));T(n)>0&&t.length>=1&&Fe(t[0]).each((o=>{const r=Ho(o,t),a=T(v(n,((e,t)=>"scope"!==t&&"celltype"!==t)))>0,s=A(n,"celltype");(a||A(n,"scope"))&&((e,t,o,l)=>{const n=1===t.length;P(t,(t=>{const r=t.element,a=n?f:l,s=vo(e,r);((e,t,o,l)=>{l("scope")&&e.setAttrib("scope",o.scope),l("class")&&e.setAttrib("class",o.class),l("height")&&e.setStyle("height",Rt(o.height)),l("width")&&t.setStyle("width",Rt(o.width))})(s,t.column.map((t=>vo(e,t))).getOr(s),o,a),it(e)&&((e,t,o)=>{o("backgroundcolor")&&e.setFormat("tablecellbackgroundcolor",t.backgroundcolor),o("bordercolor")&&e.setFormat("tablecellbordercolor",t.bordercolor),o("borderstyle")&&e.setFormat("tablecellborderstyle",t.borderstyle),o("borderwidth")&&e.setFormat("tablecellborderwidth",Rt(t.borderwidth))})(s,o,a),l("halign")&&Qe(e,r,o.halign),l("valign")&&((e,t,o)=>{Ke.each("top middle bottom".split(" "),(l=>{l!==o&&e.formatter.remove("valign"+l,{},t)})),o&&e.formatter.apply("valign"+o,{},t)})(e,r,o.valign)}))})(e,r,l,b(A,n)),s&&((e,t)=>{e.execCommand("mceTableCellType",!1,{type:t.celltype,no_events:!0})})(e,l),Xe(e,o.dom,{structure:s,style:a})}))})(e,t,o,n),e.focus()}))},Vo=e=>{const t=Kt(e);if(0===t.length)return;const o=((e,t)=>{const o=Fe(t[0]).map((o=>N(Ho(o,t),(t=>((e,t,o,l)=>{const n=e.dom,r=(e,t)=>n.getStyle(e,t)||n.getAttrib(e,t);return{width:r(l.getOr(t),"width"),height:r(t,"height"),scope:n.getAttrib(t,"scope"),celltype:(a=t,a.nodeName.toLowerCase()),class:n.getAttrib(t,"class",""),halign:Fo(e,t),valign:qo(e,t),...o?ko(t):{}};var a})(e,t.element,it(e),t.column)))));return Bo(o.getOrDie())})(e,t),l={type:"tabpanel",tabs:[{title:"General",name:"general",items:So(e)},Co(e,"cell")]},n={type:"panel",items:[{type:"grid",columns:2,items:So(e)}]};e.windowManager.open({title:"Cell Properties",size:"normal",body:it(e)?l:n,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:o,onSubmit:b(jo,e,t,o)})},zo=[{type:"listbox",name:"type",label:"Row type",items:[{text:"Header",value:"header"},{text:"Body",value:"body"},{text:"Footer",value:"footer"}]},{type:"listbox",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"}],Wo=e=>zo.concat((e=>{const t=mo(ht(e));return t.length>0?y.some({name:"class",type:"listbox",label:"Class",items:t}):y.none()})(e).toArray()),$o=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact((()=>{((e,t,o,l)=>{const n=v(l,((e,t)=>o[t]!==e));if(T(n)>0){const o=A(n,"type"),r=!o||T(n)>1;r&&((e,t,o,l)=>{const n=1===t.length?f:l;P(t,(t=>{const r=vo(e,t);((e,t,o)=>{o("class")&&e.setAttrib("class",t.class),o("height")&&e.setStyle("height",Rt(t.height))})(r,o,n),mt(e)&&((e,t,o)=>{o("backgroundcolor")&&e.setStyle("background-color",t.backgroundcolor),o("bordercolor")&&e.setStyle("border-color",t.bordercolor),o("borderstyle")&&e.setStyle("border-style",t.borderstyle)})(r,o,n),l("align")&&Qe(e,t,o.align)}))})(e,t,l,b(A,n)),o&&((e,t)=>{e.execCommand("mceTableRowType",!1,{type:t.type,no_events:!0})})(e,l),Fe(V.fromDom(t[0])).each((t=>Xe(e,t.dom,{structure:o,style:r})))}})(e,t,o,n),e.focus()}))},Uo=e=>{const t=Jt(Ot(e),Wt.selected);if(0===t.length)return;const o=N(t,(t=>((e,t,o)=>{const l=e.dom;return{height:l.getStyle(t,"height")||l.getAttrib(t,"height"),class:l.getAttrib(t,"class",""),type:Lo(t),align:Fo(e,t),...o?ko(t):{}}})(e,t.dom,mt(e)))),l=Bo(o),n={type:"tabpanel",tabs:[{title:"General",name:"general",items:Wo(e)},Co(e,"row")]},r={type:"panel",items:[{type:"grid",columns:2,items:Wo(e)}]};e.windowManager.open({title:"Row Properties",size:"normal",body:mt(e)?n:r,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:l,onSubmit:b($o,e,N(t,(e=>e.dom)),l)})},Go=(e,t,o)=>{const l=o?[{type:"input",name:"cols",label:"Cols",inputMode:"numeric"},{type:"input",name:"rows",label:"Rows",inputMode:"numeric"}]:[],n=ut(e)?[{type:"input",name:"cellspacing",label:"Cell spacing",inputMode:"numeric"},{type:"input",name:"cellpadding",label:"Cell padding",inputMode:"numeric"},{type:"input",name:"border",label:"Border width"},{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[],r=t.length>0?[{type:"listbox",name:"class",label:"Class",items:t}]:[];return l.concat([{type:"input",name:"width",label:"Width"},{type:"input",name:"height",label:"Height"}]).concat(n).concat([{type:"listbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]).concat(r)},Ko=(e,t,o,n)=>{if("TD"===t.tagName||"TH"===t.tagName)l(o)&&s(n)?e.setStyle(t,o,n):e.setStyles(t,o);else if(t.children)for(let l=0;l<t.children.length;l++)Ko(e,t.children[l],o,n)},Jo=(e,t,o,l)=>{const n=e.dom,r=l.getData(),s=v(r,((e,t)=>o[t]!==e));l.close(),""===r.class&&delete r.class,e.undoManager.transact((()=>{if(!t){const o=Re(r.cols).getOr(1),l=Re(r.rows).getOr(1);e.execCommand("mceInsertTable",!1,{rows:l,columns:o}),t=Gt(Ot(e),At(e)).bind((t=>Fe(t,At(e)))).map((e=>e.dom)).getOrDie()}if(T(s)>0){((e,t,o)=>{const l=e.dom,n={},r={};if(a(o.class)||(n.class=o.class),r.height=Rt(o.height),bt(e)?r.width=Rt(o.width):l.getAttrib(t,"width")&&(n.width=(e=>e?e.replace(/px$/,""):"")(o.width)),bt(e)?(r["border-width"]=Rt(o.border),r["border-spacing"]=Rt(o.cellspacing)):(n.border=o.border,n.cellpadding=o.cellpadding,n.cellspacing=o.cellspacing),bt(e)&&t.children)for(let n=0;n<t.children.length;n++)Ko(l,t.children[n],{"border-width":Rt(o.border),padding:Rt(o.cellpadding)}),dt(e)&&Ko(l,t.children[n],{"border-color":o.bordercolor});if(dt(e)){const e=o;r["background-color"]=e.backgroundcolor,r["border-color"]=e.bordercolor,r["border-style"]=e.borderstyle}n.style=l.serializeStyle({...Tt(e),...r}),l.setAttribs(t,{...xt(e),...n})})(e,t,r);const o=n.select("caption",t)[0];(o&&!r.caption||!o&&r.caption)&&e.execCommand("mceTableToggleCaption"),Qe(e,t,r.align)}if(e.focus(),e.addVisual(),T(s)>0){const o=A(s,"caption"),l=!o||T(s)>1;Xe(e,t,{structure:o,style:l})}}))},Qo=(e,t)=>{const o=e.dom;let l,n=((e,t)=>{const o=Tt(e),l=xt(e),n=t?{borderstyle:x(o,"border-style").getOr(""),bordercolor:Po(x(o,"border-color").getOr("")),backgroundcolor:Po(x(o,"background-color").getOr(""))}:{};return{height:"",width:"100%",cellspacing:"",cellpadding:"",caption:!1,class:"",align:"",border:"",...o,...l,...n,...(()=>{const t=o["border-width"];return bt(e)&&t?{border:t}:x(l,"border").fold((()=>({})),(e=>({border:e})))})(),...{...x(o,"border-spacing").or(x(l,"cellspacing")).fold((()=>({})),(e=>({cellspacing:e}))),...x(o,"border-padding").or(x(l,"cellpadding")).fold((()=>({})),(e=>({cellpadding:e})))}}})(e,dt(e));t?(n.cols="1",n.rows="1",dt(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor="")):(l=o.getParent(e.selection.getStart(),"table",e.getBody()),l?n=((e,t,o)=>{const l=e.dom,n=bt(e)?l.getStyle(t,"border-spacing")||l.getAttrib(t,"cellspacing"):l.getAttrib(t,"cellspacing")||l.getStyle(t,"border-spacing"),r=bt(e)?Je(l,t,"padding")||l.getAttrib(t,"cellpadding"):l.getAttrib(t,"cellpadding")||Je(l,t,"padding");return{width:l.getStyle(t,"width")||l.getAttrib(t,"width"),height:l.getStyle(t,"height")||l.getAttrib(t,"height"),cellspacing:null!=n?n:"",cellpadding:null!=r?r:"",border:((t,o)=>{const l=Ie(V.fromDom(o),"border-width");return bt(e)&&l.isSome()?l.getOr(""):t.getAttrib(o,"border")||Je(e.dom,o,"border-width")||Je(e.dom,o,"border")||""})(l,t),caption:!!l.select("caption",t)[0],class:l.getAttrib(t,"class",""),align:Fo(e,t),...o?ko(t):{}}})(e,l,dt(e)):dt(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor=""));const r=mo(ft(e));r.length>0&&n.class&&(n.class=n.class.replace(/\s*mce\-item\-table\s*/g,""));const a={type:"grid",columns:2,items:Go(e,r,t)},s=dt(e)?{type:"tabpanel",tabs:[{title:"General",name:"general",items:[a]},Co(e,"table")]}:{type:"panel",items:[a]};e.windowManager.open({title:"Table Properties",size:"normal",body:s,onSubmit:b(Jo,e,l,n),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:n})},Xo=u,Yo=e=>{const t=(e,t)=>ye(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&q(e,(e=>t(e,"rowspan")||t(e,"colspan")))?y.some(e):y.none()},Zo=(e,t,o)=>{return t.length<=1?y.none():(l=e,n=o.firstSelectedSelector,r=o.lastSelectedSelector,Vt(l,n,r).bind((e=>{const t=e=>Z(l,e),o="thead,tfoot,tbody,table",n=ue(e.first,o,t),r=ue(e.last,o,t);return n.bind((t=>r.bind((o=>Z(t,o)?((e,t,o)=>{const l=It(e);return Dt(l,t,o)})(e.table,e.first,e.last):y.none()))))}))).map((e=>({bounds:e,cells:t})));var l,n,r},el=e=>{const t=so(y.none()),o=so([]);let l=y.none();const n=Q("caption"),r=e=>l.forall((t=>!t[e])),a=()=>Ut(Ot(e),At(e)).bind((t=>{return o=Ce(Fe(t),Ut((e=>V.fromDom(e.selection.getEnd()))(e),At(e)).bind(Fe),((o,l)=>Z(o,l)?n(t)?y.some((e=>({element:e,mergable:y.none(),unmergable:y.none(),selection:[e]}))(t)):y.some(((e,t,o)=>({element:o,mergable:Zo(t,e,Wt),unmergable:Yo(e),selection:Xo(e)}))(Kt(e),o,t)):y.none())),o.bind(u);var o})),s=e=>Fe(e.element).map((t=>{const o=We(t),l=_o(o,e).getOr([]),n=B(l,((e,t)=>(t.isLocked&&(e.onAny=!0,0===t.column?e.onFirst=!0:t.column+t.colspan>=o.grid.columns&&(e.onLast=!0)),e)),{onAny:!1,onFirst:!1,onLast:!1});return{mergeable:Io(o,e).isSome(),unmergeable:Mo(o,e).isSome(),locked:n}})),c=()=>{t.set((e=>{let t,o=!1;return(...l)=>(o||(o=!0,t=e.apply(null,l)),t)})(a)()),l=t.get().bind(s),P(o.get(),g)},i=e=>(e(),o.set(o.get().concat([e])),()=>{o.set(k(o.get(),(t=>t!==e)))}),m=(e,o)=>i((()=>t.get().fold((()=>{e.setEnabled(!1)}),(t=>{e.setEnabled(!o(t))})))),d=(e,o,l)=>i((()=>t.get().fold((()=>{e.setEnabled(!1),e.setActive(!1)}),(t=>{e.setEnabled(!o(t)),e.setActive(l(t))})))),p=e=>l.exists((t=>t.locked[e])),b=(t,o)=>l=>d(l,(e=>n(e.element)),(()=>e.queryCommandValue(t)===o)),f=b("mceTableRowType","header"),w=b("mceTableColType","th");return e.on("NodeChange ExecCommand TableSelectorChange",c),{onSetupTable:e=>m(e,(e=>!1)),onSetupCellOrRow:e=>m(e,(e=>n(e.element))),onSetupColumn:e=>t=>m(t,(t=>n(t.element)||p(e))),onSetupPasteable:e=>t=>m(t,(t=>n(t.element)||e().isNone())),onSetupPasteableColumn:(e,t)=>o=>m(o,(o=>n(o.element)||e().isNone()||p(t))),onSetupMergeable:e=>m(e,(e=>r("mergeable"))),onSetupUnmergeable:e=>m(e,(e=>r("unmergeable"))),resetTargets:c,onSetupTableWithCaption:t=>d(t,h,(t=>Fe(t.element,At(e)).exists((e=>pe(e,"caption").isSome())))),onSetupTableRowHeaders:f,onSetupTableColumnHeaders:w,targets:t.get}};var tl=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const ol=e=>{var t;const o=null!==(t=tl.read())&&void 0!==t?t:[];return H(o,(t=>y.from(t.getType(e))))},ll=()=>ol("x-tinymce/dom-table-rows"),nl=()=>ol("x-tinymce/dom-table-columns");e.add("table",(e=>{const t=el(e);(e=>{const t=e.options.register;t("table_border_widths",{processor:"object[]",default:tt}),t("table_border_styles",{processor:"object[]",default:ot}),t("table_cell_advtab",{processor:"boolean",default:!0}),t("table_row_advtab",{processor:"boolean",default:!0}),t("table_advtab",{processor:"boolean",default:!0}),t("table_appearance_options",{processor:"boolean",default:!0}),t("table_grid",{processor:"boolean",default:!et.deviceType.isTouch()}),t("table_cell_class_list",{processor:"object[]",default:[]}),t("table_row_class_list",{processor:"object[]",default:[]}),t("table_class_list",{processor:"object[]",default:[]}),t("table_toolbar",{processor:"string",default:"tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"}),t("table_background_color_map",{processor:"object[]",default:[]}),t("table_border_color_map",{processor:"object[]",default:[]})})(e),(e=>{C({mceTableProps:b(Qo,e,!1),mceTableRowProps:b(Uo,e),mceTableCellProps:b(Vo,e)},((t,o)=>e.addCommand(o,(()=>t())))),e.addCommand("mceInsertTableDialog",(t=>{Qo(e,!0)}))})(e),((e,t)=>{const o=t=>()=>e.execCommand(t),l=(t,l)=>!!e.queryCommandSupported(l.command)&&(e.ui.registry.addMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)}),!0),n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},r=t=>{e.execCommand("mceInsertTable",!1,{rows:t.numRows,columns:t.numColumns})},a=[l("tableinsertrowbefore",{text:"Insert row before",icon:"table-insert-row-above",command:"mceTableInsertRowBefore",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{text:"Insert row after",icon:"table-insert-row-after",command:"mceTableInsertRowAfter",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{text:"Delete row",icon:"table-delete-row",command:"mceTableDeleteRow",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{text:"Row properties",icon:"table-row-properties",command:"mceTableRowProps",onSetup:t.onSetupCellOrRow}),l("tablecutrow",{text:"Cut row",icon:"cut-row",command:"mceTableCutRow",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{text:"Copy row",icon:"duplicate-row",command:"mceTableCopyRow",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{text:"Paste row before",icon:"paste-row-before",command:"mceTablePasteRowBefore",onSetup:t.onSetupPasteable(ll)}),l("tablepasterowafter",{text:"Paste row after",icon:"paste-row-after",command:"mceTablePasteRowAfter",onSetup:t.onSetupPasteable(ll)})],s=[l("tableinsertcolumnbefore",{text:"Insert column before",icon:"table-insert-column-before",command:"mceTableInsertColBefore",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolumnafter",{text:"Insert column after",icon:"table-insert-column-after",command:"mceTableInsertColAfter",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecolumn",{text:"Delete column",icon:"table-delete-column",command:"mceTableDeleteCol",onSetup:t.onSetupColumn("onAny")}),l("tablecutcolumn",{text:"Cut column",icon:"cut-column",command:"mceTableCutCol",onSetup:t.onSetupColumn("onAny")}),l("tablecopycolumn",{text:"Copy column",icon:"duplicate-column",command:"mceTableCopyCol",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolumnbefore",{text:"Paste column before",icon:"paste-column-before",command:"mceTablePasteColBefore",onSetup:t.onSetupPasteableColumn(nl,"onFirst")}),l("tablepastecolumnafter",{text:"Paste column after",icon:"paste-column-after",command:"mceTablePasteColAfter",onSetup:t.onSetupPasteableColumn(nl,"onLast")})],i=[l("tablecellprops",{text:"Cell properties",icon:"table-cell-properties",command:"mceTableCellProps",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{text:"Merge cells",icon:"table-merge-cells",command:"mceTableMergeCells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{text:"Split cell",icon:"table-split-cells",command:"mceTableSplitCells",onSetup:t.onSetupUnmergeable})];pt(e)?e.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"inserttable",onAction:r}]}):e.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:o("mceInsertTableDialog")}),e.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:o("mceInsertTableDialog")}),l("tableprops",{text:"Table properties",onSetup:t.onSetupTable,command:"mceTableProps"}),l("deletetable",{text:"Delete table",icon:"table-delete-table",onSetup:t.onSetupTable,command:"mceTableDelete"}),D(a,!0)&&e.ui.registry.addNestedMenuItem("row",{type:"nestedmenuitem",text:"Row",getSubmenuItems:d("tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter")}),D(s,!0)&&e.ui.registry.addNestedMenuItem("column",{type:"nestedmenuitem",text:"Column",getSubmenuItems:d("tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter")}),D(i,!0)&&e.ui.registry.addNestedMenuItem("cell",{type:"nestedmenuitem",text:"Cell",getSubmenuItems:d("tablecellprops tablemergecells tablesplitcells")}),e.ui.registry.addContextMenu("table",{update:()=>(t.resetTargets(),t.targets().fold(d(""),(e=>"caption"===z(e.element)?"tableprops deletetable":"cell row column | advtablesort | tableprops deletetable")))});const m=bo(ft(e));0!==m.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addNestedMenuItem("tableclass",{icon:"table-classes",text:"Table styles",getSubmenuItems:()=>uo(e,m,"tableclass",(t=>e.execCommand("mceTableToggleClass",!1,t))),onSetup:t.onSetupTable});const u=bo(gt(e));0!==u.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addNestedMenuItem("tablecellclass",{icon:"table-cell-classes",text:"Cell styles",getSubmenuItems:()=>uo(e,u,"tablecellclass",(t=>e.execCommand("mceTableCellToggleClass",!1,t))),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addNestedMenuItem("tablecellvalign",{icon:"vertical-align",text:"Vertical align",getSubmenuItems:()=>uo(e,Qt,"tablecellverticalalign",po(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderwidth",{icon:"border-width",text:"Border width",getSubmenuItems:()=>uo(e,st(e),"tablecellborderwidth",po(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderstyle",{icon:"border-style",text:"Border style",getSubmenuItems:()=>uo(e,ct(e),"tablecellborderstyle",po(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbackgroundcolor",{icon:"cell-background-color",text:"Background color",getSubmenuItems:()=>ho(e,wt(e),"background-color"),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbordercolor",{icon:"cell-border-color",text:"Border color",getSubmenuItems:()=>ho(e,St(e),"border-color"),onSetup:t.onSetupCellOrRow})),n("tablecaption",{icon:"table-caption",text:"Table caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{text:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:fo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{text:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:yo(e),onSetup:t.onSetupTableRowHeaders})})(e,t),((e,t)=>{e.ui.registry.addMenuButton("table",{tooltip:"Table",icon:"table",fetch:e=>e("inserttable | cell row column | advtablesort | tableprops deletetable")});const o=t=>()=>e.execCommand(t),l=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})};l("tableprops",{tooltip:"Table properties",command:"mceTableProps",icon:"table",onSetup:t.onSetupTable}),l("tabledelete",{tooltip:"Delete table",command:"mceTableDelete",icon:"table-delete-table",onSetup:t.onSetupTable}),l("tablecellprops",{tooltip:"Cell properties",command:"mceTableCellProps",icon:"table-cell-properties",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{tooltip:"Merge cells",command:"mceTableMergeCells",icon:"table-merge-cells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{tooltip:"Split cell",command:"mceTableSplitCells",icon:"table-split-cells",onSetup:t.onSetupUnmergeable}),l("tableinsertrowbefore",{tooltip:"Insert row before",command:"mceTableInsertRowBefore",icon:"table-insert-row-above",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{tooltip:"Insert row after",command:"mceTableInsertRowAfter",icon:"table-insert-row-after",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{tooltip:"Delete row",command:"mceTableDeleteRow",icon:"table-delete-row",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{tooltip:"Row properties",command:"mceTableRowProps",icon:"table-row-properties",onSetup:t.onSetupCellOrRow}),l("tableinsertcolbefore",{tooltip:"Insert column before",command:"mceTableInsertColBefore",icon:"table-insert-column-before",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolafter",{tooltip:"Insert column after",command:"mceTableInsertColAfter",icon:"table-insert-column-after",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecol",{tooltip:"Delete column",command:"mceTableDeleteCol",icon:"table-delete-column",onSetup:t.onSetupColumn("onAny")}),l("tablecutrow",{tooltip:"Cut row",command:"mceTableCutRow",icon:"cut-row",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{tooltip:"Copy row",command:"mceTableCopyRow",icon:"duplicate-row",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{tooltip:"Paste row before",command:"mceTablePasteRowBefore",icon:"paste-row-before",onSetup:t.onSetupPasteable(ll)}),l("tablepasterowafter",{tooltip:"Paste row after",command:"mceTablePasteRowAfter",icon:"paste-row-after",onSetup:t.onSetupPasteable(ll)}),l("tablecutcol",{tooltip:"Cut column",command:"mceTableCutCol",icon:"cut-column",onSetup:t.onSetupColumn("onAny")}),l("tablecopycol",{tooltip:"Copy column",command:"mceTableCopyCol",icon:"duplicate-column",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolbefore",{tooltip:"Paste column before",command:"mceTablePasteColBefore",icon:"paste-column-before",onSetup:t.onSetupPasteableColumn(nl,"onFirst")}),l("tablepastecolafter",{tooltip:"Paste column after",command:"mceTablePasteColAfter",icon:"paste-column-after",onSetup:t.onSetupPasteableColumn(nl,"onLast")}),l("tableinsertdialog",{tooltip:"Insert table",command:"mceInsertTableDialog",icon:"table"});const r=bo(ft(e));0!==r.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addMenuButton("tableclass",{icon:"table-classes",tooltip:"Table styles",fetch:go(e,r,"tableclass",(t=>e.execCommand("mceTableToggleClass",!1,t))),onSetup:t.onSetupTable});const a=bo(gt(e));0!==a.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addMenuButton("tablecellclass",{icon:"table-cell-classes",tooltip:"Cell styles",fetch:go(e,a,"tablecellclass",(t=>e.execCommand("mceTableCellToggleClass",!1,t))),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addMenuButton("tablecellvalign",{icon:"vertical-align",tooltip:"Vertical align",fetch:go(e,Qt,"tablecellverticalalign",po(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderwidth",{icon:"border-width",tooltip:"Border width",fetch:go(e,st(e),"tablecellborderwidth",po(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderstyle",{icon:"border-style",tooltip:"Border style",fetch:go(e,ct(e),"tablecellborderstyle",po(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbackgroundcolor",{icon:"cell-background-color",tooltip:"Background color",fetch:t=>t(ho(e,wt(e),"background-color")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbordercolor",{icon:"cell-border-color",tooltip:"Border color",fetch:t=>t(ho(e,St(e),"border-color")),onSetup:t.onSetupCellOrRow})),n("tablecaption",{tooltip:"Table caption",icon:"table-caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{tooltip:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:fo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{tooltip:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:yo(e),onSetup:t.onSetupTableColumnHeaders})})(e,t),(e=>{const t=yt(e);t.length>0&&e.ui.registry.addContextToolbar("table",{predicate:t=>e.dom.is(t,"table")&&e.getBody().contains(t),items:t,scope:"node",position:"node"})})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(a=n=e,(r=String).prototype.isPrototypeOf(a)||(null===(s=n.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var a,n,r,s})(t)===e,a=t("string"),n=t("object"),r=t("array"),s=("function",e=>"function"==typeof e);const l=(!1,()=>false);var o=tinymce.util.Tools.resolve("tinymce.util.Tools");const c=e=>t=>t.options.get(e),i=c("template_cdate_classes"),u=c("template_mdate_classes"),m=c("template_selected_content_classes"),p=c("template_preview_replace_values"),d=c("template_replace_values"),h=c("templates"),g=c("template_cdate_format"),v=c("template_mdate_format"),f=c("content_style"),y=c("content_css_cors"),_=c("body_class"),b=(e,t)=>{if((e=""+e).length<t)for(let a=0;a<t-e.length;a++)e="0"+e;return e},M=(e,t,a=new Date)=>{const n="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),r="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),s="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),l="January February March April May June July August September October November December".split(" ");return(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("%D","%m/%d/%Y")).replace("%r","%I:%M:%S %p")).replace("%Y",""+a.getFullYear())).replace("%y",""+a.getYear())).replace("%m",b(a.getMonth()+1,2))).replace("%d",b(a.getDate(),2))).replace("%H",""+b(a.getHours(),2))).replace("%M",""+b(a.getMinutes(),2))).replace("%S",""+b(a.getSeconds(),2))).replace("%I",""+((a.getHours()+11)%12+1))).replace("%p",a.getHours()<12?"AM":"PM")).replace("%B",""+e.translate(l[a.getMonth()]))).replace("%b",""+e.translate(s[a.getMonth()]))).replace("%A",""+e.translate(r[a.getDay()]))).replace("%a",""+e.translate(n[a.getDay()]))).replace("%%","%")};class T{constructor(e,t){this.tag=e,this.value=t}static some(e){return new T(!0,e)}static none(){return T.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?T.some(e(this.value)):T.none()}bind(e){return this.tag?e(this.value):T.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:T.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return null==e?T.none():T.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}T.singletonNone=new T(!1);const x=Object.hasOwnProperty,S={'"':"&quot;","<":"&lt;",">":"&gt;","&":"&amp;","'":"&#039;"},w=e=>e.replace(/["'<>&]/g,(e=>{return(t=S,a=e,((e,t)=>x.call(e,t))(t,a)?T.from(t[a]):T.none()).getOr(e);var t,a})),C=(e,t,a)=>((a,n)=>{for(let n=0,s=a.length;n<s;n++)if(r=a[n],e.hasClass(t,r))return!0;var r;return!1})(a.split(/\s+/)),O=(e,t)=>(o.each(t,((t,a)=>{s(t)&&(t=t(a)),e=e.replace(new RegExp("\\{\\$"+a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\}","g"),t)})),e),A=(e,t)=>{const a=e.dom,n=d(e);o.each(a.select("*",t),(e=>{o.each(n,((t,n)=>{a.hasClass(e,n)&&s(t)&&t(e)}))}))},D=(e,t,a)=>{const n=e.dom,r=e.selection.getContent();a=O(a,d(e));let s=n.create("div",{},a);const l=n.select(".mceTmpl",s);l&&l.length>0&&(s=n.create("div"),s.appendChild(l[0].cloneNode(!0))),o.each(n.select("*",s),(t=>{C(n,t,i(e))&&(t.innerHTML=M(e,g(e))),C(n,t,u(e))&&(t.innerHTML=M(e,v(e))),C(n,t,m(e))&&(t.innerHTML=r)})),A(e,s),e.execCommand("mceInsertContent",!1,s.innerHTML),e.addVisual()};var I=tinymce.util.Tools.resolve("tinymce.Env");const N=(e,t)=>{const a=(e,t)=>((e,t,a)=>{for(let n=0,r=e.length;n<r;n++){const r=e[n];if(t(r,n))return T.some(r);if(a(r,n))break}return T.none()})(e,(e=>e.text===t),l),n=t=>{e.windowManager.alert("Could not load the specified template.",(()=>t.focus("template")))},r=e=>e.value.url.fold((()=>Promise.resolve(e.value.content.getOr(""))),(e=>fetch(e).then((e=>e.ok?e.text():Promise.reject())))),s=(e,t)=>(s,l)=>{if("template"===l.name){const l=s.getData().template;a(e,l).each((e=>{s.block("Loading..."),r(e).then((a=>{t(s,e,a)})).catch((()=>{t(s,e,""),s.setEnabled("save",!1),n(s)}))}))}},c=t=>s=>{const l=s.getData();a(t,l.template).each((t=>{r(t).then((t=>{e.execCommand("mceInsertTemplate",!1,t),s.close()})).catch((()=>{s.setEnabled("save",!1),n(s)}))}))};(()=>{if(!t||0===t.length){const t=e.translate("No templates defined.");return e.notificationManager.open({text:t,type:"info"}),T.none()}return T.from(o.map(t,((e,t)=>{const a=e=>void 0!==e.url;return{selected:0===t,text:e.title,value:{url:a(e)?T.from(e.url):T.none(),content:a(e)?T.none():T.from(e.content),description:e.description}}})))})().each((t=>{const a=(e=>((e,t)=>{const a=e.length,n=new Array(a);for(let t=0;t<a;t++){const a=e[t];n[t]={text:(r=a).text,value:r.text}}var r;return n})(e))(t),l=(e,a)=>({title:"Insert Template",size:"large",body:{type:"panel",items:e},initialData:a,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:c(t),onChange:s(t,i)}),i=(t,n,r)=>{const s=((e,t)=>{var a;if(-1===t.indexOf("<html>")){let n="";const r=null!==(a=f(e))&&void 0!==a?a:"",s=y(e)?' crossorigin="anonymous"':"";o.each(e.contentCSS,(t=>{n+='<link type="text/css" rel="stylesheet" href="'+e.documentBaseURI.toAbsolute(t)+'"'+s+">"})),r&&(n+='<style type="text/css">'+r+"</style>");const l=_(e),c=e.dom.encode,i='<script>document.addEventListener && document.addEventListener("click", function(e) {for (var elm = e.target; elm; elm = elm.parentNode) {if (elm.nodeName === "A" && !('+(I.os.isMacOS()||I.os.isiOS()?"e.metaKey":"e.ctrlKey && !e.altKey")+")) {e.preventDefault();}}}, false);<\/script> ",u=e.getBody().dir,m=u?' dir="'+c(u)+'"':"";t='<!DOCTYPE html><html><head><base href="'+c(e.documentBaseURI.getURI())+'">'+n+i+'</head><body class="'+c(l)+'"'+m+">"+t+"</body></html>"}return O(t,p(e))})(e,r),c=[{type:"selectbox",name:"template",label:"Templates",items:a},{type:"htmlpanel",html:`<p aria-live="polite">${w(n.value.description)}</p>`},{label:"Preview",type:"iframe",name:"preview",sandboxed:!1,transparent:!1}],i={template:n.text,preview:s};t.unblock(),t.redial(l(c,i)),t.focus("template")},u=e.windowManager.open(l([],{template:"",preview:""}));u.block("Loading..."),r(t[0]).then((e=>{i(u,t[0],e)})).catch((()=>{i(u,t[0],""),u.setEnabled("save",!1),n(u)}))}))};e.add("template",(e=>{(e=>{const t=e.options.register;t("template_cdate_classes",{processor:"string",default:"cdate"}),t("template_mdate_classes",{processor:"string",default:"mdate"}),t("template_selected_content_classes",{processor:"string",default:"selcontent"}),t("template_preview_replace_values",{processor:"object"}),t("template_replace_values",{processor:"object"}),t("templates",{processor:e=>a(e)||((e,t)=>{if(r(e)){for(let a=0,n=e.length;a<n;++a)if(!t(e[a]))return!1;return!0}return!1})(e,n)||s(e),default:[]}),t("template_cdate_format",{processor:"string",default:e.translate("%Y-%m-%d")}),t("template_mdate_format",{processor:"string",default:e.translate("%Y-%m-%d")})})(e),(e=>{const t=()=>e.execCommand("mceTemplate");e.ui.registry.addButton("template",{icon:"template",tooltip:"Insert template",onAction:t}),e.ui.registry.addMenuItem("template",{icon:"template",text:"Insert template...",onAction:t})})(e),(e=>{e.addCommand("mceInsertTemplate",function(e,...t){return(...a)=>{const n=t.concat(a);return e.apply(null,n)}}(D,e)),e.addCommand("mceTemplate",((e,t)=>()=>{const n=h(e);s(n)?n(t):a(n)?fetch(n).then((e=>{e.ok&&e.json().then(t)})):t(n)})(e,(e=>t=>{N(e,t)})(e)))})(e),(e=>{e.on("PreProcess",(t=>{const a=e.dom,n=v(e);o.each(a.select("div",t.node),(t=>{a.hasClass(t,"mceTmpl")&&(o.each(a.select("*",t),(t=>{C(a,t,u(e))&&(t.innerHTML=M(e,n))})),A(e,t))}))}))})(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const s=(t,s,o)=>{t.dom.toggleClass(t.getBody(),"mce-visualblocks"),o.set(!o.get()),((t,s)=>{t.dispatch("VisualBlocks",{state:s})})(t,o.get())},o=("visualblocks_default_state",t=>t.options.get("visualblocks_default_state"));const e=(t,s)=>o=>{o.setActive(s.get());const e=t=>o.setActive(t.state);return t.on("VisualBlocks",e),()=>t.off("VisualBlocks",e)};t.add("visualblocks",((t,l)=>{(t=>{(0,t.options.register)("visualblocks_default_state",{processor:"boolean",default:!1})})(t);const a=(t=>{let s=!1;return{get:()=>s,set:t=>{s=t}}})();((t,o,e)=>{t.addCommand("mceVisualBlocks",(()=>{s(t,0,e)}))})(t,0,a),((t,s)=>{const o=()=>t.execCommand("mceVisualBlocks");t.ui.registry.addToggleButton("visualblocks",{icon:"visualblocks",tooltip:"Show blocks",onAction:o,onSetup:e(t,s)}),t.ui.registry.addToggleMenuItem("visualblocks",{text:"Show blocks",icon:"visualblocks",onAction:o,onSetup:e(t,s)})})(t,a),((t,e,l)=>{t.on("PreviewFormats AfterPreviewFormats",(s=>{l.get()&&t.dom.toggleClass(t.getBody(),"mce-visualblocks","afterpreviewformats"===s.type)})),t.on("init",(()=>{o(t)&&s(t,0,l)}))})(t,0,a)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=t=>e=>typeof e===t,n=t=>"string"===(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&(n=o=t,(s=String).prototype.isPrototypeOf(n)||(null===(r=o.constructor)||void 0===r?void 0:r.name)===s.name)?"string":e;var n,o,s,r})(t),o=(null,t=>null===t);const s=e("boolean"),r=e("number");class a{constructor(t,e){this.tag=t,this.value=e}static some(t){return new a(!0,t)}static none(){return a.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?a.some(t(this.value)):a.none()}bind(t){return this.tag?t(this.value):a.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:a.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return null==t?a.none():a.some(t)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}a.singletonNone=new a(!1);const i=(t,e)=>{for(let n=0,o=t.length;n<o;n++)e(t[n],n)},l=Object.keys,u=(t,e)=>{const n=l(t);for(let o=0,s=n.length;o<s;o++){const s=n[o];e(t[s],s)}};"undefined"!=typeof window?window:Function("return this;")();const c=t=>t.dom.nodeValue,d=t=>3===(t=>t.dom.nodeType)(t),h=(t,e,o)=>{((t,e,o)=>{if(!(n(o)||s(o)||r(o)))throw console.error("Invalid call to Attribute.set. Key ",e,":: Value ",o,":: Element ",t),new Error("Attribute value was not simple");t.setAttribute(e,o+"")})(t.dom,e,o)},g=(t,e)=>{t.dom.removeAttribute(e)},m=(t,e)=>{const n=((t,e)=>{const n=t.dom.getAttribute(e);return null===n?void 0:n})(t,e);return void 0===n||""===n?[]:n.split(" ")},v=t=>void 0!==t.dom.classList,p=t=>{if(null==t)throw new Error("Node cannot be null or undefined");return{dom:t}},f=p,y={"\xa0":"nbsp","\xad":"shy"},b=(t,e)=>{let n="";return u(t,((t,e)=>{n+=e})),new RegExp("["+n+"]",e?"g":"")},w=b(y),A=b(y,!0),k=(t=>{let e="";return u(t,(t=>{e&&(e+=","),e+="span.mce-"+t})),e})(y),N="mce-nbsp",C=t=>'<span data-mce-bogus="1" class="mce-'+y[t]+'">'+t+"</span>",T=t=>{const e=c(t);return d(t)&&n(e)&&w.test(e)},O=(t,e)=>{let n=[];const o=((t,e)=>{const n=t.length,o=new Array(n);for(let s=0;s<n;s++){const n=t[s];o[s]=e(n,s)}return o})(t.dom.childNodes,f);return i(o,(t=>{e(t)&&(n=n.concat([t])),n=n.concat(O(t,e))})),n},B=t=>"span"===t.nodeName.toLowerCase()&&t.classList.contains("mce-nbsp-wrap"),S=(t,e)=>{const n=t.dom,o=O(f(e),T);i(o,(e=>{var o;const s=e.dom.parentNode;if(B(s))r=f(s),a=N,v(r)?r.dom.classList.add(a):((t,e)=>{((t,e,n)=>{const o=m(t,e).concat([n]);h(t,e,o.join(" "))})(t,"class",e)})(r,a);else{const s=n.encode(null!==(o=c(e))&&void 0!==o?o:"").replace(A,C),r=n.create("div",{},s);let a;for(;a=r.lastChild;)n.insertAfter(a,e.dom);t.dom.remove(e.dom)}var r,a}))},V=(t,e)=>{const n=t.dom.select(k,e);i(n,(e=>{var n,o;B(e)?(n=f(e),o=N,v(n)?n.dom.classList.remove(o):((t,e)=>{((t,e,n)=>{const o=((t,e)=>{const o=[];for(let e=0,s=t.length;e<s;e++){const s=t[e];s!==n&&o.push(s)}return o})(m(t,e));o.length>0?h(t,e,o.join(" ")):g(t,e)})(t,"class",e)})(n,o),(t=>{const e=v(t)?t.dom.classList:(t=>m(t,"class"))(t);0===e.length&&g(t,"class")})(n)):t.dom.remove(e,!0)}))},E=t=>{const e=t.getBody(),n=t.selection.getBookmark();let o=((t,e)=>{for(;t.parentNode;){if(t.parentNode===e)return e;t=t.parentNode}})(t.selection.getNode(),e);o=void 0!==o?o:e,V(t,o),S(t,o),t.selection.moveToBookmark(n)},L=(t,e)=>{((t,e)=>{t.dispatch("VisualChars",{state:e})})(t,e.get());const n=t.getBody();!0===e.get()?S(t,n):V(t,n)},_=("visualchars_default_state",t=>t.options.get("visualchars_default_state"));const j=(t,e)=>{const n=((t,e)=>{let n=null;return{cancel:()=>{o(n)||(clearTimeout(n),n=null)},throttle:(...e)=>{o(n)&&(n=setTimeout((()=>{n=null,t.apply(null,e)}),300))}}})((()=>{E(t)}));t.on("keydown",(o=>{!0===e.get()&&(13===o.keyCode?E(t):n.throttle())})),t.on("remove",n.cancel)},x=(t,e)=>n=>{n.setActive(e.get());const o=t=>n.setActive(t.state);return t.on("VisualChars",o),()=>t.off("VisualChars",o)};t.add("visualchars",(t=>{(t=>{(0,t.options.register)("visualchars_default_state",{processor:"boolean",default:!1})})(t);const e=(t=>{let e=t;return{get:()=>e,set:t=>{e=t}}})(_(t));return((t,e)=>{t.addCommand("mceVisualChars",(()=>{((t,e)=>{e.set(!e.get());const n=t.selection.getBookmark();L(t,e),t.selection.moveToBookmark(n)})(t,e)}))})(t,e),((t,e)=>{const n=()=>t.execCommand("mceVisualChars");t.ui.registry.addToggleButton("visualchars",{tooltip:"Show invisible characters",icon:"visualchars",onAction:n,onSetup:x(t,e)}),t.ui.registry.addToggleMenuItem("visualchars",{text:"Show invisible characters",icon:"visualchars",onAction:n,onSetup:x(t,e)})})(t,e),j(t,e),((t,e)=>{t.on("init",(()=>{L(t,e)}))})(t,e),(t=>({isEnabled:()=>t.get()}))(e)}))}();
/**
 * TinyMCE version 6.3.1 (2022-12-06)
 */
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(null,t=>null===t);const n=t=>t,o="[-'\\.\u2018\u2019\u2024\ufe52\uff07\uff0e]",r="[:\xb7\xb7\u05f4\u2027\ufe13\ufe55\uff1a]",c="[\xb1+*/,;;\u0589\u060c\u060d\u066c\u07f8\u2044\ufe10\ufe14\ufe50\ufe54\uff0c\uff1b]",u="[0-9\u0660-\u0669\u066b\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\uaa50-\uaa59\uabf0-\uabf9]",s="\\r",a="\\n",l="[\v\f\x85\u2028\u2029]",i="[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f\u109a-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8\u19c9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f\u1b00-\u1b04\u1b34-\u1b44\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1baa\u1be6-\u1bf3\u1c24-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe3-\uabea\uabec\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]",g="[\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200e\u200f\u202a-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb]",d="[\u3031-\u3035\u309b\u309c\u30a0-\u30fa\u30fc-\u30ff\u31f0-\u31ff\u32d0-\u32fe\u3300-\u3357\uff66-\uff9d]",p="[=_\u203f\u2040\u2054\ufe33\ufe34\ufe4d-\ufe4f\uff3f\u2200-\u22ff<>]",h="[!-#%-*,-\\/:;?@\\[-\\]_{}\xa1\xab\xb7\xbb\xbf;\xb7\u055a-\u055f\u0589\u058a\u05be\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1361-\u1368\u1400\u166d\u166e\u169b\u169c\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cd3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205e\u207d\u207e\u208d\u208e\u3008\u3009\u2768-\u2775\u27c5\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc\u29fd\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e2e\u2e30\u2e31\u3001-\u3003\u3008-\u3011\u3014-\u301f\u3030\u303d\u30a0\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uabeb\ufd3e\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a\uff1b\uff1f\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]",C=[new RegExp("[A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f3\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bc0-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u24b6-\u24e9\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005\u303b\u303c\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790\ua791\ua7a0-\ua7a9\ua7fa-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uffa0-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]"),new RegExp(o),new RegExp(r),new RegExp(c),new RegExp(u),new RegExp(s),new RegExp(a),new RegExp(l),new RegExp(i),new RegExp(g),new RegExp(d),new RegExp(p),new RegExp("@")],y=new RegExp("^"+h+"$"),m=C,w=t=>{let e=13;const n=m.length;for(let o=0;o<n;++o){const n=m[o];if(n&&n.test(t)){e=o;break}}return e},f=(t,e)=>{const n=t[e],o=t[e+1];if(e<0||e>t.length-1&&0!==e)return!1;if(0===n&&0===o)return!1;const r=t[e+2];if(0===n&&(2===o||1===o||12===o)&&0===r)return!1;const c=t[e-1];return(2!==n&&1!==n&&12!==o||0!==o||0!==c)&&(4!==n&&0!==n||4!==o&&0!==o)&&(3!==n&&1!==n||4!==o||4!==c)&&(4!==n||3!==o&&1!==o||4!==r)&&8!==n&&9!==n&&8!==c&&9!==c&&8!==o&&9!==o&&(5!==n||6!==o)&&(7===n||5===n||6===n||7===o||5===o||6===o||(10!==n||10!==o)&&(11!==o||0!==n&&4!==n&&10!==n&&11!==n)&&(11!==n||0!==o&&4!==o&&10!==o)&&12!==n)},W=/^\s+$/,x=y,E=t=>"http"===t||"https"===t,R=(t,e)=>{const n=((t,e)=>{let n;for(n=e;n<t.length&&!W.test(t[n]);n++);return n})(t,e+1);return"://"===t.slice(e+1,n).join("").substr(0,3)?n:e},S=(t,e,n)=>{n={includeWhitespace:!1,includePunctuation:!1,...n};const o=[],r=[];for(let n=0;n<t.length;n++){const c=e(t[n]);"\ufeff"!==c&&(o.push(t[n]),r.push(c))}return((t,e,n,o)=>{const r=[];let c=[];for(let u=0;u<n.length;++u)if(c.push(t[u]),f(n,u)){const n=e[u];if((o.includeWhitespace||!W.test(n))&&(o.includePunctuation||!x.test(n))){const n=u-c.length+1,o=u+1,s=e.slice(n,o).join("");if(E(s)){const n=R(e,u),r=t.slice(o,n);Array.prototype.push.apply(c,r),u=n}r.push(c)}c=[]}return r})(o,r,((t,e)=>{const n=t.length,o=new Array(n);for(let r=0;r<n;r++){const n=t[r];o[r]=e(n,r)}return o})(r,(t=>{const e={};return n=>{if(e[n])return e[n];{const o=t(n);return e[n]=o,o}}})(w)),n)};var b=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");const v=(t,e)=>{const n=e.getBlockElements(),o=e.getVoidElements(),r=t=>n[t.nodeName]||o[t.nodeName],c=[];let u="";const s=new b(t,t);let a;for(;a=s.next();)3===a.nodeType?u+=a.data.replace(/\uFEFF/g,""):r(a)&&u.length&&(c.push(u),u="");return u.length&&c.push(u),c},F=t=>t.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"_").length,T=(t,e)=>{const o=(t=>t.replace(/\u200B/g,""))(v(t,e).join("\n"));return S(o.split(""),n).length},A=(t,e)=>{const n=v(t,e).join("");return F(n)},B=(t,e)=>{const n=v(t,e).join("").replace(/\s/g,"");return F(n)},D=(t,e)=>()=>e(t.getBody(),t.schema),j=(t,e)=>()=>e(t.selection.getRng().cloneContents(),t.schema),k=t=>D(t,T);var U=tinymce.util.Tools.resolve("tinymce.util.Delay");const M=(t,e)=>{((t,e)=>{t.dispatch("wordCountUpdate",{wordCount:{words:e.body.getWordCount(),characters:e.body.getCharacterCount(),charactersWithoutSpaces:e.body.getCharacterCountWithoutSpaces()}})})(t,e)},P=(t,n,o)=>{const r=((t,n)=>{let o=null;return{cancel:()=>{e(o)||(clearTimeout(o),o=null)},throttle:(...r)=>{e(o)&&(o=setTimeout((()=>{o=null,t.apply(null,r)}),n))}}})((()=>M(t,n)),o);t.on("init",(()=>{M(t,n),U.setEditorTimeout(t,(()=>{t.on("SetContent BeforeAddUndo Undo Redo ViewUpdate keyup",r.throttle)}),0),t.on("remove",r.cancel)}))};((e=300)=>{t.add("wordcount",(t=>{const n=(t=>({body:{getWordCount:k(t),getCharacterCount:D(t,A),getCharacterCountWithoutSpaces:D(t,B)},selection:{getWordCount:j(t,T),getCharacterCount:j(t,A),getCharacterCountWithoutSpaces:j(t,B)},getCount:k(t)}))(t);return((t,e)=>{t.addCommand("mceWordCount",(()=>((t,e)=>{t.windowManager.open({title:"Word Count",body:{type:"panel",items:[{type:"table",header:["Count","Document","Selection"],cells:[["Words",String(e.body.getWordCount()),String(e.selection.getWordCount())],["Characters (no spaces)",String(e.body.getCharacterCountWithoutSpaces()),String(e.selection.getCharacterCountWithoutSpaces())],["Characters",String(e.body.getCharacterCount()),String(e.selection.getCharacterCount())]]}]},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}]})})(t,e)))})(t,n),(t=>{const e=()=>t.execCommand("mceWordCount");t.ui.registry.addButton("wordcount",{tooltip:"Word count",icon:"character-count",onAction:e}),t.ui.registry.addMenuItem("wordcount",{text:"Word count",icon:"character-count",onAction:e})})(t),P(t,n,e),n}))})()}();
(function() {
  var Toolbox;

  Toolbox = {};

  this.Toolbox = Toolbox;

  Toolbox.doesStringContain = function(string, substring) {
    return string.indexOf(substring) >= 0;
  };

  Toolbox.uuid = function() {
    return ("" + Date.now() + Math.random()).replace(/[^0-9]/, "");
  };

  Toolbox.slugify = function(string) {
    var slug;
    slug = string.replace(/[^a-z_]/g, "_");
    return slug.replace(/__+/, "_").replace(/^_|_$/, "");
  };

  Toolbox.fileBaseName = function(filePath) {
    var filePathParts;
    filePathParts = filePath.split("\\");
    return filePathParts[filePathParts.length - 1];
  };

  Toolbox.isolateEvent = function(evt) {
    var $evt;
    $evt = $.Event(evt);
    $evt.stopPropagation();
    return $evt;
  };

  Toolbox.stopEvent = function(evt) {
    var $evt;
    $evt = $.Event(evt);
    $evt.preventDefault();
    return $evt;
  };

  Toolbox.cancelEvent = function(evt) {
    var $evt;
    $evt = Toolbox.stopEvent(evt);
    $evt.stopPropagation();
    return $evt;
  };

  Toolbox.killEvent = function(evt) {
    var $evt;
    $evt = Toolbox.cancelEvent(evt);
    $evt.stopImmediatePropagation();
    return $evt;
  };

  Toolbox.timer = function(time, func) {
    return setTimeout(func, time);
  };

  Toolbox.isTouchDevice = function() {
    return "ontouchstart" in window || navigator.maxTouchPoints;
  };

  Toolbox.setObjectDefaults = function(object, defaults) {
    return Toolbox.mergeObjects(defaults, object);
  };

  Toolbox.mergeObjects = function(initialObject, mergeObject) {
    return $.extend({}, initialObject, mergeObject);
  };

  Toolbox.getCookie = function(namespace) {
    return Cookies.getJSON(namespace);
  };

  Toolbox.setCookie = function(namespace, value, options) {
    options = Toolbox.setObjectDefaults(options, {
      expires: 365
    });
    Cookies.set(namespace, value, options);
    return value;
  };

  Toolbox.deleteCookie = function(namespace) {
    var value;
    value = Toolbox.getCookie(namespace);
    Cookies.remove(namespace);
    return value;
  };

  Toolbox.generateToken = function(options) {
    var parts;
    if (options == null) {
      options = {};
    }
    parts = [options.prefix, Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), options.suffix];
    return $.grep(parts, function(part) {
      return part;
    }).join("-");
  };

  Toolbox.getSubdomain = function() {
    var locationParts;
    locationParts = window.location.hostname.split(".");
    if (locationParts.length === 3) {
      return locationParts[0];
    }
  };

  Toolbox.requestIdleCallback = (window.requestIdleCallback || window.setTimeout).bind(window);

  Toolbox.loadJavascriptPromise = function(src, options) {
    var promise;
    options || (options = {});
    Toolbox.loadJavascriptPromiseCache || (Toolbox.loadJavascriptPromiseCache = {});
    if (Toolbox.loadJavascriptPromiseCache[src] && options.enableCache !== false) {
      return Toolbox.loadJavascriptPromiseCache[src];
    }
    promise = new Promise(function(resolve, reject) {
      var scriptTag;
      scriptTag = document.createElement("script");
      if (options.isModule) {
        scriptTag.setAttribute("type", "module");
        scriptTag.setAttribute("src", src);
      } else {
        scriptTag.setAttribute("type", "text/javascript");
        scriptTag.setAttribute("async", "async");
        scriptTag.setAttribute("defer", "defer");
        scriptTag.setAttribute("src", src);
      }
      scriptTag.addEventListener("load", function() {
        if (options.onLoadRemoveTag) {
          scriptTag.remove();
        }
        return Toolbox.requestIdleCallback(resolve);
      });
      scriptTag.addEventListener("error", reject);
      scriptTag.addEventListener("onerror", reject);
      return document.body.appendChild(scriptTag);
    });
    return Toolbox.loadJavascriptPromiseCache[src] = promise;
  };

  Toolbox.loadCssPromise = function(src, options) {
    options || (options = {});
    Toolbox.loadCssPromiseCache || (Toolbox.loadCssPromiseCache = {});
    if (Toolbox.loadCssPromiseCache[src] && options.enableCache !== false) {
      return Toolbox.loadCssPromiseCache[src];
    }
    new Promise(function(resolve, reject) {
      var linkTag;
      linkTag = document.createElement("link");
      linkTag.setAttribute("type", "text/css");
      linkTag.setAttribute("rel", "stylesheet");
      linkTag.setAttribute("media", "screen,print");
      linkTag.setAttribute("href", src);
      linkTag.addEventListener("load", function() {
        if (options.cleanupTag) {
          linkTag.remove();
        }
        return Toolbox.requestIdleCallback(resolve);
      });
      linkTag.addEventListener("error", reject);
      linkTag.addEventListener("onerror", reject);
      return document.body.appendChild(linkTag);
    });
    return Toolbox.loadCssPromiseCache[src] = promise;
  };

  this.Toolbox = Toolbox;

}).call(this);
(function() {
  window.$ = jQuery;

  window.logger = {};

  window.logger.email = function(email) {
    var flashLines, flashMessage, pastSubjects, ref, ref1;
    email.subject || (email.subject = "No Subject");
    email.body || (email.body = "No Details");
    email.stacktrace || (email.stacktrace = email.body.split("STACKTRACE:")[1]);
    if (email.level) {
      email.subject = email.level + " " + email.subject;
    }
    email.subject = $.trim(email.subject);
    pastSubjects = $.map(window.logger.emails, function(pastEmail) {
      return pastEmail.subject;
    });
    if (((ref = email.level) === "ERROR" || ref === "FATAL") && ((ref1 = window.finalforms) != null ? typeof ref1.environment === "function" ? ref1.environment() : void 0 : void 0) === "development") {
      flashLines = ["DEVELOPMENT JAVASCRIPT DEBUG"];
      flashLines.push(email.subject);
      if (email.body !== "No Details") {
        flashLines.push(email.body);
      }
      flashMessage = flashLines.join("\n").replaceAll("\n", "<br />");
      window.flash.alert(flashMessage);
    }
    if ($.inArray(email.subject, pastSubjects) === -1 && window.logger.emails.length <= 2) {
      if (email.stacktrace) {
        if (!email.stacktrace.match("finalforms")) {
          return;
        }
        if (email.stacktrace.match("global code@")) {
          return;
        }
      }
      if (email.subject.match("unsafe-eval")) {
        return;
      }
      if (email.subject.match("Blocked a frame with origin")) {
        return;
      }
      if (email.subject.match("androidInterface is not defined")) {
        return;
      }
      if (email.subject.match("preventDefault") && stacktrace.match(/Modal.*\.hide/)) {
        return;
      }
      if (email.body.match("auctioneer.50million.club")) {
        return;
      }
      if (email.subject.match("window.ztePage.log")) {
        return;
      }
      if (email.subject.match("TypeError: Cannot read property") && email.body.match("zteMove")) {
        return;
      }
      if (email.subject.match("Access is denied")) {
        return;
      }
      if (email.subject.match("RangeError: Maximum call stack size exceeded") && email.body.match("translate.google.com")) {
        return;
      }
      if (email.subject.match(/Zoom.*504.*GATEWAY_TIMEOUT/)) {
        return;
      }
      if (email.subject.match(/Zoom.*404.*Not Found/)) {
        return;
      }
      if (email.subject.match(/SyntaxError.*invalid or illegal/)) {
        return;
      }
      if (email.subject.match("Cannot read property 'tooltip' of undefined") && stacktrace.match("HighchartApi")) {
        return;
      }
      window.logger.emails.push(email);
      return $.ajax({
        type: 'POST',
        url: '/log',
        data: {
          subject: email.subject,
          body: email.body
        }
      });
    }
  };

  window.logger.emails = [];

  window.logger.debug = function(email) {
    return window.logger.email(Toolbox.mergeObjects(email, {
      level: "DEBUG"
    }));
  };

  window.logger.info = function(email) {
    return window.logger.email(Toolbox.mergeObjects(email, {
      level: "INFO"
    }));
  };

  window.logger.warn = function(email) {
    return window.logger.email(Toolbox.mergeObjects(email, {
      level: "WARN"
    }));
  };

  window.logger.error = function(email) {
    return window.logger.email(Toolbox.mergeObjects(email, {
      level: "ERROR"
    }));
  };

  window.logger.fatal = function(email) {
    return window.logger.email(Toolbox.mergeObjects(email, {
      level: "FATAL"
    }));
  };

  window.flash = function(level, message) {
    var $container, $flash, alerts;
    $container = $('#flash-container');
    alerts = {
      notice: 'success',
      info: 'info',
      warn: 'warning',
      alert: 'danger'
    };
    $flash = $("<div class='flash-message alert alert-" + (alerts[level] || level) + "'></div>");
    $flash.append('<button class="close" data-dismiss="alert">&times</button>').append(message);
    return $container.append($flash);
  };

  window.flash.clear = function() {
    return $('#flash-container').empty();
  };

  window.flash.info = function(message) {
    return this('info', message);
  };

  window.flash.notice = function(message) {
    return this('notice', message);
  };

  window.flash.warn = function(message) {
    return this('warn', message);
  };

  window.flash.alert = function(message) {
    return this('alert', message);
  };

  window.flash.support_path = function(text) {
    return '<a href="/documentation/support">' + text + '</a>';
  };

  window.flash.alert.support = function() {
    var message;
    message = "<p>We encountered a problem while trying to complete your request. " + ("Please " + (window.flash.support_path('contact support')) + " if this problem persists.</p>");
    window.flash.alert(message);
    return $("html,body").scrollTop(0);
  };

  window.error = {};

  window.error.test = function() {
    return fake_function_name_for_error_testing();
  };

  window.error.log = function(error, options) {
    var body, subject;
    try {
      if ((error != null ? error.stack : void 0) != null) {
        subject = "Javascript: " + error.message;
        body = "HREF: " + window.location.href + "\nCATCH: manual\nFROM: " + (options != null ? options.from : void 0) + "\nDETAILS: " + (options != null ? options.details : void 0) + "\nEMAILS:\n" + (window.logger.emails.join("\n")) + "\n\nERROR: " + error.message + "\nSTACKTRACE:\n" + error.stack;
        return window.logger.error({
          subject: subject,
          body: body
        });
      }
    } catch (error1) {

    }
  };

  window.onerror = function(message, filename, line, column, error) {
    var body, ref, subject;
    try {
      if ((filename != null) && (column != null) && ((error != null ? error.stack : void 0) != null)) {
        subject = "Javascript: " + message;
        body = "HREF: " + window.location.href + "\nCATCH: global\nFROM: onerror\nEMAILS:\n" + (window.logger.emails.join("\n")) + "\n\nERROR: " + message + "\nFILE: " + filename + "\nLINE: " + line + "\nCOL: " + column + "\nSTACKTRACE:\n" + error.stack;
        window.logger.error({
          subject: subject,
          body: body
        });
      }
      return (ref = window.Analytics) != null ? ref.trackError(message) : void 0;
    } catch (error1) {

    }
  };

}).call(this);
(function() {
  var base, base1;

  window.$ = jQuery;

  window.finalforms = {};

  (base = window.finalforms).identity || (base.identity = {});

  (base1 = window.finalforms).database || (base1.database = {});

  window.finalforms.environment = function() {
    return $("meta[name=environment]").prop("content");
  };

  window.finalforms.version = function() {
    return $("meta[name=version]").prop("content");
  };

  window.finalforms.timer = function(time, func) {
    return setTimeout(func, time);
  };

  window.finalforms.stop_event = function(evt) {
    return window.finalforms.prevent_event(evt);
  };

  window.finalforms.prevent_event = function(evt) {
    try {
      return evt.preventDefault();
    } catch (error) {
      return $.Event(evt).preventDefault();
    }
  };

  window.finalforms.cancel_event = function(evt) {
    window.finalforms.prevent_event(evt);
    return evt.stopImmediatePropagation();
  };

  window.finalforms.user_agent = function() {
    return navigator.userAgent || navigator.vendor || window.opera;
  };

  window.finalforms.mobile_user_agent = function() {
    return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(window.finalforms.user_agent()) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(window.finalforms.user_agent().substr(0, 4));
  };

  window.finalforms.queryParams = function() {
    var pairs, query, queryParams;
    queryParams = {};
    query = decodeURIComponent(window.location.search.substring(1));
    if (query === "") {
      return queryParams;
    }
    pairs = query.split('&');
    $.each(pairs, function(i, pair) {
      var key, value;
      key = pair.split('=')[0];
      value = pair.split('=')[1];
      if (key && key !== "") {
        return queryParams[key] = value;
      }
    });
    return queryParams;
  };

  $(function() {
    return Zoom.start();
  });

}).call(this);
(function() {
  $.fn.clearData = function(namespace) {
    this.each(function(i, element) {
      var $element;
      $element = $(element);
      $element.removeData(namespace);
      return $element.removeAttr("data-" + namespace);
    });
    return this;
  };

}).call(this);
(function() {
  $.fn.clearLink = function(namespace) {
    this.filter("a").each(function(i, element) {
      var $element;
      $element = $(element);
      return $element.prop("href", "javascript:void(0)");
    });
    return this;
  };

}).call(this);
(function() {
  $.fn.replaceCurrentHTML = function(options) {
    if (options == null) {
      options = {};
    }
    this.filter("[id]").each(function(i, updated) {
      var $current, $updated, id, target_id;
      $updated = $(updated);
      id = $updated.attr("id");
      target_id = "#" + id;
      $current = $(target_id);
      if ($current.length !== 0) {
        if (options.fadeIn) {
          if ($.contains(document.documentElement, $updated[0])) {
            $updated.hide();
          } else {
            $updated.css("display", "none");
          }
          $current.replaceWith($updated);
          return $updated.fadeIn($.isNumeric(options.fadeIn) ? options.fadeIn : 200);
        } else {
          return $current.replaceWith($updated);
        }
      }
    });
    return this;
  };

}).call(this);
(function() {
  var refreshModalTableBind, refreshSearchableTableBind;

  refreshModalTableBind = function(uuid) {
    var $refresh, $table, ajax, path;
    if (uuid == null) {
      uuid = Toolbox.uuid();
    }
    $table = $("#background-exports-owner-modal-table");
    $refresh = $("#background-exports-owner-modal-table-refresh-link");
    if (!$table.data("refreshing")) {
      $table.data("refreshing", uuid);
    }
    if ($table.length > 0 && $refresh.length > 0 && $table.data("refreshing") === uuid) {
      path = $refresh.attr("href");
      if (!Toolbox.doesStringContain(path, "running_export_ids")) {
        return;
      }
      ajax = $.ajax({
        url: path,
        headers: {
          "X-Zoom-Format": "partial"
        }
      });
      return ajax.done(function(html) {
        $(html).each(function(i, element) {
          var $element;
          $element = $(element);
          if ($element.prop("nodeName") === "TABLE") {
            return $element.find("tr").replaceCurrentHTML({
              fadeIn: true
            });
          } else {
            return $element.replaceCurrentHTML({
              fadeIn: true
            });
          }
        });
        return Toolbox.timer(5000, function() {
          return refreshModalTableBind(uuid);
        });
      });
    }
  };

  refreshSearchableTableBind = function(uuid) {
    var $refresh, $table, ajax, path;
    if (uuid == null) {
      uuid = Toolbox.uuid();
    }
    $table = $("#background-exports-owner-searchable-table");
    $refresh = $("#background-exports-owner-searchable-table-refresh-link");
    if (!$table.data("refreshing")) {
      $table.data("refreshing", uuid);
    }
    if ($table.length > 0 && $refresh.length > 0 && $table.data("refreshing") === uuid) {
      path = $refresh.attr("href");
      if (!Toolbox.doesStringContain(path, "running_export_ids")) {
        return;
      }
      ajax = $.ajax({
        url: path,
        headers: {
          "X-Zoom-Format": "partial"
        }
      });
      return ajax.done(function(html) {
        $(html).each(function(i, element) {
          var $element;
          $element = $(element);
          if ($element.prop("nodeName") === "TABLE") {
            return $element.find("tr").replaceCurrentHTML({
              fadeIn: true
            });
          } else {
            return $element.replaceCurrentHTML({
              fadeIn: true
            });
          }
        });
        return Toolbox.timer(5000, function() {
          return refreshSearchableTableBind(uuid);
        });
      });
    }
  };

  $(document).on("loaded.bs.modal", function() {
    return refreshModalTableBind();
  });

  $(window).on('zoom:page:done', function() {
    return refreshSearchableTableBind();
  });

}).call(this);
(function() {
  $(document).on("click", "[data-clipboard]", function(evt) {
    var $this, clipboard, clipboardOptions;
    $this = $(this);
    clipboardOptions = $this.data("clipboard");
    if (ClipboardFactory.isSupported()) {
      clipboard = ClipboardFactory.build(clipboardOptions);
      clipboard.on("success", function() {
        if (clipboardOptions.success != null) {
          return eval(clipboardOptions.success);
        }
      });
      clipboard.on("error", function() {
        flash.info("Your browser does not support copying to clipboard. You will have to manually copy and paste.");
        if (clipboardOptions.error != null) {
          return eval(clipboardOptions.error);
        }
      });
      if (clipboardOptions.flash !== false) {
        clipboard.on("success", function() {
          var originalColor, successColor, transitionDuration;
          successColor = "#5cb85c";
          originalColor = $this.css("color");
          transitionDuration = (parseFloat($this.css("transition-duration")) || 0.2) * 1000;
          $this.css("color", successColor);
          return Toolbox.timer(transitionDuration + 300, function() {
            return $this.css("color", originalColor);
          });
        });
      }
      return clipboard.copy();
    } else {
      return flash.info("Your browser does not support copying to clipboard. You will have to manually copy and paste.");
    }
  });

}).call(this);
(function() {
  $(document).on('click', '[data-clone]', function(evt) {
    var $clone, $element, clone_id, container, target;
    $element = $(this);
    target = $element.data('clone').target;
    container = $element.data('clone').container;
    $clone = $(target).clone(true, true);
    $clone.find('[disabled]').prop('disabled', false);
    clone_id = new Date().getTime().toString();
    $.each(['id', 'name', 'for'], function(i, attribute) {
      return $clone.find("[" + attribute + "*=CLONE]").data('clone_id', clone_id).attr(attribute, function(i, value) {
        return value.replace(/CLONE/g, clone_id);
      });
    });
    return $(container).append($clone.children());
  });

}).call(this);
(function() {
  $(document).on('click', 'a[data-confirm]', function(evt) {
    var $a;
    $a = $(this);
    if (window.confirm($a.data('confirm'))) {
      if ($a.data('onconfirm')) {
        return eval($a.data('onconfirm'));
      }
    } else {
      window.finalforms.stop_event(evt);
      return evt.stopImmediatePropagation();
    }
  });

  $(document).on('click', 'input[type=submit][data-confirm]', function(evt) {
    var $submit;
    $submit = $(this);
    if (window.confirm($submit.data('confirm'))) {
      if ($submit.data('onconfirm')) {
        return eval($submit.data('onconfirm'));
      }
    } else {
      window.finalforms.stop_event(evt);
      return evt.stopImmediatePropagation();
    }
  });

  $(document).on('submit', 'form[data-confirm]', function(evt) {
    var $form;
    $form = $(this);
    if (window.confirm($form.data('confirm'))) {
      if ($form.data('onconfirm')) {
        return eval($form.data('onconfirm'));
      }
    } else {
      window.finalforms.stop_event(evt);
      return evt.stopImmediatePropagation();
    }
  });

}).call(this);
(function() {
  window.csrf = {};

  window.csrf.input = function() {
    return $('<input />').attr('name', this.param()).val(this.token());
  };

  window.csrf.token = function() {
    return $('meta[name=csrf-token]').attr('content');
  };

  window.csrf.param = function() {
    return $('meta[name=csrf-param]').attr('content');
  };

  window.csrf.header = 'X-CSRF-Token';

  $.ajaxPrefilter(function(options, originalOptions, xhr) {
    if (!options.crossDomain) {
      return xhr.setRequestHeader(window.csrf.header, window.csrf.token());
    }
  });

  $(document).on('submit', 'form', function(evt) {
    return $(this).find("input[name=" + (window.csrf.param()) + "]").val(window.csrf.token());
  });

}).call(this);
(function() {
  var disabledLinks, parseDisableContent, removeDisable;

  parseDisableContent = function($element) {
    var data;
    data = $element.data("disable");
    if ($.type(data) === "object") {
      return data.html || data.text || "";
    } else {
      return data;
    }
  };

  $(document).on("submit", "form", function(evt) {
    var $form, $submits, hasDisableClickedClass;
    $form = $(this);
    if ($form.hasClass("timeout")) {
      window.finalforms.cancel_event(evt);
    } else {
      $form.addClass("timeout");
      window.finalforms.timer(1000, function() {
        return $form.removeClass("timeout");
      });
    }
    $submits = $form.find("input[type=submit][data-disable]");
    if ($form.prop("id")) {
      $submits = $submits.add("input[type=submit][data-disable][form=" + ($form.prop("id")) + "]");
    }
    hasDisableClickedClass = $submits.hasClass("disable-clicked");
    return $submits.each(function(i, submit) {
      var $submit;
      $submit = $(submit);
      $submit.prop("disabled", true);
      $submit.addClass("data-disabled");
      if (hasDisableClickedClass && $submit.hasClass("disable-clicked")) {
        $submit.val(parseDisableContent($submit));
        return $submit.removeClass("disable-clicked");
      }
    });
  });

  $(document).on("click", "a[data-disable]", function(evt) {
    var $a;
    $a = $(this);
    $a.addClass("disabled data-disabled");
    $a.html(parseDisableContent($a));
    return window.finalforms.stop_event(evt);
  });

  $(document).on("click", "a.disabled", function(evt) {
    return window.finalforms.stop_event(evt);
  });

  removeDisable = function() {
    $("form.timeout").removeClass("timeout");
    $("input.data-disabled[type=submit]").each(function(i, submit) {
      var $submit;
      $submit = $(submit);
      if (("" + ($submit.data("undisable"))) !== "false") {
        $submit.prop("disabled", false);
        return $submit.removeClass("data-disable");
      }
    });
    return $("a.data-disabled").each(function(i, a) {
      var $a;
      $a = $(a);
      if (("" + ($a.data("undisable"))) !== "false") {
        return $a.removeClass("disabled data-disabled");
      }
    });
  };

  disabledLinks = function() {
    return $("a.disabled").not(".never-void-disable").each(function(i, a) {
      var $a, href;
      $a = $(a);
      href = "" + ($a.prop("href"));
      if (href.match("javascript:")) {
        return;
      }
      if (href === "#") {
        return;
      }
      $a.clearLink();
      $a.clearData("confirm");
      $a.clearData("disable");
      if ($a.data("toggle") === "modal") {
        return $a.clearData("toggle");
      }
    });
  };

  $(window).on("zoom:page:always", removeDisable);

  $(window).on("zoom:partial:always", removeDisable);

  $(window).on("zoom:page:done", disabledLinks);

  $(window).on("zoom:partial:done", disabledLinks);

}).call(this);
(function() {
  var disableAutocompleteBind;

  disableAutocompleteBind = function() {
    if (window.chrome) {
      return $("input[autocomplete='off']").each(function(i, input) {
        return $(input).prop("autocomplete", "disabled");
      });
    }
  };

  $(window).on('zoom:page:done', disableAutocompleteBind);

  $(window).on('zoom:partial:done', disableAutocompleteBind);

  $(window).on("google:address_autocomplete:setup", disableAutocompleteBind);

}).call(this);
(function() {
  var dragoverBind, dropOutsideZoneBind;

  dragoverBind = function() {
    return $("[data-drag-and-drop]").each(function(i, element) {
      var $data, $element;
      $element = $(element);
      if ($element.data("drag-and-drop-bind")) {
        return;
      }
      $element.data("drag-and-drop-bind", true);
      $data = $element.data("drag-and-drop");
      $data.state = 0;
      $element.on("dragover", function(evt) {
        Toolbox.cancelEvent(evt);
        if ($data.ondragover) {
          return eval($data.ondragover);
        }
      });
      if ($data.ondragenter) {
        $element.on("dragenter", function(evt) {
          Toolbox.cancelEvent(evt);
          $data.state++;
          return eval($data.ondragenter);
        });
      }
      if ($data.ondragleave) {
        $element.on("dragleave", function(evt) {
          Toolbox.cancelEvent(evt);
          $data.state--;
          if ($data.state === 0) {
            return eval($data.ondragleave);
          }
        });
      }
      if ($data.ondrop) {
        return $element.on("drop", function(evt) {
          Toolbox.cancelEvent(evt);
          $data.state = 0;
          $element.trigger("dragleave");
          return eval($data.ondrop);
        });
      }
    });
  };

  dropOutsideZoneBind = function(evt) {
    var $dragZones, $dropZones, $target;
    $target = $(evt.target);
    $dropZones = $(".drag-and-drop-zone");
    if ($dropZones.has($target).length === 0) {
      Toolbox.cancelEvent(evt);
      $dropZones.addClass("drag-and-drop-zone");
      $dropZones.removeClass("drag-and-drop-zone-on");
    }
    return $dragZones = $("[data-drag-and-drop]").each(function(i, element) {
      return $(element).data("drag-and-drop").state = 0;
    });
  };

  $(window).on("zoom:page:done", dragoverBind);

  $(window).on("zoom:partial:done", dragoverBind);

  $(document).on("loaded.bs.modal", dragoverBind);

  $(window).on("drop", dropOutsideZoneBind);

}).call(this);
(function() {
  var dropdownBind;

  dropdownBind = function() {
    $(document).on("click", ".dropdown-keep-open", function() {
      return $(document).one("hide.bs.dropdown", function(evt) {
        return Toolbox.cancelEvent(evt);
      });
    });
    return $("div.dropdown[data-dropdown]").each(function(i, dropdown) {
      var $dropdown, dropdownData;
      $dropdown = $(dropdown);
      dropdownData = $dropdown.data("dropdown");
      return $.each(dropdownData, function(key, params) {
        if (key === "onshow") {
          return $dropdown.on("show.bs.dropdown", function(evt) {
            return eval(params);
          });
        } else if (key === "onshown") {
          return $dropdown.on("shown.bs.dropdown", function(evt) {
            return eval(params);
          });
        } else if (key === "onhide") {
          return $dropdown.on("hide.bs.dropdown", function(evt) {
            return eval(params);
          });
        } else if (key === "onhidden") {
          return $dropdown.on("hidden.bs.dropdown", function(evt) {
            return eval(params);
          });
        }
      });
    });
  };

  $(window).on('zoom:page:done', dropdownBind);

  $(window).on('zoom:partial:done', dropdownBind);

}).call(this);
(function() {
  var ecardsBind;

  ecardsBind = function() {
    var $ecardsContainer, $formatters, exportOptions, exportSize;
    if ($('.ecards-export').size() !== 0) {
      $ecardsContainer = $('.ecards-container');
      $formatters = $('.ecards-formatter');
      exportOptions = $ecardsContainer.data('ecards');
      exportSize = window.parseInt(exportOptions.size);
      $('.ecard-loaders').each(function(i, container) {
        var $container, $loaders, $loadingDisable, $loadingHide, $loadingShow, $progress, ref;
        $container = $(container);
        $progress = $('#ecards-load-progress');
        $loaders = $container.find('.ecard-loader');
        $loadingShow = $('.ecards-loading-show');
        $loadingHide = $('.ecards-loading-hide');
        $loadingDisable = $('.ecards-loading-disable');
        $loaders.each(function(i, loader) {
          var $loader, loaderOptions, progress;
          $loader = $(loader);
          loaderOptions = $loader.data('ecards');
          progress = loaderOptions.progress;
          return loader.loadEcards = function() {
            var ajax;
            ajax = $.ajax({
              type: 'GET',
              url: loader.href
            });
            ajax.fail(function() {
              return window.flash.alert.support();
            });
            ajax.done(function(result, xhr, status) {
              var $ecards;
              $ecards = $(result).filter('*');
              return $ecardsContainer.append($ecards);
            });
            return ajax.always(function() {
              var percent, ref;
              $progress.find('.progress-count').text(progress);
              percent = (window.parseInt(progress / exportSize * 100)) + "%";
              $progress.find('.progress-bar').css({
                width: percent
              }).text(percent);
              if (!((ref = $loaders[i + 1]) != null ? ref.loadEcards() : void 0)) {
                $progress.remove();
                $loadingShow.hide();
                $loadingDisable.removeClass('disabled');
                return $loadingHide.show();
              }
            });
          };
        });
        if ((ref = $loaders[0]) != null ? ref.loadEcards() : void 0) {
          $loadingHide.hide();
          $loadingDisable.addClass('disabled');
          return $loadingShow.show();
        }
      });
      return $formatters.click(function() {
        var $ecards, $formattingDisable, $formattingHide, $formattingShow, $page, $printText, $this, format, formatOptions, newPage, pageCount;
        $this = $(this);
        $formattingShow = $('.ecards-formatting-show');
        $formattingHide = $('.ecards-formatting-hide');
        $formattingDisable = $('.ecards-formatting-disable');
        $printText = $('.print-text');
        formatOptions = $this.data('ecards');
        format = formatOptions.format;
        pageCount = 0;
        newPage = function() {
          var $newPage;
          pageCount += 1;
          $newPage = $("<div class='ecard-page print'></div>");
          if (pageCount !== 1) {
            $newPage.addClass("hidden");
          }
          return $newPage;
        };
        $formatters.parents("li.active").removeClass("active");
        $this.parents("li").addClass("active");
        $printText.text($this.text());
        $ecardsContainer.removeClass('ecards-1x1 ecards-2x1 ecards-3x1').addClass("ecards-" + format);
        $ecards = $ecardsContainer.find('.ecard').detach().removeClass("col-xs-4 col-xs-6 col-xs-12");
        $ecardsContainer.html('');
        $formattingHide.hide();
        $formattingDisable.addClass('disabled');
        $formattingShow.show();
        if (format === "1x1") {
          $ecards.addClass("col-xs-12").each(function(i, ecard) {
            return $ecardsContainer.append(newPage().html(ecard));
          });
        } else if (format === "2x1") {
          $page = void 0;
          $ecards.addClass("col-xs-6").each(function(i, ecard) {
            if (i % 2 === 0) {
              $page = newPage();
            }
            $page.append(ecard);
            if (i % 2 === 1 || i === $ecards.length - 1) {
              return $ecardsContainer.append($page);
            }
          });
        } else if (format === "3x1") {
          $page = void 0;
          $ecards.addClass("col-xs-4").each(function(i, ecard) {
            if (i % 3 === 0) {
              $page = newPage();
            }
            $page.append(ecard);
            if (i % 3 === 2 || i === $ecards.length - 1) {
              return $ecardsContainer.append($page);
            }
          });
        }
        $formattingShow.hide();
        $formattingDisable.removeClass('disabled');
        return $formattingHide.show();
      });
    }
  };

  $(window).on('zoom:page:done', ecardsBind);

}).call(this);
(function() {
  $(document).on("submit", "form.iframe", function(evt) {
    var $form, $iframe, id;
    $form = $(evt.currentTarget);
    id = $form.prop("id");
    $iframe = $("#" + ($form.prop("target")));
    return $iframe.on("load", function(evt) {
      var $iframeHTML, details, error, file, iframeHTML, onload, ref;
      onload = $iframe.data("onload");
      if (onload != null) {
        eval(onload);
      }
      try {
        iframeHTML = $iframe.contents().find("body").html();
        $iframeHTML = $("<div/>").html(iframeHTML);
        $iframeHTML.children("[id]").each(function(i, partial) {
          return $(partial).replaceCurrentHTML({
            fadeIn: true
          });
        });
        return Zoom.pubsub.publish(Zoom.events.partial.done);
      } catch (error1) {
        error = error1;
        file = (ref = $form.find("input[type=file]")[0]) != null ? ref.files[0] : void 0;
        if ((file != null ? file.size : void 0) > 36700160) {
          window.flash.alert(file.name + " is too large, maximum file size is 35MB");
        } else {
          window.flash.alert.support();
        }
        if (file != null) {
          details = "name: " + file.name + "\ntype: " + file.type + "\nsize: " + file.size;
          return window.error.log(error, {
            from: "form.iframe",
            details: details
          });
        }
      }
    });
  });

}).call(this);
(function() {
  var googleMapInit;

  googleMapInit = function() {
    var $map;
    $map = $(".google-map-container").find("[data-google-map-init]");
    if ($map.length > 0) {
      return eval($map.data("google-map-init"));
    }
  };

  $(window).on('zoom:page:done', googleMapInit);

}).call(this);
(function() {
  var maskBind;

  maskBind = function() {
    var formats, helpers, inputmaskTranslations, momentValueFormatter;
    momentValueFormatter = function(outputFormat) {
      return function(unformattedValue) {
        var unformattedMoment;
        unformattedMoment = moment(unformattedValue);
        if (unformattedMoment.isValid()) {
          return unformattedMoment.format(outputFormat);
        } else {
          return unformattedValue;
        }
      };
    };
    formats = {
      "phone_number": {
        mask: "000-000-0000[x0{1,6}]",
        validator: /^\d{3}-\d{3}-\d{4}(x\d{1,6})?$/,
        defaultPlaceholder: "000-000-0000"
      },
      "address_zip": {
        mask: "00000[-0000]",
        validator: /^\d{5}(-\d{4})?$/,
        defaultPlaceholder: "00000"
      },
      "date": {
        mask: "00/00/00[00]",
        validator: /^\d{2}\/\d{2}\/\d{2}(\d{2})?$/,
        defaultPlaceholder: "MM/DD/YY",
        initialValueFormatter: momentValueFormatter("MM/DD/YY")
      },
      "date_yyyy_mm_dd": {
        mask: "0000-00-00",
        validator: /^\d{4}-\d{2}-\d{2}$/,
        defaultPlaceholder: "YYYY-MM-DD",
        initialValueFormatter: momentValueFormatter("YYYY-MM-DD")
      },
      "date_mm_dd_yy": {
        mask: "00/00/00[00]",
        validator: /^\d{2}\/\d{2}\/\d{2}(\d{2})?$/,
        defaultPlaceholder: "MM/DD/YY",
        initialValueFormatter: momentValueFormatter("MM/DD/YY")
      },
      "date_mm_dd_yyyy": {
        mask: "00/00/0000",
        validator: /^\d{2}\/\d{2}\/\d{4}$/,
        defaultPlaceholder: "MM/DD/YYYY",
        initialValueFormatter: momentValueFormatter("MM/DD/YYYY")
      },
      "m_d_y_date": {
        mask: "00/00/00[00]",
        validator: /^\d{2}\/\d{2}\/\d{2}(\d{2})?$/,
        defaultPlaceholder: "MM/DD/YYYY"
      }
    };
    inputmaskTranslations = {
      "A": {
        validator: "[A-Za-z]",
        cardinality: 1
      },
      "0": {
        validator: "[0-9]",
        cardinality: 1
      },
      "W": {
        validator: "[a-zA-Z0-9]",
        cardinality: 1
      }
    };
    helpers = {
      applyDefaultPlaceholder: function($input, defaultPlaceholder) {
        if (!$input.attr("placeholder")) {
          return $input.attr("placeholder", defaultPlaceholder);
        }
      },
      applyValidator: function($input, validator) {
        var $parent, updateClass;
        $parent = $input.parent();
        updateClass = function() {
          if (!$input.val()) {
            return $parent.removeClass("has-success").removeClass("has-error");
          } else if ($input.val().match(validator)) {
            return $parent.removeClass("has-error").addClass("has-success");
          } else {
            return $parent.removeClass("has-success").addClass("has-error");
          }
        };
        $input.keyup(updateClass);
        return $input.change(updateClass);
      },
      applyValueFormatter: function($input, valueFormatter) {
        return $input.val(valueFormatter($input.val()));
      }
    };
    return $("input[type=text][data-constraint]").each(function(i, input) {
      var $input, constraint, formatOptions, inputmaskOptions;
      $input = $(input);
      constraint = $input.data("constraint");
      formatOptions = formats[constraint];
      if (!formatOptions || $input.prop("hasInputmask") === "true") {
        return;
      }
      $input.prop("hasInputmask", "true");
      inputmaskOptions = {
        mask: formatOptions.mask,
        definitions: inputmaskTranslations,
        placeholder: "_",
        showTooltip: false,
        greedy: false,
        showMaskOnFocus: true,
        showMaskOnHover: false
      };
      if (formatOptions.defaultPlaceholder) {
        helpers.applyDefaultPlaceholder($input, formatOptions.defaultPlaceholder);
      }
      if (formatOptions.initialValueFormatter) {
        helpers.applyValueFormatter($input, formatOptions.initialValueFormatter);
      }
      if (window.finalforms.mobile_user_agent()) {
        return;
      }
      if (formatOptions.validator) {
        helpers.applyValidator($input, formatOptions.validator);
      }
      return $input.inputmask(inputmaskOptions);
    });
  };

  $(window).on("zoom:page:done", maskBind);

  $(document).on("loaded.bs.modal", maskBind);

}).call(this);
(function() {
  var noscriptBind;

  noscriptBind = function() {
    $('.noscript').remove();
    return $('input[name=javascript]').val('true');
  };

  $(window).on('zoom:page:done', noscriptBind);

  $(window).on('zoom:partial:done', noscriptBind);

}).call(this);
(function() {
  var notificationBind;

  notificationBind = function() {
    return $("[data-notification]").each(function(i, element) {
      var $element, notification;
      $element = $(element);
      notification = $element.data("notification");
      if (!$.isPlainObject(notification)) {
        return;
      }
      return $.each(notification, function(method, params) {
        var $select2, popoverHide, popoverShow, popoverTrigger, tooltipHide, tooltipShow, tooltipTrigger;
        if (method === "popover" && $element.data("bs.popover") === void 0) {
          if (!params["placement"]) {
            params["placement"] = "auto top";
          }
          if (!params["container"]) {
            params["container"] = "#body-wrapper";
          }
          if ("" + params["delay"] === "true") {
            params["delay"] = {
              show: 0,
              hide: 300
            };
          }
          if ($element.hasClass("select2")) {
            $element.finalformsSelect2();
            popoverTrigger = params["trigger"];
            params["trigger"] = "manual";
            $select2 = $($element.data("select2").container);
            $select2.popover(params);
            popoverShow = function() {
              return $select2.popover("show");
            };
            popoverHide = function() {
              return $select2.popover("hide");
            };
            if (popoverTrigger.match(/hover/)) {
              $select2.hover(popoverShow, popoverHide);
            } else if (popoverTrigger.match(/focus|click/)) {
              $element.on('select2-open', function() {
                return popoverShow();
              });
              $element.on('select2-close', function() {
                return popoverHide();
              });
            }
          } else {
            $element.popover(params);
          }
        }
        if (method === "tooltip" && $element.data("bs.tooltip") === void 0) {
          if (!params["placement"]) {
            params["placement"] = "auto top";
          }
          if (!params["container"]) {
            params["container"] = "#body-wrapper";
          }
          if ("" + params["delay"] === "true") {
            params["delay"] = {
              show: 0,
              hide: 300
            };
          }
          if ($element.hasClass("select2")) {
            $element.finalformsSelect2();
            tooltipTrigger = params["trigger"];
            params["trigger"] = "manual";
            $select2 = $($element.data("select2").container);
            $select2.tooltip(params);
            tooltipShow = function() {
              return $select2.tooltip("show");
            };
            tooltipHide = function() {
              return $select2.tooltip("hide");
            };
            if (tooltipTrigger.match(/hover/)) {
              return $select2.hover(tooltipShow, tooltipHide);
            } else if (tooltipTrigger.match(/focus|click/)) {
              $element.on('select2-open', function() {
                return tooltipShow();
              });
              return $element.on('select2-close', function() {
                return tooltipHide();
              });
            }
          } else {
            return $element.tooltip(params);
          }
        }
      });
    });
  };

  $(window).on("zoom:page:done", notificationBind);

  $(window).on("zoom:partial:done", notificationBind);

  $(document).on("loaded.bs.modal", notificationBind);

}).call(this);
(function() {
  var paginateBind;

  paginateBind = function() {
    var $gaps, $next, $pages, $pagination, $previous, border, options, pages, spacing;
    $pagination = $('.pagination-js');
    $pages = $pagination.find('.page');
    $gaps = $pagination.find('.gap-page');
    pages = $pages.length;
    $previous = $pagination.find('.previous-page');
    $next = $pagination.find('.next-page');
    options = $pagination.data('pagination') || {};
    border = options.border || 2;
    spacing = options.spacing || 2;
    $next.find('a').on('click', function(evt) {
      var current;
      current = $pages.index($pages.filter('.active')) + 1;
      if (current !== pages) {
        return $pages.eq(current).find('a').click();
      }
    });
    $previous.find('a').on('click', function(evt) {
      var current;
      current = $pages.index($pages.filter('.active')) + 1;
      if (current !== 1) {
        return $pages.eq(current - 2).find('a').click();
      }
    });
    $pages.find('a').on('click', function(evt) {
      var $current, current;
      $current = $(this).parents('.page').first();
      current = $pages.index($current) + 1;
      $gaps.addClass('hidden');
      if (pages >= (border + spacing) * 2 + 1) {
        $pages.addClass('hidden');
        if (current <= border + spacing + 1) {
          $pages.slice(0, current).removeClass('hidden');
        } else {
          $pages.slice(0, border).removeClass('hidden');
          $pages.slice((current - 1) - spacing, current - 1).removeClass('hidden');
          $gaps.eq(border).removeClass('hidden');
        }
        if (current + spacing + border >= pages) {
          $pages.slice(current - 1, pages).removeClass('hidden');
        } else {
          $pages.slice(current - 1, current + spacing).removeClass('hidden');
          $pages.slice(pages - border, pages).removeClass('hidden');
          $gaps.eq(pages - border).removeClass('hidden');
        }
      } else {
        $pages.removeClass('hidden');
      }
      $pages.removeClass('active');
      $current.addClass('active');
      if (current === 1) {
        $previous.addClass('disabled');
      } else {
        $previous.removeClass('disabled');
      }
      if (current === pages) {
        $next.addClass('disabled');
      } else {
        $next.removeClass('disabled');
      }
      return $('.paged').addClass('hidden').filter(".page" + current).removeClass('hidden');
    });
    return $pages.filter('.active').first().find('a').click();
  };

  $(window).on('zoom:page:done', paginateBind);

}).call(this);
(function() {
  var popoverBind;

  popoverBind = function() {
    var defaults;
    defaults = {};
    return $("[data-toggle=popover]").popover(defaults);
  };

  $(window).on('zoom:page:done', popoverBind);

  $(window).on('zoom:partial:done', popoverBind);

  $.fn.tooltip.Constructor.DEFAULTS.whiteList["*"].push("style");

  $.fn.popover.Constructor.prototype.originalLeave = $.fn.popover.Constructor.prototype.leave;

  $.fn.popover.Constructor.prototype.leave = function(obj) {
    var popover;
    popover = obj instanceof this.constructor ? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type);
    this.originalLeave.call(this, obj);
    if (popover.$tip) {
      return popover.$tip.one('mouseenter', function() {
        clearTimeout(popover.timeout);
        return popover.$tip.one('mouseleave', function() {
          return $.fn.popover.Constructor.prototype.leave.call(popover, obj);
        });
      });
    }
  };

}).call(this);
(function() {
  $(document).on('change', 'select[data-selectgroup]', function(evt) {
    var $group, $select;
    $select = $(this);
    $group = $("select[data-selectgroup='" + ($select.data('selectgroup')) + "']");
    if ($select.val() !== '') {
      return $group.not($select).each(function(i, groupselect) {
        var $groupselect;
        $groupselect = $(groupselect);
        if ($select.val() === $groupselect.val()) {
          return $groupselect.val('');
        }
      });
    }
  });

}).call(this);
(function() {
  var stripeBind;

  stripeBind = function() {
    return $("form.stripe-checkout").each(function(i, form) {
      var $form, $tokenField, $triggers, checkoutDefaults, checkoutOptions, configureDefaults, configureOptions, handler;
      $form = $(form);
      $triggers = $form.find(".stripe-checkout-trigger");
      configureDefaults = {
        image: "/favicon-160x160.png",
        locale: "auto",
        tokenFieldSelector: "input.stripe-checkout-token"
      };
      checkoutDefaults = {
        name: "FinalForms SecurePay",
        description: "Pay Fees",
        zipCode: true
      };
      configureOptions = $.extend(true, {}, configureDefaults, $form.data("stripe").configure);
      checkoutOptions = $.extend(true, {}, checkoutDefaults, $form.data("stripe").checkout);
      $tokenField = $form.find(configureOptions.tokenFieldSelector);
      delete configureOptions.tokenFieldSelector;
      configureOptions.token = function(token) {
        $tokenField.val(token.id);
        $triggers.each(function(i, trigger) {
          var $trigger, text;
          $trigger = $(trigger);
          text = $trigger.data("disable") || "Payment Processing...";
          return $trigger.text(text).prop("disabled", true);
        });
        return $form.submit();
      };
      handler = StripeCheckout.configure(configureOptions);
      $triggers.on("click", function(evt) {
        handler.open(checkoutOptions);
        return evt.preventDefault();
      });
      return $(window).on("popstate", function() {
        return handler.close();
      });
    });
  };

  $(window).on("zoom:page:done", stripeBind);

}).call(this);
(function() {
  var dynamicColspanBind;

  dynamicColspanBind = function() {
    return $("td.colspan-max").each(function(i, td) {
      var $headers, $siblings, $table, $td, maxColspan, siblingsColspan;
      $td = $(td);
      $td.removeClass("colspan-max").addClass("colspan-maxed");
      $table = $td.parents("table").first();
      $headers = $table.find("tr").first().find("th,td");
      $siblings = $td.siblings("td");
      maxColspan = 0;
      siblingsColspan = 0;
      $headers.each(function(i, header) {
        return maxColspan += parseInt($(header).attr("colspan") || 1);
      });
      $siblings.each(function(i, sibling) {
        return siblingsColspan += parseInt($(sibling).attr("colspan") || 1);
      });
      return $td.attr("colspan", maxColspan - siblingsColspan);
    });
  };

  $(window).on("zoom:page:done", dynamicColspanBind);

  $(window).on("zoom:partial:done", dynamicColspanBind);

}).call(this);
(function() {
  var bindTinymceEditor, bindTinymcePage, bindTinymcePartial;

  bindTinymcePartial = function() {
    tinymce.remove();
    return bindTinymceEditor();
  };

  bindTinymcePage = function() {
    tinymce.remove();
    return bindTinymceEditor();
  };

  bindTinymceEditor = function() {
    var ref, version;
    version = ((ref = window.finalforms) != null ? ref.version() : void 0) || new Date().toJSON().slice(0, 10);
    return $(".tinymce").each(function(i, textarea) {
      var $textarea, textareaRows, tinymceConfig;
      $textarea = $(textarea);
      tinymceConfig = {
        setup: function(editor) {
          return editor.on("change", function() {
            return tinymce.triggerSave();
          });
        },
        target: textarea,
        promotion: false,
        branding: false,
        theme: "silver",
        paste_data_images: false,
        block_unsupported_drop: true,
        browser_spellcheck: true,
        content_css: ["/tinymce/iframe_content.css?version=" + version, "/tinymce/iframe_ui_content.css?version=" + version],
        skin: false,
        elementpath: false,
        resize: "both",
        contextmenu: false,
        plugins: ["autolink", "autoresize", "autosave", "charmap", "code", "directionality", "fullscreen", "help", "image", "link", "lists", "quickbars", "table", "wordcount"],
        quickbars_insert_toolbar: false,
        quickbars_selection_toolbar: false,
        toolbar: ["fullscreen", "bold italic underline removeformat", "numlist bullist outdent indent", "backcolor forecolor", "link", "alignleft aligncenter alignright | fontsize | undo redo | charmap code help"].join(" | "),
        toolbar_mode: "floating",
        mobile: {
          toolbar: ["undo redo", "bold italic underline", "numlist bullist outdent indent", "backcolor forecolor", "link", "alignleft aligncenter alignright", "fontsize", "charmap code help"].join(" | "),
          toolbar_mode: "floating"
        },
        link_context_toolbar: true,
        link_assume_external_targets: true,
        link_default_target: "_blank",
        autosave_interval: "5s",
        autosave_restore_when_empty: false,
        height: 0,
        min_height: $textarea.outerHeight() + 60
      };
      if (tinymceConfig.min_height === 60) {
        textareaRows = window.parseInt($textarea.prop("rows")) || 5;
        tinymceConfig.min_height = textareaRows * 25 + 60;
      }
      return tinymce.init(tinymceConfig);
    });
  };

  $(window).on("zoom:page:done", bindTinymcePage);

  $(window).on("zoom:partial:done", bindTinymcePartial);

  $(document).on("loaded.bs.modal", bindTinymcePartial);

}).call(this);
(function() {
  var tooltipBind;

  tooltipBind = function() {
    var defaults;
    defaults = {};
    return $("[data-toggle=tooltip]").tooltip(defaults);
  };

  $(window).on('zoom:page:done', tooltipBind);

  $(window).on('zoom:partial:done', tooltipBind);

  $.fn.tooltip.Constructor.prototype.originalLeave = $.fn.tooltip.Constructor.prototype.leave;

  $.fn.tooltip.Constructor.prototype.leave = function(obj) {
    var tooltip;
    tooltip = obj instanceof this.constructor ? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type);
    this.originalLeave.call(this, obj);
    if (tooltip.$tip) {
      return tooltip.$tip.one('mouseenter', function() {
        clearTimeout(tooltip.timeout);
        return tooltip.$tip.one('mouseleave', function() {
          return $.fn.tooltip.Constructor.prototype.leave.call(tooltip, obj);
        });
      });
    }
  };

}).call(this);
(function() {
  var triggerClickBind;

  triggerClickBind = function() {
    var idsToClick, triggerClick;
    idsToClick = finalforms.queryParams()["trigger_click"];
    if (idsToClick) {
      idsToClick = idsToClick.split(",");
      triggerClick = function() {
        var $clicked;
        $clicked = $("#" + (idsToClick.shift())).click();
        if (idsToClick.length !== 0) {
          if ($clicked.data("toggle") === "modal") {
            return $($clicked.data("target")).one("hidden.bs.modal", function() {
              return finalforms.timer(500, function() {
                return triggerClick();
              });
            });
          } else {
            return triggerClick();
          }
        }
      };
      return triggerClick();
    }
  };

  $(window).on('zoom:page:done', triggerClickBind);

}).call(this);
(function() {
  var youtubeIframeBind, youtubeIframePlayerReady, youtubeIframePlayerStateChange;

  youtubeIframeBind = function() {
    var $youtubeApiScript, $youtubeIframes;
    $youtubeIframes = $("[data-youtube-iframe]");
    if ($youtubeIframes.length === 0) {
      return;
    }
    if (typeof YT === "undefined") {
      $youtubeApiScript = $("<script>").attr("src", "https://www.youtube.com/iframe_api");
      $("#content").append($youtubeApiScript);
      return;
    }
    return $youtubeIframes.each(function(i, iframe) {
      var $iframe, config, player;
      $iframe = $(iframe);
      if ($iframe.prop("id") === "") {
        $iframe.prop("id", Toolbox.uuid());
      }
      config = $iframe.data("youtube-iframe");
      player = new YT.Player(iframe, {
        videoId: config.videoId,
        playerVars: config.playerVars,
        events: {
          onReady: youtubeIframePlayerReady,
          onStateChange: youtubeIframePlayerStateChange
        }
      });
      $iframe = $("#" + $iframe.prop("id"));
      return $iframe.data("youtube-iframe").player = player;
    });
  };

  youtubeIframePlayerReady = function(evt) {
    var $iframe, config, ref;
    $iframe = $(evt.target.g);
    config = $iframe.data("youtube-iframe");
    return eval((ref = config.events) != null ? ref.on_ready : void 0);
  };

  youtubeIframePlayerStateChange = function(evt) {
    var $iframe, config, ref;
    $iframe = $(evt.target.g);
    config = $iframe.data("youtube-iframe");
    $.each(YT.PlayerState, function(state, stateId) {
      var ref, stateCallbackKey;
      if (evt.data === stateId) {
        stateCallbackKey = "on_" + (state.toLocaleLowerCase());
        return eval((ref = config.events) != null ? ref[stateCallbackKey] : void 0);
      }
    });
    return eval((ref = config.events) != null ? ref["on_any"] : void 0);
  };

  window.onYouTubeIframeAPIReady = function() {
    return $(window).trigger("youtube:iframeapi:ready");
  };

  $(window).on("zoom:page:done", youtubeIframeBind);

  $(window).on("youtube:iframeapi:ready", youtubeIframeBind);

}).call(this);
(function() {
  var hideOpenModalBind, removeModalBackdropBind, resetAjaxModalContentBind, saveOriginalAjaxModalContentBind;

  saveOriginalAjaxModalContentBind = function() {
    var $modal, originalBody, originalFooter, originalHeader;
    $modal = $("#ajax-modal");
    if ($modal.length === 1 && ($modal.data("original.bs.modal") == null)) {
      originalHeader = $modal.find(".modal-header.original").clone(true, true);
      originalBody = $modal.find(".modal-body.original").clone(true, true);
      originalFooter = $modal.find(".modal-footer.original").clone(true, true);
      if (originalHeader.length === 1 && originalBody.length === 1 && originalFooter.length === 1) {
        return $modal.data("original.bs.modal", {
          header: originalHeader,
          body: originalBody,
          footer: originalFooter
        });
      }
    }
  };

  resetAjaxModalContentBind = function() {
    var $modal;
    $modal = $("#ajax-modal");
    $modal.removeData("bs.modal");
    if ($modal.data("original.bs.modal")) {
      return $.each($modal.data("original.bs.modal"), function(section, originalHtml) {
        var $section;
        $section = $modal.find(".modal-" + section);
        if (!$section.hasClass("original")) {
          return $section.replaceWith(originalHtml);
        }
      });
    }
  };

  hideOpenModalBind = function(evt, params) {
    if (("" + params.zoomOptions.data.closeModal) !== "false") {
      return $(".modal.in").modal("hide");
    } else if (("" + params.zoomOptions.data.scrollToTop) !== "false") {
      return $("#ajax-modal").scrollTop(0);
    }
  };

  removeModalBackdropBind = function() {
    $("div.modal-backdrop").remove();
    return $("body").removeClass("modal-open");
  };

  $(window).on("zoom:page:fetch", hideOpenModalBind);

  $(window).on("zoom:partial:fetch", hideOpenModalBind);

  $(window).on("zoom:page:setup", removeModalBackdropBind);

  $(window).on("zoom:page:done", function() {
    saveOriginalAjaxModalContentBind();
    return resetAjaxModalContentBind();
  });

  $(document).on("hide.bs.modal", "#ajax-modal", function() {
    return window.finalforms.timer(300, resetAjaxModalContentBind);
  });

}).call(this);
(function() {
  var ClipboardFactory;

  ClipboardFactory = {};

  ClipboardFactory.isSupported = ClipboardJS.isSupported;

  ClipboardFactory.build = function(options) {
    var clipboard;
    clipboard = {};
    clipboard.options = options;
    clipboard.virtualHiddenElement = function() {
      return $("<textarea>").prop("id", Toolbox.generateToken({
        prefix: "clipboard"
      })).css("display", "none");
    };
    clipboard.hub = {};
    clipboard.on = function(namespace, callback) {
      if (callback) {
        return $(clipboard.hub).on(namespace, callback);
      }
    };
    clipboard.trigger = function(namespace) {
      return $(clipboard.hub).triggerHandler(namespace);
    };
    clipboard.text = function() {
      if (clipboard.options.text != null) {
        return options.text;
      } else if (clipboard.options.target != null) {
        return $(clipboard.options.target).text();
      } else {
        return "";
      }
    };
    clipboard.copy = function() {
      var $tmp, lib, text;
      if (!ClipboardFactory.isSupported()) {
        return "";
      }
      text = clipboard.text();
      $tmp = clipboard.virtualHiddenElement().text(text);
      $("body").append($tmp);
      lib = new ClipboardJS("#" + ($tmp.prop("id")), {
        text: function() {
          return text;
        }
      });
      lib.on("success", function() {
        return clipboard.trigger("success");
      });
      lib.on("error", function() {
        return clipboard.trigger("error");
      });
      $tmp.click();
      $tmp.remove();
      return text;
    };
    return clipboard;
  };

  this.ClipboardFactory = ClipboardFactory;

}).call(this);
(function() {
  var formAffixBind;

  formAffixBind = function() {
    var $affix, $parent, options;
    $affix = $('#form-affix');
    if ($affix.length === 0) {
      return $("#content").css({
        "min-height": ''
      });
    } else {
      if ($affix.css('position') === 'fixed') {
        $parent = $affix.parent();
        $affix.width($parent.width());
        options = {};
        options.scroll = $(window).scrollTop();
        options.ceiling = $parent.offset().top;
        options.offset = 0;
        options.floor = $(document).height() - $('footer').outerHeight(true) - $affix.outerHeight();
        options.bottom = $affix.offset().top + $affix.outerHeight(true);
        window.options = options;
        $("#content").css({
          "min-height": $affix.height() + options.offset
        });
        if (options.scroll <= options.ceiling - options.offset) {
          $affix.css({
            top: options.ceiling - options.scroll
          });
        } else if (options.floor - options.scroll <= options.offset) {
          $affix.css({
            top: options.floor - options.scroll
          });
        } else {
          $affix.css({
            top: options.offset
          });
        }
      } else {
        $affix.css({
          top: '',
          width: ''
        });
      }
      return Toolbox.timer(10, formAffixBind);
    }
  };

  $(window).on('zoom:page:done', formAffixBind);

}).call(this);
(function() {
  var GoogleAddressAutocomplete;

  GoogleAddressAutocomplete = {};

  GoogleAddressAutocomplete.noop = function() {
    return true;
  };

  GoogleAddressAutocomplete.addressParts = {
    street: {
      matcher: /_(street_address|street)$/
    },
    city: {
      matcher: /_city$/
    },
    state: {
      matcher: /_state$/
    },
    zip: {
      matcher: /_zip$/
    }
  };

  GoogleAddressAutocomplete.autocompleteAddress = function(address) {
    var addressWas, city, components, place, ref, ref1, ref2, ref3, ref4, state, street, zip;
    place = address.googleAutocomplete.getPlace();
    components = {};
    $.each(place.address_components, function(i, component) {
      return $.each(component.types, function(n, type) {
        return components[type] = component;
      });
    });
    if (components.route) {
      addressWas = {};
      $.each(GoogleAddressAutocomplete.addressParts, function(partName, part) {
        addressWas[partName] = address[partName].$field.val();
        return address[partName].$field.val("");
      });
      street = $.trim((((ref = components.street_number) != null ? ref.long_name : void 0) || "") + " " + (((ref1 = components.route) != null ? ref1.long_name : void 0) || ""));
      city = ((ref2 = components.locality) != null ? ref2.long_name : void 0) || "";
      state = ((ref3 = components.administrative_area_level_1) != null ? ref3.short_name : void 0) || "";
      zip = ((ref4 = components.postal_code) != null ? ref4.long_name : void 0) || "";
      if (Toolbox.getSubdomain() === "westbranch-oh") {
        if (street.match(/Township Line Road/)) {
          street = street.replace(/Township Line Road/, "Mountz Road");
        }
      }
      address.street.$field.val(street).change();
      address.city.$field.val(city).change();
      address.state.$field.val(state).change();
      if (zip && addressWas.zip.startsWith(zip + "-")) {
        zip = addressWas.zip;
      }
      return address.zip.$field.val(zip).change();
    }
  };

  GoogleAddressAutocomplete.geolocateAddress = function(address) {
    var circle, geolocation, ref, ref1;
    geolocation = (ref = window.finalforms.database) != null ? (ref1 = ref.address) != null ? ref1.geolocation : void 0 : void 0;
    if ((geolocation != null ? geolocation.latitude : void 0) && (geolocation != null ? geolocation.longitude : void 0)) {
      circle = new google.maps.Circle({
        center: {
          lat: parseFloat(geolocation.latitude),
          lng: parseFloat(geolocation.longitude)
        },
        radius: 25000
      });
      return address.googleAutocomplete.setBounds(circle.getBounds());
    }
  };

  GoogleAddressAutocomplete.buildAddressPart = function(field) {
    var $field, config, name;
    $field = $(field);
    config = $field.data("addressautocomplete");
    if (!$.isPlainObject(config)) {
      config = {};
    }
    config.$field = $field;
    name = Toolbox.slugify($field.prop("name"));
    $.each(GoogleAddressAutocomplete.addressParts, function(partName, part) {
      if (name.match(part.matcher)) {
        config.part || (config.part = partName);
        return config.group || (config.group = name.replace(part.matcher, ""));
      }
    });
    return config;
  };

  GoogleAddressAutocomplete.bindAddressGeolocate = function(address) {
    return address.street.$field.on("focus", function() {
      return GoogleAddressAutocomplete.geolocateAddress(address);
    });
  };

  GoogleAddressAutocomplete.bindAddressAutocomplete = function(address) {
    address.googleAutocomplete = new google.maps.places.Autocomplete(address.street.$field[0], {
      types: ["address"]
    });

    /*
    disable_unit_number_autocomplete.coffee we set inputs with autocomplete="off" to autocomplete="disabled" on Chrome
    however, a callback triggered by the line above re-overrides this back to autocomplete="off"
    the two lines below trigger an event that re-runs disableAutocompleteBind to correctly set autocomplete back to "disabled" on Chrome
    the 10 second timer is just a fallback for those with very slow connections
     */
    Toolbox.timer(2000, function() {
      return $(window).trigger("google:address_autocomplete:setup");
    });
    Toolbox.timer(10000, function() {
      return $(window).trigger("google:address_autocomplete:setup");
    });
    address.googleAutocomplete.setFields(["address_components"]);
    address.street.$field.on("keydown", function(evt) {
      if (evt.keyCode === 13) {
        return Toolbox.stopEvent(evt);
      }
    });
    return address.googleAutocomplete.addListener("place_changed", function() {
      return GoogleAddressAutocomplete.autocompleteAddress(address);
    });
  };

  GoogleAddressAutocomplete.bind = function() {
    var $addressFields, addresses;
    if (!window.google) {
      return;
    }
    addresses = {};
    $addressFields = $("[data-addressautocomplete]");
    $addressFields.each(function(i, field) {
      var addressPart, name1;
      addressPart = GoogleAddressAutocomplete.buildAddressPart(field);
      if (addressPart.group) {
        addresses[name1 = addressPart.group] || (addresses[name1] = {});
        return addresses[addressPart.group][addressPart.part] = addressPart;
      } else {
        return window.logger.error({
          subject: "GoogleAddressAutocomplete: Unable to parse address part from field: " + (addressPart.$field.prop("name"))
        });
      }
    });
    return $.each(addresses, function(group, address) {
      var missingParts;
      missingParts = [];
      $.each(GoogleAddressAutocomplete.addressParts, function(partName, part) {
        if (!address[partName]) {
          return missingParts.push(partName);
        }
      });
      if (missingParts.length !== 0) {
        window.logger.error({
          subject: "GoogleAddressAutocomplete [" + group + "] Missing Parts: " + (missingParts.join(", ")),
          body: "You can manually assign the part/group in the data attribute:\naddressautocomplete: { group: \"properties_<prefix>\", part: \"street\" }\nFor \"student_<city/state/zip/street_address>\" properties the prefix would be \"student\" so group would be \"properties_student\""
        });
        return;
      }
      GoogleAddressAutocomplete.bindAddressGeolocate(address);
      return GoogleAddressAutocomplete.bindAddressAutocomplete(address);
    });
  };

  this.GoogleAddressAutocomplete = GoogleAddressAutocomplete;

  $(window).on("zoom:page:done", GoogleAddressAutocomplete.bind);

}).call(this);
(function() {
  var Analytics, base, config, configSetup, gtag, initialize, name, sendWebVitals, trackError, trackEvent, trackPage, trackPageDeferred, trackUserProperties;

  window.finalforms || (window.finalforms = {});

  (base = window.finalforms).ga4 || (base.ga4 = {});

  config = window.finalforms.ga4;

  config.dataStreamId = "G-YHR3YXDXTH";

  config.dataLayerKey || (config.dataLayerKey = "ga4DataLayer");

  window[name = config.dataLayerKey] || (window[name] = []);

  gtag = function() {
    return window[config.dataLayerKey].push(arguments);
  };

  gtag("js", new Date);

  sendWebVitals = function() {
    var sendToGoogleAnalytics;
    if (window.webVitals) {
      sendToGoogleAnalytics = function(metric) {
        return gtag("event", metric.name, {
          value: metric.delta,
          metric_id: metric.id,
          metric_value: metric.value,
          metric_delta: metric.delta
        });
      };
      window.webVitals.onCLS(sendToGoogleAnalytics);
      window.webVitals.onFID(sendToGoogleAnalytics);
      return window.webVitals.onLCP(sendToGoogleAnalytics);
    }
  };

  initialize = function() {
    if (!config.isInitialized) {
      config.isInitialized = true;
      Toolbox.loadJavascriptPromise('https://www.googletagmanager.com/gtag/js?l=' + config.dataLayerKey + '&id=' + config.dataStreamId)["catch"](function(error) {
        return console.log("Failed to load Google Analytics", error);
      });
      return Toolbox.loadJavascriptPromise('https://unpkg.com/web-vitals@3/dist/web-vitals.iife.js').then(sendWebVitals)["catch"](function(error) {
        return console.error("Failed to load web-vitals", error);
      });
    }
  };

  configSetup = function() {
    if (!config.isSetup) {
      config.isSetup = true;
      return gtag("config", config.dataStreamId, {
        debug_mode: config.enableDebug,
        send_page_view: false,
        linker: {
          domains: ["finalforms.com", "finalforms-amp.com"]
        }
      });
    }
  };

  trackUserProperties = function() {
    config.display_mode = "browser";
    config.lastUserProperties || (config.lastUserProperties = {});
    if (navigator.standalone) {
      config.display_mode = "standalone-ios";
    }
    if (window.matchMedia && window.matchMedia("(display-mode: standalone)").matches) {
      config.display_mode = "standalone";
    }
    if (window.finalforms.database.class_slug === "district") {
      config.currentUserProperties = {
        product: "districts",
        role: window.finalforms.identity.role,
        district: window.finalforms.database.subdomain,
        lifecycleStage: window.finalforms.database.lifecycle_stage,
        displayMode: config.display_mode
      };
    } else if (window.finalforms.database.class_slug === "athletic_association") {
      config.currentUserProperties = {
        product: "tower",
        role: window.finalforms.identity.role,
        athletic_association: window.finalforms.database.subdomain,
        displayMode: config.display_mode
      };
    }
    if (JSON.stringify(config.lastUserProperties) !== JSON.stringify(config.currentUserProperties)) {
      gtag("set", "user_properties", config.currentUserProperties);
      return config.lastUserProperties = config.currentUserProperties;
    }
  };

  trackError = function(description, fatal) {
    return trackEvent("exception", {
      description: description,
      fatal: fatal || false
    });
  };

  trackEvent = function(action, extra) {
    extra = extra || {};
    return gtag("event", action, extra);
  };

  trackPage = function(event) {
    var pagePath, pagePathParts, payload, results;
    config.lastLoggedUrl || (config.lastLoggedUrl = null);
    config.currentUrl || (config.currentUrl = null);
    config.currentUrl = (event != null ? event.to : void 0) || window.location.href.replace(/#.*/g, "");
    if (config.lastLoggedUrl !== config.currentUrl) {
      config.lastLoggedUrl = config.currentUrl;
      pagePathParts = config.currentUrl.split(window.location.hostname);
      pagePathParts.shift();
      pagePath = pagePathParts.join(window.location.hostname);
      gtag("config", config.dataStreamId, {
        page_location: config.currentUrl,
        page_path: pagePath
      });
      results = [];
      while (config.events.length) {
        payload = config.events.pop();
        results.push(trackEvent(payload.action, payload.extra));
      }
      return results;
    }
  };

  trackPageDeferred = function(event) {
    return Toolbox.requestIdleCallback(function() {
      if (config.enableTracking) {
        initialize();
        configSetup();
        trackUserProperties();
        return trackPage(event);
      }
    });
  };

  Analytics = {
    gtag: gtag,
    initialize: initialize,
    configSetup: configSetup,
    trackUserProperties: trackUserProperties,
    trackEvent: trackEvent,
    trackError: trackError,
    trackPage: trackPage,
    trackPageDeferred: trackPageDeferred
  };

  this.Analytics = Analytics;

  $(window).on("zoom:page:done", trackPageDeferred);

  $(window).on("zoom:partial:done", trackPageDeferred);

}).call(this);
(function() {
  var GoogleMaps;

  GoogleMaps = {};

  GoogleMaps.dataIds = {
    mapDataId: "googleMap",
    markersDataId: "googleMapMarkers",
    boundsDataId: "googleMapBounds",
    focusedMarkerDataId: "googleMapFocusedMarker",
    infoWindowDataId: "googleMapInfoWindow"
  };

  GoogleMaps.markerIcons = {
    marker_red_dot: "/assets/google_maps/marker_red_dot-266e823fa0ee653b63b7fad2bbf4d23f5761b759975acfaad1fe86401f5672cf.png",
    marker_blue_dot: "/assets/google_maps/marker_blue_dot-b8a53c22da20c0ba4d768a5a2633b608a604a233e79f766aaf1f7e90dd93a7c7.png",
    marker_green_dot: "/assets/google_maps/marker_green_dot-51d3e9217f0f108b3fc8935a69bbd19b40d424d1b5fadce59041c33f37090516.png",
    marker_home_blue: "/assets/google_maps/marker_home_blue-f47a6c035550eeea2bb10c2bde520400a907a311beac28a21b13025591415416.png",
    marker_school_red: "/assets/google_maps/marker_school_red-ef3644ef4610949a9a37196a75f6e5c75c0cee633428c1583387d8c250af1205.png",
    marker_school_yellow: "/assets/google_maps/marker_school_yellow-df757e17415d7537d8717009d087a7b974629e912b5f32fad207c891b4eb8e30.png",
    marker_school_green: "/assets/google_maps/marker_school_green-22940df5c85dbfdd310ffd3078e61e27be6b34d0cd87dd2fdeaac74f888663f1.png",
    marker_school_grey: "/assets/google_maps/marker_school_grey-9be601350a222c5143c262cd2ae848a25085690531ab67c732fbd71f440704b9.png"
  };

  GoogleMaps.zoomLevels = {
    world: 1,
    continent: 5,
    city: 10,
    street: 16,
    buildings: 20,
    max: 21
  };

  GoogleMaps.initMap = function(mapElement, mapOptions) {
    var $mapElement, defaults, map;
    if (mapOptions == null) {
      mapOptions = {};
    }
    defaults = {
      center: {
        lat: 37.0902,
        lng: -95.7129
      },
      zoom: GoogleMaps.zoomLevels.continent,
      maxZoom: 16,
      disableDefaultUI: false
    };
    mapOptions = Toolbox.mergeObjects(mapOptions, defaults);
    $mapElement = $(mapElement);
    if ($mapElement.length > 0) {
      if (!$mapElement.data(GoogleMaps.dataIds.mapDataId)) {
        map = new google.maps.Map($mapElement[0], mapOptions);
        GoogleMaps.setMap($mapElement, map);
        return map;
      } else {
        return $mapElement.data(GoogleMaps.dataIds.mapDataId);
      }
    }
  };

  GoogleMaps.focusMap = function(mapElement) {
    var $mapElement, bounds, map;
    $mapElement = $(mapElement);
    map = GoogleMaps.getMap($mapElement);
    bounds = GoogleMaps.getBounds($mapElement);
    map.fitBounds(bounds);
    map.panToBounds(bounds);
    return GoogleMaps.setFocusedMarker($mapElement, null);
  };

  GoogleMaps.getMap = function(mapElement) {
    var $mapElement;
    $mapElement = $(mapElement);
    return GoogleMaps.initMap($mapElement);
  };

  GoogleMaps.setMap = function(mapElement, map) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.mapDataId, map);
  };

  GoogleMaps.initMarker = function(mapElement, markerParams, markerOnClick) {
    var $mapElement, coordinate, googleCoordinate, map, marker, markers;
    if (markerOnClick == null) {
      markerOnClick = null;
    }
    $mapElement = $(mapElement);
    map = GoogleMaps.getMap($mapElement);
    markers = GoogleMaps.getMarkers($mapElement);
    coordinate = markerParams.coordinate;
    if (!coordinate.latitude || !coordinate.longitude) {
      return null;
    }
    googleCoordinate = new google.maps.LatLng(coordinate.latitude, coordinate.longitude);
    marker = new google.maps.Marker({
      position: googleCoordinate,
      map: map,
      icon: GoogleMaps.markerIcons[markerParams.icon] || GoogleMaps.markerIcons.marker_red_dot
    });
    if (markerParams.infoWindowContent) {
      google.maps.event.addListener(marker, "click", function() {
        GoogleMaps.closeInfoWindow($mapElement);
        GoogleMaps.setInfoWindowContent($mapElement, markerParams.infoWindowContent);
        return GoogleMaps.openInfoWindow($mapElement, marker);
      });
    }
    $.each(markerParams.data, function(dataKey, dataValue) {
      return $(marker).data(dataKey, dataValue);
    });
    if (markerOnClick) {
      google.maps.event.addListener(marker, "click", markerOnClick);
    }
    markers[markerParams.markerId] = marker;
    GoogleMaps.setMarkers($mapElement, markers);
    return marker;
  };

  GoogleMaps.addMarker = function(mapElement, markerParams, markerOnClick) {
    var $mapElement, marker;
    if (markerOnClick == null) {
      markerOnClick = null;
    }
    if (!markerParams.coordinate || !markerParams.markerId) {
      return;
    }
    $mapElement = $(mapElement);
    marker = GoogleMaps.initMarker($mapElement, markerParams, markerOnClick);
    if (marker) {
      return GoogleMaps.extendBounds($mapElement, marker.getPosition());
    }
  };

  GoogleMaps.focusMarker = function(mapElement, markerId) {
    var $mapElement, map, marker, markers;
    $mapElement = $(mapElement);
    map = GoogleMaps.getMap($mapElement);
    markers = GoogleMaps.getMarkers($mapElement);
    marker = markers[markerId];
    if (marker) {
      GoogleMaps.animateZoomIn($mapElement, {
        startZoom: map.getZoom(),
        endZoom: GoogleMaps.zoomLevels.street,
        googleCoordinate: marker.getPosition()
      });
      return GoogleMaps.setFocusedMarker($mapElement, marker);
    }
  };

  GoogleMaps.getMarkers = function(mapElement) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.markersDataId) || {};
  };

  GoogleMaps.setMarkers = function(mapElement, markers) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.markersDataId, markers);
  };

  GoogleMaps.getFocusedMarker = function(mapElement) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.focusedMarkerDataId);
  };

  GoogleMaps.setFocusedMarker = function(mapElement, focusedMarker) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.focusedMarkerDataId, focusedMarker);
  };

  GoogleMaps.setInfoWindow = function(mapElement, infoWindow) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.infoWindowDataId, infoWindow);
  };

  GoogleMaps.getInfoWindow = function(mapElement) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.infoWindowDataId);
  };

  GoogleMaps.setInfoWindowContent = function(mapElement, content) {
    var $mapElement, infoWindow;
    $mapElement = $(mapElement);
    infoWindow = GoogleMaps.getInfoWindow($mapElement);
    if (!infoWindow) {
      infoWindow = new google.maps.InfoWindow;
    }
    infoWindow.setContent(content);
    return GoogleMaps.setInfoWindow($mapElement, infoWindow);
  };

  GoogleMaps.openInfoWindow = function(mapElement, marker) {
    var $mapElement, infoWindow, map;
    $mapElement = $(mapElement);
    map = GoogleMaps.getMap($mapElement);
    infoWindow = GoogleMaps.getInfoWindow($mapElement);
    if (infoWindow) {
      return infoWindow.open({
        anchor: marker,
        map: map
      });
    }
  };

  GoogleMaps.closeInfoWindow = function(mapElement) {
    var $mapElement, infoWindow;
    $mapElement = $(mapElement);
    infoWindow = GoogleMaps.getInfoWindow($mapElement);
    if (infoWindow) {
      return infoWindow.close();
    }
  };

  GoogleMaps.extendBounds = function(mapElement, googleCoordinate) {
    var $mapElement, bounds;
    $mapElement = $(mapElement);
    bounds = GoogleMaps.getBounds($mapElement);
    if (!bounds.contains(googleCoordinate)) {
      bounds.extend(googleCoordinate);
    }
    return GoogleMaps.setBounds($mapElement, bounds);
  };

  GoogleMaps.getBounds = function(mapElement) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.boundsDataId) || new google.maps.LatLngBounds();
  };

  GoogleMaps.setBounds = function(mapElement, bounds) {
    var $mapElement;
    $mapElement = $(mapElement);
    return $mapElement.data(GoogleMaps.dataIds.boundsDataId, bounds);
  };

  GoogleMaps.zoomTo = function(mapElement, markerId) {
    var $mapElement;
    $mapElement = $(mapElement);
    GoogleMaps.focusMap($mapElement);
    return GoogleMaps.focusMarker($mapElement, markerId);
  };

  GoogleMaps.animateZoomIn = function(mapElement, zoomParams) {
    var $mapElement, endZoom, map, startZoom;
    $mapElement = $(mapElement);
    map = GoogleMaps.getMap($mapElement);
    startZoom = zoomParams.startZoom;
    endZoom = zoomParams.endZoom;
    if (startZoom < endZoom) {
      Toolbox.timer(300, function() {
        return GoogleMaps.animateZoomIn($mapElement, {
          startZoom: startZoom + 1,
          endZoom: endZoom,
          googleCoordinate: zoomParams.googleCoordinate
        });
      });
      return Toolbox.timer(300, function() {
        map.setZoom(zoomParams.startZoom);
        return map.panTo(zoomParams.googleCoordinate);
      });
    } else {

    }
  };

  GoogleMaps.bounceMarker = function(mapElement, markerId) {
    var $mapElement, marker, markers;
    $mapElement = $(mapElement);
    markers = GoogleMaps.getMarkers($mapElement);
    marker = markers[markerId];
    marker.setAnimation(google.maps.Animation.BOUNCE);
    return Toolbox.timer(750, function() {
      return marker.setAnimation(null);
    });
  };

  GoogleMaps.noop = function() {
    return true;
  };

  this.GoogleMaps = GoogleMaps;

}).call(this);
(function() {
  var GoogleRecaptcha;

  GoogleRecaptcha = {};

  GoogleRecaptcha.bind = function() {
    return $(".google-recaptcha").each(function(i, element) {
      if ((typeof grecaptcha !== "undefined" && grecaptcha !== null ? grecaptcha.render : void 0) != null) {
        return grecaptcha.render(element, {
          sitekey: "6LczoAoaAAAAANYt4AeenHcVXfBLo1QCbpAxJ8pc"
        });
      }
    });
  };

  window.googleRecaptchaBind = function() {
    return GoogleRecaptcha.bind();
  };

  $(window).on("zoom:page:done", GoogleRecaptcha.bind);

}).call(this);
(function() {
  var HighchartApi;

  $(window).on('zoom:page:done', function() {
    var setSubtitle;
    $(".widget-highchart").each(function(index, highchartItem) {
      return new HighchartApi(highchartItem);
    });
    if ($("#dashboard-filter-form").length !== 0) {
      setSubtitle = function() {
        var $form, queryParams;
        $form = $("#dashboard-filter-form");
        queryParams = $form.serializeArray().reduce((function(formData, input) {
          formData[input.name] = input.value;
          return formData;
        }), {});
        $.get("/highcharts/dashboard", queryParams).then(function(data) {
          if (data.subtitle) {
            return $(".main-subtitle").html(data.subtitle);
          }
        });
        $.get("/highcharts/dashboard", queryParams).then(function(data) {
          if (data.student_count) {
            return $(".student-count").html(data.student_count);
          }
        });
        $.get("/highcharts/dashboard", queryParams).then(function(data) {
          if (data.staff_count) {
            return $(".staff-count").html(data.staff_count);
          }
        });
        $.get("/highcharts/dashboard", queryParams).then(function(data) {
          if (data.coach_count) {
            return $(".coach-count").html(data.coach_count);
          }
        });
        $.get("/highcharts/dashboard", queryParams).then(function(data) {
          if (data.athlete_count) {
            return $(".athlete-count").html(data.athlete_count);
          }
        });
        $.get("/highcharts/dashboard", queryParams).then(function(data) {
          if (data.team_count) {
            return $(".team-count").html(data.team_count);
          }
        });
        $.get("/highcharts/dashboard", queryParams).then(function(data) {
          if (data.sport_count) {
            return $(".sport-count").html(data.sport_count);
          }
        });
        return false;
      };
      $("#dashboard-filter-form").submit(setSubtitle);
      return setSubtitle();
    }
  });

  Highcharts.Tooltip.prototype.remove = Highcharts.Tooltip.prototype.hide;

  Highcharts.Tooltip.prototype.hide = (function(_this) {
    return function() {
      return {};
    };
  })(this);

  HighchartApi = (function() {
    HighchartApi.allCharts = [];

    HighchartApi.closeAllTooltips = function() {
      return this.allCharts.forEach(function(highchart) {
        return highchart.closeTooltip();
      });
    };

    function HighchartApi(widgetWrapper) {
      this.constructor.allCharts.push(this);
      this.wrapper = $(widgetWrapper);
      this.chartId = this.wrapper.find(".widget-container").attr("id");
      this.form = $("#dashboard-filter-form");
      this.render().then(this.addEventListeners.bind(this));
    }

    HighchartApi.prototype.addEventListeners = function() {
      this.form.submit((function(_this) {
        return function(event) {
          _this.render();
          return false;
        };
      })(this));
      return $('body').click((function(_this) {
        return function() {
          return _this.closeTooltip();
        };
      })(this));
    };

    HighchartApi.prototype.queryParams = function() {
      return this.form.serializeArray().reduce((function(formData, input) {
        formData[input.name] = input.value;
        return formData;
      }), {});
    };

    HighchartApi.prototype.fetchChartData = function() {
      var endpoint;
      endpoint = this.wrapper.data("endpoint");
      return $.get(endpoint, this.queryParams()).then((function(_this) {
        return function(data) {
          return $.extend(true, {}, data, _this.chartExtension());
        };
      })(this));
    };

    HighchartApi.prototype.closeTooltip = function() {
      var ref, ref1;
      if ((ref = this.chart) != null ? (ref1 = ref.tooltip) != null ? ref1.remove : void 0 : void 0) {
        return this.chart.tooltip.remove();
      }
    };

    HighchartApi.prototype.showTooltip = function(point) {
      this.constructor.closeAllTooltips();
      if (this.chart.options.disable_tooltip) {
        return;
      }
      this.chart.tooltip.options.enabled = true;
      this.chart.tooltip.refresh(point);
      return this.chart.tooltip.options.enabled = false;
    };

    HighchartApi.prototype.render = function() {
      return this.fetchChartData().then((function(_this) {
        return function(data) {
          if ($("#" + _this.chartId).length === 0) {
            return;
          }
          if (!_this.chart) {
            return _this.chart = Highcharts.chart(_this.chartId, data);
          } else {
            _this.chart.series[0].setData(data.series[0].data);
            if (_this.chart.subtitle) {
              return _this.chart.subtitle.update(data.subtitle);
            }
          }
        };
      })(this));
    };

    HighchartApi.prototype.chartExtension = function() {
      return {
        plotOptions: {
          series: {
            point: {
              events: {
                click: (function(_this) {
                  return function(event) {
                    event.stopPropagation();
                    return _this.showTooltip(event.point);
                  };
                })(this),
                legendItemClick: (function(_this) {
                  return function(event) {
                    var point, pointName;
                    event.preventDefault();
                    event.browserEvent.stopPropagation();
                    pointName = event.target.name;
                    point = _this.chart.series[0].points.find(function(point) {
                      return point.name === pointName;
                    });
                    return _this.showTooltip(point);
                  };
                })(this)
              }
            }
          }
        }
      };
    };

    return HighchartApi;

  })();

  HighchartApi.allCharts = [];

}).call(this);
(function() {
  var importBind;

  importBind = function() {
    var $failed, $failed_csv, $failed_rows, $forms, $forms_container, $progress_bar, $progress_count, $success, $success_rows, current, total;
    if ($('#body-wrapper').hasClass('import')) {
      $forms_container = $('#import_forms_container');
      $forms = $forms_container.find('form');
      $success = $('#successful_imports');
      $success_rows = $success.find('tbody.rows');
      $failed = $('#failed_imports');
      $failed_csv = $('#failed_imports_csv');
      $failed_rows = $failed.find('tbody.rows');
      $progress_bar = $('#import_progress_bar');
      $progress_count = $('#import_progress_count');
      total = $forms_container.data('total');
      current = 0;
      $forms.each(function(i, form) {
        var $form;
        $form = $(form);
        return form["import"] = function() {
          var ajax;
          ajax = $.ajax({
            type: 'POST',
            url: form.action,
            data: $form.serialize()
          });
          ajax.fail(function() {
            var $tr, csv, raw_csv;
            window.flash.alert.support();
            csv = $form.find('[name=csv]').val();
            $failed.removeClass('hidden');
            $tr = $('<tr class="danger"><td>One of these lines caused an error.<br />Please contact support with this information.</td><td><pre></pre></td></tr>');
            $tr.find('pre').text(csv);
            $failed_rows.prepend($tr);
            raw_csv = csv.split(/\r?\n/);
            raw_csv.shift();
            raw_csv = raw_csv.join("\n");
            return $failed_csv.append(raw_csv);
          });
          ajax.done(function(result, xhr, status) {
            var $result;
            $result = $(result).filter('*');
            return $result.filter('tr').each(function(i, row) {
              var $row, failed_csv_text, failed_csv_with_errors, failed_error_text;
              $row = $(row);
              if ($row.hasClass('success')) {
                $success.removeClass('hidden');
                if ($row.attr('id') && $success_rows.find("#" + ($row.attr('id'))).length > 0) {
                  return $row.replaceCurrentHTML();
                } else {
                  return $success_rows.prepend($row);
                }
              } else {
                $failed.removeClass('hidden');
                $failed_rows.prepend($row);
                failed_csv_text = $row.find('.csv').text().trim();
                failed_error_text = $row.find('.errors').text().replace(/\r?\n/, ". ").replace(/"/g, "'").trim();
                failed_csv_with_errors = failed_csv_text + ',"' + failed_error_text + "\"\r\n";
                return $failed_csv.append(failed_csv_with_errors);
              }
            });
          });
          return ajax.always(function() {
            var percent;
            current += window.parseInt($form.find('[name=rows]').val());
            percent = (window.parseInt(current / total * 100)) + "%";
            $progress_count.text(current);
            $progress_bar.css({
              width: percent
            }).text(percent);
            if ($forms[i + 1]) {
              $forms[i + 1]["import"]();
            } else {
              $("[data-import-done]").each(function(i, element) {
                var $element;
                $element = $(element);
                return eval($element.data('import-done'));
              });
            }
            if (current === total) {
              if ($failed_rows.find("td").length === 0) {
                return $("[data-import-all-success]").each(function(i, element) {
                  var $element;
                  $element = $(element);
                  return eval($element.data("import-all-success"));
                });
              } else {
                return $("[data-import-any-failure]").each(function(i, element) {
                  var $element;
                  $element = $(element);
                  return eval($element.data("import-any-failure"));
                });
              }
            }
          });
        };
      });
      if ($forms[0]) {
        return $forms[0]["import"]();
      } else {
        return $progress_bar.css({
          width: '100%'
        }).text('100%');
      }
    }
  };

  $(window).on('zoom:page:done', importBind);

}).call(this);
(function() {
  var bindModalMiddleClickBlocker;

  bindModalMiddleClickBlocker = function() {
    return $("[data-toggle=modal]").mousedown(function(event) {
      if (event.button === 1) {
        event.preventDefault();
        return event.target.click();
      }
    });
  };

  $(window).on("zoom:page:done", bindModalMiddleClickBlocker);

}).call(this);
(function() {
  var searchableTableBind;

  searchableTableBind = function() {
    var $blankify, $checkboxes, $form, $inputs, $page, $radios, $resets, $selects, $submits, $whenSearchingHide, $whenSearchingShow, newSearchBind, setSearchingStatus;
    $form = $("form.searchable");
    $inputs = $form.find(".filters input, input.filter").not("[type=checkbox],[type=radio]").not(".filter-ignore");
    $selects = $form.find("select, select.filter").not(".filter-ignore");
    $checkboxes = $form.find(".filters input[type=checkbox], input[type=checkbox].filter").not(".filter-ignore");
    $radios = $form.find(".filters input[type=radio], input[type=radio].filter").not(".filter-ignore");
    $blankify = $form.find(".filter-blankify");
    $resets = $form.find(".search-reset");
    $submits = $form.find(".search-submit");
    $page = $inputs.filter("[name=page]");
    $whenSearchingHide = $form.find(".search-hide");
    $whenSearchingShow = $form.find(".search-show, .search-reset");
    $blankify.add($inputs).add($selects).add($checkboxes).add($radios).each(function(i, filter) {
      return $(filter).data("search", {});
    });
    $inputs.add($selects).each(function(i, filter) {
      return $(filter).data("search")["default"] = "" + ($(filter).data("search-default") != null ? $(filter).data("search-default") : "");
    });
    $checkboxes.each(function(i, checkbox) {
      return $(checkbox).data("search")["default"] = ("" + ($(checkbox).data("search-default"))) === "true";
    });
    $radios.each(function(i, radio) {
      return $(radio).data("search")["default"] = "" + ($(radio).data("search-default") != null ? $(radio).data("search-default") : $(radio).val());
    });
    newSearchBind = function(evt) {
      if ($page.length === 1) {
        $page.val($page.data("search")["default"]);
      }
      $blankify.add($inputs).add($selects).each(function(i, filter) {
        var $filter;
        $filter = $(filter);
        if ($filter.val() === "" && ($filter.data("search")["default"] === "" || $filter.hasClass("filter-blankify"))) {
          $filter.data("search").name = $filter.prop("name");
          return $filter.prop("name", "");
        }
      });
      $submits.html("Submitting Search...").addClass("disabled");
      $form.submit();
      return $blankify.add($inputs).add($selects).each(function(i, filter) {
        var $filter;
        $filter = $(filter);
        if ($filter.data("search").name) {
          $filter.prop("name", $filter.data("search").name);
          return delete ($filter.data("search").name);
        }
      });
    };
    $form.find(".dropdown-menu").click(function(evt) {
      if ($(evt.target).closest("a").length === 0) {
        return Toolbox.isolateEvent(evt);
      }
    });
    $submits.click(newSearchBind);
    $inputs.add($selects).add($checkboxes).add($radios).not(".status-filter").change(newSearchBind);
    $inputs.keydown(function(evt) {
      if (evt.keyCode === 13) {
        Toolbox.stopEvent(evt);
        $(this).trigger("onchange");
        return newSearchBind();
      }
    });
    $resets.click(function(evt) {
      $inputs.add($selects).not(".filter-reset-ignore").each(function(i, filter) {
        return $(filter).val($(filter).data("search")["default"]);
      });
      $checkboxes.not(".filter-reset-ignore").each(function(i, checkbox) {
        return $(checkbox).prop("checked", $(checkbox).data("search")["default"]);
      });
      $radios.not(".filter-reset-ignore").each(function(i, radio) {
        return $(radio).prop("checked", false);
      });
      return newSearchBind();
    });
    setSearchingStatus = function(value) {
      if (value) {
        $whenSearchingHide.hide();
        return $whenSearchingShow.show();
      } else {
        $whenSearchingHide.show();
        return $whenSearchingShow.hide();
      }
    };
    setSearchingStatus(false);
    $inputs.add($selects).not(".filter-reset-ignore").each(function(i, filter) {
      if ($(filter).val() !== $(filter).data("search")["default"]) {
        return setSearchingStatus(true);
      }
    });
    $checkboxes.not(".filter-reset-ignore").each(function(i, checkbox) {
      var $checkbox;
      $checkbox = $(checkbox);
      if ($checkbox.prop("checked")) {
        if ($checkbox.val() !== $checkbox.data("search")["default"]) {
          return setSearchingStatus(true);
        }
      } else {
        if ($checkbox.val() === $checkbox.data("search")["default"]) {
          return setSearchingStatus(true);
        }
      }
    });
    $radios.not(".filter-reset-ignore").each(function(i, radio) {
      if ($(radio).prop("checked")) {
        return setSearchingStatus(true);
      }
    });
    if (window.location.search === "") {
      $inputs.tooltip({
        placement: "top",
        title: "Press enter to apply",
        trigger: "focus"
      });
      return $inputs.blur(function() {
        return $inputs.tooltip("destroy");
      });
    }
  };

  $(window).on("zoom:page:done", searchableTableBind);

}).call(this);
(function() {
  var select2Bind;

  $.fn.finalformsSelect2 = function() {
    return $.each(this, function(i, select2) {
      var $select2, ajaxDefaults, escapeHTML, eventJs, options, select2_menu, url;
      $select2 = $(select2);
      if (!$select2.data("select2")) {
        options = $select2.data("select2-options") || {};
        escapeHTML = function(value) {
          return $("<div>").text(value).html();
        };
        $.each(["validation-error", "state-info"], function(i, cssClass) {
          if ($select2.hasClass(cssClass)) {
            options.containerCssClass = "'" + (options.containerCssClass || "") + " " + cssClass + "'";
            return options.dropdownCssClass = "'" + (options.dropdownCssClass || "") + " " + cssClass + "'";
          }
        });
        if ($.type(options.ajax) === "string") {
          url = options.ajax;
          delete options.ajax;
          ajaxDefaults = {
            ajax: {
              url: url,
              dataType: "json",
              type: "GET",
              quietMillis: 200,
              data: function(search, page) {
                var ajaxParams, select2Options;
                select2Options = $select2.data("select2-options") || {};
                ajaxParams = select2Options.ajaxParams || {};
                return $.extend({}, {
                  search: search,
                  page: page,
                  selected: $select2.val()
                }, ajaxParams);
              },
              results: function(data, page) {
                return {
                  results: data.results,
                  more: page < window.parseInt(data.pages)
                };
              }
            },
            formatResult: function(result) {
              if (result.label_html != null) {
                return result.label_html;
              } else {
                return escapeHTML(result.label);
              }
            },
            formatSelection: function(result) {
              return escapeHTML(result.label);
            },
            initSelection: function(element, callback) {
              var ajax, error_message, handleResult;
              error_message = "finalformsSelect2 bad " + ($(element).prop("id")) + " initial result";
              handleResult = function(result) {
                var body;
                if ($.type(result) === "array") {
                  if (options.multiple) {
                    return callback(result);
                  } else {
                    if (result.length > 1) {
                      window.logger.error({
                        subject: error_message + ": too many",
                        body: "results: " + (JSON.stringify(result))
                      });
                    }
                    return callback(result[0]);
                  }
                } else {
                  body = JSON.stringify(result);
                  if (!body.match("You must login before visiting that page")) {
                    window.logger.error({
                      subject: error_message + ": malformed",
                      body: "result: " + body
                    });
                  }
                  return callback([]);
                }
              };
              if (options.preload) {
                return handleResult(options.preload);
              } else {
                ajax = $.ajax({
                  url: url,
                  type: "GET",
                  data: {
                    initial: $(element).val()
                  }
                });
                ajax.done(function(result, xhr, status) {
                  return handleResult(result);
                });
                return ajax.fail(function(evt, status, error) {
                  return window.error.log(error, {
                    details: error_message + ": status=" + status + " error=" + error + " evt: " + evt.responseText + " " + evt.status
                  });
                });
              }
            }
          };
          options = $.extend(ajaxDefaults, options);
        }
        eventJs = "";
        if ($.type(options.eventJs) === "string") {
          eventJs = options.eventJs;
          delete options.eventJs;
        }
        options.formatResultCssClass = function(select2Option) {
          var addClasses;
          addClasses = [];
          $.each(select2Option.element, function(i, selectOption) {
            if ($(selectOption).hasClass("hidden")) {
              return addClasses.push("hidden");
            }
          });
          return addClasses.join(" ");
        };
        select2_menu = $select2.select2(options);
        if (eventJs !== "") {
          return eval(eventJs);
        }
      }
    });
  };

  select2Bind = function() {
    return $("select.select2,input.select2").finalformsSelect2();
  };

  $(window).on("zoom:page:done", select2Bind);

  $(window).on("zoom:partial:done", select2Bind);

  $(document).on("loaded.bs.modal", ".ajax-modal", select2Bind);

}).call(this);
(function() {
  var Zoom;

  Zoom = {};

  Zoom.zoomVersion = "2.1.0";

  Zoom.selectors = {
    ignore: ".zoom-ignore",
    ignoreContainer: ".zoom-ignore-container",
    disabled: ".disabled",
    update: ".zoom-update",
    javascript: "script.zoom-eval",
    loader: ".zooming",
    partial: ".zoom-partial"
  };

  Zoom.events = {
    start: "start",
    history: {
      push: "history:pushed",
      pop: "history:poped"
    },
    partial: {
      fetch: "partial:fetch",
      fail: "partial:fail",
      setup: "partial:setup",
      done: "partial:done",
      always: "partial:always"
    },
    page: {
      fetch: "page:fetch",
      fail: "page:fail",
      setup: "page:setup",
      done: "page:done",
      cancel: "page:cancel",
      always: "page:always"
    }
  };

  Zoom.logger = {
    level: "info",
    info: function(namespace, details) {
      if (Zoom.logger.level === "info") {
        return typeof console !== "undefined" && console !== null ? typeof console.info === "function" ? console.info(namespace, details) : void 0 : void 0;
      }
    },
    debug: function(namespace, details) {
      if (Zoom.logger.level === "debug") {
        return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(namespace, details) : void 0 : void 0;
      }
    },
    error: function(namespace, details) {
      return typeof console !== "undefined" && console !== null ? typeof console.error === "function" ? console.error(namespace, details) : void 0 : void 0;
    }
  };

  Zoom.toolbox = {
    evalInContext: function(js) {
      return (function() {
        return eval(js);
      }).call(window);
    },
    getVersion: function($doc) {
      if ($doc == null) {
        $doc = $(document);
      }
      return $doc.find("meta[name=version]").attr("content");
    },
    stopEvent: function(evt) {
      var error;
      try {
        return evt.preventDefault();
      } catch (error1) {
        error = error1;
        return $.Event(evt).preventDefault();
      }
    },
    normalizeURL: function(url) {
      return $("<a />").attr("href", url)[0].href.replace(/#.*/g, "");
    },
    currentURL: function() {
      return window.location.href.replace(/#.*/g, "");
    },
    currentOrigin: function() {
      return window.location.origin || (window.location.protocol + "//" + window.location.host);
    },
    startsWith: function(string, value) {
      return $.type(string) === "string" && $.type(value) === "string" && string.slice(0, value.length) === value;
    },
    scrollToTop: function() {
      return $("html,body").scrollTop(0);
    },
    userAgent: navigator.userAgent || navigator.vendor || window.opera,
    createDocument: function(html) {
      return (new DOMParser).parseFromString(html, "text/html");
    },
    clickEventIsSignificant: function(event) {
      return !((event.target && event.isContentEditable) || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);
    },
    isHTMLContent: function(evt) {
      var contentType;
      return (contentType = evt.getResponseHeader("Content-Type")) && contentType.match(/^(?:text\/html|application\/xhtml\+xml|application\/xml)(?:;|$)/);
    },
    logFail: function(from, details) {
      var body, subject;
      details.zoomSupported = Zoom.zoomSupported;
      details.zoomVersion = Zoom.zoomVersion;
      subject = ("Zoom " + details.zoomVersion + " " + from + " fail: " + details.evt.status + " " + (details.evt.state()) + "-" + details.status + "-" + details.error).replace(/ +/g, " ");
      body = "url: " + details.ajaxOptions.url + "\ntype: " + details.ajaxOptions.type + "\nstate: " + (details.evt.state()) + "\nstatus: " + details.status + "\nerror: " + details.error + "\n\ndetails:\n" + (JSON.stringify(details, null, "  "));
      if (subject === ("Zoom " + details.zoomVersion + " page fail: 0 rejected-error-")) {
        return false;
      }
      if (subject === ("Zoom " + details.zoomVersion + " partial fail: 0 rejected-error-")) {
        return false;
      }
      return window.logger.info({
        subject: subject,
        body: body
      });
    }
  };

  Zoom.history = (function() {
    var api, hasChanged, historySupported, isSupported, poped, previous, push, willChange;
    api = window.history;
    previous = Zoom.toolbox.currentURL();
    willChange = function(url) {
      return Zoom.toolbox.normalizeURL(url) !== Zoom.toolbox.currentURL();
    };
    hasChanged = function() {
      return Zoom.toolbox.normalizeURL(previous) !== Zoom.toolbox.currentURL();
    };
    push = function(url) {
      url = Zoom.toolbox.normalizeURL(url);
      if (willChange(url)) {
        api.pushState(url, "", url);
        Zoom.pubsub.publish(Zoom.events.history.push, {
          from: previous,
          to: url
        });
        return previous = url;
      }
    };
    poped = function() {
      var url;
      if (hasChanged()) {
        url = Zoom.toolbox.currentURL();
        Zoom.pubsub.publish(Zoom.events.history.pop, {
          from: previous,
          to: url
        });
        previous = url;
        return Zoom.page({
          url: url
        }, {
          historyPush: false,
          historyPoped: true
        });
      }
    };
    historySupported = void 0;
    isSupported = function() {
      var canPush, isBuggy, ua;
      if (historySupported != null) {
        return historySupported;
      }
      canPush = api && "pushState" in api && "state" in api;
      ua = Zoom.toolbox.userAgent;
      isBuggy = true;
      isBuggy && (isBuggy = ua.indexOf("Android 2.") !== -1 || ua.indexOf("Android 4.0") !== -1);
      isBuggy && (isBuggy = ua.indexOf("Mobile Safari") !== -1);
      isBuggy && (isBuggy = ua.indexOf("Chrome") === -1);
      isBuggy && (isBuggy = ua.indexOf("Windows Phone") === -1);
      return historySupported = canPush && !isBuggy;
    };
    return {
      willChange: willChange,
      hasChanged: hasChanged,
      push: push,
      poped: poped,
      previous: previous,
      isSupported: isSupported
    };
  })();

  Zoom.storage = (function() {
    var api, boolean, get, isSupported, namespace, remove, set, storageSupported;
    try {
      api = window.sessionStorage;
    } catch (error1) {
      storageSupported = false;
    }
    namespace = function(key) {
      return "Zoom." + key;
    };
    get = function(key) {
      return api.getItem(namespace(key));
    };
    boolean = function(key) {
      if (get(key) === "true") {
        return true;
      } else if (get(key) === "false") {
        return false;
      }
    };
    set = function(key, value) {
      if (value != null) {
        api.setItem(namespace(key), String(value));
        return value;
      } else {
        return remove(key);
      }
    };
    remove = function(key) {
      var value;
      value = get(key);
      api.removeItem(namespace(key));
      return value;
    };
    isSupported = function() {
      var canGet, canRemove, canSet, key, value;
      if (storageSupported != null) {
        return storageSupported;
      }
      return storageSupported = (function() {
        var ref;
        try {
          ref = ["storage.storageSupported", "true"], key = ref[0], value = ref[1];
          canSet = set(key, value) === value;
          canGet = get(key) === value;
          canRemove = remove(key) === value && remove(key) === null;
          return canSet && canGet && canRemove;
        } catch (error1) {
          return false;
        }
      })();
    };
    return {
      get: get,
      set: set,
      remove: remove,
      boolean: boolean,
      isSupported: isSupported
    };
  })();

  Zoom.loader = (function() {
    var hide, namespace, show;
    namespace = ".zooming";
    show = function() {
      return $(namespace).css("visibility", "visible");
    };
    hide = function() {
      return $(namespace).css("visibility", "hidden");
    };
    return {
      show: show,
      hide: hide
    };
  })();

  Zoom.pubsub = (function() {
    var mediator, namespace, publish, subscribe;
    namespace = function(key) {
      return "zoom:" + key;
    };
    mediator = window;
    publish = function(key, details) {
      if (details == null) {
        details = {};
      }
      Zoom.logger.debug(namespace(key), details);
      return $(mediator).trigger(namespace(key), details);
    };
    subscribe = function(key, details) {
      if (details == null) {
        details = {};
      }
      Zoom.logger.debug(namespace(key), details);
      return $(mediator).on(namespace(key), details);
    };
    return {
      mediator: mediator,
      publish: publish,
      subscribe: subscribe
    };
  })();

  Zoom.partial = (function() {
    var fetch, fetching;
    fetching = void 0;
    fetch = function(ajaxOptions, zoomOptions) {
      var request;
      zoomOptions = $.extend({}, zoomOptions);
      if (!$.isPlainObject(zoomOptions.data)) {
        zoomOptions.data = {};
      }
      ajaxOptions = $.extend({
        type: "GET",
        headers: {}
      }, ajaxOptions);
      ajaxOptions.type = String(ajaxOptions.type).toUpperCase();
      ajaxOptions.headers["X-Zoom-Format"] = "partial";
      ajaxOptions.beforeSend = function(ajaxParams, ajaxSettings) {
        ajaxOptions = ajaxSettings;
        Zoom.pubsub.publish(Zoom.events.partial.fetch, {
          ajaxOptions: ajaxOptions,
          zoomOptions: zoomOptions,
          ajaxParams: ajaxParams
        });
        if (("" + zoomOptions.data.loader) === "true") {
          return Zoom.loader.show();
        }
      };
      request = $.ajax(ajaxOptions);
      request.fail(function(evt, status, error) {
        if (typeof zoomOptions.fail === "function") {
          zoomOptions.fail();
        }
        Zoom.pubsub.publish(Zoom.events.partial.fail, {
          ajaxOptions: ajaxOptions,
          zoomOptions: zoomOptions,
          evt: evt,
          status: status,
          error: error
        });
        Zoom.partial.lastFail = {
          ajaxOptions: {
            url: ajaxOptions.url,
            type: ajaxOptions.type
          },
          zoomOptions: zoomOptions,
          evt: evt,
          status: status,
          error: error
        };
        return Zoom.toolbox.logFail("partial", Zoom.partial.lastFail);
      });
      request.done(function(response, status, evt) {
        var $partial, replacePartialDocumentHtml;
        if (Zoom.toolbox.isHTMLContent(evt)) {
          $partial = $(response);
          replacePartialDocumentHtml = function(elements) {
            return $(elements).filter("[id]").not(Zoom.selectors.javascript).each(function(i, html) {
              var $html, $target;
              $html = $(html);
              $target = $("#" + ($html.attr("id")));
              if ($target.closest(Zoom.selectors.update).length > 0) {
                return $html.replaceCurrentHTML({
                  fadeIn: true
                });
              }
            });
          };
          replacePartialDocumentHtml($partial.not("[data-zoom-partial-target]"));
          $partial.filter("[data-zoom-partial-target]").each(function(i, targetContainer) {
            var $target, $targetContainer, targetSelector;
            $targetContainer = $(targetContainer);
            targetSelector = $targetContainer.data("zoom-partial-target");
            $target = $targetContainer.find(targetSelector);
            return replacePartialDocumentHtml($target);
          });
          Zoom.pubsub.publish(Zoom.events.partial.setup, {
            ajaxOptions: ajaxOptions,
            zoomOptions: zoomOptions,
            response: response,
            status: status,
            evt: evt
          });
          Zoom.toolbox.evalInContext($partial.filter(Zoom.selectors.javascript).text());
          if (typeof zoomOptions.done === "function") {
            zoomOptions.done();
          }
          return Zoom.pubsub.publish(Zoom.events.partial.done, {
            ajaxOptions: ajaxOptions,
            zoomOptions: zoomOptions,
            response: response,
            status: status,
            evt: evt
          });
        } else {
          return typeof zoomOptions.done === "function" ? zoomOptions.done() : void 0;
        }
      });
      request.always(function(response_or_ajax, status, ajax_or_error) {
        fetching = void 0;
        if (typeof zoomOptions.always === "function") {
          zoomOptions.always();
        }
        if (("" + zoomOptions.data.loader) === "true") {
          Zoom.loader.hide();
        }
        return Zoom.pubsub.publish(Zoom.events.partial.always, {
          ajaxOptions: ajaxOptions,
          zoomOptions: zoomOptions,
          response_or_ajax: response_or_ajax,
          status: status,
          ajax_or_error: ajax_or_error
        });
      });
      return request;
    };
    return fetch;
  })();

  Zoom.page = (function() {
    var failures, fetch, fetching, isSupported, pageSupported;
    failures = 0;
    fetching = void 0;
    fetch = function(ajaxOptions, zoomOptions) {
      var request;
      zoomOptions = $.extend({
        historyPush: true
      }, zoomOptions);
      if (!$.isPlainObject(zoomOptions.data)) {
        zoomOptions.data = {};
      }
      ajaxOptions = $.extend({
        type: "GET",
        headers: {}
      }, ajaxOptions);
      ajaxOptions.type = String(ajaxOptions.type).toUpperCase();
      ajaxOptions.headers["X-Zoom-Format"] = "page";
      ajaxOptions.beforeSend = function(ajaxParams, ajaxSettings) {
        if (ajaxSettings.type === "GET" && zoomOptions.historyPush && !Zoom.history.willChange(ajaxSettings.url)) {
          if (("" + zoomOptions.data.cancellable) !== "false") {
            Zoom.pubsub.publish(Zoom.events.page.cancel, {
              ajaxOptions: ajaxOptions,
              zoomOptions: zoomOptions,
              ajaxSettings: ajaxSettings
            });
            return false;
          }
        }
        if (fetching != null) {
          if (typeof fetching.abort === "function") {
            fetching.abort();
          }
        }
        fetching = ajaxParams;
        ajaxOptions = ajaxSettings;
        Zoom.loader.show();
        return Zoom.pubsub.publish(Zoom.events.page.fetch, {
          ajaxOptions: ajaxOptions,
          zoomOptions: zoomOptions,
          ajaxParams: ajaxParams
        });
      };
      request = $.ajax(ajaxOptions);
      request.fail(function(evt, status, error) {
        var canceledFail, disableSupport, historyFail, unknownFail;
        canceledFail = status === "canceled" || status === "abort";
        unknownFail = evt.state() === "rejected" && evt.status === 0 && (evt.responseText === "" || (evt.responseText == null));
        historyFail = unknownFail && zoomOptions.historyPoped;
        if (!canceledFail && !historyFail) {
          failures += 1;
          disableSupport = failures >= 2;
          if (disableSupport) {
            Zoom.setSupported(false);
          }
          if (Zoom.isSupported()) {
            if (typeof zoomOptions.fail === "function") {
              zoomOptions.fail();
            }
            Zoom.pubsub.publish(Zoom.events.page.fail, {
              ajaxOptions: ajaxOptions,
              zoomOptions: zoomOptions,
              evt: evt,
              status: status,
              error: error
            });
            Zoom.page.lastFail = {
              ajaxOptions: {
                url: ajaxOptions.url,
                type: ajaxOptions.type
              },
              zoomOptions: zoomOptions,
              evt: evt,
              status: status,
              error: error,
              failures: failures
            };
            if (disableSupport) {
              return Zoom.toolbox.logFail("page", Zoom.page.lastFail);
            }
          }
        }
      });
      request.done(function(response, status, evt) {
        var $doc, doc, historyURL, javascript;
        if (Zoom.toolbox.isHTMLContent(evt)) {
          doc = Zoom.toolbox.createDocument(response);
          $doc = $(doc);
          if (Zoom.toolbox.getVersion($doc) !== Zoom.toolbox.getVersion()) {
            Zoom.zoomSupported = false;
          }
          javascript = $doc.find(Zoom.selectors.javascript).text();
          $doc.find(Zoom.selectors.update).not(Zoom.selectors.javascript).replaceCurrentHTML();
          Zoom.pubsub.publish(Zoom.events.page.setup, {
            ajaxOptions: ajaxOptions,
            zoomOptions: zoomOptions,
            response: response,
            status: status,
            evt: evt
          });
          Zoom.toolbox.evalInContext(javascript);
          if (zoomOptions.historyPush) {
            historyURL = evt.getResponseHeader("X-Zoom-History-URL") || Zoom.toolbox.currentURL();
            Zoom.history.push(historyURL);
          }
          if (typeof zoomOptions.done === "function") {
            zoomOptions.done();
          }
          return Zoom.pubsub.publish(Zoom.events.page.done, {
            ajaxOptions: ajaxOptions,
            zoomOptions: zoomOptions,
            response: response,
            status: status,
            evt: evt
          });
        } else {
          return typeof zoomOptions.done === "function" ? zoomOptions.done() : void 0;
        }
      });
      request.always(function(response_or_ajax, status, ajax_or_error) {
        fetching = void 0;
        Zoom.loader.hide();
        if (typeof zoomOptions.always === "function") {
          zoomOptions.always();
        }
        if (zoomOptions.data.scrollToTop !== false) {
          Zoom.toolbox.scrollToTop();
        }
        return Zoom.pubsub.publish(Zoom.events.page.always, {
          ajaxOptions: ajaxOptions,
          zoomOptions: zoomOptions,
          response_or_ajax: response_or_ajax,
          status: status,
          ajax_or_error: ajax_or_error
        });
      });
      return request;
    };
    pageSupported = void 0;
    isSupported = function() {
      var doc, error;
      if (pageSupported != null) {
        return pageSupported;
      }
      return pageSupported = (function() {
        try {
          doc = Zoom.toolbox.createDocument('<!DOCTYPE html><html lang="en"><head></head><body>true</body></html>');
          return $(doc).find("body").text() === "true";
        } catch (error1) {
          error = error1;
          return false;
        }
      })();
    };
    fetch.isSupported = isSupported;
    return fetch;
  })();

  Zoom.zoomSupported = Zoom.storage.isSupported() ? Zoom.storage.boolean("zoomSupported") : void 0;

  Zoom.setSupported = function(value, options) {
    if (options == null) {
      options = {
        store: true
      };
    }
    if (options.store && Zoom.storage.isSupported()) {
      Zoom.storage.set("zoomSupported", value);
    }
    return Zoom.zoomSupported = value;
  };

  Zoom.isSupported = function() {
    if (Zoom.zoomSupported != null) {
      return Zoom.zoomSupported;
    }
    Zoom.setSupported(Zoom.history.isSupported() && Zoom.storage.isSupported() && Zoom.page.isSupported());
    if (Zoom.zoomSupported) {
      $.ajax({
        url: "/ping",
        type: "GET"
      }).fail(function(evt, status, error) {
        if (status === "rejected") {
          return Zoom.setSupported(false);
        }
      });
      $.ajax({
        url: "/ping",
        type: "POST"
      }).fail(function(evt, status, error) {
        if (status === "rejected") {
          return Zoom.setSupported(false);
        }
      });
    }
    return Zoom.zoomSupported;
  };

  Zoom.watch = (function() {
    var everything, forms, history, links, watching;
    watching = {
      history: false,
      links: false,
      forms: false
    };
    history = function() {
      if (watching.history) {
        return watching;
      } else {
        watching.history = true;
      }
      $(window).on("popstate", function(evt) {
        if (Zoom.isSupported()) {
          return Zoom.history.poped();
        }
      });
      return watching;
    };
    links = function() {
      if (watching.links) {
        return watching;
      } else {
        watching.links = true;
      }
      $(document).on("click", "a", function(evt) {
        var $a, $form, a, ajaxOptions, data, error, method, ref, type, url, zoomOptions;
        try {
          ref = [this, $(this), this.href], a = ref[0], $a = ref[1], url = ref[2];
          if (!Zoom.toolbox.clickEventIsSignificant(evt)) {
            return true;
          }
          if (Zoom.toolbox.startsWith($a.attr("href"), "#") || !Zoom.toolbox.startsWith(url, Zoom.toolbox.currentOrigin())) {
            return true;
          }
          if ($a.filter(Zoom.selectors.ignore).length !== 0 || $a.parents(Zoom.selectors.ignoreContainer).length !== 0) {
            return true;
          }
          if ($a.filter("[target=_blank]").length !== 0) {
            return true;
          }
          method = ($a.data("method") || "GET").toUpperCase();
          type = method === "GET" ? "GET" : "POST";
          data = type !== "GET" ? {
            _method: method
          } : {};
          ajaxOptions = {
            url: url,
            type: type,
            data: data
          };
          zoomOptions = {
            fail: function() {
              if ($a.data("zoom-fail") != null) {
                return eval($a.data("zoom-fail"));
              }
            },
            done: function() {
              if ($a.data("zoom-done") != null) {
                return eval($a.data("zoom-done"));
              }
            },
            always: function() {
              if ($a.data("zoom-always") != null) {
                return eval($a.data("zoom-always"));
              }
            },
            retry: function() {
              return typeof a.click === "function" ? a.click() : void 0;
            },
            data: $a.data("zoom")
          };
          if ($a.filter(Zoom.selectors.partial).length !== 0) {
            Zoom.partial(ajaxOptions, zoomOptions);
            return Zoom.toolbox.stopEvent(evt);
          } else if (Zoom.isSupported()) {
            Zoom.page(ajaxOptions, zoomOptions);
            return Zoom.toolbox.stopEvent(evt);
          } else if (type !== "GET") {
            $form = $("<form></form>").attr("method", type).attr("action", url).hide();
            $form.append($("<input />").attr("name", "_method").val(method));
            $("body").append($form);
            $form.submit();
            return Zoom.toolbox.stopEvent(evt);
          }
        } catch (error1) {
          error = error1;
          return window.error.log(error, {
            from: "Zoom.a.click"
          });
        }
      });
      return watching;
    };
    forms = function() {
      if (watching.forms) {
        return watching;
      } else {
        watching.forms = true;
      }
      $(document).on("submit", "form", function(evt) {
        var $form, ajaxOptions, error, form, method, ref, type, url, zoomOptions;
        try {
          ref = [this, $(this), this.action], form = ref[0], $form = ref[1], url = ref[2];
          if (!Zoom.toolbox.startsWith(url, Zoom.toolbox.currentOrigin())) {
            return true;
          }
          if ($form.filter(Zoom.selectors.ignore).length !== 0 || $form.parents(Zoom.selectors.ignoreContainer).length !== 0) {
            return true;
          }
          method = $form.find("input[name=_method]").val();
          method = (method && method !== "" ? method : $form.attr("method")).toUpperCase();
          type = method === "GET" ? "GET" : "POST";
          ajaxOptions = {
            url: url,
            type: type,
            data: $form.serialize()
          };
          zoomOptions = {
            fail: function() {
              if ($form.data("zoom-fail") != null) {
                return eval($form.data("zoom-fail"));
              }
            },
            done: function() {
              if ($form.data("zoom-done") != null) {
                return eval($form.data("zoom-done"));
              }
            },
            always: function() {
              if ($form.data("zoom-always") != null) {
                return eval($form.data("zoom-always"));
              }
            },
            retry: function() {
              return $form.submit();
            },
            data: $form.data("zoom")
          };
          if ($form.filter(Zoom.selectors.partial).length !== 0) {
            Zoom.partial(ajaxOptions, zoomOptions);
            return Zoom.toolbox.stopEvent(evt);
          } else if (Zoom.isSupported()) {
            Zoom.page(ajaxOptions, zoomOptions);
            return Zoom.toolbox.stopEvent(evt);
          }
        } catch (error1) {
          error = error1;
          return window.error.log(error, {
            from: "Zoom.form.submit"
          });
        }
      });
      return watching;
    };
    everything = function() {
      history();
      links();
      forms();
      return watching;
    };
    return {
      watching: watching,
      everything: everything,
      history: history,
      forms: forms,
      links: links
    };
  })();

  Zoom.start = (function() {
    var start;
    start = function() {
      Zoom.isSupported();
      Zoom.watch.everything();
      Zoom.pubsub.publish(Zoom.events.start, Zoom.watch.watching);
      Zoom.pubsub.publish(Zoom.events.page.done, Zoom.watch.watching);
      return Zoom.pubsub.publish(Zoom.events.page.always, Zoom.watch.watching);
    };
    return start;
  })();

  this.Zoom = Zoom;

}).call(this);
