cypress-visibility

Code - github/cypress-io/cypress - to check if an element is visible

이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greatest.deepsurf.us/scripts/482857/1397356/cypress-visibility.js을(를) 사용하여 포함하는 라이브러리입니다.

  1. // ==UserScript==
  2. // @name cypress-visibility
  3. // @namespace flomk.userscripts
  4. // @version 1.4
  5. // @description Code - github/cypress-io/cypress - to check if an element is visible
  6. // @author flomk
  7. // @grant none
  8. // @include *
  9. // @connect unpkg.com
  10. // ==/UserScript==
  11.  
  12. ((global, factory) => {
  13. global = typeof globalThis !== 'undefined' ? globalThis : global || self;
  14. factory(global.cypressVisibility={});
  15. })(this, exports => {
  16. const _ = function (exports) {
  17. 'use strict';
  18.  
  19. function isObject(value) {
  20. var type = typeof value;
  21. return value != null && (type == 'object' || type == 'function');
  22. }
  23. var objectCreate = Object.create;
  24. var baseCreate = function () {
  25. function object() {}
  26. return function (proto) {
  27. if (!isObject(proto)) {
  28. return {};
  29. }
  30. if (objectCreate) {
  31. return objectCreate(proto);
  32. }
  33. object.prototype = proto;
  34. var result = new object();
  35. object.prototype = undefined;
  36. return result;
  37. };
  38. }();
  39. function baseLodash() {}
  40. var MAX_ARRAY_LENGTH = 4294967295;
  41. function LazyWrapper(value) {
  42. this.__wrapped__ = value;
  43. this.__actions__ = [];
  44. this.__dir__ = 1;
  45. this.__filtered__ = false;
  46. this.__iteratees__ = [];
  47. this.__takeCount__ = MAX_ARRAY_LENGTH;
  48. this.__views__ = [];
  49. }
  50. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  51. LazyWrapper.prototype.constructor = LazyWrapper;
  52. function LodashWrapper(value, chainAll) {
  53. this.__wrapped__ = value;
  54. this.__actions__ = [];
  55. this.__chain__ = !!chainAll;
  56. this.__index__ = 0;
  57. this.__values__ = undefined;
  58. }
  59. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  60. LodashWrapper.prototype.constructor = LodashWrapper;
  61. var isArray = Array.isArray;
  62. function isObjectLike(value) {
  63. return value != null && typeof value == 'object';
  64. }
  65. function copyArray(source, array) {
  66. var index = -1,
  67. length = source.length;
  68. array || (array = Array(length));
  69. while (++index < length) {
  70. array[index] = source[index];
  71. }
  72. return array;
  73. }
  74. function wrapperClone(wrapper) {
  75. if (wrapper instanceof LazyWrapper) {
  76. return wrapper.clone();
  77. }
  78. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  79. result.__actions__ = copyArray(wrapper.__actions__);
  80. result.__index__ = wrapper.__index__;
  81. result.__values__ = wrapper.__values__;
  82. return result;
  83. }
  84. var objectProto$e = Object.prototype;
  85. var hasOwnProperty$b = objectProto$e.hasOwnProperty;
  86. function lodash(value) {
  87. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  88. if (value instanceof LodashWrapper) {
  89. return value;
  90. }
  91. if (hasOwnProperty$b.call(value, '__wrapped__')) {
  92. return wrapperClone(value);
  93. }
  94. }
  95. return new LodashWrapper(value);
  96. }
  97. lodash.prototype = baseLodash.prototype;
  98. lodash.prototype.constructor = lodash;
  99. function chain(value) {
  100. var result = lodash(value);
  101. result.__chain__ = true;
  102. return result;
  103. }
  104. function listCacheClear() {
  105. this.__data__ = [];
  106. this.size = 0;
  107. }
  108. function eq(value, other) {
  109. return value === other || value !== value && other !== other;
  110. }
  111. function assocIndexOf(array, key) {
  112. var length = array.length;
  113. while (length--) {
  114. if (eq(array[length][0], key)) {
  115. return length;
  116. }
  117. }
  118. return -1;
  119. }
  120. var arrayProto = Array.prototype;
  121. var splice = arrayProto.splice;
  122. function listCacheDelete(key) {
  123. var data = this.__data__,
  124. index = assocIndexOf(data, key);
  125. if (index < 0) {
  126. return false;
  127. }
  128. var lastIndex = data.length - 1;
  129. if (index == lastIndex) {
  130. data.pop();
  131. } else {
  132. splice.call(data, index, 1);
  133. }
  134. --this.size;
  135. return true;
  136. }
  137. function listCacheGet(key) {
  138. var data = this.__data__,
  139. index = assocIndexOf(data, key);
  140. return index < 0 ? undefined : data[index][1];
  141. }
  142. function listCacheHas(key) {
  143. return assocIndexOf(this.__data__, key) > -1;
  144. }
  145. function listCacheSet(key, value) {
  146. var data = this.__data__,
  147. index = assocIndexOf(data, key);
  148. if (index < 0) {
  149. ++this.size;
  150. data.push([key, value]);
  151. } else {
  152. data[index][1] = value;
  153. }
  154. return this;
  155. }
  156. function ListCache(entries) {
  157. var index = -1,
  158. length = entries == null ? 0 : entries.length;
  159. this.clear();
  160. while (++index < length) {
  161. var entry = entries[index];
  162. this.set(entry[0], entry[1]);
  163. }
  164. }
  165. ListCache.prototype.clear = listCacheClear;
  166. ListCache.prototype['delete'] = listCacheDelete;
  167. ListCache.prototype.get = listCacheGet;
  168. ListCache.prototype.has = listCacheHas;
  169. ListCache.prototype.set = listCacheSet;
  170. function stackClear() {
  171. this.__data__ = new ListCache();
  172. this.size = 0;
  173. }
  174. function stackDelete(key) {
  175. var data = this.__data__,
  176. result = data['delete'](key);
  177. this.size = data.size;
  178. return result;
  179. }
  180. function stackGet(key) {
  181. return this.__data__.get(key);
  182. }
  183. function stackHas(key) {
  184. return this.__data__.has(key);
  185. }
  186. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  187. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  188. var root = freeGlobal || freeSelf || Function('return this')();
  189. var Symbol = root.Symbol;
  190. var objectProto$d = Object.prototype;
  191. var hasOwnProperty$a = objectProto$d.hasOwnProperty;
  192. var nativeObjectToString$1 = objectProto$d.toString;
  193. var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
  194. function getRawTag(value) {
  195. var isOwn = hasOwnProperty$a.call(value, symToStringTag$1),
  196. tag = value[symToStringTag$1];
  197. try {
  198. value[symToStringTag$1] = undefined;
  199. var unmasked = true;
  200. } catch (e) {}
  201. var result = nativeObjectToString$1.call(value);
  202. if (unmasked) {
  203. if (isOwn) {
  204. value[symToStringTag$1] = tag;
  205. } else {
  206. delete value[symToStringTag$1];
  207. }
  208. }
  209. return result;
  210. }
  211. var objectProto$c = Object.prototype;
  212. var nativeObjectToString = objectProto$c.toString;
  213. function objectToString(value) {
  214. return nativeObjectToString.call(value);
  215. }
  216. var nullTag = '[object Null]',
  217. undefinedTag = '[object Undefined]';
  218. var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  219. function baseGetTag(value) {
  220. if (value == null) {
  221. return value === undefined ? undefinedTag : nullTag;
  222. }
  223. return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
  224. }
  225. var asyncTag = '[object AsyncFunction]',
  226. funcTag$1 = '[object Function]',
  227. genTag = '[object GeneratorFunction]',
  228. proxyTag = '[object Proxy]';
  229. function isFunction(value) {
  230. if (!isObject(value)) {
  231. return false;
  232. }
  233. var tag = baseGetTag(value);
  234. return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
  235. }
  236. var coreJsData = root['__core-js_shared__'];
  237. var maskSrcKey = function () {
  238. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  239. return uid ? 'Symbol(src)_1.' + uid : '';
  240. }();
  241. function isMasked(func) {
  242. return !!maskSrcKey && maskSrcKey in func;
  243. }
  244. var funcProto$2 = Function.prototype;
  245. var funcToString$2 = funcProto$2.toString;
  246. function toSource(func) {
  247. if (func != null) {
  248. try {
  249. return funcToString$2.call(func);
  250. } catch (e) {}
  251. try {
  252. return func + '';
  253. } catch (e) {}
  254. }
  255. return '';
  256. }
  257. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  258. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  259. var funcProto$1 = Function.prototype,
  260. objectProto$b = Object.prototype;
  261. var funcToString$1 = funcProto$1.toString;
  262. var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
  263. var reIsNative = RegExp('^' + funcToString$1.call(hasOwnProperty$9).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  264. function baseIsNative(value) {
  265. if (!isObject(value) || isMasked(value)) {
  266. return false;
  267. }
  268. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  269. return pattern.test(toSource(value));
  270. }
  271. function getValue(object, key) {
  272. return object == null ? undefined : object[key];
  273. }
  274. function getNative(object, key) {
  275. var value = getValue(object, key);
  276. return baseIsNative(value) ? value : undefined;
  277. }
  278. var Map = getNative(root, 'Map');
  279. var nativeCreate = getNative(Object, 'create');
  280. function hashClear() {
  281. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  282. this.size = 0;
  283. }
  284. function hashDelete(key) {
  285. var result = this.has(key) && delete this.__data__[key];
  286. this.size -= result ? 1 : 0;
  287. return result;
  288. }
  289. var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
  290. var objectProto$a = Object.prototype;
  291. var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
  292. function hashGet(key) {
  293. var data = this.__data__;
  294. if (nativeCreate) {
  295. var result = data[key];
  296. return result === HASH_UNDEFINED$2 ? undefined : result;
  297. }
  298. return hasOwnProperty$8.call(data, key) ? data[key] : undefined;
  299. }
  300. var objectProto$9 = Object.prototype;
  301. var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
  302. function hashHas(key) {
  303. var data = this.__data__;
  304. return nativeCreate ? data[key] !== undefined : hasOwnProperty$7.call(data, key);
  305. }
  306. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  307. function hashSet(key, value) {
  308. var data = this.__data__;
  309. this.size += this.has(key) ? 0 : 1;
  310. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
  311. return this;
  312. }
  313. function Hash(entries) {
  314. var index = -1,
  315. length = entries == null ? 0 : entries.length;
  316. this.clear();
  317. while (++index < length) {
  318. var entry = entries[index];
  319. this.set(entry[0], entry[1]);
  320. }
  321. }
  322. Hash.prototype.clear = hashClear;
  323. Hash.prototype['delete'] = hashDelete;
  324. Hash.prototype.get = hashGet;
  325. Hash.prototype.has = hashHas;
  326. Hash.prototype.set = hashSet;
  327. function mapCacheClear() {
  328. this.size = 0;
  329. this.__data__ = {
  330. 'hash': new Hash(),
  331. 'map': new (Map || ListCache)(),
  332. 'string': new Hash()
  333. };
  334. }
  335. function isKeyable(value) {
  336. var type = typeof value;
  337. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  338. }
  339. function getMapData(map, key) {
  340. var data = map.__data__;
  341. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  342. }
  343. function mapCacheDelete(key) {
  344. var result = getMapData(this, key)['delete'](key);
  345. this.size -= result ? 1 : 0;
  346. return result;
  347. }
  348. function mapCacheGet(key) {
  349. return getMapData(this, key).get(key);
  350. }
  351. function mapCacheHas(key) {
  352. return getMapData(this, key).has(key);
  353. }
  354. function mapCacheSet(key, value) {
  355. var data = getMapData(this, key),
  356. size = data.size;
  357. data.set(key, value);
  358. this.size += data.size == size ? 0 : 1;
  359. return this;
  360. }
  361. function MapCache(entries) {
  362. var index = -1,
  363. length = entries == null ? 0 : entries.length;
  364. this.clear();
  365. while (++index < length) {
  366. var entry = entries[index];
  367. this.set(entry[0], entry[1]);
  368. }
  369. }
  370. MapCache.prototype.clear = mapCacheClear;
  371. MapCache.prototype['delete'] = mapCacheDelete;
  372. MapCache.prototype.get = mapCacheGet;
  373. MapCache.prototype.has = mapCacheHas;
  374. MapCache.prototype.set = mapCacheSet;
  375. var LARGE_ARRAY_SIZE = 200;
  376. function stackSet(key, value) {
  377. var data = this.__data__;
  378. if (data instanceof ListCache) {
  379. var pairs = data.__data__;
  380. if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
  381. pairs.push([key, value]);
  382. this.size = ++data.size;
  383. return this;
  384. }
  385. data = this.__data__ = new MapCache(pairs);
  386. }
  387. data.set(key, value);
  388. this.size = data.size;
  389. return this;
  390. }
  391. function Stack(entries) {
  392. var data = this.__data__ = new ListCache(entries);
  393. this.size = data.size;
  394. }
  395. Stack.prototype.clear = stackClear;
  396. Stack.prototype['delete'] = stackDelete;
  397. Stack.prototype.get = stackGet;
  398. Stack.prototype.has = stackHas;
  399. Stack.prototype.set = stackSet;
  400. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  401. function setCacheAdd(value) {
  402. this.__data__.set(value, HASH_UNDEFINED);
  403. return this;
  404. }
  405. function setCacheHas(value) {
  406. return this.__data__.has(value);
  407. }
  408. function SetCache(values) {
  409. var index = -1,
  410. length = values == null ? 0 : values.length;
  411. this.__data__ = new MapCache();
  412. while (++index < length) {
  413. this.add(values[index]);
  414. }
  415. }
  416. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  417. SetCache.prototype.has = setCacheHas;
  418. function arraySome(array, predicate) {
  419. var index = -1,
  420. length = array == null ? 0 : array.length;
  421. while (++index < length) {
  422. if (predicate(array[index], index, array)) {
  423. return true;
  424. }
  425. }
  426. return false;
  427. }
  428. function cacheHas(cache, key) {
  429. return cache.has(key);
  430. }
  431. var COMPARE_PARTIAL_FLAG$5 = 1,
  432. COMPARE_UNORDERED_FLAG$3 = 2;
  433. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  434. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
  435. arrLength = array.length,
  436. othLength = other.length;
  437. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  438. return false;
  439. }
  440. var arrStacked = stack.get(array);
  441. var othStacked = stack.get(other);
  442. if (arrStacked && othStacked) {
  443. return arrStacked == other && othStacked == array;
  444. }
  445. var index = -1,
  446. result = true,
  447. seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : undefined;
  448. stack.set(array, other);
  449. stack.set(other, array);
  450. while (++index < arrLength) {
  451. var arrValue = array[index],
  452. othValue = other[index];
  453. if (customizer) {
  454. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  455. }
  456. if (compared !== undefined) {
  457. if (compared) {
  458. continue;
  459. }
  460. result = false;
  461. break;
  462. }
  463. if (seen) {
  464. if (!arraySome(other, function (othValue, othIndex) {
  465. if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  466. return seen.push(othIndex);
  467. }
  468. })) {
  469. result = false;
  470. break;
  471. }
  472. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  473. result = false;
  474. break;
  475. }
  476. }
  477. stack['delete'](array);
  478. stack['delete'](other);
  479. return result;
  480. }
  481. var Uint8Array = root.Uint8Array;
  482. function mapToArray(map) {
  483. var index = -1,
  484. result = Array(map.size);
  485. map.forEach(function (value, key) {
  486. result[++index] = [key, value];
  487. });
  488. return result;
  489. }
  490. function setToArray(set) {
  491. var index = -1,
  492. result = Array(set.size);
  493. set.forEach(function (value) {
  494. result[++index] = value;
  495. });
  496. return result;
  497. }
  498. var COMPARE_PARTIAL_FLAG$4 = 1,
  499. COMPARE_UNORDERED_FLAG$2 = 2;
  500. var boolTag$1 = '[object Boolean]',
  501. dateTag$1 = '[object Date]',
  502. errorTag$1 = '[object Error]',
  503. mapTag$2 = '[object Map]',
  504. numberTag$1 = '[object Number]',
  505. regexpTag$1 = '[object RegExp]',
  506. setTag$2 = '[object Set]',
  507. stringTag$2 = '[object String]',
  508. symbolTag$1 = '[object Symbol]';
  509. var arrayBufferTag$1 = '[object ArrayBuffer]',
  510. dataViewTag$2 = '[object DataView]';
  511. var symbolProto$1 = Symbol ? Symbol.prototype : undefined,
  512. symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
  513. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  514. switch (tag) {
  515. case dataViewTag$2:
  516. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  517. return false;
  518. }
  519. object = object.buffer;
  520. other = other.buffer;
  521. case arrayBufferTag$1:
  522. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  523. return false;
  524. }
  525. return true;
  526. case boolTag$1:
  527. case dateTag$1:
  528. case numberTag$1:
  529. return eq(+object, +other);
  530. case errorTag$1:
  531. return object.name == other.name && object.message == other.message;
  532. case regexpTag$1:
  533. case stringTag$2:
  534. return object == other + '';
  535. case mapTag$2:
  536. var convert = mapToArray;
  537. case setTag$2:
  538. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
  539. convert || (convert = setToArray);
  540. if (object.size != other.size && !isPartial) {
  541. return false;
  542. }
  543. var stacked = stack.get(object);
  544. if (stacked) {
  545. return stacked == other;
  546. }
  547. bitmask |= COMPARE_UNORDERED_FLAG$2;
  548. stack.set(object, other);
  549. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  550. stack['delete'](object);
  551. return result;
  552. case symbolTag$1:
  553. if (symbolValueOf) {
  554. return symbolValueOf.call(object) == symbolValueOf.call(other);
  555. }
  556. }
  557. return false;
  558. }
  559. function arrayPush(array, values) {
  560. var index = -1,
  561. length = values.length,
  562. offset = array.length;
  563. while (++index < length) {
  564. array[offset + index] = values[index];
  565. }
  566. return array;
  567. }
  568. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  569. var result = keysFunc(object);
  570. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  571. }
  572. function arrayFilter(array, predicate) {
  573. var index = -1,
  574. length = array == null ? 0 : array.length,
  575. resIndex = 0,
  576. result = [];
  577. while (++index < length) {
  578. var value = array[index];
  579. if (predicate(value, index, array)) {
  580. result[resIndex++] = value;
  581. }
  582. }
  583. return result;
  584. }
  585. function stubArray() {
  586. return [];
  587. }
  588. var objectProto$8 = Object.prototype;
  589. var propertyIsEnumerable$1 = objectProto$8.propertyIsEnumerable;
  590. var nativeGetSymbols = Object.getOwnPropertySymbols;
  591. var getSymbols = !nativeGetSymbols ? stubArray : function (object) {
  592. if (object == null) {
  593. return [];
  594. }
  595. object = Object(object);
  596. return arrayFilter(nativeGetSymbols(object), function (symbol) {
  597. return propertyIsEnumerable$1.call(object, symbol);
  598. });
  599. };
  600. function baseTimes(n, iteratee) {
  601. var index = -1,
  602. result = Array(n);
  603. while (++index < n) {
  604. result[index] = iteratee(index);
  605. }
  606. return result;
  607. }
  608. var argsTag$2 = '[object Arguments]';
  609. function baseIsArguments(value) {
  610. return isObjectLike(value) && baseGetTag(value) == argsTag$2;
  611. }
  612. var objectProto$7 = Object.prototype;
  613. var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
  614. var propertyIsEnumerable = objectProto$7.propertyIsEnumerable;
  615. var isArguments = baseIsArguments(function () {
  616. return arguments;
  617. }()) ? baseIsArguments : function (value) {
  618. return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  619. };
  620. function stubFalse() {
  621. return false;
  622. }
  623. var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
  624. var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
  625. var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
  626. var Buffer = moduleExports$1 ? root.Buffer : undefined;
  627. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  628. var isBuffer = nativeIsBuffer || stubFalse;
  629. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  630. var reIsUint = /^(?:0|[1-9]\d*)$/;
  631. function isIndex(value, length) {
  632. var type = typeof value;
  633. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  634. return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  635. }
  636. var MAX_SAFE_INTEGER = 9007199254740991;
  637. function isLength(value) {
  638. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  639. }
  640. var argsTag$1 = '[object Arguments]',
  641. arrayTag$1 = '[object Array]',
  642. boolTag = '[object Boolean]',
  643. dateTag = '[object Date]',
  644. errorTag = '[object Error]',
  645. funcTag = '[object Function]',
  646. mapTag$1 = '[object Map]',
  647. numberTag = '[object Number]',
  648. objectTag$3 = '[object Object]',
  649. regexpTag = '[object RegExp]',
  650. setTag$1 = '[object Set]',
  651. stringTag$1 = '[object String]',
  652. weakMapTag$1 = '[object WeakMap]';
  653. var arrayBufferTag = '[object ArrayBuffer]',
  654. dataViewTag$1 = '[object DataView]',
  655. float32Tag = '[object Float32Array]',
  656. float64Tag = '[object Float64Array]',
  657. int8Tag = '[object Int8Array]',
  658. int16Tag = '[object Int16Array]',
  659. int32Tag = '[object Int32Array]',
  660. uint8Tag = '[object Uint8Array]',
  661. uint8ClampedTag = '[object Uint8ClampedArray]',
  662. uint16Tag = '[object Uint16Array]',
  663. uint32Tag = '[object Uint32Array]';
  664. var typedArrayTags = {};
  665. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  666. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag] = typedArrayTags[setTag$1] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
  667. function baseIsTypedArray(value) {
  668. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  669. }
  670. function baseUnary(func) {
  671. return function (value) {
  672. return func(value);
  673. };
  674. }
  675. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  676. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  677. var moduleExports = freeModule && freeModule.exports === freeExports;
  678. var freeProcess = moduleExports && freeGlobal.process;
  679. var nodeUtil = function () {
  680. try {
  681. var types = freeModule && freeModule.require && freeModule.require('util').types;
  682. if (types) {
  683. return types;
  684. }
  685. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  686. } catch (e) {}
  687. }();
  688. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  689. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  690. var objectProto$6 = Object.prototype;
  691. var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
  692. function arrayLikeKeys(value, inherited) {
  693. var isArr = isArray(value),
  694. isArg = !isArr && isArguments(value),
  695. isBuff = !isArr && !isArg && isBuffer(value),
  696. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  697. skipIndexes = isArr || isArg || isBuff || isType,
  698. result = skipIndexes ? baseTimes(value.length, String) : [],
  699. length = result.length;
  700. for (var key in value) {
  701. if ((inherited || hasOwnProperty$5.call(value, key)) && !(skipIndexes && (key == 'length' || isBuff && (key == 'offset' || key == 'parent') || isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || isIndex(key, length)))) {
  702. result.push(key);
  703. }
  704. }
  705. return result;
  706. }
  707. var objectProto$5 = Object.prototype;
  708. function isPrototype(value) {
  709. var Ctor = value && value.constructor,
  710. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$5;
  711. return value === proto;
  712. }
  713. function overArg(func, transform) {
  714. return function (arg) {
  715. return func(transform(arg));
  716. };
  717. }
  718. var nativeKeys = overArg(Object.keys, Object);
  719. var objectProto$4 = Object.prototype;
  720. var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
  721. function baseKeys(object) {
  722. if (!isPrototype(object)) {
  723. return nativeKeys(object);
  724. }
  725. var result = [];
  726. for (var key in Object(object)) {
  727. if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
  728. result.push(key);
  729. }
  730. }
  731. return result;
  732. }
  733. function isArrayLike(value) {
  734. return value != null && isLength(value.length) && !isFunction(value);
  735. }
  736. function keys(object) {
  737. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  738. }
  739. function getAllKeys(object) {
  740. return baseGetAllKeys(object, keys, getSymbols);
  741. }
  742. var COMPARE_PARTIAL_FLAG$3 = 1;
  743. var objectProto$3 = Object.prototype;
  744. var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  745. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  746. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
  747. objProps = getAllKeys(object),
  748. objLength = objProps.length,
  749. othProps = getAllKeys(other),
  750. othLength = othProps.length;
  751. if (objLength != othLength && !isPartial) {
  752. return false;
  753. }
  754. var index = objLength;
  755. while (index--) {
  756. var key = objProps[index];
  757. if (!(isPartial ? key in other : hasOwnProperty$3.call(other, key))) {
  758. return false;
  759. }
  760. }
  761. var objStacked = stack.get(object);
  762. var othStacked = stack.get(other);
  763. if (objStacked && othStacked) {
  764. return objStacked == other && othStacked == object;
  765. }
  766. var result = true;
  767. stack.set(object, other);
  768. stack.set(other, object);
  769. var skipCtor = isPartial;
  770. while (++index < objLength) {
  771. key = objProps[index];
  772. var objValue = object[key],
  773. othValue = other[key];
  774. if (customizer) {
  775. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  776. }
  777. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
  778. result = false;
  779. break;
  780. }
  781. skipCtor || (skipCtor = key == 'constructor');
  782. }
  783. if (result && !skipCtor) {
  784. var objCtor = object.constructor,
  785. othCtor = other.constructor;
  786. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  787. result = false;
  788. }
  789. }
  790. stack['delete'](object);
  791. stack['delete'](other);
  792. return result;
  793. }
  794. var DataView = getNative(root, 'DataView');
  795. var Promise$1 = getNative(root, 'Promise');
  796. var Set = getNative(root, 'Set');
  797. var WeakMap = getNative(root, 'WeakMap');
  798. var mapTag = '[object Map]',
  799. objectTag$2 = '[object Object]',
  800. promiseTag = '[object Promise]',
  801. setTag = '[object Set]',
  802. weakMapTag = '[object WeakMap]';
  803. var dataViewTag = '[object DataView]';
  804. var dataViewCtorString = toSource(DataView),
  805. mapCtorString = toSource(Map),
  806. promiseCtorString = toSource(Promise$1),
  807. setCtorString = toSource(Set),
  808. weakMapCtorString = toSource(WeakMap);
  809. var getTag = baseGetTag;
  810. if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
  811. getTag = function (value) {
  812. var result = baseGetTag(value),
  813. Ctor = result == objectTag$2 ? value.constructor : undefined,
  814. ctorString = Ctor ? toSource(Ctor) : '';
  815. if (ctorString) {
  816. switch (ctorString) {
  817. case dataViewCtorString:
  818. return dataViewTag;
  819. case mapCtorString:
  820. return mapTag;
  821. case promiseCtorString:
  822. return promiseTag;
  823. case setCtorString:
  824. return setTag;
  825. case weakMapCtorString:
  826. return weakMapTag;
  827. }
  828. }
  829. return result;
  830. };
  831. }
  832. var getTag$1 = getTag;
  833. var COMPARE_PARTIAL_FLAG$2 = 1;
  834. var argsTag = '[object Arguments]',
  835. arrayTag = '[object Array]',
  836. objectTag$1 = '[object Object]';
  837. var objectProto$2 = Object.prototype;
  838. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  839. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  840. var objIsArr = isArray(object),
  841. othIsArr = isArray(other),
  842. objTag = objIsArr ? arrayTag : getTag$1(object),
  843. othTag = othIsArr ? arrayTag : getTag$1(other);
  844. objTag = objTag == argsTag ? objectTag$1 : objTag;
  845. othTag = othTag == argsTag ? objectTag$1 : othTag;
  846. var objIsObj = objTag == objectTag$1,
  847. othIsObj = othTag == objectTag$1,
  848. isSameTag = objTag == othTag;
  849. if (isSameTag && isBuffer(object)) {
  850. if (!isBuffer(other)) {
  851. return false;
  852. }
  853. objIsArr = true;
  854. objIsObj = false;
  855. }
  856. if (isSameTag && !objIsObj) {
  857. stack || (stack = new Stack());
  858. return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  859. }
  860. if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
  861. var objIsWrapped = objIsObj && hasOwnProperty$2.call(object, '__wrapped__'),
  862. othIsWrapped = othIsObj && hasOwnProperty$2.call(other, '__wrapped__');
  863. if (objIsWrapped || othIsWrapped) {
  864. var objUnwrapped = objIsWrapped ? object.value() : object,
  865. othUnwrapped = othIsWrapped ? other.value() : other;
  866. stack || (stack = new Stack());
  867. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  868. }
  869. }
  870. if (!isSameTag) {
  871. return false;
  872. }
  873. stack || (stack = new Stack());
  874. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  875. }
  876. function baseIsEqual(value, other, bitmask, customizer, stack) {
  877. if (value === other) {
  878. return true;
  879. }
  880. if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
  881. return value !== value && other !== other;
  882. }
  883. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  884. }
  885. var COMPARE_PARTIAL_FLAG$1 = 1,
  886. COMPARE_UNORDERED_FLAG$1 = 2;
  887. function baseIsMatch(object, source, matchData, customizer) {
  888. var index = matchData.length,
  889. length = index,
  890. noCustomizer = !customizer;
  891. if (object == null) {
  892. return !length;
  893. }
  894. object = Object(object);
  895. while (index--) {
  896. var data = matchData[index];
  897. if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  898. return false;
  899. }
  900. }
  901. while (++index < length) {
  902. data = matchData[index];
  903. var key = data[0],
  904. objValue = object[key],
  905. srcValue = data[1];
  906. if (noCustomizer && data[2]) {
  907. if (objValue === undefined && !(key in object)) {
  908. return false;
  909. }
  910. } else {
  911. var stack = new Stack();
  912. if (customizer) {
  913. var result = customizer(objValue, srcValue, key, object, source, stack);
  914. }
  915. if (!(result === undefined ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
  916. return false;
  917. }
  918. }
  919. }
  920. return true;
  921. }
  922. function isStrictComparable(value) {
  923. return value === value && !isObject(value);
  924. }
  925. function getMatchData(object) {
  926. var result = keys(object),
  927. length = result.length;
  928. while (length--) {
  929. var key = result[length],
  930. value = object[key];
  931. result[length] = [key, value, isStrictComparable(value)];
  932. }
  933. return result;
  934. }
  935. function matchesStrictComparable(key, srcValue) {
  936. return function (object) {
  937. if (object == null) {
  938. return false;
  939. }
  940. return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
  941. };
  942. }
  943. function baseMatches(source) {
  944. var matchData = getMatchData(source);
  945. if (matchData.length == 1 && matchData[0][2]) {
  946. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  947. }
  948. return function (object) {
  949. return object === source || baseIsMatch(object, source, matchData);
  950. };
  951. }
  952. var symbolTag = '[object Symbol]';
  953. function isSymbol(value) {
  954. return typeof value == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag;
  955. }
  956. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  957. reIsPlainProp = /^\w*$/;
  958. function isKey(value, object) {
  959. if (isArray(value)) {
  960. return false;
  961. }
  962. var type = typeof value;
  963. if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
  964. return true;
  965. }
  966. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  967. }
  968. var FUNC_ERROR_TEXT = 'Expected a function';
  969. function memoize(func, resolver) {
  970. if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
  971. throw new TypeError(FUNC_ERROR_TEXT);
  972. }
  973. var memoized = function () {
  974. var args = arguments,
  975. key = resolver ? resolver.apply(this, args) : args[0],
  976. cache = memoized.cache;
  977. if (cache.has(key)) {
  978. return cache.get(key);
  979. }
  980. var result = func.apply(this, args);
  981. memoized.cache = cache.set(key, result) || cache;
  982. return result;
  983. };
  984. memoized.cache = new (memoize.Cache || MapCache)();
  985. return memoized;
  986. }
  987. memoize.Cache = MapCache;
  988. var MAX_MEMOIZE_SIZE = 500;
  989. function memoizeCapped(func) {
  990. var result = memoize(func, function (key) {
  991. if (cache.size === MAX_MEMOIZE_SIZE) {
  992. cache.clear();
  993. }
  994. return key;
  995. });
  996. var cache = result.cache;
  997. return result;
  998. }
  999. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1000. var reEscapeChar = /\\(\\)?/g;
  1001. var stringToPath = memoizeCapped(function (string) {
  1002. var result = [];
  1003. if (string.charCodeAt(0) === 46) {
  1004. result.push('');
  1005. }
  1006. string.replace(rePropName, function (match, number, quote, subString) {
  1007. result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
  1008. });
  1009. return result;
  1010. });
  1011. function arrayMap(array, iteratee) {
  1012. var index = -1,
  1013. length = array == null ? 0 : array.length,
  1014. result = Array(length);
  1015. while (++index < length) {
  1016. result[index] = iteratee(array[index], index, array);
  1017. }
  1018. return result;
  1019. }
  1020. var INFINITY$2 = 1 / 0;
  1021. var symbolProto = Symbol ? Symbol.prototype : undefined,
  1022. symbolToString = symbolProto ? symbolProto.toString : undefined;
  1023. function baseToString(value) {
  1024. if (typeof value == 'string') {
  1025. return value;
  1026. }
  1027. if (isArray(value)) {
  1028. return arrayMap(value, baseToString) + '';
  1029. }
  1030. if (isSymbol(value)) {
  1031. return symbolToString ? symbolToString.call(value) : '';
  1032. }
  1033. var result = value + '';
  1034. return result == '0' && 1 / value == -INFINITY$2 ? '-0' : result;
  1035. }
  1036. function toString(value) {
  1037. return value == null ? '' : baseToString(value);
  1038. }
  1039. function castPath(value, object) {
  1040. if (isArray(value)) {
  1041. return value;
  1042. }
  1043. return isKey(value, object) ? [value] : stringToPath(toString(value));
  1044. }
  1045. var INFINITY$1 = 1 / 0;
  1046. function toKey(value) {
  1047. if (typeof value == 'string' || isSymbol(value)) {
  1048. return value;
  1049. }
  1050. var result = value + '';
  1051. return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
  1052. }
  1053. function baseGet(object, path) {
  1054. path = castPath(path, object);
  1055. var index = 0,
  1056. length = path.length;
  1057. while (object != null && index < length) {
  1058. object = object[toKey(path[index++])];
  1059. }
  1060. return index && index == length ? object : undefined;
  1061. }
  1062. function get(object, path, defaultValue) {
  1063. var result = object == null ? undefined : baseGet(object, path);
  1064. return result === undefined ? defaultValue : result;
  1065. }
  1066. function baseHasIn(object, key) {
  1067. return object != null && key in Object(object);
  1068. }
  1069. function hasPath(object, path, hasFunc) {
  1070. path = castPath(path, object);
  1071. var index = -1,
  1072. length = path.length,
  1073. result = false;
  1074. while (++index < length) {
  1075. var key = toKey(path[index]);
  1076. if (!(result = object != null && hasFunc(object, key))) {
  1077. break;
  1078. }
  1079. object = object[key];
  1080. }
  1081. if (result || ++index != length) {
  1082. return result;
  1083. }
  1084. length = object == null ? 0 : object.length;
  1085. return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
  1086. }
  1087. function hasIn(object, path) {
  1088. return object != null && hasPath(object, path, baseHasIn);
  1089. }
  1090. var COMPARE_PARTIAL_FLAG = 1,
  1091. COMPARE_UNORDERED_FLAG = 2;
  1092. function baseMatchesProperty(path, srcValue) {
  1093. if (isKey(path) && isStrictComparable(srcValue)) {
  1094. return matchesStrictComparable(toKey(path), srcValue);
  1095. }
  1096. return function (object) {
  1097. var objValue = get(object, path);
  1098. return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  1099. };
  1100. }
  1101. function identity(value) {
  1102. return value;
  1103. }
  1104. function baseProperty(key) {
  1105. return function (object) {
  1106. return object == null ? undefined : object[key];
  1107. };
  1108. }
  1109. function basePropertyDeep(path) {
  1110. return function (object) {
  1111. return baseGet(object, path);
  1112. };
  1113. }
  1114. function property(path) {
  1115. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  1116. }
  1117. function baseIteratee(value) {
  1118. if (typeof value == 'function') {
  1119. return value;
  1120. }
  1121. if (value == null) {
  1122. return identity;
  1123. }
  1124. if (typeof value == 'object') {
  1125. return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  1126. }
  1127. return property(value);
  1128. }
  1129. function createFind(findIndexFunc) {
  1130. return function (collection, predicate, fromIndex) {
  1131. var iterable = Object(collection);
  1132. if (!isArrayLike(collection)) {
  1133. var iteratee = baseIteratee(predicate);
  1134. collection = keys(collection);
  1135. predicate = function (key) {
  1136. return iteratee(iterable[key], key, iterable);
  1137. };
  1138. }
  1139. var index = findIndexFunc(collection, predicate, fromIndex);
  1140. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  1141. };
  1142. }
  1143. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  1144. var length = array.length,
  1145. index = fromIndex + (fromRight ? 1 : -1);
  1146. while (fromRight ? index-- : ++index < length) {
  1147. if (predicate(array[index], index, array)) {
  1148. return index;
  1149. }
  1150. }
  1151. return -1;
  1152. }
  1153. var reWhitespace = /\s/;
  1154. function trimmedEndIndex(string) {
  1155. var index = string.length;
  1156. while (index-- && reWhitespace.test(string.charAt(index))) {}
  1157. return index;
  1158. }
  1159. var reTrimStart = /^\s+/;
  1160. function baseTrim(string) {
  1161. return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') : string;
  1162. }
  1163. var NAN = 0 / 0;
  1164. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1165. var reIsBinary = /^0b[01]+$/i;
  1166. var reIsOctal = /^0o[0-7]+$/i;
  1167. var freeParseInt = parseInt;
  1168. function toNumber(value) {
  1169. if (typeof value == 'number') {
  1170. return value;
  1171. }
  1172. if (isSymbol(value)) {
  1173. return NAN;
  1174. }
  1175. if (isObject(value)) {
  1176. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1177. value = isObject(other) ? other + '' : other;
  1178. }
  1179. if (typeof value != 'string') {
  1180. return value === 0 ? value : +value;
  1181. }
  1182. value = baseTrim(value);
  1183. var isBinary = reIsBinary.test(value);
  1184. return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
  1185. }
  1186. var INFINITY = 1 / 0,
  1187. MAX_INTEGER = 1.7976931348623157e+308;
  1188. function toFinite(value) {
  1189. if (!value) {
  1190. return value === 0 ? value : 0;
  1191. }
  1192. value = toNumber(value);
  1193. if (value === INFINITY || value === -INFINITY) {
  1194. var sign = value < 0 ? -1 : 1;
  1195. return sign * MAX_INTEGER;
  1196. }
  1197. return value === value ? value : 0;
  1198. }
  1199. function toInteger(value) {
  1200. var result = toFinite(value),
  1201. remainder = result % 1;
  1202. return result === result ? remainder ? result - remainder : result : 0;
  1203. }
  1204. var nativeMax = Math.max;
  1205. function findIndex(array, predicate, fromIndex) {
  1206. var length = array == null ? 0 : array.length;
  1207. if (!length) {
  1208. return -1;
  1209. }
  1210. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  1211. if (index < 0) {
  1212. index = nativeMax(length + index, 0);
  1213. }
  1214. return baseFindIndex(array, baseIteratee(predicate), index);
  1215. }
  1216. var find = createFind(findIndex);
  1217. var objectProto$1 = Object.prototype;
  1218. var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
  1219. function baseHas(object, key) {
  1220. return object != null && hasOwnProperty$1.call(object, key);
  1221. }
  1222. function has(object, path) {
  1223. return object != null && hasPath(object, path, baseHas);
  1224. }
  1225. var getPrototype = overArg(Object.getPrototypeOf, Object);
  1226. var objectTag = '[object Object]';
  1227. var funcProto = Function.prototype,
  1228. objectProto = Object.prototype;
  1229. var funcToString = funcProto.toString;
  1230. var hasOwnProperty = objectProto.hasOwnProperty;
  1231. var objectCtorString = funcToString.call(Object);
  1232. function isPlainObject(value) {
  1233. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  1234. return false;
  1235. }
  1236. var proto = getPrototype(value);
  1237. if (proto === null) {
  1238. return true;
  1239. }
  1240. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  1241. return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
  1242. }
  1243. function isElement(value) {
  1244. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  1245. }
  1246. var stringTag = '[object String]';
  1247. function isString(value) {
  1248. return typeof value == 'string' || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag;
  1249. }
  1250. function result(object, path, defaultValue) {
  1251. path = castPath(path, object);
  1252. var index = -1,
  1253. length = path.length;
  1254. if (!length) {
  1255. length = 1;
  1256. object = undefined;
  1257. }
  1258. while (++index < length) {
  1259. var value = object == null ? undefined : object[toKey(path[index])];
  1260. if (value === undefined) {
  1261. index = length;
  1262. value = defaultValue;
  1263. }
  1264. object = isFunction(value) ? value.call(object) : value;
  1265. }
  1266. return object;
  1267. }
  1268. exports.chain = chain;
  1269. exports.find = find;
  1270. exports.has = has;
  1271. exports.isElement = isElement;
  1272. exports.isFunction = isFunction;
  1273. exports.isString = isString;
  1274. exports.keys = keys;
  1275. exports.result = result;
  1276. return exports;
  1277. }({});
  1278. const $document = (() => {
  1279. const docNode = Node.DOCUMENT_NODE;
  1280. const docFragmentNode = Node.DOCUMENT_FRAGMENT_NODE;
  1281. const isDocument = (obj) => {
  1282. try {
  1283. let node = obj;
  1284. return (node === null || node === void 0 ? void 0 : node.nodeType) === docNode || (node === null || node === void 0 ? void 0 : node.nodeType) === docFragmentNode;
  1285. }
  1286. catch (error) {
  1287. return false;
  1288. }
  1289. };
  1290. const hasActiveWindow = (doc) => {
  1291. if (navigator.appCodeName === 'Mozilla' && !doc.location) return false;
  1292. return !!doc.defaultView;
  1293. };
  1294. const getDocumentFromElement = (el) => {
  1295. if (isDocument(el)) return el;
  1296. return el.ownerDocument;
  1297. };
  1298. return {
  1299. isDocument,
  1300. hasActiveWindow,
  1301. getDocumentFromElement
  1302. }
  1303. })();
  1304.  
  1305.  
  1306. const $window = (() => {
  1307. const isWindow = function (obj) {
  1308. try {
  1309. return Boolean(obj && obj.window === obj);
  1310. }
  1311. catch (error) {
  1312. return false;
  1313. }
  1314. };
  1315. const getWindowByDocument = (doc) => {
  1316. // parentWindow for IE
  1317. return doc.defaultView || doc.parentWindow
  1318. }
  1319. const getWindowByElement = function (el) {
  1320. if ($window.isWindow(el)) {
  1321. return el
  1322. }
  1323.  
  1324. const doc = $document.getDocumentFromElement(el)
  1325.  
  1326. return getWindowByDocument(doc)
  1327. }
  1328. return {
  1329. isWindow,
  1330. getWindowByElement
  1331. }
  1332. })();
  1333.  
  1334. const $detached = (() => {
  1335.  
  1336. const isAttached = function (elem) {
  1337. if ($window.isWindow(elem)) return true;
  1338.  
  1339. const nodes = [];
  1340. if (elem) nodes.push(elem);
  1341. if (nodes.length === 0) return false;
  1342.  
  1343. return nodes.every((node) => {
  1344. const doc = $document.getDocumentFromElement(node);
  1345. if (!$document.hasActiveWindow(doc)) return false;
  1346. return node.isConnected;
  1347. });
  1348. };
  1349.  
  1350. const isDetached = elem => !isAttached(elem)
  1351.  
  1352. return {
  1353. isDetached
  1354. }
  1355. })();
  1356.  
  1357. const $utils = (() => {
  1358. function switchCase(value, casesObj, defaultKey = 'default') {
  1359. if (_.has(casesObj, value)) return _.result(casesObj, value);
  1360. if (_.has(casesObj, defaultKey)) return _.result(casesObj, defaultKey);
  1361. const keys = _.keys(casesObj);
  1362. throw new Error(`The switch/case value: '${value}' did not match any cases: ${keys.join(', ')}.`);
  1363. }
  1364.  
  1365. const stringify = (el, form = 'long') => {
  1366. // if we are formatting the window object
  1367. if ($window.isWindow(el)) return '<window>';
  1368.  
  1369. // if we are formatting the document object
  1370. if ($document.isDocument(el)) return '<document>';
  1371.  
  1372. // convert this to jquery if its not already one
  1373. // const $el = $jquery.wrap(el);
  1374.  
  1375. const long = () => {
  1376. const str = el.cloneNode().outerHTML
  1377.  
  1378. const text = _.chain(el.textContent).clean().truncate({ length: 10 }).value();
  1379. const children = el.children.length;
  1380.  
  1381. if (children) return str.replace('></', '>...</');
  1382.  
  1383. if (text) return str.replace('></', `>${text}</`);
  1384.  
  1385. return str;
  1386. };
  1387.  
  1388. const short = () => {
  1389. const id = el.id;
  1390. const klass = el.getAttribute('class');
  1391. let str = el.tagName.toLowerCase();
  1392.  
  1393. if (id) str += `#${id}`;
  1394.  
  1395. // using attr here instead of class because
  1396. // svg's return an SVGAnimatedString object
  1397. // instead of a normal string when calling
  1398. // the property 'class'
  1399. if (klass) str += `.${klass.split(/\s+/).join('.')}`;
  1400.  
  1401. // if we have more than one element,
  1402. // format it so that the user can see there's more
  1403. // if ($el.length > 1) {
  1404. // return `[ <${str}>, ${$el.length - 1} more... ]`;
  1405. // }
  1406.  
  1407. return `<${str}>`;
  1408. };
  1409.  
  1410. return switchCase(form, {
  1411. long,
  1412. short
  1413. });
  1414. };
  1415. return { stringify }
  1416. })();
  1417.  
  1418. const $contenteditable = (() => {
  1419. const isContentEditable = (el) => {
  1420. return $nativeProps.getNativeProp(el, 'isContentEditable') || $document.getDocumentFromElement(el).designMode === 'on';
  1421. };
  1422.  
  1423. const isDesignModeDocumentElement = el => {
  1424. return isElement(el) && $elementHelpers.getTagName(el) === 'html' && isContentEditable(el)
  1425. }
  1426.  
  1427. return {
  1428. isDesignModeDocumentElement
  1429. }
  1430. })();
  1431.  
  1432. const $complexElements = (() => {
  1433. const fixedOrStickyRe = /(fixed|sticky)/;
  1434.  
  1435. const focusableSelectors = [
  1436. 'a[href]',
  1437. 'area[href]',
  1438. 'input:not([disabled])',
  1439. 'select:not([disabled])',
  1440. 'textarea:not([disabled])',
  1441. 'button:not([disabled])',
  1442. 'iframe',
  1443. '[tabindex]',
  1444. '[contenteditable]'
  1445. ];
  1446. const isFocusable = elem => focusableSelectors.some(sel => elem.matches(sel)) || $contenteditable.isDesignModeDocumentElement(elem);
  1447.  
  1448. const getFirstFixedOrStickyPositionParent = elem => {
  1449. if (isUndefinedOrHTMLBodyDoc(elem)) return null;
  1450.  
  1451. if (fixedOrStickyRe.test(getComputedStyle(elem).position)) return elem;
  1452.  
  1453. /* walk up the tree until we find an element with a fixed/sticky position */
  1454. return $find.findParent(elem, node => {
  1455.  
  1456. if (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) return null
  1457. else if (fixedOrStickyRe.test(getComputedStyle(node).position)) return node;
  1458.  
  1459. return null;
  1460. });
  1461. };
  1462.  
  1463. const elOrAncestorIsFixedOrSticky = elem => {
  1464. return !!getFirstFixedOrStickyPositionParent(elem);
  1465. };
  1466. return {
  1467. isFocusable,
  1468. elOrAncestorIsFixedOrSticky
  1469. }
  1470. })();
  1471.  
  1472.  
  1473. const $shadow = (() => {
  1474. const isShadowRoot = (maybeRoot) => {
  1475. return (maybeRoot === null || maybeRoot === void 0 ? void 0 : maybeRoot.toString()) === '[object ShadowRoot]';
  1476. };
  1477. const isWithinShadowRoot = (node) => {
  1478. return isShadowRoot(node.getRootNode());
  1479. };
  1480. const getShadowElementFromPoint = (node, x, y) => {
  1481. var _a;
  1482. const nodeFromPoint = (_a = node === null || node === void 0 ? void 0 : node.shadowRoot) === null || _a === void 0 ? void 0 : _a.elementFromPoint(x, y);
  1483. if (!nodeFromPoint || nodeFromPoint === node)
  1484. return node;
  1485. return getShadowElementFromPoint(nodeFromPoint, x, y);
  1486. };
  1487.  
  1488. return {
  1489. isWithinShadowRoot,
  1490. getShadowElementFromPoint
  1491. }
  1492. })();
  1493.  
  1494.  
  1495. const $find = (() => {
  1496. const getParentNode = el => {
  1497. // if the element has a direct parent element,
  1498. // simply return it.
  1499. if (el.parentElement) return el.parentElement;
  1500.  
  1501. const root = el.getRootNode();
  1502.  
  1503. // if the element is inside a shadow root,
  1504. // return the host of the root.
  1505. if (root && $shadow.isWithinShadowRoot(el)) return root.host;
  1506.  
  1507. return null;
  1508. };
  1509.  
  1510. const getParent = elem => getParentNode(elem);
  1511.  
  1512. const findParent = (el, condition) => {
  1513. const collectParent = node => {
  1514. const parent = getParentNode(node);
  1515.  
  1516. if (!parent) return null;
  1517.  
  1518. const parentMatchingCondition = condition(parent, node);
  1519.  
  1520. if (parentMatchingCondition) return parentMatchingCondition;
  1521.  
  1522. return collectParent(parent);
  1523. };
  1524.  
  1525. return collectParent(el);
  1526. };
  1527. const isUndefinedOrHTMLBodyDoc = elem => {
  1528. return !elem || elem.matches('body,html') || $document.isDocument(elem);
  1529. };
  1530.  
  1531. const getAllParents = (el, untilSelectorOrEl) => {
  1532. const collectParents = (parents, node) => {
  1533. const parent = getParentNode(node);
  1534. const selOrElemMatch = _.isString(untilSelectorOrEl) ? parent.matches(untilSelectorOrEl) : parent === untilSelectorOrEl;
  1535. // if (!parent || (untilSelectorOrEl && parent.matches(untilSelectorOrEl))) return parents;
  1536. if (!parent || (untilSelectorOrEl && selOrElemMatch)) return parents;
  1537. return collectParents(parents.concat(parent), parent);
  1538. };
  1539. return collectParents([], el);
  1540. };
  1541. const isAncestor = (elem, maybeAncestor) => {
  1542. return getAllParents(elem).indexOf(maybeAncestor) >= 0;
  1543. };
  1544. const isChild = (elem, maybeChild) => {
  1545. return Array.from(elem.children).indexOf(maybeChild) >= 0;
  1546. };
  1547. const isDescendent = (elem1, elem2) => {
  1548. if (!elem2) return false;
  1549. if (elem1 === elem2) return true;
  1550. return (findParent(elem2, node => {
  1551. if (node === elem1) return node;
  1552. }) === elem1);
  1553. };
  1554.  
  1555. const getTagName = el => {
  1556. const tagName = el.tagName || '';
  1557. return tagName.toLowerCase();
  1558. };
  1559. const getFirstParentWithTagName = (elem, tagName) => {
  1560. if (isUndefinedOrHTMLBodyDoc(elem) || !tagName) return null;
  1561. if (getTagName(elem) === tagName) return elem;
  1562. return findParent(elem, node => {
  1563. if (getTagName(node) === tagName) return node;
  1564. return null;
  1565. });
  1566. };
  1567.  
  1568. const elementFromPoint = (doc, x, y) => {
  1569. let elFromPoint = doc.elementFromPoint(x, y);
  1570. return $shadow.getShadowElementFromPoint(elFromPoint, x, y);
  1571. };
  1572. return {
  1573. isAncestor,
  1574. isChild,
  1575. isDescendent,
  1576. isUndefinedOrHTMLBodyDoc,
  1577. getParent,
  1578. findParent,
  1579. elementFromPoint,
  1580. getFirstParentWithTagName,
  1581. getAllParents
  1582. }
  1583. })();
  1584.  
  1585.  
  1586. const $elementHelpers = (() => {
  1587. const getTagName = el => {
  1588. const tagName = el.tagName || '';
  1589. return tagName.toLowerCase();
  1590. };
  1591. const isElement = function (obj) {
  1592. try {
  1593. return Boolean(obj && _.isElement(obj));
  1594. }
  1595. catch (error) {
  1596. return false;
  1597. }
  1598. };
  1599. const isInput = (el) => getTagName(el) === 'input';
  1600. const isTextarea = (el) => getTagName(el) === 'textarea';
  1601. const isSelect = (el) => getTagName(el) === 'select';
  1602. const isButton = (el) => getTagName(el) === 'button';
  1603. const isBody = (el) => getTagName(el) === 'body';
  1604. const isHTML = el => getTagName(el) === 'html';
  1605. const isOption = el => getTagName(el) === 'option';
  1606. const isOptgroup = el => getTagName(el) === 'optgroup';
  1607. const isSvg = function (el) {
  1608. try {
  1609. return 'ownerSVGElement' in el;
  1610. }
  1611. catch (error) {
  1612. return false;
  1613. }
  1614. };
  1615. return {
  1616. isSvg,
  1617. isBody,
  1618. isHTML,
  1619. isOption,
  1620. isElement,
  1621. isOptgroup,
  1622. isButton,
  1623. isSelect,
  1624. isTextarea,
  1625. isInput
  1626. }
  1627. })();
  1628.  
  1629.  
  1630. const $nativeProps = (() => {
  1631. const descriptor = (klass, prop) => {
  1632. const desc = Object.getOwnPropertyDescriptor(window[klass].prototype, prop);
  1633. if (desc === undefined) {
  1634. throw new Error(`Error, could not get property descriptor for ${klass} ${prop}. This should never happen`);
  1635. }
  1636. return desc;
  1637. };
  1638. const _isContentEditable = function () {
  1639. if ($elementHelpers.isSvg(this)) return false;
  1640. return descriptor('HTMLElement', 'isContentEditable').get;
  1641. };
  1642. const _getValue = function () {
  1643. if ($elementHelpers.isInput(this)) return descriptor('HTMLInputElement', 'value').get;
  1644. if ($elementHelpers.isTextarea(this)) return descriptor('HTMLTextAreaElement', 'value').get;
  1645. if ($elementHelpers.isSelect(this)) return descriptor('HTMLSelectElement', 'value').get;
  1646. if ($elementHelpers.isButton(this)) return descriptor('HTMLButtonElement', 'value').get;
  1647. return descriptor('HTMLOptionElement', 'value').get;
  1648. };
  1649. const _getSelectionStart = function () {
  1650. if ($elementHelpers.isInput(this)) return descriptor('HTMLInputElement', 'selectionStart').get;
  1651. if ($elementHelpers.isTextarea(this)) return descriptor('HTMLTextAreaElement', 'selectionStart').get;
  1652. throw new Error('this should never happen, cannot get selectionStart');
  1653. };
  1654. const _getSelectionEnd = function () {
  1655. if ($elementHelpers.isInput(this)) return descriptor('HTMLInputElement', 'selectionEnd').get;
  1656. if ($elementHelpers.isTextarea(this)) return descriptor('HTMLTextAreaElement', 'selectionEnd').get;
  1657. throw new Error('this should never happen, cannot get selectionEnd');
  1658. };
  1659. const _getType = function () {
  1660. if ($elementHelpers.isInput(this)) return descriptor('HTMLInputElement', 'type').get;
  1661. if ($elementHelpers.isButton(this)) return descriptor('HTMLButtonElement', 'type').get;
  1662. throw new Error('this should never happen, cannot get type');
  1663. };
  1664. const _getMaxLength = function () {
  1665. if ($elementHelpers.isInput(this)) return descriptor('HTMLInputElement', 'maxLength').get;
  1666. if ($elementHelpers.isTextarea(this)) return descriptor('HTMLTextAreaElement', 'maxLength').get;
  1667. throw new Error('this should never happen, cannot get maxLength');
  1668. };
  1669. const nativeGetters = {
  1670. value: _getValue,
  1671. isContentEditable: _isContentEditable,
  1672. isCollapsed: descriptor('Selection', 'isCollapsed').get,
  1673. selectionStart: _getSelectionStart,
  1674. selectionEnd: _getSelectionEnd,
  1675. type: _getType,
  1676. activeElement: descriptor('Document', 'activeElement').get,
  1677. body: descriptor('Document', 'body').get,
  1678. frameElement: Object.getOwnPropertyDescriptor(window, 'frameElement').get,
  1679. maxLength: _getMaxLength,
  1680. };
  1681. const getNativeProp = function (obj, prop) {
  1682. const nativeProp = nativeGetters[prop];
  1683. if (!nativeProp) {
  1684. const props = _.keys(nativeGetters).join(', ');
  1685. throw new Error(`attempted to use a native getter prop called: ${prop}. Available props are: ${props}`);
  1686. }
  1687. let retProp = nativeProp.call(obj, prop);
  1688. if (_.isFunction(retProp)) {
  1689. retProp = retProp.call(obj, prop);
  1690. }
  1691. return retProp;
  1692. };
  1693.  
  1694. return {
  1695. getNativeProp
  1696. }
  1697. })();
  1698.  
  1699.  
  1700. const $elements = {
  1701. ...$find,
  1702. ...$elementHelpers,
  1703. ...$complexElements,
  1704. ...$detached,
  1705. ...$utils,
  1706. ...$nativeProps
  1707. };
  1708.  
  1709. const $transform = (() => {
  1710. const existsInvisibleBackface = (list) => {
  1711. return !!_.find(list, { backfaceVisibility: 'hidden' });
  1712. };
  1713. const extractTransformInfo = (el) => {
  1714. const style = getComputedStyle(el);
  1715. const backfaceVisibility = style.getPropertyValue('backface-visibility');
  1716. if (backfaceVisibility === '') return null;
  1717. return {
  1718. backfaceVisibility,
  1719. transformStyle: style.getPropertyValue('transform-style'),
  1720. transform: style.getPropertyValue('transform'),
  1721. };
  1722. };
  1723. const numberRegex = /-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/g;
  1724. const defaultNormal = [0, 0, 1];
  1725. const viewVector = [0, 0, -1];
  1726. const identityMatrix3D = [
  1727. 1, 0, 0, 0,
  1728. 0, 1, 0, 0,
  1729. 0, 0, 1, 0,
  1730. 0, 0, 0, 1,
  1731. ];
  1732. const TINY_NUMBER = 1e-5;
  1733. const toMatrix3d = (m2d) => {
  1734. return [
  1735. m2d[0], m2d[1], 0, 0,
  1736. m2d[2], m2d[3], 0, 0,
  1737. 0, 0, 1, 0,
  1738. m2d[4], m2d[5], 0, 1,
  1739. ];
  1740. };
  1741. const parseMatrix3D = (transform) => {
  1742. if (transform === 'none') return identityMatrix3D;
  1743. if (transform.startsWith('matrix3d')) {
  1744. const matrix = transform.substring(8).match(numberRegex).map((n) => {
  1745. return parseFloat(n);
  1746. });
  1747. return matrix;
  1748. }
  1749. return toMatrix3d(transform.match(numberRegex).map((n) => parseFloat(n)));
  1750. };
  1751. const nextPreserve3d = (i, list) => {
  1752. return i + 1 < list.length && list[i + 1].transformStyle === 'preserve-3d';
  1753. };
  1754. const finalNormal = (startIndex, list) => {
  1755. let i = startIndex;
  1756. let normal = findNormal(parseMatrix3D(list[i].transform));
  1757. while (nextPreserve3d(i, list)) {
  1758. i++;
  1759. normal = findNormal(parseMatrix3D(list[i].transform), normal);
  1760. }
  1761. return normal;
  1762. };
  1763. const checkBackface = (normal) => {
  1764. let dot = viewVector[2] * normal[2];
  1765. if (Math.abs(dot) < TINY_NUMBER) {
  1766. dot = 0;
  1767. }
  1768. return dot >= 0;
  1769. };
  1770. const elIsBackface = (list) => {
  1771. if (list.length > 1 && list[1].transformStyle === 'preserve-3d') {
  1772. if (list[0].backfaceVisibility === 'hidden') {
  1773. let normal = finalNormal(0, list);
  1774. if (checkBackface(normal)) return true;
  1775. }
  1776. else {
  1777. if (list[1].backfaceVisibility === 'hidden') {
  1778. if (list[0].transform === 'none') {
  1779. let normal = finalNormal(1, list);
  1780. if (checkBackface(normal)) return true;
  1781. }
  1782. }
  1783. let normal = finalNormal(0, list);
  1784. return isElementOrthogonalWithView(normal);
  1785. }
  1786. }
  1787. else {
  1788. for (let i = 0; i < list.length; i++) {
  1789. if (i > 0 && list[i].transformStyle === 'preserve-3d') {
  1790. continue;
  1791. }
  1792. if (list[i].backfaceVisibility === 'hidden' && list[i].transform.startsWith('matrix3d')) {
  1793. let normal = findNormal(parseMatrix3D(list[i].transform));
  1794. if (checkBackface(normal)) return true;
  1795. }
  1796. }
  1797. }
  1798. return false;
  1799. };
  1800. const extractTransformInfoFromElements = (elem, list = []) => {
  1801. const info = extractTransformInfo(elem);
  1802. if (info) {
  1803. list.push(info);
  1804. }
  1805. const parent = $elements.getParent(elem);
  1806. if ($document.isDocument(parent) || parent === null) return list;
  1807. return extractTransformInfoFromElements(parent, list);
  1808. };
  1809. const isElementOrthogonalWithView = (normal) => {
  1810. const dot = viewVector[2] * normal[2];
  1811. return Math.abs(dot) < TINY_NUMBER;
  1812. };
  1813. const toUnitVector = (v) => {
  1814. const length = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
  1815. return [v[0] / length, v[1] / length, v[2] / length];
  1816. };
  1817. const findNormal = (matrix, normal = defaultNormal) => {
  1818. const m = matrix;
  1819. const v = normal;
  1820. const computedNormal = [
  1821. m[0] * v[0] + m[4] * v[1] + m[8] * v[2],
  1822. m[1] * v[0] + m[5] * v[1] + m[9] * v[2],
  1823. m[2] * v[0] + m[6] * v[1] + m[10] * v[2],
  1824. ];
  1825. return toUnitVector(computedNormal);
  1826. };
  1827. const is3DMatrixScaledTo0 = (m3d) => {
  1828. const xAxisScaledTo0 = m3d[0] === 0 && m3d[4] === 0 && m3d[8] === 0;
  1829. const yAxisScaledTo0 = m3d[1] === 0 && m3d[5] === 0 && m3d[9] === 0;
  1830. const zAxisScaledTo0 = m3d[2] === 0 && m3d[6] === 0 && m3d[10] === 0;
  1831. if (xAxisScaledTo0 || yAxisScaledTo0 || zAxisScaledTo0) return true;
  1832. return false;
  1833. };
  1834. const isTransformedToZero = ({ transform }) => {
  1835. if (transform === 'none') return false;
  1836. if (transform.startsWith('matrix3d')) {
  1837. const matrix3d = parseMatrix3D(transform);
  1838. if (is3DMatrixScaledTo0(matrix3d)) return true;
  1839. const normal = findNormal(matrix3d);
  1840. return isElementOrthogonalWithView(normal);
  1841. }
  1842. const m = parseMatrix2D(transform);
  1843. if (is2DMatrixScaledTo0(m)) return true;
  1844. return false;
  1845. };
  1846. const parseMatrix2D = (transform) => {
  1847. return transform.match(numberRegex).map((n) => parseFloat(n));
  1848. };
  1849. const is2DMatrixScaledTo0 = (m) => {
  1850. const xAxisScaledTo0 = m[0] === 0 && m[2] === 0;
  1851. const yAxisScaledTo0 = m[1] === 0 && m[3] === 0;
  1852. if (xAxisScaledTo0 || yAxisScaledTo0) return true;
  1853. return false;
  1854. };
  1855. const elIsTransformedToZero = (list) => {
  1856. if (list.some((info) => info.transformStyle === 'preserve-3d')) {
  1857. const normal = finalNormal(0, list);
  1858. return isElementOrthogonalWithView(normal);
  1859. }
  1860. return !!_.find(list, (info) => isTransformedToZero(info));
  1861. };
  1862. const detectVisibility = (elem) => {
  1863. const list = extractTransformInfoFromElements(elem);
  1864. if (existsInvisibleBackface(list)) return elIsBackface(list) ? 'backface' : 'visible';
  1865. return elIsTransformedToZero(list) ? 'transformed' : 'visible';
  1866. };
  1867. return {
  1868. detectVisibility
  1869. }
  1870. })();
  1871.  
  1872. const $coordinates = (() => {
  1873. const getElementAtPointFromViewport = (doc, x, y) => $elements.elementFromPoint(doc, x, y);
  1874. const isAutIframe = (win) => {
  1875. const parent = win.parent;
  1876. return $window.isWindow(parent) && !$elements.getNativeProp(parent, 'frameElement');
  1877. };
  1878. const getFirstValidSizedRect = (el) => {
  1879. return _.find(el.getClientRects(), (rect) => rect.width && rect.height) || el.getBoundingClientRect();
  1880. };
  1881.  
  1882. const getCoordsByPosition = (left, top, xPosition = 'center', yPosition = 'center') => {
  1883. const getLeft = () => {
  1884. switch (xPosition) {
  1885. case 'left': return Math.ceil(left);
  1886. case 'center': return Math.floor(left);
  1887. case 'right': return Math.floor(left) - 1;
  1888. }
  1889. };
  1890. const getTop = () => {
  1891. switch (yPosition) {
  1892. case 'top': return Math.ceil(top);
  1893. case 'center': return Math.floor(top);
  1894. case 'bottom': return Math.floor(top) - 1;
  1895. }
  1896. };
  1897. return {
  1898. x: getLeft(),
  1899. y: getTop(),
  1900. };
  1901. };
  1902.  
  1903. const getCenterCoordinates = (rect) => {
  1904. const x = rect.left + (rect.width / 2);
  1905. const y = rect.top + (rect.height / 2);
  1906. return getCoordsByPosition(x, y, 'center', 'center');
  1907. };
  1908.  
  1909. const getElementPositioning = (el) => {
  1910. let autFrame;
  1911. const win = $window.getWindowByElement(el);
  1912. const rect = getFirstValidSizedRect(el);
  1913. const getRectFromAutIframe = (rect) => {
  1914. let x = 0;
  1915. let y = 0;
  1916. let curWindow = win;
  1917. let frame;
  1918. while ($window.isWindow(curWindow) && !isAutIframe(curWindow) && curWindow.parent !== curWindow) {
  1919. frame = $elements.getNativeProp(curWindow, 'frameElement');
  1920. if (curWindow && frame) {
  1921. const frameRect = frame.getBoundingClientRect();
  1922. x += frameRect.left;
  1923. y += frameRect.top;
  1924. }
  1925. curWindow = curWindow.parent;
  1926. }
  1927. autFrame = curWindow;
  1928. return {
  1929. left: x + rect.left,
  1930. top: y + rect.top,
  1931. right: x + rect.right,
  1932. bottom: y + rect.top,
  1933. width: rect.width,
  1934. height: rect.height,
  1935. };
  1936. };
  1937. const rectFromAut = getRectFromAutIframe(rect);
  1938. const rectFromAutCenter = getCenterCoordinates(rectFromAut);
  1939. const rectCenter = getCenterCoordinates(rect);
  1940. const topCenter = Math.ceil(rectCenter.y);
  1941. const leftCenter = Math.ceil(rectCenter.x);
  1942. return {
  1943. scrollTop: el.scrollTop,
  1944. scrollLeft: el.scrollLeft,
  1945. width: rect.width,
  1946. height: rect.height,
  1947. fromElViewport: {
  1948. doc: win.document,
  1949. top: rect.top,
  1950. left: rect.left,
  1951. right: rect.right,
  1952. bottom: rect.bottom,
  1953. topCenter,
  1954. leftCenter,
  1955. },
  1956. fromElWindow: {
  1957. top: Math.ceil(rect.top + win.scrollY),
  1958. left: rect.left + win.scrollX,
  1959. topCenter: Math.ceil(topCenter + win.scrollY),
  1960. leftCenter: leftCenter + win.scrollX,
  1961. },
  1962. fromAutWindow: {
  1963. top: Math.ceil(rectFromAut.top + autFrame.scrollY),
  1964. left: rectFromAut.left + autFrame.scrollX,
  1965. topCenter: Math.ceil(rectFromAutCenter.y + autFrame.scrollY),
  1966. leftCenter: rectFromAutCenter.x + autFrame.scrollX,
  1967. },
  1968. };
  1969. };
  1970. return {
  1971. getElementPositioning,
  1972. getElementAtPointFromViewport
  1973. }
  1974. })();
  1975. const {
  1976. // find
  1977. isAncestor,
  1978. isChild,
  1979. isDescendent,
  1980. isUndefinedOrHTMLBodyDoc,
  1981. getParent,
  1982. getFirstParentWithTagName,
  1983. getAllParents,
  1984.  
  1985. // elementHelpers
  1986. isElement,
  1987. isBody,
  1988. isHTML,
  1989. isOption,
  1990. isOptgroup,
  1991.  
  1992. // complexElements
  1993. elOrAncestorIsFixedOrSticky,
  1994. isFocusable,
  1995.  
  1996. // detached
  1997. isDetached,
  1998.  
  1999.  
  2000. // utils
  2001. stringify: stringifyElement
  2002. } = $elements;
  2003.  
  2004.  
  2005. const isZeroLengthAndTransformNone = (width, height, transform) => (width <= 0 && transform === 'none') || (height <= 0 && transform === 'none');
  2006. const isZeroLengthAndOverflowHidden = (width, height, overflowHidden) => (width <= 0 && overflowHidden) || (height <= 0 && overflowHidden);
  2007. const elOffsetWidth = elem => elem.offsetWidth;
  2008.  
  2009. const elOffsetHeight = elem => elem.offsetHeight;
  2010.  
  2011. const elHasNoOffsetWidthOrHeight = elem => (elOffsetWidth(elem) <= 0) || (elOffsetHeight(elem) <= 0);
  2012. const elHasVisibilityHidden = elem => getComputedStyle(elem).getPropertyValue('visibility') === 'hidden';
  2013. const elHasVisibilityCollapse = elem => getComputedStyle(elem).getPropertyValue('visibility') === 'collapse';
  2014. const elHasVisibilityHiddenOrCollapse = ($el) => elHasVisibilityHidden($el) || elHasVisibilityCollapse($el);
  2015. const elHasOpacityZero = elem => getComputedStyle(elem).getPropertyValue('opacity') === '0';
  2016. const elHasDisplayNone = elem => getComputedStyle(elem).getPropertyValue('display') === 'none';
  2017. const elHasDisplayInline = elem => getComputedStyle(elem).getPropertyValue('display') === 'inline';
  2018. const elHasOverflowHidden = elem => {
  2019. const style = getComputedStyle(elem);
  2020. const cssOverflow = [
  2021. style.getPropertyValue('overflow'),
  2022. style.getPropertyValue('overflow-y'),
  2023. style.getPropertyValue('overflow-x')
  2024. ];
  2025. return cssOverflow.includes('hidden');
  2026. };
  2027. const elHasPositionRelative = elem => getComputedStyle(elem).getPropertyValue('position') === 'relative';
  2028. const elHasPositionAbsolute = elem => getComputedStyle(elem).getPropertyValue('position') === 'absolute';
  2029. const ensureEl = (el, methodName) => {
  2030. if (!isElement(el)) {
  2031. throw new Error(`\`${methodName}\` failed because it requires a DOM element. The subject received was: \`${el}\``);
  2032. }
  2033. };
  2034. const elHasNoEffectiveWidthOrHeight = (el) => {
  2035. const style = getComputedStyle(el);
  2036. const transform = style.getPropertyValue('transform');
  2037. const width = elOffsetWidth(el);
  2038. const height = elOffsetHeight(el);
  2039. const overflowHidden = elHasOverflowHidden(el);
  2040. return isZeroLengthAndTransformNone(width, height, transform) || isZeroLengthAndOverflowHidden(width, height, overflowHidden) || (el.getClientRects().length <= 0);
  2041. };
  2042. const elDescendentsHavePositionFixedOrAbsolute = function (parent, child) {
  2043. const parents = getAllParents(child, parent);
  2044. const arr = [...parents, child];
  2045. return arr.some(elem => fixedOrAbsoluteRe.test(getComputedStyle(elem).getPropertyValue('position')))
  2046. // const $els = $jquery.wrap(parents).add(child);
  2047. // return _.some($els.get(), (el) => {
  2048. // return fixedOrAbsoluteRe.test($jquery.wrap(el).css('position'));
  2049. // });
  2050. };
  2051. const elIsHiddenByAncestors = (elem, checkOpacity, origEl = elem) => {
  2052. const parent = getParent(elem);
  2053. if (isUndefinedOrHTMLBodyDoc(parent)) return false;
  2054. if (elHasOpacityZero(parent) && checkOpacity) return true;
  2055. if (elHasOverflowHidden(parent) && elHasNoEffectiveWidthOrHeight(parent)) return !elDescendentsHavePositionFixedOrAbsolute(parent, origEl);
  2056. return elIsHiddenByAncestors(parent, checkOpacity, origEl);
  2057. };
  2058. const elAtCenterPoint = elem => {
  2059. const doc = $document.getDocumentFromElement(elem);
  2060. const elProps = $coordinates.getElementPositioning(elem);
  2061. const { topCenter, leftCenter } = elProps.fromElViewport;
  2062. const el = $coordinates.getElementAtPointFromViewport(doc, leftCenter, topCenter);
  2063. if (el) return el
  2064. };
  2065. const elIsNotElementFromPoint = elem => {
  2066. const elAtPoint = elAtCenterPoint(elem);
  2067. if (isDescendent(elem, elAtPoint)) return false;
  2068. if ((getComputedStyle(elem).getPropertyValue('pointer-events') === 'none' || getComputedStyle(elem.parentElement).getPropertyValue('pointer-events') === 'none') &&
  2069. (elAtPoint && isAncestor(elem, elAtPoint))) return false;
  2070. return true;
  2071. };
  2072. const elHasClippableOverflow = elem => {
  2073. const style = getComputedStyle(elem)
  2074. return OVERFLOW_PROPS.includes(style.getPropertyValue('overflow')) || OVERFLOW_PROPS.includes(style.getPropertyValue('overflow-y')) || OVERFLOW_PROPS.includes(style.getPropertyValue('overflow-x'));
  2075. };
  2076. const canClipContent = (elem, ancestor) => {
  2077. if (!elHasClippableOverflow(ancestor)) return false;
  2078. const offsetParent = elem.offsetParent;
  2079. if (!elHasPositionRelative(elem) && isAncestor(ancestor, offsetParent)) return false;
  2080. if (elHasPositionAbsolute(offsetParent) && isChild(ancestor, offsetParent)) return false;
  2081. return true;
  2082. };
  2083. const elIsOutOfBoundsOfAncestorsOverflow = (elem, ancestor = getParent(elem)) => {
  2084. if (isUndefinedOrHTMLBodyDoc(ancestor)) return false;
  2085. const elProps = $coordinates.getElementPositioning(elem);
  2086. if (canClipContent(elem, ancestor)) {
  2087. const ancestorProps = $coordinates.getElementPositioning(ancestor);
  2088. if ((elProps.fromElWindow.left > (ancestorProps.width + ancestorProps.fromElWindow.left)) ||
  2089. ((elProps.fromElWindow.left + elProps.width) < ancestorProps.fromElWindow.left) ||
  2090. (elProps.fromElWindow.top > (ancestorProps.height + ancestorProps.fromElWindow.top)) ||
  2091. ((elProps.fromElWindow.top + elProps.height) < ancestorProps.fromElWindow.top)) return true;
  2092. }
  2093. return elIsOutOfBoundsOfAncestorsOverflow(elem, getParent(ancestor));
  2094. };
  2095. const isHiddenByAncestors = (elem, methodName = 'isHiddenByAncestors()', options = { checkOpacity: true }) => {
  2096. ensureEl(elem, methodName);
  2097. if (elIsHiddenByAncestors(elem, options.checkOpacity)) return true;
  2098.  
  2099. // removed because I am just trying to find out if the element is "visible" outside the viewport
  2100. // if (elOrAncestorIsFixedOrSticky(elem)) return elIsNotElementFromPoint(elem);
  2101. return elIsOutOfBoundsOfAncestorsOverflow(elem);
  2102. };
  2103. const fixedOrAbsoluteRe = /(fixed|absolute)/;
  2104. const OVERFLOW_PROPS = ['hidden', 'scroll', 'auto'];
  2105. const isVisible = elem => !isHidden(elem, 'isVisible()');
  2106. const isHidden = (el, methodName = 'isHidden()', options = { checkOpacity: true }) => {
  2107. if (isStrictlyHidden(el, methodName, options, isHidden)) return true;
  2108. return isHiddenByAncestors(el, methodName, options);
  2109. };
  2110. const isStrictlyHidden = (elem, methodName = 'isStrictlyHidden()', options = { checkOpacity: true }, recurse) => {
  2111. ensureEl(elem, methodName);
  2112.  
  2113. if (isBody(elem) || isHTML(elem)) return false;
  2114. if (isOption(elem) || isOptgroup(elem)) {
  2115. if (elHasDisplayNone(elem)) return true;
  2116. const select = getFirstParentWithTagName(elem, 'select');
  2117. if (select) return recurse ? recurse(select, methodName, options) : isStrictlyHidden(select, methodName, options);
  2118. }
  2119. if (elHasNoEffectiveWidthOrHeight(elem)) {
  2120. if (elHasDisplayInline(elem)) return !elHasVisibleChild(elem);
  2121. return true;
  2122. }
  2123. if (elHasVisibilityHiddenOrCollapse(elem)) return true;
  2124. // try {
  2125. if ($transform.detectVisibility(elem) !== 'visible') return true;
  2126. // } catch(err){}
  2127. if (elHasOpacityZero(elem) && options.checkOpacity) return true;
  2128. return false;
  2129. };
  2130. const isW3CRendered = elem => !(parentHasDisplayNone(elem) || getComputedStyle(elem).getPropertyValue('visibility') === 'hidden');
  2131. const isW3CFocusable = elem => isFocusable(elem) && isW3CRendered(elem);
  2132. const elHasVisibleChild = elem => Array.from(elem.children).some(child => isVisible(child));
  2133. const parentHasNoOffsetWidthOrHeightAndOverflowHidden = function ($el) {
  2134. if (isUndefinedOrHTMLBodyDoc($el)) return false;
  2135. if (elHasOverflowHidden($el) && elHasNoEffectiveWidthOrHeight($el)) return $el;
  2136. return parentHasNoOffsetWidthOrHeightAndOverflowHidden(getParent($el));
  2137. };
  2138. const parentHasDisplayNone = elem => {
  2139. if ($document.isDocument(elem) || elem === null) return false;
  2140. if (elHasDisplayNone(elem)) return elem;
  2141. return parentHasDisplayNone(getParent(elem));
  2142. };
  2143. const parentHasVisibilityHidden = elem => {
  2144. if ($document.isDocument(elem) || elem === null) return false;
  2145. if (elHasVisibilityHidden(elem)) return elem;
  2146. return parentHasVisibilityHidden(getParent(elem));
  2147. };
  2148. const parentHasVisibilityCollapse = elem => {
  2149. if ($document.isDocument(elem) || elem === null) return false;
  2150. if (elHasVisibilityCollapse(elem)) return elem;
  2151. return parentHasVisibilityCollapse(getParent(elem));
  2152. };
  2153. const parentHasOpacityZero = elem => {
  2154. if ($document.isDocument(elem) || elem === null) return false;
  2155. if (elHasOpacityZero(elem)) return elem;
  2156. return parentHasOpacityZero(getParent(elem));
  2157. };
  2158. const getReasonIsHidden = (elem, options = { checkOpacity: true }) => {
  2159. const node = stringifyElement(elem, 'short');
  2160. let width = elOffsetWidth(elem);
  2161. let height = elOffsetHeight(elem);
  2162. let $parent;
  2163. let parentNode;
  2164. if (elHasDisplayNone(elem)) return `This element \`${node}\` is not visible because it has CSS property: \`display: none\``;
  2165. if ($parent = parentHasDisplayNone(getParent(elem))) {
  2166. parentNode = stringifyElement($parent, 'short');
  2167. return `This element \`${node}\` is not visible because its parent \`${parentNode}\` has CSS property: \`display: none\``;
  2168. }
  2169. if ($parent = parentHasVisibilityHidden(getParent(elem))) {
  2170. parentNode = stringifyElement($parent, 'short');
  2171. return `This element \`${node}\` is not visible because its parent \`${parentNode}\` has CSS property: \`visibility: hidden\``;
  2172. }
  2173. if ($parent = parentHasVisibilityCollapse(getParent(elem))) {
  2174. parentNode = stringifyElement($parent, 'short');
  2175. return `This element \`${node}\` is not visible because its parent \`${parentNode}\` has CSS property: \`visibility: collapse\``;
  2176. }
  2177. if (isDetached(elem)) return `This element \`${node}\` is not visible because it is detached from the DOM`;
  2178. if (elHasVisibilityHidden(elem)) return `This element \`${node}\` is not visible because it has CSS property: \`visibility: hidden\``;
  2179. if (elHasVisibilityCollapse(elem)) return `This element \`${node}\` is not visible because it has CSS property: \`visibility: collapse\``;
  2180. if (elHasOpacityZero(elem) && options.checkOpacity) return `This element \`${node}\` is not visible because it has CSS property: \`opacity: 0\``;
  2181.  
  2182. if (($parent = parentHasOpacityZero(getParent(elem))) && options.checkOpacity) {
  2183. parentNode = stringifyElement($parent, 'short');
  2184. return `This element \`${node}\` is not visible because its parent \`${parentNode}\` has CSS property: \`opacity: 0\``;
  2185. }
  2186. if (elHasNoOffsetWidthOrHeight(elem)) return `This element \`${node}\` is not visible because it has an effective width and height of: \`${width} x ${height}\` pixels.`;
  2187. const transformResult = $transform.detectVisibility(elem);
  2188. if (transformResult === 'transformed') return `This element \`${node}\` is not visible because it is hidden by transform.`;
  2189. if (transformResult === 'backface') return `This element \`${node}\` is not visible because it is rotated and its backface is hidden.`;
  2190. if ($parent = parentHasNoOffsetWidthOrHeightAndOverflowHidden(getParent(elem))) {
  2191. parentNode = stringifyElement($parent, 'short');
  2192. width = elOffsetWidth($parent);
  2193. height = elOffsetHeight($parent);
  2194. return `This element \`${node}\` is not visible because its parent \`${parentNode}\` has CSS property: \`overflow: hidden\` and an effective width and height of: \`${width} x ${height}\` pixels.`;
  2195. }
  2196. if (elOrAncestorIsFixedOrSticky(elem)) {
  2197. if (elIsNotElementFromPoint(elem)) {
  2198. const covered = stringifyElement(elAtCenterPoint(elem));
  2199. if (covered) return `This element \`${node}\` is not visible because it has CSS property: \`position: fixed\` and it's being covered by another element:\n\n\`${covered}\``;
  2200. return `This element \`${node}\` is not visible because its ancestor has \`position: fixed\` CSS property and it is overflowed by other elements. How about scrolling to the element with \`cy.scrollIntoView()\`?`;
  2201. }
  2202. }
  2203. else {
  2204. if (elIsOutOfBoundsOfAncestorsOverflow(elem)) return `This element \`${node}\` is not visible because its content is being clipped by one of its parent elements, which has a CSS property of overflow: \`hidden\`, \`scroll\` or \`auto\``;
  2205. }
  2206. return `This element \`${node}\` is not visible.`;
  2207. };
  2208.  
  2209. Object.assign(exports, {
  2210. isVisible,
  2211. isHidden,
  2212. isStrictlyHidden,
  2213. isHiddenByAncestors,
  2214. getReasonIsHidden,
  2215. isW3CFocusable,
  2216. isW3CRendered
  2217. })
  2218. })