conflict-detection.dev.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. "use strict";
  2. function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
  3. /*!
  4. * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com
  5. * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
  6. */
  7. (function (global, factory) {
  8. (typeof exports === "undefined" ? "undefined" : _typeof2(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory(global['fontawesome-free-conflict-detection'] = {});
  9. })(void 0, function (exports) {
  10. 'use strict';
  11. function _typeof(obj) {
  12. if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
  13. _typeof = function _typeof(obj) {
  14. return _typeof2(obj);
  15. };
  16. } else {
  17. _typeof = function _typeof(obj) {
  18. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  19. };
  20. }
  21. return _typeof(obj);
  22. }
  23. function _defineProperty(obj, key, value) {
  24. if (key in obj) {
  25. Object.defineProperty(obj, key, {
  26. value: value,
  27. enumerable: true,
  28. configurable: true,
  29. writable: true
  30. });
  31. } else {
  32. obj[key] = value;
  33. }
  34. return obj;
  35. }
  36. function _objectSpread(target) {
  37. for (var i = 1; i < arguments.length; i++) {
  38. var source = arguments[i] != null ? arguments[i] : {};
  39. var ownKeys = Object.keys(source);
  40. if (typeof Object.getOwnPropertySymbols === 'function') {
  41. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  42. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  43. }));
  44. }
  45. ownKeys.forEach(function (key) {
  46. _defineProperty(target, key, source[key]);
  47. });
  48. }
  49. return target;
  50. }
  51. var _WINDOW = {};
  52. var _DOCUMENT = {};
  53. try {
  54. if (typeof window !== 'undefined') _WINDOW = window;
  55. if (typeof document !== 'undefined') _DOCUMENT = document;
  56. } catch (e) {}
  57. var _ref = _WINDOW.navigator || {},
  58. _ref$userAgent = _ref.userAgent,
  59. userAgent = _ref$userAgent === void 0 ? '' : _ref$userAgent;
  60. var WINDOW = _WINDOW;
  61. var DOCUMENT = _DOCUMENT;
  62. var IS_BROWSER = !!WINDOW.document;
  63. var IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
  64. var IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
  65. var functions = [];
  66. var listener = function listener() {
  67. DOCUMENT.removeEventListener('DOMContentLoaded', listener);
  68. loaded = 1;
  69. functions.map(function (fn) {
  70. return fn();
  71. });
  72. };
  73. var loaded = false;
  74. if (IS_DOM) {
  75. loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
  76. if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
  77. }
  78. function domready(fn) {
  79. if (!IS_DOM) return;
  80. loaded ? setTimeout(fn, 0) : functions.push(fn);
  81. }
  82. function report(_ref) {
  83. var nodesTested = _ref.nodesTested,
  84. nodesFound = _ref.nodesFound;
  85. var timedOutTests = {};
  86. for (var key in nodesFound) {
  87. if (!(nodesTested.conflict[key] || nodesTested.noConflict[key])) {
  88. timedOutTests[key] = nodesFound[key];
  89. }
  90. }
  91. var conflictsCount = Object.keys(nodesTested.conflict).length;
  92. if (conflictsCount > 0) {
  93. console.info("%cConflict".concat(conflictsCount > 1 ? 's' : '', " found:"), 'color: darkred; font-size: large');
  94. var data = {};
  95. for (var _key in nodesTested.conflict) {
  96. var item = nodesTested.conflict[_key];
  97. data[_key] = {
  98. 'tagName': item.tagName,
  99. 'src/href': item.src || item.href || 'n/a',
  100. 'innerText excerpt': item.innerText && item.innerText !== '' ? item.innerText.slice(0, 200) + '...' : '(empty)'
  101. };
  102. }
  103. console.table(data);
  104. }
  105. var noConflictsCount = Object.keys(nodesTested.noConflict).length;
  106. if (noConflictsCount > 0) {
  107. console.info("%cNo conflict".concat(noConflictsCount > 1 ? 's' : '', " found with ").concat(noConflictsCount == 1 ? 'this' : 'these', ":"), 'color: green; font-size: large');
  108. var _data = {};
  109. for (var _key2 in nodesTested.noConflict) {
  110. var _item = nodesTested.noConflict[_key2];
  111. _data[_key2] = {
  112. 'tagName': _item.tagName,
  113. 'src/href': _item.src || _item.href || 'n/a',
  114. 'innerText excerpt': _item.innerText && _item.innerText !== '' ? _item.innerText.slice(0, 200) + '...' : '(empty)'
  115. };
  116. }
  117. console.table(_data);
  118. }
  119. var timeOutCount = Object.keys(timedOutTests).length;
  120. if (timeOutCount > 0) {
  121. console.info("%cLeftovers--we timed out before collecting test results for ".concat(timeOutCount == 1 ? 'this' : 'these', ":"), 'color: blue; font-size: large');
  122. var _data2 = {};
  123. for (var _key3 in timedOutTests) {
  124. var _item2 = timedOutTests[_key3];
  125. _data2[_key3] = {
  126. 'tagName': _item2.tagName,
  127. 'src/href': _item2.src || _item2.href || 'n/a',
  128. 'innerText excerpt': _item2.innerText && _item2.innerText !== '' ? _item2.innerText.slice(0, 200) + '...' : '(empty)'
  129. };
  130. }
  131. console.table(_data2);
  132. }
  133. }
  134. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  135. function createCommonjsModule(fn, module) {
  136. return module = {
  137. exports: {}
  138. }, fn(module, module.exports), module.exports;
  139. }
  140. var md5 = createCommonjsModule(function (module) {
  141. (function ($) {
  142. /**
  143. * Add integers, wrapping at 2^32.
  144. * This uses 16-bit operations internally to work around bugs in interpreters.
  145. *
  146. * @param {number} x First integer
  147. * @param {number} y Second integer
  148. * @returns {number} Sum
  149. */
  150. function safeAdd(x, y) {
  151. var lsw = (x & 0xffff) + (y & 0xffff);
  152. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  153. return msw << 16 | lsw & 0xffff;
  154. }
  155. /**
  156. * Bitwise rotate a 32-bit number to the left.
  157. *
  158. * @param {number} num 32-bit number
  159. * @param {number} cnt Rotation count
  160. * @returns {number} Rotated number
  161. */
  162. function bitRotateLeft(num, cnt) {
  163. return num << cnt | num >>> 32 - cnt;
  164. }
  165. /**
  166. * Basic operation the algorithm uses.
  167. *
  168. * @param {number} q q
  169. * @param {number} a a
  170. * @param {number} b b
  171. * @param {number} x x
  172. * @param {number} s s
  173. * @param {number} t t
  174. * @returns {number} Result
  175. */
  176. function md5cmn(q, a, b, x, s, t) {
  177. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
  178. }
  179. /**
  180. * Basic operation the algorithm uses.
  181. *
  182. * @param {number} a a
  183. * @param {number} b b
  184. * @param {number} c c
  185. * @param {number} d d
  186. * @param {number} x x
  187. * @param {number} s s
  188. * @param {number} t t
  189. * @returns {number} Result
  190. */
  191. function md5ff(a, b, c, d, x, s, t) {
  192. return md5cmn(b & c | ~b & d, a, b, x, s, t);
  193. }
  194. /**
  195. * Basic operation the algorithm uses.
  196. *
  197. * @param {number} a a
  198. * @param {number} b b
  199. * @param {number} c c
  200. * @param {number} d d
  201. * @param {number} x x
  202. * @param {number} s s
  203. * @param {number} t t
  204. * @returns {number} Result
  205. */
  206. function md5gg(a, b, c, d, x, s, t) {
  207. return md5cmn(b & d | c & ~d, a, b, x, s, t);
  208. }
  209. /**
  210. * Basic operation the algorithm uses.
  211. *
  212. * @param {number} a a
  213. * @param {number} b b
  214. * @param {number} c c
  215. * @param {number} d d
  216. * @param {number} x x
  217. * @param {number} s s
  218. * @param {number} t t
  219. * @returns {number} Result
  220. */
  221. function md5hh(a, b, c, d, x, s, t) {
  222. return md5cmn(b ^ c ^ d, a, b, x, s, t);
  223. }
  224. /**
  225. * Basic operation the algorithm uses.
  226. *
  227. * @param {number} a a
  228. * @param {number} b b
  229. * @param {number} c c
  230. * @param {number} d d
  231. * @param {number} x x
  232. * @param {number} s s
  233. * @param {number} t t
  234. * @returns {number} Result
  235. */
  236. function md5ii(a, b, c, d, x, s, t) {
  237. return md5cmn(c ^ (b | ~d), a, b, x, s, t);
  238. }
  239. /**
  240. * Calculate the MD5 of an array of little-endian words, and a bit length.
  241. *
  242. * @param {Array} x Array of little-endian words
  243. * @param {number} len Bit length
  244. * @returns {Array<number>} MD5 Array
  245. */
  246. function binlMD5(x, len) {
  247. /* append padding */
  248. x[len >> 5] |= 0x80 << len % 32;
  249. x[(len + 64 >>> 9 << 4) + 14] = len;
  250. var i;
  251. var olda;
  252. var oldb;
  253. var oldc;
  254. var oldd;
  255. var a = 1732584193;
  256. var b = -271733879;
  257. var c = -1732584194;
  258. var d = 271733878;
  259. for (i = 0; i < x.length; i += 16) {
  260. olda = a;
  261. oldb = b;
  262. oldc = c;
  263. oldd = d;
  264. a = md5ff(a, b, c, d, x[i], 7, -680876936);
  265. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
  266. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
  267. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
  268. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
  269. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
  270. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
  271. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
  272. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
  273. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
  274. c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
  275. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
  276. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
  277. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
  278. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
  279. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
  280. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
  281. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
  282. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
  283. b = md5gg(b, c, d, a, x[i], 20, -373897302);
  284. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
  285. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
  286. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
  287. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
  288. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
  289. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
  290. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
  291. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
  292. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
  293. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
  294. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
  295. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
  296. a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
  297. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
  298. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
  299. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
  300. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
  301. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
  302. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
  303. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
  304. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
  305. d = md5hh(d, a, b, c, x[i], 11, -358537222);
  306. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
  307. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
  308. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
  309. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
  310. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
  311. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
  312. a = md5ii(a, b, c, d, x[i], 6, -198630844);
  313. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
  314. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
  315. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
  316. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
  317. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
  318. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
  319. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
  320. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
  321. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
  322. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
  323. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
  324. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
  325. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
  326. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
  327. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
  328. a = safeAdd(a, olda);
  329. b = safeAdd(b, oldb);
  330. c = safeAdd(c, oldc);
  331. d = safeAdd(d, oldd);
  332. }
  333. return [a, b, c, d];
  334. }
  335. /**
  336. * Convert an array of little-endian words to a string
  337. *
  338. * @param {Array<number>} input MD5 Array
  339. * @returns {string} MD5 string
  340. */
  341. function binl2rstr(input) {
  342. var i;
  343. var output = '';
  344. var length32 = input.length * 32;
  345. for (i = 0; i < length32; i += 8) {
  346. output += String.fromCharCode(input[i >> 5] >>> i % 32 & 0xff);
  347. }
  348. return output;
  349. }
  350. /**
  351. * Convert a raw string to an array of little-endian words
  352. * Characters >255 have their high-byte silently ignored.
  353. *
  354. * @param {string} input Raw input string
  355. * @returns {Array<number>} Array of little-endian words
  356. */
  357. function rstr2binl(input) {
  358. var i;
  359. var output = [];
  360. output[(input.length >> 2) - 1] = undefined;
  361. for (i = 0; i < output.length; i += 1) {
  362. output[i] = 0;
  363. }
  364. var length8 = input.length * 8;
  365. for (i = 0; i < length8; i += 8) {
  366. output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
  367. }
  368. return output;
  369. }
  370. /**
  371. * Calculate the MD5 of a raw string
  372. *
  373. * @param {string} s Input string
  374. * @returns {string} Raw MD5 string
  375. */
  376. function rstrMD5(s) {
  377. return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));
  378. }
  379. /**
  380. * Calculates the HMAC-MD5 of a key and some data (raw strings)
  381. *
  382. * @param {string} key HMAC key
  383. * @param {string} data Raw input string
  384. * @returns {string} Raw MD5 string
  385. */
  386. function rstrHMACMD5(key, data) {
  387. var i;
  388. var bkey = rstr2binl(key);
  389. var ipad = [];
  390. var opad = [];
  391. var hash;
  392. ipad[15] = opad[15] = undefined;
  393. if (bkey.length > 16) {
  394. bkey = binlMD5(bkey, key.length * 8);
  395. }
  396. for (i = 0; i < 16; i += 1) {
  397. ipad[i] = bkey[i] ^ 0x36363636;
  398. opad[i] = bkey[i] ^ 0x5c5c5c5c;
  399. }
  400. hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
  401. return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));
  402. }
  403. /**
  404. * Convert a raw string to a hex string
  405. *
  406. * @param {string} input Raw input string
  407. * @returns {string} Hex encoded string
  408. */
  409. function rstr2hex(input) {
  410. var hexTab = '0123456789abcdef';
  411. var output = '';
  412. var x;
  413. var i;
  414. for (i = 0; i < input.length; i += 1) {
  415. x = input.charCodeAt(i);
  416. output += hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f);
  417. }
  418. return output;
  419. }
  420. /**
  421. * Encode a string as UTF-8
  422. *
  423. * @param {string} input Input string
  424. * @returns {string} UTF8 string
  425. */
  426. function str2rstrUTF8(input) {
  427. return unescape(encodeURIComponent(input));
  428. }
  429. /**
  430. * Encodes input string as raw MD5 string
  431. *
  432. * @param {string} s Input string
  433. * @returns {string} Raw MD5 string
  434. */
  435. function rawMD5(s) {
  436. return rstrMD5(str2rstrUTF8(s));
  437. }
  438. /**
  439. * Encodes input string as Hex encoded string
  440. *
  441. * @param {string} s Input string
  442. * @returns {string} Hex encoded string
  443. */
  444. function hexMD5(s) {
  445. return rstr2hex(rawMD5(s));
  446. }
  447. /**
  448. * Calculates the raw HMAC-MD5 for the given key and data
  449. *
  450. * @param {string} k HMAC key
  451. * @param {string} d Input string
  452. * @returns {string} Raw MD5 string
  453. */
  454. function rawHMACMD5(k, d) {
  455. return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
  456. }
  457. /**
  458. * Calculates the Hex encoded HMAC-MD5 for the given key and data
  459. *
  460. * @param {string} k HMAC key
  461. * @param {string} d Input string
  462. * @returns {string} Raw MD5 string
  463. */
  464. function hexHMACMD5(k, d) {
  465. return rstr2hex(rawHMACMD5(k, d));
  466. }
  467. /**
  468. * Calculates MD5 value for a given string.
  469. * If a key is provided, calculates the HMAC-MD5 value.
  470. * Returns a Hex encoded string unless the raw argument is given.
  471. *
  472. * @param {string} string Input string
  473. * @param {string} [key] HMAC key
  474. * @param {boolean} raw Raw oytput switch
  475. * @returns {string} MD5 output
  476. */
  477. function md5(string, key, raw) {
  478. if (!key) {
  479. if (!raw) {
  480. return hexMD5(string);
  481. }
  482. return rawMD5(string);
  483. }
  484. if (!raw) {
  485. return hexHMACMD5(key, string);
  486. }
  487. return rawHMACMD5(key, string);
  488. }
  489. if (module.exports) {
  490. module.exports = md5;
  491. } else {
  492. $.md5 = md5;
  493. }
  494. })(commonjsGlobal);
  495. });
  496. function md5ForNode(node) {
  497. if (null === node || 'object' !== _typeof(node)) return undefined;
  498. if (node.src) {
  499. return md5(node.src);
  500. } else if (node.href) {
  501. return md5(node.href);
  502. } else if (node.innerText && '' !== node.innerText) {
  503. // eslint-disable-line yoda
  504. return md5(node.innerText);
  505. } else {
  506. return undefined;
  507. }
  508. }
  509. var diagScriptId = 'fa-kits-diag';
  510. var nodeUnderTestId = 'fa-kits-node-under-test';
  511. var md5Attr = 'data-md5';
  512. var detectionIgnoreAttr = 'data-fa-detection-ignore';
  513. var timeoutAttr = 'data-fa-detection-timeout';
  514. var resultsCollectionMaxWaitAttr = 'data-fa-detection-results-collection-max-wait';
  515. function pollUntil(_ref) {
  516. var _ref$fn = _ref.fn,
  517. fn = _ref$fn === void 0 ? function () {
  518. return true;
  519. } : _ref$fn,
  520. _ref$initialDuration = _ref.initialDuration,
  521. initialDuration = _ref$initialDuration === void 0 ? 1 : _ref$initialDuration,
  522. _ref$maxDuration = _ref.maxDuration,
  523. maxDuration = _ref$maxDuration === void 0 ? WINDOW.FontAwesomeDetection.timeout : _ref$maxDuration,
  524. _ref$showProgress = _ref.showProgress,
  525. showProgress = _ref$showProgress === void 0 ? false : _ref$showProgress,
  526. progressIndicator = _ref.progressIndicator;
  527. return new Promise(function (resolve, reject) {
  528. // eslint-disable-line compat/compat
  529. function poll(duration, cumulativeDuration) {
  530. setTimeout(function () {
  531. var result = fn();
  532. if (showProgress) {
  533. console.info(progressIndicator);
  534. }
  535. if (!!result) {
  536. // eslint-disable-line no-extra-boolean-cast
  537. resolve(result);
  538. } else {
  539. var nextDuration = 250;
  540. var nextCumulativeDuration = nextDuration + cumulativeDuration;
  541. if (nextCumulativeDuration <= maxDuration) {
  542. poll(nextDuration, nextCumulativeDuration);
  543. } else {
  544. reject('timeout'); // eslint-disable-line prefer-promise-reject-errors
  545. }
  546. }
  547. }, duration);
  548. }
  549. poll(initialDuration, 0);
  550. });
  551. }
  552. function detectWebfontConflicts() {
  553. var linkTags = Array.from(DOCUMENT.getElementsByTagName('link')).filter(function (t) {
  554. return !t.hasAttribute(detectionIgnoreAttr);
  555. });
  556. var styleTags = Array.from(DOCUMENT.getElementsByTagName('style')).filter(function (t) {
  557. if (t.hasAttribute(detectionIgnoreAttr)) {
  558. return false;
  559. } // If the browser has loaded the FA5 CSS, let's not test that <style> element.
  560. // Its enough that we'll be testing for traces of the corresponding JS being loaded, and testing
  561. // this <style> would only produce a false negative anyway.
  562. if (WINDOW.FontAwesomeConfig && t.innerText.match(new RegExp("svg:not\\(:root\\)\\.".concat(WINDOW.FontAwesomeConfig.replacementClass)))) {
  563. return false;
  564. }
  565. return true;
  566. });
  567. function runDiag(scriptOrLinkTag, md5) {
  568. var diagFrame = DOCUMENT.createElement('iframe'); // Using "visibility: hidden; position: absolute" instead of "display: none;" because
  569. // Firefox will not return the expected results for getComputedStyle if our iframe has display: none.
  570. diagFrame.setAttribute('style', 'visibility: hidden; position: absolute; height: 0; width: 0;');
  571. var testIconId = 'fa-test-icon-' + md5;
  572. var iTag = DOCUMENT.createElement('i');
  573. iTag.setAttribute('class', 'fa fa-coffee');
  574. iTag.setAttribute('id', testIconId);
  575. var diagScript = DOCUMENT.createElement('script');
  576. diagScript.setAttribute('id', diagScriptId); // WARNING: this function will be toString()'d and assigned to innerText of the diag script
  577. // element that we'll be putting into a diagnostic iframe.
  578. // That means that this code won't compile until after the outer script has run and injected
  579. // this code into the iframe. There are some compile time errors that might occur there.
  580. // For example, using single line (double-slash) comments like this one inside that function
  581. // will probably cause it to choke. Chrome will show an error like this:
  582. // Uncaught SyntaxError: Unexpected end of input
  583. var diagScriptFun = function diagScriptFun(nodeUnderTestId, testIconId, md5, parentOrigin) {
  584. parent.FontAwesomeDetection.__pollUntil({
  585. fn: function fn() {
  586. var iEl = document.getElementById(testIconId);
  587. var computedStyle = window.getComputedStyle(iEl);
  588. var fontFamily = computedStyle.getPropertyValue('font-family');
  589. if (!!fontFamily.match(/FontAwesome/) || !!fontFamily.match(/Font Awesome 5/)) {
  590. return true;
  591. } else {
  592. return false;
  593. }
  594. }
  595. }).then(function () {
  596. var node = document.getElementById(nodeUnderTestId);
  597. parent.postMessage({
  598. type: 'fontawesome-conflict',
  599. technology: 'webfont',
  600. href: node.href,
  601. innerText: node.innerText,
  602. tagName: node.tagName,
  603. md5: md5
  604. }, parentOrigin);
  605. })["catch"](function (e) {
  606. var node = document.getElementById(nodeUnderTestId);
  607. if (e === 'timeout') {
  608. parent.postMessage({
  609. type: 'no-conflict',
  610. technology: 'webfont',
  611. href: node.src,
  612. innerText: node.innerText,
  613. tagName: node.tagName,
  614. md5: md5
  615. }, parentOrigin);
  616. } else {
  617. console.error(e);
  618. }
  619. });
  620. };
  621. var parentOrigin = WINDOW.location.origin === 'file://' ? '*' : WINDOW.location.origin;
  622. diagScript.innerText = "(".concat(diagScriptFun.toString(), ")('").concat(nodeUnderTestId, "', '").concat(testIconId || 'foo', "', '").concat(md5, "', '").concat(parentOrigin, "');");
  623. diagFrame.onload = function () {
  624. diagFrame.contentDocument.head.appendChild(diagScript);
  625. diagFrame.contentDocument.head.appendChild(scriptOrLinkTag);
  626. diagFrame.contentDocument.body.appendChild(iTag);
  627. };
  628. domready(function () {
  629. return DOCUMENT.body.appendChild(diagFrame);
  630. });
  631. }
  632. var cssByMD5 = {};
  633. for (var i = 0; i < linkTags.length; i++) {
  634. var linkUnderTest = DOCUMENT.createElement('link');
  635. linkUnderTest.setAttribute('id', nodeUnderTestId);
  636. linkUnderTest.setAttribute('href', linkTags[i].href);
  637. linkUnderTest.setAttribute('rel', linkTags[i].rel);
  638. var md5ForLink = md5ForNode(linkTags[i]);
  639. linkUnderTest.setAttribute(md5Attr, md5ForLink);
  640. cssByMD5[md5ForLink] = linkTags[i];
  641. runDiag(linkUnderTest, md5ForLink);
  642. }
  643. for (var _i = 0; _i < styleTags.length; _i++) {
  644. var styleUnderTest = DOCUMENT.createElement('style');
  645. styleUnderTest.setAttribute('id', nodeUnderTestId);
  646. var md5ForStyle = md5ForNode(styleTags[_i]);
  647. styleUnderTest.setAttribute(md5Attr, md5ForStyle);
  648. styleUnderTest.innerText = styleTags[_i].innerText;
  649. cssByMD5[md5ForStyle] = styleTags[_i];
  650. runDiag(styleUnderTest, md5ForStyle);
  651. }
  652. return cssByMD5;
  653. }
  654. function detectSvgConflicts(currentScript) {
  655. var scripts = Array.from(DOCUMENT.scripts).filter(function (t) {
  656. return !t.hasAttribute(detectionIgnoreAttr) && t !== currentScript;
  657. });
  658. var scriptsByMD5 = {};
  659. var _loop = function _loop(scriptIdx) {
  660. var diagFrame = DOCUMENT.createElement('iframe');
  661. diagFrame.setAttribute('style', 'display:none;');
  662. var scriptUnderTest = DOCUMENT.createElement('script');
  663. scriptUnderTest.setAttribute('id', nodeUnderTestId);
  664. var md5ForScript = md5ForNode(scripts[scriptIdx]);
  665. scriptUnderTest.setAttribute(md5Attr, md5ForScript);
  666. scriptsByMD5[md5ForScript] = scripts[scriptIdx];
  667. if (scripts[scriptIdx].src !== '') {
  668. scriptUnderTest.src = scripts[scriptIdx].src;
  669. }
  670. if (scripts[scriptIdx].innerText !== '') {
  671. scriptUnderTest.innerText = scripts[scriptIdx].innerText;
  672. }
  673. scriptUnderTest.async = true;
  674. var diagScript = DOCUMENT.createElement('script');
  675. diagScript.setAttribute('id', diagScriptId);
  676. var parentOrigin = WINDOW.location.origin === 'file://' ? '*' : WINDOW.location.origin;
  677. var diagScriptFun = function diagScriptFun(nodeUnderTestId, md5, parentOrigin) {
  678. parent.FontAwesomeDetection.__pollUntil({
  679. fn: function fn() {
  680. return !!window.FontAwesomeConfig;
  681. }
  682. }).then(function () {
  683. var scriptNode = document.getElementById(nodeUnderTestId);
  684. parent.postMessage({
  685. type: 'fontawesome-conflict',
  686. technology: 'js',
  687. src: scriptNode.src,
  688. innerText: scriptNode.innerText,
  689. tagName: scriptNode.tagName,
  690. md5: md5
  691. }, parentOrigin);
  692. })["catch"](function (e) {
  693. var scriptNode = document.getElementById(nodeUnderTestId);
  694. if (e === 'timeout') {
  695. parent.postMessage({
  696. type: 'no-conflict',
  697. src: scriptNode.src,
  698. innerText: scriptNode.innerText,
  699. tagName: scriptNode.tagName,
  700. md5: md5
  701. }, parentOrigin);
  702. } else {
  703. console.error(e);
  704. }
  705. });
  706. };
  707. diagScript.innerText = "(".concat(diagScriptFun.toString(), ")('").concat(nodeUnderTestId, "', '").concat(md5ForScript, "', '").concat(parentOrigin, "');");
  708. diagFrame.onload = function () {
  709. diagFrame.contentDocument.head.appendChild(diagScript);
  710. diagFrame.contentDocument.head.appendChild(scriptUnderTest);
  711. };
  712. domready(function () {
  713. return DOCUMENT.body.appendChild(diagFrame);
  714. });
  715. };
  716. for (var scriptIdx = 0; scriptIdx < scripts.length; scriptIdx++) {
  717. _loop(scriptIdx);
  718. }
  719. return scriptsByMD5;
  720. }
  721. function setDoneResults(_ref2) {
  722. var nodesTested = _ref2.nodesTested,
  723. nodesFound = _ref2.nodesFound;
  724. WINDOW.FontAwesomeDetection = WINDOW.FontAwesomeDetection || {};
  725. WINDOW.FontAwesomeDetection.nodesTested = nodesTested;
  726. WINDOW.FontAwesomeDetection.nodesFound = nodesFound;
  727. WINDOW.FontAwesomeDetection.detectionDone = true;
  728. }
  729. function conflictDetection() {
  730. var report$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
  731. var nodesTested = {
  732. conflict: {},
  733. noConflict: {}
  734. };
  735. WINDOW.onmessage = function (e) {
  736. if (WINDOW.location.origin === 'file://' || e.origin === WINDOW.location.origin) {
  737. if (e && e.data) {
  738. if (e.data.type === 'fontawesome-conflict') {
  739. nodesTested.conflict[e.data.md5] = e.data;
  740. } else if (e.data.type === 'no-conflict') {
  741. nodesTested.noConflict[e.data.md5] = e.data;
  742. }
  743. }
  744. }
  745. };
  746. var scriptsToTest = detectSvgConflicts(DOCUMENT.currentScript);
  747. var cssToTest = detectWebfontConflicts();
  748. var nodesFound = _objectSpread({}, scriptsToTest, cssToTest);
  749. var testCount = Object.keys(scriptsToTest).length + Object.keys(cssToTest).length; // The resultsCollectionMaxWait allows for the time between when the tests running under
  750. // child iframes call postMessage with their results, and when the parent window
  751. // receives and handles those events with window.onmessage.
  752. // Making it configurable allows us to test the scenario where this timeout is exceeded.
  753. // Naming it something very different from "timeout" is to help avoid the potential ambiguity between
  754. // these two timeout-related settings.
  755. var masterTimeout = WINDOW.FontAwesomeDetection.timeout + WINDOW.FontAwesomeDetection.resultsCollectionMaxWait;
  756. console.group('Font Awesome Detector');
  757. if (testCount === 0) {
  758. console.info('%cAll Good!', 'color: green; font-size: large');
  759. console.info('We didn\'t find anything that needs testing for conflicts. Ergo, no conflicts.');
  760. } else {
  761. console.info("Testing ".concat(testCount, " possible conflicts."));
  762. console.info("We'll wait about ".concat(Math.round(WINDOW.FontAwesomeDetection.timeout / 10) / 100, " seconds while testing these and\n") + "then up to another ".concat(Math.round(WINDOW.FontAwesomeDetection.resultsCollectionMaxWait / 10) / 100, " to allow the browser time\n") + "to accumulate the results. But we'll probably be outta here way before then.\n\n");
  763. console.info("You can adjust those durations by assigning values to these attributes on the <script> element that loads this detection:");
  764. console.info("\t%c".concat(timeoutAttr, "%c: milliseconds to wait for each test before deciding whether it's a conflict."), 'font-weight: bold;', 'font-size: normal;');
  765. console.info("\t%c".concat(resultsCollectionMaxWaitAttr, "%c: milliseconds to wait for the browser to accumulate test results before giving up."), 'font-weight: bold;', 'font-size: normal;');
  766. pollUntil({
  767. // Give this overall timer a little extra cushion
  768. maxDuration: masterTimeout,
  769. showProgress: true,
  770. progressIndicator: 'waiting...',
  771. fn: function fn() {
  772. return Object.keys(nodesTested.conflict).length + Object.keys(nodesTested.noConflict).length >= testCount;
  773. }
  774. }).then(function () {
  775. console.info('DONE!');
  776. setDoneResults({
  777. nodesTested: nodesTested,
  778. nodesFound: nodesFound
  779. });
  780. report$$1({
  781. nodesTested: nodesTested,
  782. nodesFound: nodesFound
  783. });
  784. console.groupEnd();
  785. })["catch"](function (e) {
  786. if (e === 'timeout') {
  787. console.info('TIME OUT! We waited until we got tired. Here\'s what we found:');
  788. setDoneResults({
  789. nodesTested: nodesTested,
  790. nodesFound: nodesFound
  791. });
  792. report$$1({
  793. nodesTested: nodesTested,
  794. nodesFound: nodesFound
  795. });
  796. } else {
  797. console.info('Whoops! We hit an error:', e);
  798. console.info('Here\'s what we\'d found up until that error:');
  799. setDoneResults({
  800. nodesTested: nodesTested,
  801. nodesFound: nodesFound
  802. });
  803. report$$1({
  804. nodesTested: nodesTested,
  805. nodesFound: nodesFound
  806. });
  807. }
  808. console.groupEnd();
  809. });
  810. }
  811. } // Allow clients to access, and in some cases, override some properties
  812. var initialConfig = WINDOW.FontAwesomeDetection || {}; // These can be overridden
  813. var _default = {
  814. report: report,
  815. timeout: +(DOCUMENT.currentScript.getAttribute(timeoutAttr) || "2000"),
  816. resultsCollectionMaxWait: +(DOCUMENT.currentScript.getAttribute(resultsCollectionMaxWaitAttr) || "5000")
  817. };
  818. var _config = _objectSpread({}, _default, initialConfig, {
  819. // These cannot be overridden
  820. __pollUntil: pollUntil,
  821. md5ForNode: md5ForNode,
  822. detectionDone: false,
  823. nodesTested: null,
  824. nodesFound: null
  825. });
  826. WINDOW.FontAwesomeDetection = _config;
  827. var PRODUCTION = function () {
  828. try {
  829. return process.env.NODE_ENV === 'production';
  830. } catch (e) {
  831. return false;
  832. }
  833. }();
  834. function bunker(fn) {
  835. try {
  836. fn();
  837. } catch (e) {
  838. if (!PRODUCTION) {
  839. throw e;
  840. }
  841. }
  842. }
  843. bunker(function () {
  844. if (IS_BROWSER && IS_DOM) {
  845. conflictDetection(window.FontAwesomeDetection.report);
  846. }
  847. });
  848. exports.conflictDetection = conflictDetection;
  849. Object.defineProperty(exports, '__esModule', {
  850. value: true
  851. });
  852. });