vis-network
Version:
A dynamic, browser-based visualization library.
1,644 lines (1,333 loc) • 1.36 MB
JavaScript
/**
* vis-network
* https://visjs.github.io/vis-network/
*
* A dynamic, browser-based visualization library.
*
* @version 9.1.0
* @date 2021-08-29T08:47:25.454Z
*
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
*
* @license
* vis.js is dual licensed under both
*
* 1. The Apache 2.0 License
* http://www.apache.org/licenses/LICENSE-2.0
*
* and
*
* 2. The MIT License
* http://opensource.org/licenses/MIT
*
* vis.js may be distributed under either license.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vis = global.vis || {}));
}(this, (function (exports) { 'use strict';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var check = function (it) {
return it && it.Math == Math && it;
}; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global_1 = // eslint-disable-next-line es/no-global-this -- safe
check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe
check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback
function () {
return this;
}() || Function('return this')();
var fails = function (exec) {
try {
return !!exec();
} catch (error) {
return true;
}
};
var descriptors = !fails(function () {
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
return Object.defineProperty({}, 1, {
get: function () {
return 7;
}
})[1] != 7;
});
var $propertyIsEnumerable$1 = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var getOwnPropertyDescriptor$5 = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug
var NASHORN_BUG = getOwnPropertyDescriptor$5 && !$propertyIsEnumerable$1.call({
1: 2
}, 1); // `Object.prototype.propertyIsEnumerable` method implementation
// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
var f$6 = NASHORN_BUG ? function propertyIsEnumerable(V) {
var descriptor = getOwnPropertyDescriptor$5(this, V);
return !!descriptor && descriptor.enumerable;
} : $propertyIsEnumerable$1;
var objectPropertyIsEnumerable = {
f: f$6
};
var createPropertyDescriptor = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
var toString$1 = {}.toString;
var classofRaw = function (it) {
return toString$1.call(it).slice(8, -1);
};
var split = ''.split; // fallback for non-array-like ES3 and non-enumerable old V8 strings
var indexedObject = fails(function () {
// throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
// eslint-disable-next-line no-prototype-builtins -- safe
return !Object('z').propertyIsEnumerable(0);
}) ? function (it) {
return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
} : Object;
// `RequireObjectCoercible` abstract operation
// https://tc39.es/ecma262/#sec-requireobjectcoercible
var requireObjectCoercible = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
var toIndexedObject = function (it) {
return indexedObject(requireObjectCoercible(it));
};
var isObject$1 = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
var path = {};
var aFunction$1 = function (variable) {
return typeof variable == 'function' ? variable : undefined;
};
var getBuiltIn = function (namespace, method) {
return arguments.length < 2 ? aFunction$1(path[namespace]) || aFunction$1(global_1[namespace]) : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
};
var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
var process = global_1.process;
var Deno = global_1.Deno;
var versions = process && process.versions || Deno && Deno.version;
var v8 = versions && versions.v8;
var match, version;
if (v8) {
match = v8.split('.');
version = match[0] < 4 ? 1 : match[0] + match[1];
} else if (engineUserAgent) {
match = engineUserAgent.match(/Edge\/(\d+)/);
if (!match || match[1] >= 74) {
match = engineUserAgent.match(/Chrome\/(\d+)/);
if (match) version = match[1];
}
}
var engineV8Version = version && +version;
/* eslint-disable es/no-symbol -- required for testing */
// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion
// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
!Symbol.sham && engineV8Version && engineV8Version < 41;
});
/* eslint-disable es/no-symbol -- required for testing */
var useSymbolAsUid = nativeSymbol && !Symbol.sham && typeof Symbol.iterator == 'symbol';
var isSymbol = useSymbolAsUid ? function (it) {
return typeof it == 'symbol';
} : function (it) {
var $Symbol = getBuiltIn('Symbol');
return typeof $Symbol == 'function' && Object(it) instanceof $Symbol;
};
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
var ordinaryToPrimitive = function (input, pref) {
var fn, val;
if (pref === 'string' && typeof (fn = input.toString) == 'function' && !isObject$1(val = fn.call(input))) return val;
if (typeof (fn = input.valueOf) == 'function' && !isObject$1(val = fn.call(input))) return val;
if (pref !== 'string' && typeof (fn = input.toString) == 'function' && !isObject$1(val = fn.call(input))) return val;
throw TypeError("Can't convert object to primitive value");
};
var setGlobal = function (key, value) {
try {
// eslint-disable-next-line es/no-object-defineproperty -- safe
Object.defineProperty(global_1, key, {
value: value,
configurable: true,
writable: true
});
} catch (error) {
global_1[key] = value;
}
return value;
};
var SHARED = '__core-js_shared__';
var store$1 = global_1[SHARED] || setGlobal(SHARED, {});
var sharedStore = store$1;
var shared = createCommonjsModule(function (module) {
(module.exports = function (key, value) {
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
})('versions', []).push({
version: '3.16.1',
mode: 'pure' ,
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
});
});
// https://tc39.es/ecma262/#sec-toobject
var toObject = function (argument) {
return Object(requireObjectCoercible(argument));
};
var hasOwnProperty = {}.hasOwnProperty;
var has$1 = Object.hasOwn || function hasOwn(it, key) {
return hasOwnProperty.call(toObject(it), key);
};
var id$1 = 0;
var postfix = Math.random();
var uid = function (key) {
return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id$1 + postfix).toString(36);
};
var WellKnownSymbolsStore$1 = shared('wks');
var Symbol$1 = global_1.Symbol;
var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
var wellKnownSymbol = function (name) {
if (!has$1(WellKnownSymbolsStore$1, name) || !(nativeSymbol || typeof WellKnownSymbolsStore$1[name] == 'string')) {
if (nativeSymbol && has$1(Symbol$1, name)) {
WellKnownSymbolsStore$1[name] = Symbol$1[name];
} else {
WellKnownSymbolsStore$1[name] = createWellKnownSymbol('Symbol.' + name);
}
}
return WellKnownSymbolsStore$1[name];
};
var TO_PRIMITIVE$1 = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation
// https://tc39.es/ecma262/#sec-toprimitive
var toPrimitive = function (input, pref) {
if (!isObject$1(input) || isSymbol(input)) return input;
var exoticToPrim = input[TO_PRIMITIVE$1];
var result;
if (exoticToPrim !== undefined) {
if (pref === undefined) pref = 'default';
result = exoticToPrim.call(input, pref);
if (!isObject$1(result) || isSymbol(result)) return result;
throw TypeError("Can't convert object to primitive value");
}
if (pref === undefined) pref = 'number';
return ordinaryToPrimitive(input, pref);
};
// https://tc39.es/ecma262/#sec-topropertykey
var toPropertyKey = function (argument) {
var key = toPrimitive(argument, 'string');
return isSymbol(key) ? key : String(key);
};
var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE
var EXISTS = isObject$1(document$1) && isObject$1(document$1.createElement);
var documentCreateElement = function (it) {
return EXISTS ? document$1.createElement(it) : {};
};
var ie8DomDefine = !descriptors && !fails(function () {
// eslint-disable-next-line es/no-object-defineproperty -- requied for testing
return Object.defineProperty(documentCreateElement('div'), 'a', {
get: function () {
return 7;
}
}).a != 7;
});
var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
var f$5 = descriptors ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
O = toIndexedObject(O);
P = toPropertyKey(P);
if (ie8DomDefine) try {
return $getOwnPropertyDescriptor$1(O, P);
} catch (error) {
/* empty */
}
if (has$1(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
};
var objectGetOwnPropertyDescriptor = {
f: f$5
};
var replacement = /#|\.prototype\./;
var isForced = function (feature, detection) {
var value = data[normalize(feature)];
return value == POLYFILL ? true : value == NATIVE ? false : typeof detection == 'function' ? fails(detection) : !!detection;
};
var normalize = isForced.normalize = function (string) {
return String(string).replace(replacement, '.').toLowerCase();
};
var data = isForced.data = {};
var NATIVE = isForced.NATIVE = 'N';
var POLYFILL = isForced.POLYFILL = 'P';
var isForced_1 = isForced;
var aFunction = function (it) {
if (typeof it != 'function') {
throw TypeError(String(it) + ' is not a function');
}
return it;
};
var functionBindContext = function (fn, that, length) {
aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 0:
return function () {
return fn.call(that);
};
case 1:
return function (a) {
return fn.call(that, a);
};
case 2:
return function (a, b) {
return fn.call(that, a, b);
};
case 3:
return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function () {
return fn.apply(that, arguments);
};
};
var anObject = function (it) {
if (!isObject$1(it)) {
throw TypeError(String(it) + ' is not an object');
}
return it;
};
var $defineProperty$1 = Object.defineProperty; // `Object.defineProperty` method
// https://tc39.es/ecma262/#sec-object.defineproperty
var f$4 = descriptors ? $defineProperty$1 : function defineProperty(O, P, Attributes) {
anObject(O);
P = toPropertyKey(P);
anObject(Attributes);
if (ie8DomDefine) try {
return $defineProperty$1(O, P, Attributes);
} catch (error) {
/* empty */
}
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
var objectDefineProperty = {
f: f$4
};
var createNonEnumerableProperty = descriptors ? function (object, key, value) {
return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
var getOwnPropertyDescriptor$4 = objectGetOwnPropertyDescriptor.f;
var wrapConstructor = function (NativeConstructor) {
var Wrapper = function (a, b, c) {
if (this instanceof NativeConstructor) {
switch (arguments.length) {
case 0:
return new NativeConstructor();
case 1:
return new NativeConstructor(a);
case 2:
return new NativeConstructor(a, b);
}
return new NativeConstructor(a, b, c);
}
return NativeConstructor.apply(this, arguments);
};
Wrapper.prototype = NativeConstructor.prototype;
return Wrapper;
};
/*
options.target - name of the target object
options.global - target is the global object
options.stat - export as static methods of target
options.proto - export as prototype methods of target
options.real - real prototype method for the `pure` version
options.forced - export even if the native feature is available
options.bind - bind methods to the target, required for the `pure` version
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
options.unsafe - use the simple assignment of property instead of delete + defineProperty
options.sham - add a flag to not completely full polyfills
options.enumerable - export as enumerable property
options.noTargetGet - prevent calling a getter on target
*/
var _export = function (options, source) {
var TARGET = options.target;
var GLOBAL = options.global;
var STATIC = options.stat;
var PROTO = options.proto;
var nativeSource = GLOBAL ? global_1 : STATIC ? global_1[TARGET] : (global_1[TARGET] || {}).prototype;
var target = GLOBAL ? path : path[TARGET] || (path[TARGET] = {});
var targetPrototype = target.prototype;
var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
for (key in source) {
FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contains in native
USE_NATIVE = !FORCED && nativeSource && has$1(nativeSource, key);
targetProperty = target[key];
if (USE_NATIVE) if (options.noTargetGet) {
descriptor = getOwnPropertyDescriptor$4(nativeSource, key);
nativeProperty = descriptor && descriptor.value;
} else nativeProperty = nativeSource[key]; // export native or implementation
sourceProperty = USE_NATIVE && nativeProperty ? nativeProperty : source[key];
if (USE_NATIVE && typeof targetProperty === typeof sourceProperty) continue; // bind timers to global for call from export context
if (options.bind && USE_NATIVE) resultProperty = functionBindContext(sourceProperty, global_1); // wrap global constructors for prevent changs in this version
else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty); // make static versions for prototype methods
else if (PROTO && typeof sourceProperty == 'function') resultProperty = functionBindContext(Function.call, sourceProperty); // default case
else resultProperty = sourceProperty; // add a flag to not completely full polyfills
if (options.sham || sourceProperty && sourceProperty.sham || targetProperty && targetProperty.sham) {
createNonEnumerableProperty(resultProperty, 'sham', true);
}
target[key] = resultProperty;
if (PROTO) {
VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
if (!has$1(path, VIRTUAL_PROTOTYPE)) {
createNonEnumerableProperty(path, VIRTUAL_PROTOTYPE, {});
} // export virtual prototype methods
path[VIRTUAL_PROTOTYPE][key] = sourceProperty; // export real prototype methods
if (options.real && targetPrototype && !targetPrototype[key]) {
createNonEnumerableProperty(targetPrototype, key, sourceProperty);
}
}
}
};
var ceil = Math.ceil;
var floor$1 = Math.floor; // `ToInteger` abstract operation
// https://tc39.es/ecma262/#sec-tointeger
var toInteger = function (argument) {
return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor$1 : ceil)(argument);
};
var min$2 = Math.min; // `ToLength` abstract operation
// https://tc39.es/ecma262/#sec-tolength
var toLength = function (argument) {
return argument > 0 ? min$2(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
};
var max$2 = Math.max;
var min$1 = Math.min; // Helper for a popular repeating case of the spec:
// Let integer be ? ToInteger(index).
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
var toAbsoluteIndex = function (index, length) {
var integer = toInteger(index);
return integer < 0 ? max$2(integer + length, 0) : min$1(integer, length);
};
var createMethod$5 = function (IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = toIndexedObject($this);
var length = toLength(O.length);
var index = toAbsoluteIndex(fromIndex, length);
var value; // Array#includes uses SameValueZero equality algorithm
// eslint-disable-next-line no-self-compare -- NaN check
if (IS_INCLUDES && el != el) while (length > index) {
value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check
if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not
} else for (; length > index; index++) {
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
}
return !IS_INCLUDES && -1;
};
};
var arrayIncludes = {
// `Array.prototype.includes` method
// https://tc39.es/ecma262/#sec-array.prototype.includes
includes: createMethod$5(true),
// `Array.prototype.indexOf` method
// https://tc39.es/ecma262/#sec-array.prototype.indexof
indexOf: createMethod$5(false)
};
var hiddenKeys$1 = {};
var indexOf$3 = arrayIncludes.indexOf;
var objectKeysInternal = function (object, names) {
var O = toIndexedObject(object);
var i = 0;
var result = [];
var key;
for (key in O) !has$1(hiddenKeys$1, key) && has$1(O, key) && result.push(key); // Don't enum bug & hidden keys
while (names.length > i) if (has$1(O, key = names[i++])) {
~indexOf$3(result, key) || result.push(key);
}
return result;
};
// IE8- don't enum bug keys
var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'];
// https://tc39.es/ecma262/#sec-object.keys
// eslint-disable-next-line es/no-object-keys -- safe
var objectKeys = Object.keys || function keys(O) {
return objectKeysInternal(O, enumBugKeys);
};
// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
var f$3 = Object.getOwnPropertySymbols;
var objectGetOwnPropertySymbols = {
f: f$3
};
var $assign = Object.assign; // eslint-disable-next-line es/no-object-defineproperty -- required for testing
var defineProperty$9 = Object.defineProperty; // `Object.assign` method
// https://tc39.es/ecma262/#sec-object.assign
var objectAssign = !$assign || fails(function () {
// should have correct order of operations (Edge bug)
if (descriptors && $assign({
b: 1
}, $assign(defineProperty$9({}, 'a', {
enumerable: true,
get: function () {
defineProperty$9(this, 'b', {
value: 3,
enumerable: false
});
}
}), {
b: 2
})).b !== 1) return true; // should work with symbols and should have deterministic property order (V8 bug)
var A = {};
var B = {}; // eslint-disable-next-line es/no-symbol -- safe
var symbol = Symbol();
var alphabet = 'abcdefghijklmnopqrst';
A[symbol] = 7;
alphabet.split('').forEach(function (chr) {
B[chr] = chr;
});
return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
}) ? function assign(target, source) {
// eslint-disable-line no-unused-vars -- required for `.length`
var T = toObject(target);
var argumentsLength = arguments.length;
var index = 1;
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
var propertyIsEnumerable = objectPropertyIsEnumerable.f;
while (argumentsLength > index) {
var S = indexedObject(arguments[index++]);
var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
var length = keys.length;
var j = 0;
var key;
while (length > j) {
key = keys[j++];
if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key];
}
}
return T;
} : $assign;
// https://tc39.es/ecma262/#sec-object.assign
// eslint-disable-next-line es/no-object-assign -- required for testing
_export({
target: 'Object',
stat: true,
forced: Object.assign !== objectAssign
}, {
assign: objectAssign
});
var assign$4 = path.Object.assign;
var assign$3 = assign$4;
var assign$2 = assign$3;
var slice$6 = [].slice;
var factories = {};
var construct$3 = function (C, argsLength, args) {
if (!(argsLength in factories)) {
for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']'; // eslint-disable-next-line no-new-func -- we have no proper alternatives, IE8- only
factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')');
}
return factories[argsLength](C, args);
}; // `Function.prototype.bind` method implementation
// https://tc39.es/ecma262/#sec-function.prototype.bind
var functionBind = Function.bind || function bind(that
/* , ...args */
) {
var fn = aFunction(this);
var partArgs = slice$6.call(arguments, 1);
var boundFunction = function bound() {
var args = partArgs.concat(slice$6.call(arguments));
return this instanceof boundFunction ? construct$3(fn, args.length, args) : fn.apply(that, args);
};
if (isObject$1(fn.prototype)) boundFunction.prototype = fn.prototype;
return boundFunction;
};
// https://tc39.es/ecma262/#sec-function.prototype.bind
_export({
target: 'Function',
proto: true
}, {
bind: functionBind
});
var entryVirtual = function (CONSTRUCTOR) {
return path[CONSTRUCTOR + 'Prototype'];
};
var bind$2 = entryVirtual('Function').bind;
var FunctionPrototype = Function.prototype;
var bind_1 = function (it) {
var own = it.bind;
return it === FunctionPrototype || it instanceof Function && own === FunctionPrototype.bind ? bind$2 : own;
};
var bind$1 = bind_1;
var bind = bind$1;
/**
* Draw a circle.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param r - The radius of the circle.
*/
function drawCircle(ctx, x, y, r) {
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI, false);
ctx.closePath();
}
/**
* Draw a square.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param r - Half of the width and height of the square.
*/
function drawSquare(ctx, x, y, r) {
ctx.beginPath();
ctx.rect(x - r, y - r, r * 2, r * 2);
ctx.closePath();
}
/**
* Draw an equilateral triangle standing on a side.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param r - Half of the length of the sides.
*
* @remarks
* http://en.wikipedia.org/wiki/Equilateral_triangle
*/
function drawTriangle(ctx, x, y, r) {
ctx.beginPath(); // the change in radius and the offset is here to center the shape
r *= 1.15;
y += 0.275 * r;
var s = r * 2;
var s2 = s / 2;
var ir = Math.sqrt(3) / 6 * s; // radius of inner circle
var h = Math.sqrt(s * s - s2 * s2); // height
ctx.moveTo(x, y - (h - ir));
ctx.lineTo(x + s2, y + ir);
ctx.lineTo(x - s2, y + ir);
ctx.lineTo(x, y - (h - ir));
ctx.closePath();
}
/**
* Draw an equilateral triangle standing on a vertex.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param r - Half of the length of the sides.
*
* @remarks
* http://en.wikipedia.org/wiki/Equilateral_triangle
*/
function drawTriangleDown(ctx, x, y, r) {
ctx.beginPath(); // the change in radius and the offset is here to center the shape
r *= 1.15;
y -= 0.275 * r;
var s = r * 2;
var s2 = s / 2;
var ir = Math.sqrt(3) / 6 * s; // radius of inner circle
var h = Math.sqrt(s * s - s2 * s2); // height
ctx.moveTo(x, y + (h - ir));
ctx.lineTo(x + s2, y - ir);
ctx.lineTo(x - s2, y - ir);
ctx.lineTo(x, y + (h - ir));
ctx.closePath();
}
/**
* Draw a star.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param r - The outer radius of the star.
*/
function drawStar(ctx, x, y, r) {
// http://www.html5canvastutorials.com/labs/html5-canvas-star-spinner/
ctx.beginPath(); // the change in radius and the offset is here to center the shape
r *= 0.82;
y += 0.1 * r;
for (var n = 0; n < 10; n++) {
var radius = n % 2 === 0 ? r * 1.3 : r * 0.5;
ctx.lineTo(x + radius * Math.sin(n * 2 * Math.PI / 10), y - radius * Math.cos(n * 2 * Math.PI / 10));
}
ctx.closePath();
}
/**
* Draw a diamond.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param r - Half of the width and height of the diamond.
*
* @remarks
* http://www.html5canvastutorials.com/labs/html5-canvas-star-spinner/
*/
function drawDiamond(ctx, x, y, r) {
ctx.beginPath();
ctx.lineTo(x, y + r);
ctx.lineTo(x + r, y);
ctx.lineTo(x, y - r);
ctx.lineTo(x - r, y);
ctx.closePath();
}
/**
* Draw a rectangle with rounded corners.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param w - The width of the rectangle.
* @param h - The height of the rectangle.
* @param r - The radius of the corners.
*
* @remarks
* http://stackoverflow.com/questions/1255512/how-to-draw-a-rounded-rectangle-on-html-canvas
*/
function drawRoundRect(ctx, x, y, w, h, r) {
var r2d = Math.PI / 180;
if (w - 2 * r < 0) {
r = w / 2;
} //ensure that the radius isn't too large for x
if (h - 2 * r < 0) {
r = h / 2;
} //ensure that the radius isn't too large for y
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.arc(x + w - r, y + r, r, r2d * 270, r2d * 360, false);
ctx.lineTo(x + w, y + h - r);
ctx.arc(x + w - r, y + h - r, r, 0, r2d * 90, false);
ctx.lineTo(x + r, y + h);
ctx.arc(x + r, y + h - r, r, r2d * 90, r2d * 180, false);
ctx.lineTo(x, y + r);
ctx.arc(x + r, y + r, r, r2d * 180, r2d * 270, false);
ctx.closePath();
}
/**
* Draw an ellipse.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param w - The width of the ellipse.
* @param h - The height of the ellipse.
*
* @remarks
* http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
*
* Postfix '_vis' added to discern it from standard method ellipse().
*/
function drawEllipse(ctx, x, y, w, h) {
var kappa = 0.5522848,
ox = w / 2 * kappa,
// control point offset horizontal
oy = h / 2 * kappa,
// control point offset vertical
xe = x + w,
// x-end
ye = y + h,
// y-end
xm = x + w / 2,
// x-middle
ym = y + h / 2; // y-middle
ctx.beginPath();
ctx.moveTo(x, ym);
ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
ctx.closePath();
}
/**
* Draw an isometric cylinder.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param w - The width of the database.
* @param h - The height of the database.
*
* @remarks
* http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
*/
function drawDatabase(ctx, x, y, w, h) {
var f = 1 / 3;
var wEllipse = w;
var hEllipse = h * f;
var kappa = 0.5522848,
ox = wEllipse / 2 * kappa,
// control point offset horizontal
oy = hEllipse / 2 * kappa,
// control point offset vertical
xe = x + wEllipse,
// x-end
ye = y + hEllipse,
// y-end
xm = x + wEllipse / 2,
// x-middle
ym = y + hEllipse / 2,
// y-middle
ymb = y + (h - hEllipse / 2),
// y-midlle, bottom ellipse
yeb = y + h; // y-end, bottom ellipse
ctx.beginPath();
ctx.moveTo(xe, ym);
ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
ctx.lineTo(xe, ymb);
ctx.bezierCurveTo(xe, ymb + oy, xm + ox, yeb, xm, yeb);
ctx.bezierCurveTo(xm - ox, yeb, x, ymb + oy, x, ymb);
ctx.lineTo(x, ym);
}
/**
* Draw a dashed line.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The start position on the x axis.
* @param y - The start position on the y axis.
* @param x2 - The end position on the x axis.
* @param y2 - The end position on the y axis.
* @param pattern - List of lengths starting with line and then alternating between space and line.
*
* @author David Jordan
* @remarks
* date 2012-08-08
* http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas
*/
function drawDashedLine(ctx, x, y, x2, y2, pattern) {
ctx.beginPath();
ctx.moveTo(x, y);
var patternLength = pattern.length;
var dx = x2 - x;
var dy = y2 - y;
var slope = dy / dx;
var distRemaining = Math.sqrt(dx * dx + dy * dy);
var patternIndex = 0;
var draw = true;
var xStep = 0;
var dashLength = +pattern[0];
while (distRemaining >= 0.1) {
dashLength = +pattern[patternIndex++ % patternLength];
if (dashLength > distRemaining) {
dashLength = distRemaining;
}
xStep = Math.sqrt(dashLength * dashLength / (1 + slope * slope));
xStep = dx < 0 ? -xStep : xStep;
x += xStep;
y += slope * xStep;
if (draw === true) {
ctx.lineTo(x, y);
} else {
ctx.moveTo(x, y);
}
distRemaining -= dashLength;
draw = !draw;
}
}
/**
* Draw a hexagon.
*
* @param ctx - The context this shape will be rendered to.
* @param x - The position of the center on the x axis.
* @param y - The position of the center on the y axis.
* @param r - The radius of the hexagon.
*/
function drawHexagon(ctx, x, y, r) {
ctx.beginPath();
var sides = 6;
var a = Math.PI * 2 / sides;
ctx.moveTo(x + r, y);
for (var i = 1; i < sides; i++) {
ctx.lineTo(x + r * Math.cos(a * i), y + r * Math.sin(a * i));
}
ctx.closePath();
}
var shapeMap = {
circle: drawCircle,
dashedLine: drawDashedLine,
database: drawDatabase,
diamond: drawDiamond,
ellipse: drawEllipse,
ellipse_vis: drawEllipse,
hexagon: drawHexagon,
roundRect: drawRoundRect,
square: drawSquare,
star: drawStar,
triangle: drawTriangle,
triangleDown: drawTriangleDown
};
/**
* Returns either custom or native drawing function base on supplied name.
*
* @param name - The name of the function. Either the name of a
* CanvasRenderingContext2D property or an export from shapes.ts without the
* draw prefix.
*
* @returns The function that can be used for rendering. In case of native
* CanvasRenderingContext2D function the API is normalized to
* `(ctx: CanvasRenderingContext2D, ...originalArgs) => void`.
*/
function getShape(name) {
if (Object.prototype.hasOwnProperty.call(shapeMap, name)) {
return shapeMap[name];
} else {
return function (ctx) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
CanvasRenderingContext2D.prototype[name].call(ctx, args);
};
}
}
var componentEmitter = createCommonjsModule(function (module) {
/**
* Expose `Emitter`.
*/
{
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
}
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function (event, fn) {
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
this._callbacks = this._callbacks || {}; // all
if (0 == arguments.length) {
this._callbacks = {};
return this;
} // specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this; // remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
} // remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
} // Remove event specific arrays for event types that no
// one is subscribed for to avoid memory leak.
if (callbacks.length === 0) {
delete this._callbacks['$' + event];
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function (event) {
this._callbacks = this._callbacks || {};
var args = new Array(arguments.length - 1),
callbacks = this._callbacks['$' + event];
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function (event) {
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function (event) {
return !!this.listeners(event).length;
};
});
var toString_1 = function (argument) {
if (isSymbol(argument)) throw TypeError('Cannot convert a Symbol value to a string');
return String(argument);
};
var createMethod$4 = function (CONVERT_TO_STRING) {
return function ($this, pos) {
var S = toString_1(requireObjectCoercible($this));
var position = toInteger(pos);
var size = S.length;
var first, second;
if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
first = S.charCodeAt(position);
return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
};
};
var stringMultibyte = {
// `String.prototype.codePointAt` method
// https://tc39.es/ecma262/#sec-string.prototype.codepointat
codeAt: createMethod$4(false),
// `String.prototype.at` method
// https://github.com/mathiasbynens/String.prototype.at
charAt: createMethod$4(true)
};
var functionToString = Function.toString; // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
if (typeof sharedStore.inspectSource != 'function') {
sharedStore.inspectSource = function (it) {
return functionToString.call(it);
};
}
var inspectSource = sharedStore.inspectSource;
var WeakMap$1 = global_1.WeakMap;
var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(inspectSource(WeakMap$1));
var keys$6 = shared('keys');
var sharedKey = function (key) {
return keys$6[key] || (keys$6[key] = uid(key));
};
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
var WeakMap = global_1.WeakMap;
var set$3, get$6, has;
var enforce = function (it) {
return has(it) ? get$6(it) : set$3(it, {});
};
var getterFor = function (TYPE) {
return function (it) {
var state;
if (!isObject$1(it) || (state = get$6(it)).type !== TYPE) {
throw TypeError('Incompatible receiver, ' + TYPE + ' required');
}
return state;
};
};
if (nativeWeakMap || sharedStore.state) {
var store = sharedStore.state || (sharedStore.state = new WeakMap());
var wmget = store.get;
var wmhas = store.has;
var wmset = store.set;
set$3 = function (it, metadata) {
if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
wmset.call(store, it, metadata);
return metadata;
};
get$6 = function (it) {
return wmget.call(store, it) || {};
};
has = function (it) {
return wmhas.call(store, it);
};
} else {
var STATE = sharedKey('state');
hiddenKeys$1[STATE] = true;
set$3 = function (it, metadata) {
if (has$1(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
createNonEnumerableProperty(it, STATE, metadata);
return metadata;
};
get$6 = function (it) {
return has$1(it, STATE) ? it[STATE] : {};
};
has = function (it) {
return has$1(it, STATE);
};
}
var internalState = {
set: set$3,
get: get$6,
has: has,
enforce: enforce,
getterFor: getterFor
};
var correctPrototypeGetter = !fails(function () {
function F() {
/* empty */
}
F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
return Object.getPrototypeOf(new F()) !== F.prototype;
});
var IE_PROTO$1 = sharedKey('IE_PROTO');
var ObjectPrototype$1 = Object.prototype; // `Object.getPrototypeOf` method
// https://tc39.es/ecma262/#sec-object.getprototypeof
// eslint-disable-next-line es/no-object-getprototypeof -- safe
var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
O = toObject(O);
if (has$1(O, IE_PROTO$1)) return O[IE_PROTO$1];
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
return O.constructor.prototype;
}
return O instanceof Object ? ObjectPrototype$1 : null;
};
var ITERATOR$4 = wellKnownSymbol('iterator');
var BUGGY_SAFARI_ITERATORS$1 = false;
var returnThis$2 = function () {
return this;
}; // `%IteratorPrototype%` object
// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
/* eslint-disable es/no-array-prototype-keys -- safe */
if ([].keys) {
arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next`
if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true;else {
PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
}
}
var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails(function () {
var test = {}; // FF44- legacy iterators case
return IteratorPrototype$2[ITERATOR$4].call(test) !== test;
});
if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; // `%IteratorPrototype%[@@iterator]()` method
// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
if ((NEW_ITERATOR_PROTOTYPE) && !has$1(IteratorPrototype$2, ITERATOR$4)) {
createNonEnumerableProperty(IteratorPrototype$2, ITERATOR$4, returnThis$2);
}
var iteratorsCore = {
IteratorPrototype: IteratorPrototype$2,
BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1
};
// https://tc39.es/ecma262/#sec-object.defineproperties
// eslint-disable-next-line es/no-object-defineproperties -- safe
var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
anObject(O);
var keys = objectKeys(Properties);
var length = keys.length;
var index = 0;
var key;
while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
return O;
};
var html = getBuiltIn('document', 'documentElement');
/* global ActiveXObject -- old IE, WSH */
var GT = '>';
var LT = '<';
var PROTOTYPE$1 = 'prototype';
var SCRIPT = 'script';
var IE_PROTO = sharedKey('IE_PROTO');
var EmptyConstructor = function () {
/* empty */
};
var scriptTag = function (content) {
return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
}; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
var NullProtoObjectViaActiveX = function (activeXDocument) {
activeXDocument.write(scriptTag(''));
activeXDocument.close();
var temp = activeXDocument.parentWindow.Object;
activeXDocument = null; // avoid memory leak
return temp;
}; // Create object with fake `null` prototype: use iframe Object with cleared prototype
var NullProtoObjectViaIFrame = function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = documentCreateElement('iframe');
var JS = 'java' + SCRIPT + ':';
var iframeDocument;
if (iframe.style) {
iframe.style.display = 'none';
html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475
iframe.src = String(JS);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(scriptTag('document.F=Object'));
iframeDocument.close();
return iframeDocument.F;
}
}; // Check for document.domain and active x support
// No need to use active x approach when document.domain is not set
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
// avoid IE GC bug
var activeXDocument;
var NullProtoObject = function () {
try {
activeXDocument = new ActiveXObject('htmlfile');
} catch (error) {
/* ignore */
}
NullProtoObject = document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : // old IE
NullProtoObjectViaIFrame() || NullProtoObjectViaActiveX(activeXDocument); // WSH
var length = enumBugKeys.length;
while (length--) delete NullProtoObject[PROTOTYPE$1][enumBugKeys[length]];
return NullProtoObject();
};
hiddenKeys$1[IE_PROTO] = true; // `Object.create` method
// https://tc39.es/ecma262/#sec-object.create
var objectCreate = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
EmptyConstructor[PROTOTYPE$1] = anObject(O);
result = new EmptyConstructor();
EmptyConstructor[PROTOTYPE$1] = null; // add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = NullProtoObject();
return Properties === undefined ? result : objectDefineProperties(result, Properties);
};
var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
var test$2 = {};
test$2[TO_STRING_TAG$3] = 'z';
var toStringTagSupport = String(test$2) === '[object z]';
var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); // ES3 wrong here
var CORRECT_ARGUMENTS = classofRaw(function () {
return arguments;
}()) == 'Arguments'; // fallback for IE11 Script Access Denied error
var tryGet = function (it, key) {
try {
return it[key];
} catch (error) {
/* empty */
}
}; // getting tag from ES6+ `Object.prototype.toString`
var classof = toStringTagSupport ? classofRaw : function (it) {
var O, tag, result;
return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case
: typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$2)) == 'string' ? tag // builtinTag case
: CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback
: (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
};
// https://tc39.es/ecma262/#sec-object.prototype.tostring
var objectToString = toStringTagSupport ? {}.toString : function toString() {
return '[object ' + classof(this) + ']';
};
var defineProperty$8 = objectDefineProperty.f;
var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
var setToStringTag = function (it, TAG, STATIC, SET_METHOD) {
if (it) {
var target = STATIC ? it : it.prototype;
if (!has$1(target, TO_STRING_TAG$1)) {
defineProperty$8(target, TO_STRING_TAG$1, {
configurable: true,
value: TAG
});
}
if (SET_METHOD && !toStringTagSupport) {
createNonEnumerableProperty(target, 'toString', objectToString);
}
}
};
var iterators = {};
var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
var returnThis$1 = function () {
return this;
};
var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
var TO_STRING_TAG = NAME + ' Iterator';
IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, {
next: createPropertyDescriptor(1, next)
});
setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
iterators[TO_STRING_TAG] = returnThis$1;
return IteratorConstructor;
};
var aPossiblePrototype = function (it) {
if (!isObject$1(it) && it !== null) {
throw TypeError("Can't set " + String(it) + ' as a prototype');
}
return it;
};
/* eslint-disable no-proto -- safe */
// `Object.setPrototypeOf` method
// https://tc39.es/ecma262/#sec-object.setprototypeof
// Works with __proto__ only. Old v8 can't work with null proto objects.
// eslint-disable-next-line es/no-object-setprototypeof -- safe
var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
var CORRECT_SETTER = false;
var test = {};
var setter;
try {
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
setter.call(test, []);
CORRECT_SETTER = test instanceof Array;
} catch (error) {
/* empty */
}
return function setPrototypeOf(O, proto) {
anObject(O);
aPossiblePrototype(proto);
if (CORRECT_SETTER) setter.call(O, proto);else O.__proto__ = proto;
return O;
};
}() : undefined);
var redefine = function (target, key, value, options) {
if (options && options.enumerable) target[key] = value;else createNonEnumerableProperty(target, key, value);
};
v