UNPKG

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