conflict-detection.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. /*!
  2. * Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com
  3. * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
  4. * Copyright 2024 Fonticons, Inc.
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (factory());
  10. }(this, (function () { 'use strict';
  11. function _defineProperty(e, r, t) {
  12. return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
  13. value: t,
  14. enumerable: !0,
  15. configurable: !0,
  16. writable: !0
  17. }) : e[r] = t, e;
  18. }
  19. function ownKeys(e, r) {
  20. var t = Object.keys(e);
  21. if (Object.getOwnPropertySymbols) {
  22. var o = Object.getOwnPropertySymbols(e);
  23. r && (o = o.filter(function (r) {
  24. return Object.getOwnPropertyDescriptor(e, r).enumerable;
  25. })), t.push.apply(t, o);
  26. }
  27. return t;
  28. }
  29. function _objectSpread2(e) {
  30. for (var r = 1; r < arguments.length; r++) {
  31. var t = null != arguments[r] ? arguments[r] : {};
  32. r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
  33. _defineProperty(e, r, t[r]);
  34. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
  35. Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
  36. });
  37. }
  38. return e;
  39. }
  40. function _toPrimitive(t, r) {
  41. if ("object" != typeof t || !t) return t;
  42. var e = t[Symbol.toPrimitive];
  43. if (void 0 !== e) {
  44. var i = e.call(t, r || "default");
  45. if ("object" != typeof i) return i;
  46. throw new TypeError("@@toPrimitive must return a primitive value.");
  47. }
  48. return ("string" === r ? String : Number)(t);
  49. }
  50. function _toPropertyKey(t) {
  51. var i = _toPrimitive(t, "string");
  52. return "symbol" == typeof i ? i : i + "";
  53. }
  54. let _WINDOW = {};
  55. let _DOCUMENT = {};
  56. try {
  57. if (typeof window !== 'undefined') _WINDOW = window;
  58. if (typeof document !== 'undefined') _DOCUMENT = document;
  59. } catch (e) {}
  60. const {
  61. userAgent = ''
  62. } = _WINDOW.navigator || {};
  63. const WINDOW = _WINDOW;
  64. const DOCUMENT = _DOCUMENT;
  65. const IS_BROWSER = !!WINDOW.document;
  66. const IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
  67. const IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
  68. const functions = [];
  69. const listener = function () {
  70. DOCUMENT.removeEventListener('DOMContentLoaded', listener);
  71. loaded = 1;
  72. functions.map(fn => fn());
  73. };
  74. let loaded = false;
  75. if (IS_DOM) {
  76. loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
  77. if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
  78. }
  79. function domready (fn) {
  80. if (!IS_DOM) return;
  81. loaded ? setTimeout(fn, 0) : functions.push(fn);
  82. }
  83. function report (_ref) {
  84. let {
  85. nodesTested,
  86. nodesFound
  87. } = _ref;
  88. const timedOutTests = {};
  89. for (let key in nodesFound) {
  90. if (!(nodesTested.conflict[key] || nodesTested.noConflict[key])) {
  91. timedOutTests[key] = nodesFound[key];
  92. }
  93. }
  94. const conflictsCount = Object.keys(nodesTested.conflict).length;
  95. if (conflictsCount > 0) {
  96. console.info("%cConflict".concat(conflictsCount > 1 ? 's' : '', " found:"), 'color: darkred; font-size: large');
  97. const data = {};
  98. for (let key in nodesTested.conflict) {
  99. const item = nodesTested.conflict[key];
  100. data[key] = {
  101. 'tagName': item.tagName,
  102. 'src/href': item.src || item.href || 'n/a',
  103. 'innerText excerpt': item.innerText && item.innerText !== '' ? item.innerText.slice(0, 200) + '...' : '(empty)'
  104. };
  105. }
  106. console.table(data);
  107. }
  108. const noConflictsCount = Object.keys(nodesTested.noConflict).length;
  109. if (noConflictsCount > 0) {
  110. console.info("%cNo conflict".concat(noConflictsCount > 1 ? 's' : '', " found with ").concat(noConflictsCount === 1 ? 'this' : 'these', ":"), 'color: green; font-size: large');
  111. const data = {};
  112. for (let key in nodesTested.noConflict) {
  113. const item = nodesTested.noConflict[key];
  114. data[key] = {
  115. 'tagName': item.tagName,
  116. 'src/href': item.src || item.href || 'n/a',
  117. 'innerText excerpt': item.innerText && item.innerText !== '' ? item.innerText.slice(0, 200) + '...' : '(empty)'
  118. };
  119. }
  120. console.table(data);
  121. }
  122. const timeOutCount = Object.keys(timedOutTests).length;
  123. if (timeOutCount > 0) {
  124. console.info("%cLeftovers--we timed out before collecting test results for ".concat(timeOutCount === 1 ? 'this' : 'these', ":"), 'color: blue; font-size: large');
  125. const data = {};
  126. for (let key in timedOutTests) {
  127. const item = timedOutTests[key];
  128. data[key] = {
  129. 'tagName': item.tagName,
  130. 'src/href': item.src || item.href || 'n/a',
  131. 'innerText excerpt': item.innerText && item.innerText !== '' ? item.innerText.slice(0, 200) + '...' : '(empty)'
  132. };
  133. }
  134. console.table(data);
  135. }
  136. }
  137. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  138. function createCommonjsModule(fn, module) {
  139. return module = { exports: {} }, fn(module, module.exports), module.exports;
  140. }
  141. var md5 = createCommonjsModule(function (module) {
  142. (function ($) {
  143. /**
  144. * Add integers, wrapping at 2^32.
  145. * This uses 16-bit operations internally to work around bugs in interpreters.
  146. *
  147. * @param {number} x First integer
  148. * @param {number} y Second integer
  149. * @returns {number} Sum
  150. */
  151. function safeAdd(x, y) {
  152. var lsw = (x & 0xffff) + (y & 0xffff);
  153. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  154. return msw << 16 | lsw & 0xffff;
  155. }
  156. /**
  157. * Bitwise rotate a 32-bit number to the left.
  158. *
  159. * @param {number} num 32-bit number
  160. * @param {number} cnt Rotation count
  161. * @returns {number} Rotated number
  162. */
  163. function bitRotateLeft(num, cnt) {
  164. return num << cnt | num >>> 32 - cnt;
  165. }
  166. /**
  167. * Basic operation the algorithm uses.
  168. *
  169. * @param {number} q q
  170. * @param {number} a a
  171. * @param {number} b b
  172. * @param {number} x x
  173. * @param {number} s s
  174. * @param {number} t t
  175. * @returns {number} Result
  176. */
  177. function md5cmn(q, a, b, x, s, t) {
  178. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
  179. }
  180. /**
  181. * Basic operation the algorithm uses.
  182. *
  183. * @param {number} a a
  184. * @param {number} b b
  185. * @param {number} c c
  186. * @param {number} d d
  187. * @param {number} x x
  188. * @param {number} s s
  189. * @param {number} t t
  190. * @returns {number} Result
  191. */
  192. function md5ff(a, b, c, d, x, s, t) {
  193. return md5cmn(b & c | ~b & d, a, b, x, s, t);
  194. }
  195. /**
  196. * Basic operation the algorithm uses.
  197. *
  198. * @param {number} a a
  199. * @param {number} b b
  200. * @param {number} c c
  201. * @param {number} d d
  202. * @param {number} x x
  203. * @param {number} s s
  204. * @param {number} t t
  205. * @returns {number} Result
  206. */
  207. function md5gg(a, b, c, d, x, s, t) {
  208. return md5cmn(b & d | c & ~d, a, b, x, s, t);
  209. }
  210. /**
  211. * Basic operation the algorithm uses.
  212. *
  213. * @param {number} a a
  214. * @param {number} b b
  215. * @param {number} c c
  216. * @param {number} d d
  217. * @param {number} x x
  218. * @param {number} s s
  219. * @param {number} t t
  220. * @returns {number} Result
  221. */
  222. function md5hh(a, b, c, d, x, s, t) {
  223. return md5cmn(b ^ c ^ d, a, b, x, s, t);
  224. }
  225. /**
  226. * Basic operation the algorithm uses.
  227. *
  228. * @param {number} a a
  229. * @param {number} b b
  230. * @param {number} c c
  231. * @param {number} d d
  232. * @param {number} x x
  233. * @param {number} s s
  234. * @param {number} t t
  235. * @returns {number} Result
  236. */
  237. function md5ii(a, b, c, d, x, s, t) {
  238. return md5cmn(c ^ (b | ~d), a, b, x, s, t);
  239. }
  240. /**
  241. * Calculate the MD5 of an array of little-endian words, and a bit length.
  242. *
  243. * @param {Array} x Array of little-endian words
  244. * @param {number} len Bit length
  245. * @returns {Array<number>} MD5 Array
  246. */
  247. function binlMD5(x, len) {
  248. /* append padding */
  249. x[len >> 5] |= 0x80 << len % 32;
  250. x[(len + 64 >>> 9 << 4) + 14] = len;
  251. var i;
  252. var olda;
  253. var oldb;
  254. var oldc;
  255. var oldd;
  256. var a = 1732584193;
  257. var b = -271733879;
  258. var c = -1732584194;
  259. var d = 271733878;
  260. for (i = 0; i < x.length; i += 16) {
  261. olda = a;
  262. oldb = b;
  263. oldc = c;
  264. oldd = d;
  265. a = md5ff(a, b, c, d, x[i], 7, -680876936);
  266. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
  267. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
  268. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
  269. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
  270. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
  271. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
  272. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
  273. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
  274. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
  275. c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
  276. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
  277. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
  278. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
  279. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
  280. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
  281. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
  282. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
  283. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
  284. b = md5gg(b, c, d, a, x[i], 20, -373897302);
  285. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
  286. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
  287. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
  288. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
  289. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
  290. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
  291. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
  292. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
  293. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
  294. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
  295. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
  296. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
  297. a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
  298. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
  299. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
  300. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
  301. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
  302. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
  303. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
  304. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
  305. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
  306. d = md5hh(d, a, b, c, x[i], 11, -358537222);
  307. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
  308. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
  309. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
  310. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
  311. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
  312. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
  313. a = md5ii(a, b, c, d, x[i], 6, -198630844);
  314. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
  315. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
  316. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
  317. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
  318. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
  319. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
  320. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
  321. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
  322. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
  323. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
  324. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
  325. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
  326. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
  327. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
  328. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
  329. a = safeAdd(a, olda);
  330. b = safeAdd(b, oldb);
  331. c = safeAdd(c, oldc);
  332. d = safeAdd(d, oldd);
  333. }
  334. return [a, b, c, d];
  335. }
  336. /**
  337. * Convert an array of little-endian words to a string
  338. *
  339. * @param {Array<number>} input MD5 Array
  340. * @returns {string} MD5 string
  341. */
  342. function binl2rstr(input) {
  343. var i;
  344. var output = '';
  345. var length32 = input.length * 32;
  346. for (i = 0; i < length32; i += 8) {
  347. output += String.fromCharCode(input[i >> 5] >>> i % 32 & 0xff);
  348. }
  349. return output;
  350. }
  351. /**
  352. * Convert a raw string to an array of little-endian words
  353. * Characters >255 have their high-byte silently ignored.
  354. *
  355. * @param {string} input Raw input string
  356. * @returns {Array<number>} Array of little-endian words
  357. */
  358. function rstr2binl(input) {
  359. var i;
  360. var output = [];
  361. output[(input.length >> 2) - 1] = undefined;
  362. for (i = 0; i < output.length; i += 1) {
  363. output[i] = 0;
  364. }
  365. var length8 = input.length * 8;
  366. for (i = 0; i < length8; i += 8) {
  367. output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
  368. }
  369. return output;
  370. }
  371. /**
  372. * Calculate the MD5 of a raw string
  373. *
  374. * @param {string} s Input string
  375. * @returns {string} Raw MD5 string
  376. */
  377. function rstrMD5(s) {
  378. return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));
  379. }
  380. /**
  381. * Calculates the HMAC-MD5 of a key and some data (raw strings)
  382. *
  383. * @param {string} key HMAC key
  384. * @param {string} data Raw input string
  385. * @returns {string} Raw MD5 string
  386. */
  387. function rstrHMACMD5(key, data) {
  388. var i;
  389. var bkey = rstr2binl(key);
  390. var ipad = [];
  391. var opad = [];
  392. var hash;
  393. ipad[15] = opad[15] = undefined;
  394. if (bkey.length > 16) {
  395. bkey = binlMD5(bkey, key.length * 8);
  396. }
  397. for (i = 0; i < 16; i += 1) {
  398. ipad[i] = bkey[i] ^ 0x36363636;
  399. opad[i] = bkey[i] ^ 0x5c5c5c5c;
  400. }
  401. hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
  402. return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));
  403. }
  404. /**
  405. * Convert a raw string to a hex string
  406. *
  407. * @param {string} input Raw input string
  408. * @returns {string} Hex encoded string
  409. */
  410. function rstr2hex(input) {
  411. var hexTab = '0123456789abcdef';
  412. var output = '';
  413. var x;
  414. var i;
  415. for (i = 0; i < input.length; i += 1) {
  416. x = input.charCodeAt(i);
  417. output += hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f);
  418. }
  419. return output;
  420. }
  421. /**
  422. * Encode a string as UTF-8
  423. *
  424. * @param {string} input Input string
  425. * @returns {string} UTF8 string
  426. */
  427. function str2rstrUTF8(input) {
  428. return unescape(encodeURIComponent(input));
  429. }
  430. /**
  431. * Encodes input string as raw MD5 string
  432. *
  433. * @param {string} s Input string
  434. * @returns {string} Raw MD5 string
  435. */
  436. function rawMD5(s) {
  437. return rstrMD5(str2rstrUTF8(s));
  438. }
  439. /**
  440. * Encodes input string as Hex encoded string
  441. *
  442. * @param {string} s Input string
  443. * @returns {string} Hex encoded string
  444. */
  445. function hexMD5(s) {
  446. return rstr2hex(rawMD5(s));
  447. }
  448. /**
  449. * Calculates the raw HMAC-MD5 for the given key and data
  450. *
  451. * @param {string} k HMAC key
  452. * @param {string} d Input string
  453. * @returns {string} Raw MD5 string
  454. */
  455. function rawHMACMD5(k, d) {
  456. return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
  457. }
  458. /**
  459. * Calculates the Hex encoded HMAC-MD5 for the given key and data
  460. *
  461. * @param {string} k HMAC key
  462. * @param {string} d Input string
  463. * @returns {string} Raw MD5 string
  464. */
  465. function hexHMACMD5(k, d) {
  466. return rstr2hex(rawHMACMD5(k, d));
  467. }
  468. /**
  469. * Calculates MD5 value for a given string.
  470. * If a key is provided, calculates the HMAC-MD5 value.
  471. * Returns a Hex encoded string unless the raw argument is given.
  472. *
  473. * @param {string} string Input string
  474. * @param {string} [key] HMAC key
  475. * @param {boolean} [raw] Raw output switch
  476. * @returns {string} MD5 output
  477. */
  478. function md5(string, key, raw) {
  479. if (!key) {
  480. if (!raw) {
  481. return hexMD5(string);
  482. }
  483. return rawMD5(string);
  484. }
  485. if (!raw) {
  486. return hexHMACMD5(key, string);
  487. }
  488. return rawHMACMD5(key, string);
  489. }
  490. if (module.exports) {
  491. module.exports = md5;
  492. } else {
  493. $.md5 = md5;
  494. }
  495. })(commonjsGlobal);
  496. });
  497. function md5ForNode(node) {
  498. if (null === node || 'object' !== typeof node) return undefined;
  499. if (node.src) {
  500. return md5(node.src);
  501. } else if (node.href) {
  502. return md5(node.href);
  503. } else if (node.innerText && '' !== node.innerText) {
  504. // eslint-disable-line yoda
  505. return md5(node.innerText);
  506. } else {
  507. return undefined;
  508. }
  509. }
  510. const diagScriptId = 'fa-kits-diag';
  511. const nodeUnderTestId = 'fa-kits-node-under-test';
  512. const md5Attr = 'data-md5';
  513. const detectionIgnoreAttr = 'data-fa-detection-ignore';
  514. const timeoutAttr = 'data-fa-detection-timeout';
  515. const resultsCollectionMaxWaitAttr = 'data-fa-detection-results-collection-max-wait';
  516. const silenceErrors = e => {
  517. e.preventDefault();
  518. e.stopPropagation();
  519. };
  520. function pollUntil(_ref) {
  521. let {
  522. fn = () => true,
  523. initialDuration = 1,
  524. maxDuration = WINDOW.FontAwesomeDetection.timeout,
  525. showProgress = false,
  526. progressIndicator
  527. } = _ref;
  528. return new Promise(function (resolve, reject) {
  529. // eslint-disable-line compat/compat
  530. function poll(duration, cumulativeDuration) {
  531. setTimeout(function () {
  532. const result = fn();
  533. if (showProgress) {
  534. console.info(progressIndicator);
  535. }
  536. if (!!result) {
  537. // eslint-disable-line no-extra-boolean-cast
  538. resolve(result);
  539. } else {
  540. const nextDuration = 250;
  541. const nextCumulativeDuration = nextDuration + cumulativeDuration;
  542. if (nextCumulativeDuration <= maxDuration) {
  543. poll(nextDuration, nextCumulativeDuration);
  544. } else {
  545. reject('timeout'); // eslint-disable-line prefer-promise-reject-errors
  546. }
  547. }
  548. }, duration);
  549. }
  550. poll(initialDuration, 0);
  551. });
  552. }
  553. function detectWebfontConflicts() {
  554. const linkTags = Array.from(DOCUMENT.getElementsByTagName('link')).filter(t => !t.hasAttribute(detectionIgnoreAttr));
  555. const styleTags = Array.from(DOCUMENT.getElementsByTagName('style')).filter(t => {
  556. if (t.hasAttribute(detectionIgnoreAttr)) {
  557. return false;
  558. }
  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. const diagFrame = DOCUMENT.createElement('iframe');
  569. // Using "visibility: hidden; position: absolute" instead of "display: none;" because
  570. // Firefox will not return the expected results for getComputedStyle if our iframe has display: none.
  571. diagFrame.setAttribute('style', 'visibility: hidden; position: absolute; height: 0; width: 0;');
  572. const testIconId = 'fa-test-icon-' + md5;
  573. const iTag = DOCUMENT.createElement('i');
  574. iTag.setAttribute('class', 'fa fa-coffee');
  575. iTag.setAttribute('id', testIconId);
  576. const diagScript = DOCUMENT.createElement('script');
  577. diagScript.setAttribute('id', diagScriptId);
  578. // WARNING: this function will be toString()'d and assigned to innerText of the diag script
  579. // element that we'll be putting into a diagnostic iframe.
  580. // That means that this code won't compile until after the outer script has run and injected
  581. // this code into the iframe. There are some compile time errors that might occur there.
  582. // For example, using single line (double-slash) comments like this one inside that function
  583. // will probably cause it to choke. Chrome will show an error like this:
  584. // Uncaught SyntaxError: Unexpected end of input
  585. const diagScriptFun = (nodeUnderTestId, testIconId, md5, parentOrigin) => {
  586. parent.FontAwesomeDetection.__pollUntil({
  587. fn: () => {
  588. const iEl = document.getElementById(testIconId);
  589. const computedStyle = window.getComputedStyle(iEl);
  590. const fontFamily = computedStyle.getPropertyValue('font-family');
  591. if (!!fontFamily.match(/FontAwesome/) || !!fontFamily.match(/Font Awesome [56]/)) {
  592. return true;
  593. } else {
  594. return false;
  595. }
  596. }
  597. }).then(() => {
  598. const node = document.getElementById(nodeUnderTestId);
  599. parent.postMessage({
  600. type: 'fontawesome-conflict',
  601. technology: 'webfont',
  602. href: node.href,
  603. innerText: node.innerText,
  604. tagName: node.tagName,
  605. md5
  606. }, parentOrigin);
  607. }).catch(function (e) {
  608. const node = document.getElementById(nodeUnderTestId);
  609. if (e === 'timeout') {
  610. parent.postMessage({
  611. type: 'no-conflict',
  612. technology: 'webfont',
  613. href: node.src,
  614. innerText: node.innerText,
  615. tagName: node.tagName,
  616. md5
  617. }, parentOrigin);
  618. } else {
  619. console.error(e);
  620. }
  621. });
  622. };
  623. const parentOrigin = WINDOW.location.origin === 'file://' ? '*' : WINDOW.location.origin;
  624. diagScript.innerText = "(".concat(diagScriptFun.toString(), ")('").concat(nodeUnderTestId, "', '").concat(testIconId || 'foo', "', '").concat(md5, "', '").concat(parentOrigin, "');");
  625. diagFrame.onload = function () {
  626. diagFrame.contentWindow.addEventListener('error', silenceErrors, true);
  627. diagFrame.contentDocument.head.appendChild(diagScript);
  628. diagFrame.contentDocument.head.appendChild(scriptOrLinkTag);
  629. diagFrame.contentDocument.body.appendChild(iTag);
  630. };
  631. domready(() => DOCUMENT.body.appendChild(diagFrame));
  632. }
  633. const cssByMD5 = {};
  634. for (let i = 0; i < linkTags.length; i++) {
  635. const linkUnderTest = DOCUMENT.createElement('link');
  636. linkUnderTest.setAttribute('id', nodeUnderTestId);
  637. linkUnderTest.setAttribute('href', linkTags[i].href);
  638. linkUnderTest.setAttribute('rel', linkTags[i].rel);
  639. const md5ForLink = md5ForNode(linkTags[i]);
  640. linkUnderTest.setAttribute(md5Attr, md5ForLink);
  641. cssByMD5[md5ForLink] = linkTags[i];
  642. runDiag(linkUnderTest, md5ForLink);
  643. }
  644. for (let i = 0; i < styleTags.length; i++) {
  645. var styleUnderTest = DOCUMENT.createElement('style');
  646. styleUnderTest.setAttribute('id', nodeUnderTestId);
  647. const md5ForStyle = md5ForNode(styleTags[i]);
  648. styleUnderTest.setAttribute(md5Attr, md5ForStyle);
  649. styleUnderTest.innerText = styleTags[i].innerText;
  650. cssByMD5[md5ForStyle] = styleTags[i];
  651. runDiag(styleUnderTest, md5ForStyle);
  652. }
  653. return cssByMD5;
  654. }
  655. function detectSvgConflicts(currentScript) {
  656. const scripts = Array.from(DOCUMENT.scripts).filter(t => !t.hasAttribute(detectionIgnoreAttr) && t !== currentScript);
  657. const scriptsByMD5 = {};
  658. for (let scriptIdx = 0; scriptIdx < scripts.length; scriptIdx++) {
  659. const diagFrame = DOCUMENT.createElement('iframe');
  660. diagFrame.setAttribute('style', 'display:none;');
  661. const scriptUnderTest = DOCUMENT.createElement('script');
  662. scriptUnderTest.setAttribute('id', nodeUnderTestId);
  663. const md5ForScript = md5ForNode(scripts[scriptIdx]);
  664. scriptUnderTest.setAttribute(md5Attr, md5ForScript);
  665. scriptsByMD5[md5ForScript] = scripts[scriptIdx];
  666. if (scripts[scriptIdx].src !== '') {
  667. scriptUnderTest.src = scripts[scriptIdx].src;
  668. }
  669. if (scripts[scriptIdx].innerText !== '') {
  670. scriptUnderTest.innerText = scripts[scriptIdx].innerText;
  671. }
  672. scriptUnderTest.async = true;
  673. const diagScript = DOCUMENT.createElement('script');
  674. diagScript.setAttribute('id', diagScriptId);
  675. const parentOrigin = WINDOW.location.origin === 'file://' ? '*' : WINDOW.location.origin;
  676. const diagScriptFun = (nodeUnderTestId, md5, parentOrigin) => {
  677. parent.FontAwesomeDetection.__pollUntil({
  678. fn: () => {
  679. return !!window.FontAwesomeConfig || !!window.FontAwesomeKitConfig;
  680. }
  681. }).then(function () {
  682. const scriptNode = document.getElementById(nodeUnderTestId);
  683. parent.postMessage({
  684. type: 'fontawesome-conflict',
  685. technology: 'js',
  686. src: scriptNode.src,
  687. innerText: scriptNode.innerText,
  688. tagName: scriptNode.tagName,
  689. md5
  690. }, parentOrigin);
  691. }).catch(function (e) {
  692. var scriptNode = document.getElementById(nodeUnderTestId);
  693. if (e === 'timeout') {
  694. parent.postMessage({
  695. type: 'no-conflict',
  696. src: scriptNode.src,
  697. innerText: scriptNode.innerText,
  698. tagName: scriptNode.tagName,
  699. md5
  700. }, parentOrigin);
  701. } else {
  702. console.error(e);
  703. }
  704. });
  705. };
  706. diagScript.innerText = "(".concat(diagScriptFun.toString(), ")('").concat(nodeUnderTestId, "', '").concat(md5ForScript, "', '").concat(parentOrigin, "');");
  707. diagFrame.onload = function () {
  708. diagFrame.contentWindow.addEventListener('error', silenceErrors, true);
  709. diagFrame.contentDocument.head.appendChild(diagScript);
  710. diagFrame.contentDocument.head.appendChild(scriptUnderTest);
  711. };
  712. domready(() => DOCUMENT.body.appendChild(diagFrame));
  713. }
  714. return scriptsByMD5;
  715. }
  716. function setDoneResults(_ref2) {
  717. let {
  718. nodesTested,
  719. nodesFound
  720. } = _ref2;
  721. WINDOW.FontAwesomeDetection = WINDOW.FontAwesomeDetection || {};
  722. WINDOW.FontAwesomeDetection.nodesTested = nodesTested;
  723. WINDOW.FontAwesomeDetection.nodesFound = nodesFound;
  724. WINDOW.FontAwesomeDetection.detectionDone = true;
  725. }
  726. function conflictDetection() {
  727. let report$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
  728. const nodesTested = {
  729. conflict: {},
  730. noConflict: {}
  731. };
  732. WINDOW.onmessage = function (e) {
  733. if (WINDOW.location.origin === 'file://' || e.origin === WINDOW.location.origin) {
  734. if (e && e.data) {
  735. if (e.data.type === 'fontawesome-conflict') {
  736. nodesTested.conflict[e.data.md5] = e.data;
  737. } else if (e.data.type === 'no-conflict') {
  738. nodesTested.noConflict[e.data.md5] = e.data;
  739. }
  740. }
  741. }
  742. };
  743. const scriptsToTest = detectSvgConflicts(DOCUMENT.currentScript);
  744. const cssToTest = detectWebfontConflicts();
  745. const nodesFound = _objectSpread2(_objectSpread2({}, scriptsToTest), cssToTest);
  746. const testCount = Object.keys(scriptsToTest).length + Object.keys(cssToTest).length;
  747. // The resultsCollectionMaxWait allows for the time between when the tests running under
  748. // child iframes call postMessage with their results, and when the parent window
  749. // receives and handles those events with window.onmessage.
  750. // Making it configurable allows us to test the scenario where this timeout is exceeded.
  751. // Naming it something very different from "timeout" is to help avoid the potential ambiguity between
  752. // these two timeout-related settings.
  753. const masterTimeout = WINDOW.FontAwesomeDetection.timeout + WINDOW.FontAwesomeDetection.resultsCollectionMaxWait;
  754. console.group('Font Awesome Detector');
  755. if (testCount === 0) {
  756. console.info('%cAll Good!', 'color: green; font-size: large');
  757. console.info('We didn\'t find anything that needs testing for conflicts. Ergo, no conflicts.');
  758. } else {
  759. console.info("Testing ".concat(testCount, " possible conflicts."));
  760. 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");
  761. console.info("You can adjust those durations by assigning values to these attributes on the <script> element that loads this detection:");
  762. 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;');
  763. 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;');
  764. pollUntil({
  765. // Give this overall timer a little extra cushion
  766. maxDuration: masterTimeout,
  767. showProgress: true,
  768. progressIndicator: 'waiting...',
  769. fn: () => {
  770. return Object.keys(nodesTested.conflict).length + Object.keys(nodesTested.noConflict).length >= testCount;
  771. }
  772. }).then(() => {
  773. console.info('DONE!');
  774. setDoneResults({
  775. nodesTested,
  776. nodesFound
  777. });
  778. report$$1({
  779. nodesTested,
  780. nodesFound
  781. });
  782. console.groupEnd();
  783. }).catch(e => {
  784. if (e === 'timeout') {
  785. console.info('TIME OUT! We waited until we got tired. Here\'s what we found:');
  786. setDoneResults({
  787. nodesTested,
  788. nodesFound
  789. });
  790. report$$1({
  791. nodesTested,
  792. nodesFound
  793. });
  794. } else {
  795. console.info('Whoops! We hit an error:', e);
  796. console.info('Here\'s what we\'d found up until that error:');
  797. setDoneResults({
  798. nodesTested,
  799. nodesFound
  800. });
  801. report$$1({
  802. nodesTested,
  803. nodesFound
  804. });
  805. }
  806. console.groupEnd();
  807. });
  808. }
  809. }
  810. // Allow clients to access, and in some cases, override some properties
  811. const initialConfig = WINDOW.FontAwesomeDetection || {};
  812. // These can be overridden
  813. const _default = {
  814. report,
  815. timeout: +(DOCUMENT.currentScript.getAttribute(timeoutAttr) || "2000"),
  816. resultsCollectionMaxWait: +(DOCUMENT.currentScript.getAttribute(resultsCollectionMaxWaitAttr) || "5000")
  817. };
  818. const _config = _objectSpread2(_objectSpread2(_objectSpread2({}, _default), initialConfig), {}, {
  819. // These cannot be overridden
  820. __pollUntil: pollUntil,
  821. md5ForNode,
  822. detectionDone: false,
  823. nodesTested: null,
  824. nodesFound: null
  825. });
  826. WINDOW.FontAwesomeDetection = _config;
  827. var S = {
  828. classic: {
  829. fa: "solid",
  830. fas: "solid",
  831. "fa-solid": "solid",
  832. far: "regular",
  833. "fa-regular": "regular",
  834. fal: "light",
  835. "fa-light": "light",
  836. fat: "thin",
  837. "fa-thin": "thin",
  838. fab: "brands",
  839. "fa-brands": "brands"
  840. },
  841. duotone: {
  842. fa: "solid",
  843. fad: "solid",
  844. "fa-solid": "solid",
  845. "fa-duotone": "solid",
  846. fadr: "regular",
  847. "fa-regular": "regular",
  848. fadl: "light",
  849. "fa-light": "light",
  850. fadt: "thin",
  851. "fa-thin": "thin"
  852. },
  853. sharp: {
  854. fa: "solid",
  855. fass: "solid",
  856. "fa-solid": "solid",
  857. fasr: "regular",
  858. "fa-regular": "regular",
  859. fasl: "light",
  860. "fa-light": "light",
  861. fast: "thin",
  862. "fa-thin": "thin"
  863. },
  864. "sharp-duotone": {
  865. fa: "solid",
  866. fasds: "solid",
  867. "fa-solid": "solid",
  868. fasdr: "regular",
  869. "fa-regular": "regular",
  870. fasdl: "light",
  871. "fa-light": "light",
  872. fasdt: "thin",
  873. "fa-thin": "thin"
  874. }
  875. };
  876. var s = "classic";
  877. var G = {
  878. classic: {
  879. 900: "fas",
  880. 400: "far",
  881. normal: "far",
  882. 300: "fal",
  883. 100: "fat"
  884. },
  885. duotone: {
  886. 900: "fad",
  887. 400: "fadr",
  888. 300: "fadl",
  889. 100: "fadt"
  890. },
  891. sharp: {
  892. 900: "fass",
  893. 400: "fasr",
  894. 300: "fasl",
  895. 100: "fast"
  896. },
  897. "sharp-duotone": {
  898. 900: "fasds",
  899. 400: "fasdr",
  900. 300: "fasdl",
  901. 100: "fasdt"
  902. }
  903. };
  904. var xt = {
  905. classic: {
  906. solid: "fas",
  907. regular: "far",
  908. light: "fal",
  909. thin: "fat",
  910. brands: "fab"
  911. },
  912. duotone: {
  913. solid: "fad",
  914. regular: "fadr",
  915. light: "fadl",
  916. thin: "fadt"
  917. },
  918. sharp: {
  919. solid: "fass",
  920. regular: "fasr",
  921. light: "fasl",
  922. thin: "fast"
  923. },
  924. "sharp-duotone": {
  925. solid: "fasds",
  926. regular: "fasdr",
  927. light: "fasdl",
  928. thin: "fasdt"
  929. }
  930. };
  931. var St = {
  932. kit: {
  933. fak: "kit",
  934. "fa-kit": "kit"
  935. },
  936. "kit-duotone": {
  937. fakd: "kit-duotone",
  938. "fa-kit-duotone": "kit-duotone"
  939. }
  940. };
  941. var Ct = {
  942. kit: {
  943. "fa-kit": "fak"
  944. },
  945. "kit-duotone": {
  946. "fa-kit-duotone": "fakd"
  947. }
  948. };
  949. var Wt = {
  950. kit: {
  951. fak: "fa-kit"
  952. },
  953. "kit-duotone": {
  954. fakd: "fa-kit-duotone"
  955. }
  956. };
  957. var Et = {
  958. kit: {
  959. kit: "fak"
  960. },
  961. "kit-duotone": {
  962. "kit-duotone": "fakd"
  963. }
  964. };
  965. var po = {
  966. classic: {
  967. "fa-brands": "fab",
  968. "fa-duotone": "fad",
  969. "fa-light": "fal",
  970. "fa-regular": "far",
  971. "fa-solid": "fas",
  972. "fa-thin": "fat"
  973. },
  974. duotone: {
  975. "fa-regular": "fadr",
  976. "fa-light": "fadl",
  977. "fa-thin": "fadt"
  978. },
  979. sharp: {
  980. "fa-solid": "fass",
  981. "fa-regular": "fasr",
  982. "fa-light": "fasl",
  983. "fa-thin": "fast"
  984. },
  985. "sharp-duotone": {
  986. "fa-solid": "fasds",
  987. "fa-regular": "fasdr",
  988. "fa-light": "fasdl",
  989. "fa-thin": "fasdt"
  990. }
  991. },
  992. co = {
  993. classic: {
  994. fab: "fa-brands",
  995. fad: "fa-duotone",
  996. fal: "fa-light",
  997. far: "fa-regular",
  998. fas: "fa-solid",
  999. fat: "fa-thin"
  1000. },
  1001. duotone: {
  1002. fadr: "fa-regular",
  1003. fadl: "fa-light",
  1004. fadt: "fa-thin"
  1005. },
  1006. sharp: {
  1007. fass: "fa-solid",
  1008. fasr: "fa-regular",
  1009. fasl: "fa-light",
  1010. fast: "fa-thin"
  1011. },
  1012. "sharp-duotone": {
  1013. fasds: "fa-solid",
  1014. fasdr: "fa-regular",
  1015. fasdl: "fa-light",
  1016. fasdt: "fa-thin"
  1017. }
  1018. };
  1019. const PRODUCTION = (() => {
  1020. try {
  1021. return process.env.NODE_ENV === 'production';
  1022. } catch (e$$1) {
  1023. return false;
  1024. }
  1025. })();
  1026. function familyProxy(obj) {
  1027. // Defaults to the classic family if family is not available
  1028. return new Proxy(obj, {
  1029. get(target, prop) {
  1030. return prop in target ? target[prop] : target[s];
  1031. }
  1032. });
  1033. }
  1034. const _PREFIX_TO_STYLE = _objectSpread2({}, S);
  1035. // We changed FACSSClassesToStyleId in the icons repo to be canonical and as such, "classic" family does not have any
  1036. // duotone styles. But we do still need duotone in _PREFIX_TO_STYLE below, so we are manually adding
  1037. // {'fa-duotone': 'duotone'}
  1038. _PREFIX_TO_STYLE[s] = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, {
  1039. 'fa-duotone': 'duotone'
  1040. }), S[s]), St['kit']), St['kit-duotone']);
  1041. const PREFIX_TO_STYLE = familyProxy(_PREFIX_TO_STYLE);
  1042. const _STYLE_TO_PREFIX = _objectSpread2({}, xt);
  1043. // We changed FAStyleIdToShortPrefixId in the icons repo to be canonical and as such, "classic" family does not have any
  1044. // duotone styles. But we do still need duotone in _STYLE_TO_PREFIX below, so we are manually adding {duotone: 'fad'}
  1045. _STYLE_TO_PREFIX[s] = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, {
  1046. duotone: 'fad'
  1047. }), _STYLE_TO_PREFIX[s]), Et['kit']), Et['kit-duotone']);
  1048. const STYLE_TO_PREFIX = familyProxy(_STYLE_TO_PREFIX);
  1049. const _PREFIX_TO_LONG_STYLE = _objectSpread2({}, co);
  1050. _PREFIX_TO_LONG_STYLE[s] = _objectSpread2(_objectSpread2({}, _PREFIX_TO_LONG_STYLE[s]), Wt['kit']);
  1051. const PREFIX_TO_LONG_STYLE = familyProxy(_PREFIX_TO_LONG_STYLE);
  1052. const _LONG_STYLE_TO_PREFIX = _objectSpread2({}, po);
  1053. _LONG_STYLE_TO_PREFIX[s] = _objectSpread2(_objectSpread2({}, _LONG_STYLE_TO_PREFIX[s]), Ct['kit']);
  1054. const LONG_STYLE_TO_PREFIX = familyProxy(_LONG_STYLE_TO_PREFIX);
  1055. const _FONT_WEIGHT_TO_PREFIX = _objectSpread2({}, G);
  1056. const FONT_WEIGHT_TO_PREFIX = familyProxy(_FONT_WEIGHT_TO_PREFIX);
  1057. function bunker(fn) {
  1058. try {
  1059. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1060. args[_key - 1] = arguments[_key];
  1061. }
  1062. fn(...args);
  1063. } catch (e) {
  1064. if (!PRODUCTION) {
  1065. throw e;
  1066. }
  1067. }
  1068. }
  1069. bunker(() => {
  1070. if (IS_BROWSER && IS_DOM) {
  1071. conflictDetection(window.FontAwesomeDetection.report);
  1072. }
  1073. });
  1074. })));