fontawesome.js 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404
  1. /*!
  2. * Font Awesome Free 5.8.2 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. */
  5. (function () {
  6. 'use strict';
  7. function _typeof(obj) {
  8. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  9. _typeof = function (obj) {
  10. return typeof obj;
  11. };
  12. } else {
  13. _typeof = function (obj) {
  14. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  15. };
  16. }
  17. return _typeof(obj);
  18. }
  19. function _classCallCheck(instance, Constructor) {
  20. if (!(instance instanceof Constructor)) {
  21. throw new TypeError("Cannot call a class as a function");
  22. }
  23. }
  24. function _defineProperties(target, props) {
  25. for (var i = 0; i < props.length; i++) {
  26. var descriptor = props[i];
  27. descriptor.enumerable = descriptor.enumerable || false;
  28. descriptor.configurable = true;
  29. if ("value" in descriptor) descriptor.writable = true;
  30. Object.defineProperty(target, descriptor.key, descriptor);
  31. }
  32. }
  33. function _createClass(Constructor, protoProps, staticProps) {
  34. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  35. if (staticProps) _defineProperties(Constructor, staticProps);
  36. return Constructor;
  37. }
  38. function _defineProperty(obj, key, value) {
  39. if (key in obj) {
  40. Object.defineProperty(obj, key, {
  41. value: value,
  42. enumerable: true,
  43. configurable: true,
  44. writable: true
  45. });
  46. } else {
  47. obj[key] = value;
  48. }
  49. return obj;
  50. }
  51. function _objectSpread(target) {
  52. for (var i = 1; i < arguments.length; i++) {
  53. var source = arguments[i] != null ? arguments[i] : {};
  54. var ownKeys = Object.keys(source);
  55. if (typeof Object.getOwnPropertySymbols === 'function') {
  56. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  57. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  58. }));
  59. }
  60. ownKeys.forEach(function (key) {
  61. _defineProperty(target, key, source[key]);
  62. });
  63. }
  64. return target;
  65. }
  66. function _slicedToArray(arr, i) {
  67. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  68. }
  69. function _toConsumableArray(arr) {
  70. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  71. }
  72. function _arrayWithoutHoles(arr) {
  73. if (Array.isArray(arr)) {
  74. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  75. return arr2;
  76. }
  77. }
  78. function _arrayWithHoles(arr) {
  79. if (Array.isArray(arr)) return arr;
  80. }
  81. function _iterableToArray(iter) {
  82. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  83. }
  84. function _iterableToArrayLimit(arr, i) {
  85. var _arr = [];
  86. var _n = true;
  87. var _d = false;
  88. var _e = undefined;
  89. try {
  90. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  91. _arr.push(_s.value);
  92. if (i && _arr.length === i) break;
  93. }
  94. } catch (err) {
  95. _d = true;
  96. _e = err;
  97. } finally {
  98. try {
  99. if (!_n && _i["return"] != null) _i["return"]();
  100. } finally {
  101. if (_d) throw _e;
  102. }
  103. }
  104. return _arr;
  105. }
  106. function _nonIterableSpread() {
  107. throw new TypeError("Invalid attempt to spread non-iterable instance");
  108. }
  109. function _nonIterableRest() {
  110. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  111. }
  112. var noop = function noop() {};
  113. var _WINDOW = {};
  114. var _DOCUMENT = {};
  115. var _MUTATION_OBSERVER = null;
  116. var _PERFORMANCE = {
  117. mark: noop,
  118. measure: noop
  119. };
  120. try {
  121. if (typeof window !== 'undefined') _WINDOW = window;
  122. if (typeof document !== 'undefined') _DOCUMENT = document;
  123. if (typeof MutationObserver !== 'undefined') _MUTATION_OBSERVER = MutationObserver;
  124. if (typeof performance !== 'undefined') _PERFORMANCE = performance;
  125. } catch (e) {}
  126. var _ref = _WINDOW.navigator || {},
  127. _ref$userAgent = _ref.userAgent,
  128. userAgent = _ref$userAgent === void 0 ? '' : _ref$userAgent;
  129. var WINDOW = _WINDOW;
  130. var DOCUMENT = _DOCUMENT;
  131. var MUTATION_OBSERVER = _MUTATION_OBSERVER;
  132. var PERFORMANCE = _PERFORMANCE;
  133. var IS_BROWSER = !!WINDOW.document;
  134. var IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
  135. var IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
  136. var NAMESPACE_IDENTIFIER = '___FONT_AWESOME___';
  137. var UNITS_IN_GRID = 16;
  138. var DEFAULT_FAMILY_PREFIX = 'fa';
  139. var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
  140. var DATA_FA_I2SVG = 'data-fa-i2svg';
  141. var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
  142. var DATA_FA_PSEUDO_ELEMENT_PENDING = 'data-fa-pseudo-element-pending';
  143. var DATA_PREFIX = 'data-prefix';
  144. var DATA_ICON = 'data-icon';
  145. var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
  146. var MUTATION_APPROACH_ASYNC = 'async';
  147. var TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS = ['HTML', 'HEAD', 'STYLE', 'SCRIPT'];
  148. var PRODUCTION = function () {
  149. try {
  150. return "production" === 'production';
  151. } catch (e) {
  152. return false;
  153. }
  154. }();
  155. var PREFIX_TO_STYLE = {
  156. 'fas': 'solid',
  157. 'far': 'regular',
  158. 'fal': 'light',
  159. 'fab': 'brands',
  160. 'fa': 'solid'
  161. };
  162. var STYLE_TO_PREFIX = {
  163. 'solid': 'fas',
  164. 'regular': 'far',
  165. 'light': 'fal',
  166. 'brands': 'fab'
  167. };
  168. var LAYERS_TEXT_CLASSNAME = 'fa-layers-text';
  169. var FONT_FAMILY_PATTERN = /Font Awesome 5 (Solid|Regular|Light|Brands|Free|Pro)/;
  170. var FONT_WEIGHT_TO_PREFIX = {
  171. '900': 'fas',
  172. '400': 'far',
  173. 'normal': 'far',
  174. '300': 'fal'
  175. };
  176. var oneToTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  177. var oneToTwenty = oneToTen.concat([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
  178. var ATTRIBUTES_WATCHED_FOR_MUTATION = ['class', 'data-prefix', 'data-icon', 'data-fa-transform', 'data-fa-mask'];
  179. var RESERVED_CLASSES = ['xs', 'sm', 'lg', 'fw', 'ul', 'li', 'border', 'pull-left', 'pull-right', 'spin', 'pulse', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical', 'flip-both', 'stack', 'stack-1x', 'stack-2x', 'inverse', 'layers', 'layers-text', 'layers-counter'].concat(oneToTen.map(function (n) {
  180. return "".concat(n, "x");
  181. })).concat(oneToTwenty.map(function (n) {
  182. return "w-".concat(n);
  183. }));
  184. var initial = WINDOW.FontAwesomeConfig || {};
  185. function getAttrConfig(attr) {
  186. var element = DOCUMENT.querySelector('script[' + attr + ']');
  187. if (element) {
  188. return element.getAttribute(attr);
  189. }
  190. }
  191. function coerce(val) {
  192. // Getting an empty string will occur if the attribute is set on the HTML tag but without a value
  193. // We'll assume that this is an indication that it should be toggled to true
  194. // For example <script data-search-pseudo-elements src="..."></script>
  195. if (val === '') return true;
  196. if (val === 'false') return false;
  197. if (val === 'true') return true;
  198. return val;
  199. }
  200. if (DOCUMENT && typeof DOCUMENT.querySelector === 'function') {
  201. var attrs = [['data-family-prefix', 'familyPrefix'], ['data-replacement-class', 'replacementClass'], ['data-auto-replace-svg', 'autoReplaceSvg'], ['data-auto-add-css', 'autoAddCss'], ['data-auto-a11y', 'autoA11y'], ['data-search-pseudo-elements', 'searchPseudoElements'], ['data-observe-mutations', 'observeMutations'], ['data-mutate-approach', 'mutateApproach'], ['data-keep-original-source', 'keepOriginalSource'], ['data-measure-performance', 'measurePerformance'], ['data-show-missing-icons', 'showMissingIcons']];
  202. attrs.forEach(function (_ref) {
  203. var _ref2 = _slicedToArray(_ref, 2),
  204. attr = _ref2[0],
  205. key = _ref2[1];
  206. var val = coerce(getAttrConfig(attr));
  207. if (val !== undefined && val !== null) {
  208. initial[key] = val;
  209. }
  210. });
  211. }
  212. var _default = {
  213. familyPrefix: DEFAULT_FAMILY_PREFIX,
  214. replacementClass: DEFAULT_REPLACEMENT_CLASS,
  215. autoReplaceSvg: true,
  216. autoAddCss: true,
  217. autoA11y: true,
  218. searchPseudoElements: false,
  219. observeMutations: true,
  220. mutateApproach: 'async',
  221. keepOriginalSource: true,
  222. measurePerformance: false,
  223. showMissingIcons: true
  224. };
  225. var _config = _objectSpread({}, _default, initial);
  226. if (!_config.autoReplaceSvg) _config.observeMutations = false;
  227. var config = _objectSpread({}, _config);
  228. WINDOW.FontAwesomeConfig = config;
  229. var w = WINDOW || {};
  230. if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
  231. if (!w[NAMESPACE_IDENTIFIER].styles) w[NAMESPACE_IDENTIFIER].styles = {};
  232. if (!w[NAMESPACE_IDENTIFIER].hooks) w[NAMESPACE_IDENTIFIER].hooks = {};
  233. if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
  234. var namespace = w[NAMESPACE_IDENTIFIER];
  235. var functions = [];
  236. var listener = function listener() {
  237. DOCUMENT.removeEventListener('DOMContentLoaded', listener);
  238. loaded = 1;
  239. functions.map(function (fn) {
  240. return fn();
  241. });
  242. };
  243. var loaded = false;
  244. if (IS_DOM) {
  245. loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
  246. if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
  247. }
  248. function domready (fn) {
  249. if (!IS_DOM) return;
  250. loaded ? setTimeout(fn, 0) : functions.push(fn);
  251. }
  252. var PENDING = 'pending';
  253. var SETTLED = 'settled';
  254. var FULFILLED = 'fulfilled';
  255. var REJECTED = 'rejected';
  256. var NOOP = function NOOP() {};
  257. var isNode = typeof global !== 'undefined' && typeof global.process !== 'undefined' && typeof global.process.emit === 'function';
  258. var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
  259. var asyncQueue = [];
  260. var asyncTimer;
  261. function asyncFlush() {
  262. // run promise callbacks
  263. for (var i = 0; i < asyncQueue.length; i++) {
  264. asyncQueue[i][0](asyncQueue[i][1]);
  265. } // reset async asyncQueue
  266. asyncQueue = [];
  267. asyncTimer = false;
  268. }
  269. function asyncCall(callback, arg) {
  270. asyncQueue.push([callback, arg]);
  271. if (!asyncTimer) {
  272. asyncTimer = true;
  273. asyncSetTimer(asyncFlush, 0);
  274. }
  275. }
  276. function invokeResolver(resolver, promise) {
  277. function resolvePromise(value) {
  278. resolve(promise, value);
  279. }
  280. function rejectPromise(reason) {
  281. reject(promise, reason);
  282. }
  283. try {
  284. resolver(resolvePromise, rejectPromise);
  285. } catch (e) {
  286. rejectPromise(e);
  287. }
  288. }
  289. function invokeCallback(subscriber) {
  290. var owner = subscriber.owner;
  291. var settled = owner._state;
  292. var value = owner._data;
  293. var callback = subscriber[settled];
  294. var promise = subscriber.then;
  295. if (typeof callback === 'function') {
  296. settled = FULFILLED;
  297. try {
  298. value = callback(value);
  299. } catch (e) {
  300. reject(promise, e);
  301. }
  302. }
  303. if (!handleThenable(promise, value)) {
  304. if (settled === FULFILLED) {
  305. resolve(promise, value);
  306. }
  307. if (settled === REJECTED) {
  308. reject(promise, value);
  309. }
  310. }
  311. }
  312. function handleThenable(promise, value) {
  313. var resolved;
  314. try {
  315. if (promise === value) {
  316. throw new TypeError('A promises callback cannot return that same promise.');
  317. }
  318. if (value && (typeof value === 'function' || _typeof(value) === 'object')) {
  319. // then should be retrieved only once
  320. var then = value.then;
  321. if (typeof then === 'function') {
  322. then.call(value, function (val) {
  323. if (!resolved) {
  324. resolved = true;
  325. if (value === val) {
  326. fulfill(promise, val);
  327. } else {
  328. resolve(promise, val);
  329. }
  330. }
  331. }, function (reason) {
  332. if (!resolved) {
  333. resolved = true;
  334. reject(promise, reason);
  335. }
  336. });
  337. return true;
  338. }
  339. }
  340. } catch (e) {
  341. if (!resolved) {
  342. reject(promise, e);
  343. }
  344. return true;
  345. }
  346. return false;
  347. }
  348. function resolve(promise, value) {
  349. if (promise === value || !handleThenable(promise, value)) {
  350. fulfill(promise, value);
  351. }
  352. }
  353. function fulfill(promise, value) {
  354. if (promise._state === PENDING) {
  355. promise._state = SETTLED;
  356. promise._data = value;
  357. asyncCall(publishFulfillment, promise);
  358. }
  359. }
  360. function reject(promise, reason) {
  361. if (promise._state === PENDING) {
  362. promise._state = SETTLED;
  363. promise._data = reason;
  364. asyncCall(publishRejection, promise);
  365. }
  366. }
  367. function publish(promise) {
  368. promise._then = promise._then.forEach(invokeCallback);
  369. }
  370. function publishFulfillment(promise) {
  371. promise._state = FULFILLED;
  372. publish(promise);
  373. }
  374. function publishRejection(promise) {
  375. promise._state = REJECTED;
  376. publish(promise);
  377. if (!promise._handled && isNode) {
  378. global.process.emit('unhandledRejection', promise._data, promise);
  379. }
  380. }
  381. function notifyRejectionHandled(promise) {
  382. global.process.emit('rejectionHandled', promise);
  383. }
  384. /**
  385. * @class
  386. */
  387. function P(resolver) {
  388. if (typeof resolver !== 'function') {
  389. throw new TypeError('Promise resolver ' + resolver + ' is not a function');
  390. }
  391. if (this instanceof P === false) {
  392. throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
  393. }
  394. this._then = [];
  395. invokeResolver(resolver, this);
  396. }
  397. P.prototype = {
  398. constructor: P,
  399. _state: PENDING,
  400. _then: null,
  401. _data: undefined,
  402. _handled: false,
  403. then: function then(onFulfillment, onRejection) {
  404. var subscriber = {
  405. owner: this,
  406. then: new this.constructor(NOOP),
  407. fulfilled: onFulfillment,
  408. rejected: onRejection
  409. };
  410. if ((onRejection || onFulfillment) && !this._handled) {
  411. this._handled = true;
  412. if (this._state === REJECTED && isNode) {
  413. asyncCall(notifyRejectionHandled, this);
  414. }
  415. }
  416. if (this._state === FULFILLED || this._state === REJECTED) {
  417. // already resolved, call callback async
  418. asyncCall(invokeCallback, subscriber);
  419. } else {
  420. // subscribe
  421. this._then.push(subscriber);
  422. }
  423. return subscriber.then;
  424. },
  425. catch: function _catch(onRejection) {
  426. return this.then(null, onRejection);
  427. }
  428. };
  429. P.all = function (promises) {
  430. if (!Array.isArray(promises)) {
  431. throw new TypeError('You must pass an array to Promise.all().');
  432. }
  433. return new P(function (resolve, reject) {
  434. var results = [];
  435. var remaining = 0;
  436. function resolver(index) {
  437. remaining++;
  438. return function (value) {
  439. results[index] = value;
  440. if (! --remaining) {
  441. resolve(results);
  442. }
  443. };
  444. }
  445. for (var i = 0, promise; i < promises.length; i++) {
  446. promise = promises[i];
  447. if (promise && typeof promise.then === 'function') {
  448. promise.then(resolver(i), reject);
  449. } else {
  450. results[i] = promise;
  451. }
  452. }
  453. if (!remaining) {
  454. resolve(results);
  455. }
  456. });
  457. };
  458. P.race = function (promises) {
  459. if (!Array.isArray(promises)) {
  460. throw new TypeError('You must pass an array to Promise.race().');
  461. }
  462. return new P(function (resolve, reject) {
  463. for (var i = 0, promise; i < promises.length; i++) {
  464. promise = promises[i];
  465. if (promise && typeof promise.then === 'function') {
  466. promise.then(resolve, reject);
  467. } else {
  468. resolve(promise);
  469. }
  470. }
  471. });
  472. };
  473. P.resolve = function (value) {
  474. if (value && _typeof(value) === 'object' && value.constructor === P) {
  475. return value;
  476. }
  477. return new P(function (resolve) {
  478. resolve(value);
  479. });
  480. };
  481. P.reject = function (reason) {
  482. return new P(function (resolve, reject) {
  483. reject(reason);
  484. });
  485. };
  486. var picked = typeof Promise === 'function' ? Promise : P;
  487. var d = UNITS_IN_GRID;
  488. var meaninglessTransform = {
  489. size: 16,
  490. x: 0,
  491. y: 0,
  492. rotate: 0,
  493. flipX: false,
  494. flipY: false
  495. };
  496. function isReserved(name) {
  497. return ~RESERVED_CLASSES.indexOf(name);
  498. }
  499. function bunker(fn) {
  500. try {
  501. fn();
  502. } catch (e) {
  503. if (!PRODUCTION) {
  504. throw e;
  505. }
  506. }
  507. }
  508. function insertCss(css) {
  509. if (!css || !IS_DOM) {
  510. return;
  511. }
  512. var style = DOCUMENT.createElement('style');
  513. style.setAttribute('type', 'text/css');
  514. style.innerHTML = css;
  515. var headChildren = DOCUMENT.head.childNodes;
  516. var beforeChild = null;
  517. for (var i = headChildren.length - 1; i > -1; i--) {
  518. var child = headChildren[i];
  519. var tagName = (child.tagName || '').toUpperCase();
  520. if (['STYLE', 'LINK'].indexOf(tagName) > -1) {
  521. beforeChild = child;
  522. }
  523. }
  524. DOCUMENT.head.insertBefore(style, beforeChild);
  525. return css;
  526. }
  527. var idPool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  528. function nextUniqueId() {
  529. var size = 12;
  530. var id = '';
  531. while (size-- > 0) {
  532. id += idPool[Math.random() * 62 | 0];
  533. }
  534. return id;
  535. }
  536. function toArray(obj) {
  537. var array = [];
  538. for (var i = (obj || []).length >>> 0; i--;) {
  539. array[i] = obj[i];
  540. }
  541. return array;
  542. }
  543. function classArray(node) {
  544. if (node.classList) {
  545. return toArray(node.classList);
  546. } else {
  547. return (node.getAttribute('class') || '').split(' ').filter(function (i) {
  548. return i;
  549. });
  550. }
  551. }
  552. function getIconName(familyPrefix, cls) {
  553. var parts = cls.split('-');
  554. var prefix = parts[0];
  555. var iconName = parts.slice(1).join('-');
  556. if (prefix === familyPrefix && iconName !== '' && !isReserved(iconName)) {
  557. return iconName;
  558. } else {
  559. return null;
  560. }
  561. }
  562. function htmlEscape(str) {
  563. return "".concat(str).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  564. }
  565. function joinAttributes(attributes) {
  566. return Object.keys(attributes || {}).reduce(function (acc, attributeName) {
  567. return acc + "".concat(attributeName, "=\"").concat(htmlEscape(attributes[attributeName]), "\" ");
  568. }, '').trim();
  569. }
  570. function joinStyles(styles) {
  571. return Object.keys(styles || {}).reduce(function (acc, styleName) {
  572. return acc + "".concat(styleName, ": ").concat(styles[styleName], ";");
  573. }, '');
  574. }
  575. function transformIsMeaningful(transform) {
  576. return transform.size !== meaninglessTransform.size || transform.x !== meaninglessTransform.x || transform.y !== meaninglessTransform.y || transform.rotate !== meaninglessTransform.rotate || transform.flipX || transform.flipY;
  577. }
  578. function transformForSvg(_ref) {
  579. var transform = _ref.transform,
  580. containerWidth = _ref.containerWidth,
  581. iconWidth = _ref.iconWidth;
  582. var outer = {
  583. transform: "translate(".concat(containerWidth / 2, " 256)")
  584. };
  585. var innerTranslate = "translate(".concat(transform.x * 32, ", ").concat(transform.y * 32, ") ");
  586. var innerScale = "scale(".concat(transform.size / 16 * (transform.flipX ? -1 : 1), ", ").concat(transform.size / 16 * (transform.flipY ? -1 : 1), ") ");
  587. var innerRotate = "rotate(".concat(transform.rotate, " 0 0)");
  588. var inner = {
  589. transform: "".concat(innerTranslate, " ").concat(innerScale, " ").concat(innerRotate)
  590. };
  591. var path = {
  592. transform: "translate(".concat(iconWidth / 2 * -1, " -256)")
  593. };
  594. return {
  595. outer: outer,
  596. inner: inner,
  597. path: path
  598. };
  599. }
  600. function transformForCss(_ref2) {
  601. var transform = _ref2.transform,
  602. _ref2$width = _ref2.width,
  603. width = _ref2$width === void 0 ? UNITS_IN_GRID : _ref2$width,
  604. _ref2$height = _ref2.height,
  605. height = _ref2$height === void 0 ? UNITS_IN_GRID : _ref2$height,
  606. _ref2$startCentered = _ref2.startCentered,
  607. startCentered = _ref2$startCentered === void 0 ? false : _ref2$startCentered;
  608. var val = '';
  609. if (startCentered && IS_IE) {
  610. val += "translate(".concat(transform.x / d - width / 2, "em, ").concat(transform.y / d - height / 2, "em) ");
  611. } else if (startCentered) {
  612. val += "translate(calc(-50% + ".concat(transform.x / d, "em), calc(-50% + ").concat(transform.y / d, "em)) ");
  613. } else {
  614. val += "translate(".concat(transform.x / d, "em, ").concat(transform.y / d, "em) ");
  615. }
  616. val += "scale(".concat(transform.size / d * (transform.flipX ? -1 : 1), ", ").concat(transform.size / d * (transform.flipY ? -1 : 1), ") ");
  617. val += "rotate(".concat(transform.rotate, "deg) ");
  618. return val;
  619. }
  620. var ALL_SPACE = {
  621. x: 0,
  622. y: 0,
  623. width: '100%',
  624. height: '100%'
  625. };
  626. function makeIconMasking (_ref) {
  627. var children = _ref.children,
  628. attributes = _ref.attributes,
  629. main = _ref.main,
  630. mask = _ref.mask,
  631. transform = _ref.transform;
  632. var mainWidth = main.width,
  633. mainPath = main.icon;
  634. var maskWidth = mask.width,
  635. maskPath = mask.icon;
  636. var trans = transformForSvg({
  637. transform: transform,
  638. containerWidth: maskWidth,
  639. iconWidth: mainWidth
  640. });
  641. var maskRect = {
  642. tag: 'rect',
  643. attributes: _objectSpread({}, ALL_SPACE, {
  644. fill: 'white'
  645. })
  646. };
  647. var maskInnerGroup = {
  648. tag: 'g',
  649. attributes: _objectSpread({}, trans.inner),
  650. children: [{
  651. tag: 'path',
  652. attributes: _objectSpread({}, mainPath.attributes, trans.path, {
  653. fill: 'black'
  654. })
  655. }]
  656. };
  657. var maskOuterGroup = {
  658. tag: 'g',
  659. attributes: _objectSpread({}, trans.outer),
  660. children: [maskInnerGroup]
  661. };
  662. var maskId = "mask-".concat(nextUniqueId());
  663. var clipId = "clip-".concat(nextUniqueId());
  664. var maskTag = {
  665. tag: 'mask',
  666. attributes: _objectSpread({}, ALL_SPACE, {
  667. id: maskId,
  668. maskUnits: 'userSpaceOnUse',
  669. maskContentUnits: 'userSpaceOnUse'
  670. }),
  671. children: [maskRect, maskOuterGroup]
  672. };
  673. var defs = {
  674. tag: 'defs',
  675. children: [{
  676. tag: 'clipPath',
  677. attributes: {
  678. id: clipId
  679. },
  680. children: [maskPath]
  681. }, maskTag]
  682. };
  683. children.push(defs, {
  684. tag: 'rect',
  685. attributes: _objectSpread({
  686. fill: 'currentColor',
  687. 'clip-path': "url(#".concat(clipId, ")"),
  688. mask: "url(#".concat(maskId, ")")
  689. }, ALL_SPACE)
  690. });
  691. return {
  692. children: children,
  693. attributes: attributes
  694. };
  695. }
  696. function makeIconStandard (_ref) {
  697. var children = _ref.children,
  698. attributes = _ref.attributes,
  699. main = _ref.main,
  700. transform = _ref.transform,
  701. styles = _ref.styles;
  702. var styleString = joinStyles(styles);
  703. if (styleString.length > 0) {
  704. attributes['style'] = styleString;
  705. }
  706. if (transformIsMeaningful(transform)) {
  707. var trans = transformForSvg({
  708. transform: transform,
  709. containerWidth: main.width,
  710. iconWidth: main.width
  711. });
  712. children.push({
  713. tag: 'g',
  714. attributes: _objectSpread({}, trans.outer),
  715. children: [{
  716. tag: 'g',
  717. attributes: _objectSpread({}, trans.inner),
  718. children: [{
  719. tag: main.icon.tag,
  720. children: main.icon.children,
  721. attributes: _objectSpread({}, main.icon.attributes, trans.path)
  722. }]
  723. }]
  724. });
  725. } else {
  726. children.push(main.icon);
  727. }
  728. return {
  729. children: children,
  730. attributes: attributes
  731. };
  732. }
  733. function asIcon (_ref) {
  734. var children = _ref.children,
  735. main = _ref.main,
  736. mask = _ref.mask,
  737. attributes = _ref.attributes,
  738. styles = _ref.styles,
  739. transform = _ref.transform;
  740. if (transformIsMeaningful(transform) && main.found && !mask.found) {
  741. var width = main.width,
  742. height = main.height;
  743. var offset = {
  744. x: width / height / 2,
  745. y: 0.5
  746. };
  747. attributes['style'] = joinStyles(_objectSpread({}, styles, {
  748. 'transform-origin': "".concat(offset.x + transform.x / 16, "em ").concat(offset.y + transform.y / 16, "em")
  749. }));
  750. }
  751. return [{
  752. tag: 'svg',
  753. attributes: attributes,
  754. children: children
  755. }];
  756. }
  757. function asSymbol (_ref) {
  758. var prefix = _ref.prefix,
  759. iconName = _ref.iconName,
  760. children = _ref.children,
  761. attributes = _ref.attributes,
  762. symbol = _ref.symbol;
  763. var id = symbol === true ? "".concat(prefix, "-").concat(config.familyPrefix, "-").concat(iconName) : symbol;
  764. return [{
  765. tag: 'svg',
  766. attributes: {
  767. style: 'display: none;'
  768. },
  769. children: [{
  770. tag: 'symbol',
  771. attributes: _objectSpread({}, attributes, {
  772. id: id
  773. }),
  774. children: children
  775. }]
  776. }];
  777. }
  778. function makeInlineSvgAbstract(params) {
  779. var _params$icons = params.icons,
  780. main = _params$icons.main,
  781. mask = _params$icons.mask,
  782. prefix = params.prefix,
  783. iconName = params.iconName,
  784. transform = params.transform,
  785. symbol = params.symbol,
  786. title = params.title,
  787. extra = params.extra,
  788. _params$watchable = params.watchable,
  789. watchable = _params$watchable === void 0 ? false : _params$watchable;
  790. var _ref = mask.found ? mask : main,
  791. width = _ref.width,
  792. height = _ref.height;
  793. var widthClass = "fa-w-".concat(Math.ceil(width / height * 16));
  794. var attrClass = [config.replacementClass, iconName ? "".concat(config.familyPrefix, "-").concat(iconName) : '', widthClass].filter(function (c) {
  795. return extra.classes.indexOf(c) === -1;
  796. }).concat(extra.classes).join(' ');
  797. var content = {
  798. children: [],
  799. attributes: _objectSpread({}, extra.attributes, {
  800. 'data-prefix': prefix,
  801. 'data-icon': iconName,
  802. 'class': attrClass,
  803. 'role': extra.attributes.role || 'img',
  804. 'xmlns': 'http://www.w3.org/2000/svg',
  805. 'viewBox': "0 0 ".concat(width, " ").concat(height)
  806. })
  807. };
  808. if (watchable) {
  809. content.attributes[DATA_FA_I2SVG] = '';
  810. }
  811. if (title) content.children.push({
  812. tag: 'title',
  813. attributes: {
  814. id: content.attributes['aria-labelledby'] || "title-".concat(nextUniqueId())
  815. },
  816. children: [title]
  817. });
  818. var args = _objectSpread({}, content, {
  819. prefix: prefix,
  820. iconName: iconName,
  821. main: main,
  822. mask: mask,
  823. transform: transform,
  824. symbol: symbol,
  825. styles: extra.styles
  826. });
  827. var _ref2 = mask.found && main.found ? makeIconMasking(args) : makeIconStandard(args),
  828. children = _ref2.children,
  829. attributes = _ref2.attributes;
  830. args.children = children;
  831. args.attributes = attributes;
  832. if (symbol) {
  833. return asSymbol(args);
  834. } else {
  835. return asIcon(args);
  836. }
  837. }
  838. function makeLayersTextAbstract(params) {
  839. var content = params.content,
  840. width = params.width,
  841. height = params.height,
  842. transform = params.transform,
  843. title = params.title,
  844. extra = params.extra,
  845. _params$watchable2 = params.watchable,
  846. watchable = _params$watchable2 === void 0 ? false : _params$watchable2;
  847. var attributes = _objectSpread({}, extra.attributes, title ? {
  848. 'title': title
  849. } : {}, {
  850. 'class': extra.classes.join(' ')
  851. });
  852. if (watchable) {
  853. attributes[DATA_FA_I2SVG] = '';
  854. }
  855. var styles = _objectSpread({}, extra.styles);
  856. if (transformIsMeaningful(transform)) {
  857. styles['transform'] = transformForCss({
  858. transform: transform,
  859. startCentered: true,
  860. width: width,
  861. height: height
  862. });
  863. styles['-webkit-transform'] = styles['transform'];
  864. }
  865. var styleString = joinStyles(styles);
  866. if (styleString.length > 0) {
  867. attributes['style'] = styleString;
  868. }
  869. var val = [];
  870. val.push({
  871. tag: 'span',
  872. attributes: attributes,
  873. children: [content]
  874. });
  875. if (title) {
  876. val.push({
  877. tag: 'span',
  878. attributes: {
  879. class: 'sr-only'
  880. },
  881. children: [title]
  882. });
  883. }
  884. return val;
  885. }
  886. function makeLayersCounterAbstract(params) {
  887. var content = params.content,
  888. title = params.title,
  889. extra = params.extra;
  890. var attributes = _objectSpread({}, extra.attributes, title ? {
  891. 'title': title
  892. } : {}, {
  893. 'class': extra.classes.join(' ')
  894. });
  895. var styleString = joinStyles(extra.styles);
  896. if (styleString.length > 0) {
  897. attributes['style'] = styleString;
  898. }
  899. var val = [];
  900. val.push({
  901. tag: 'span',
  902. attributes: attributes,
  903. children: [content]
  904. });
  905. if (title) {
  906. val.push({
  907. tag: 'span',
  908. attributes: {
  909. class: 'sr-only'
  910. },
  911. children: [title]
  912. });
  913. }
  914. return val;
  915. }
  916. var noop$1 = function noop() {};
  917. var p = config.measurePerformance && PERFORMANCE && PERFORMANCE.mark && PERFORMANCE.measure ? PERFORMANCE : {
  918. mark: noop$1,
  919. measure: noop$1
  920. };
  921. var preamble = "FA \"5.8.2\"";
  922. var begin = function begin(name) {
  923. p.mark("".concat(preamble, " ").concat(name, " begins"));
  924. return function () {
  925. return end(name);
  926. };
  927. };
  928. var end = function end(name) {
  929. p.mark("".concat(preamble, " ").concat(name, " ends"));
  930. p.measure("".concat(preamble, " ").concat(name), "".concat(preamble, " ").concat(name, " begins"), "".concat(preamble, " ").concat(name, " ends"));
  931. };
  932. var perf = {
  933. begin: begin,
  934. end: end
  935. };
  936. /**
  937. * Internal helper to bind a function known to have 4 arguments
  938. * to a given context.
  939. */
  940. var bindInternal4 = function bindInternal4(func, thisContext) {
  941. return function (a, b, c, d) {
  942. return func.call(thisContext, a, b, c, d);
  943. };
  944. };
  945. /**
  946. * # Reduce
  947. *
  948. * A fast object `.reduce()` implementation.
  949. *
  950. * @param {Object} subject The object to reduce over.
  951. * @param {Function} fn The reducer function.
  952. * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
  953. * @param {Object} thisContext The context for the reducer.
  954. * @return {mixed} The final result.
  955. */
  956. var reduce = function fastReduceObject(subject, fn, initialValue, thisContext) {
  957. var keys = Object.keys(subject),
  958. length = keys.length,
  959. iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
  960. i,
  961. key,
  962. result;
  963. if (initialValue === undefined) {
  964. i = 1;
  965. result = subject[keys[0]];
  966. } else {
  967. i = 0;
  968. result = initialValue;
  969. }
  970. for (; i < length; i++) {
  971. key = keys[i];
  972. result = iterator(result, subject[key], key, subject);
  973. }
  974. return result;
  975. };
  976. function toHex(unicode) {
  977. var result = '';
  978. for (var i = 0; i < unicode.length; i++) {
  979. var hex = unicode.charCodeAt(i).toString(16);
  980. result += ('000' + hex).slice(-4);
  981. }
  982. return result;
  983. }
  984. function defineIcons(prefix, icons) {
  985. var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  986. var _params$skipHooks = params.skipHooks,
  987. skipHooks = _params$skipHooks === void 0 ? false : _params$skipHooks;
  988. var normalized = Object.keys(icons).reduce(function (acc, iconName) {
  989. var icon = icons[iconName];
  990. var expanded = !!icon.icon;
  991. if (expanded) {
  992. acc[icon.iconName] = icon.icon;
  993. } else {
  994. acc[iconName] = icon;
  995. }
  996. return acc;
  997. }, {});
  998. if (typeof namespace.hooks.addPack === 'function' && !skipHooks) {
  999. namespace.hooks.addPack(prefix, normalized);
  1000. } else {
  1001. namespace.styles[prefix] = _objectSpread({}, namespace.styles[prefix] || {}, normalized);
  1002. }
  1003. /**
  1004. * Font Awesome 4 used the prefix of `fa` for all icons. With the introduction
  1005. * of new styles we needed to differentiate between them. Prefix `fa` is now an alias
  1006. * for `fas` so we'll easy the upgrade process for our users by automatically defining
  1007. * this as well.
  1008. */
  1009. if (prefix === 'fas') {
  1010. defineIcons('fa', icons);
  1011. }
  1012. }
  1013. var styles = namespace.styles,
  1014. shims = namespace.shims;
  1015. var _byUnicode = {};
  1016. var _byLigature = {};
  1017. var _byOldName = {};
  1018. var build = function build() {
  1019. var lookup = function lookup(reducer) {
  1020. return reduce(styles, function (o, style, prefix) {
  1021. o[prefix] = reduce(style, reducer, {});
  1022. return o;
  1023. }, {});
  1024. };
  1025. _byUnicode = lookup(function (acc, icon, iconName) {
  1026. if (icon[3]) {
  1027. acc[icon[3]] = iconName;
  1028. }
  1029. return acc;
  1030. });
  1031. _byLigature = lookup(function (acc, icon, iconName) {
  1032. var ligatures = icon[2];
  1033. acc[iconName] = iconName;
  1034. ligatures.forEach(function (ligature) {
  1035. acc[ligature] = iconName;
  1036. });
  1037. return acc;
  1038. });
  1039. var hasRegular = 'far' in styles;
  1040. _byOldName = reduce(shims, function (acc, shim) {
  1041. var oldName = shim[0];
  1042. var prefix = shim[1];
  1043. var iconName = shim[2];
  1044. if (prefix === 'far' && !hasRegular) {
  1045. prefix = 'fas';
  1046. }
  1047. acc[oldName] = {
  1048. prefix: prefix,
  1049. iconName: iconName
  1050. };
  1051. return acc;
  1052. }, {});
  1053. };
  1054. build();
  1055. function byUnicode(prefix, unicode) {
  1056. return (_byUnicode[prefix] || {})[unicode];
  1057. }
  1058. function byLigature(prefix, ligature) {
  1059. return (_byLigature[prefix] || {})[ligature];
  1060. }
  1061. function byOldName(name) {
  1062. return _byOldName[name] || {
  1063. prefix: null,
  1064. iconName: null
  1065. };
  1066. }
  1067. var styles$1 = namespace.styles;
  1068. var emptyCanonicalIcon = function emptyCanonicalIcon() {
  1069. return {
  1070. prefix: null,
  1071. iconName: null,
  1072. rest: []
  1073. };
  1074. };
  1075. function getCanonicalIcon(values) {
  1076. return values.reduce(function (acc, cls) {
  1077. var iconName = getIconName(config.familyPrefix, cls);
  1078. if (styles$1[cls]) {
  1079. acc.prefix = cls;
  1080. } else if (config.autoFetchSvg && ['fas', 'far', 'fal', 'fab', 'fa'].indexOf(cls) > -1) {
  1081. acc.prefix = cls;
  1082. } else if (iconName) {
  1083. var shim = acc.prefix === 'fa' ? byOldName(iconName) : {};
  1084. acc.iconName = shim.iconName || iconName;
  1085. acc.prefix = shim.prefix || acc.prefix;
  1086. } else if (cls !== config.replacementClass && cls.indexOf('fa-w-') !== 0) {
  1087. acc.rest.push(cls);
  1088. }
  1089. return acc;
  1090. }, emptyCanonicalIcon());
  1091. }
  1092. function iconFromMapping(mapping, prefix, iconName) {
  1093. if (mapping && mapping[prefix] && mapping[prefix][iconName]) {
  1094. return {
  1095. prefix: prefix,
  1096. iconName: iconName,
  1097. icon: mapping[prefix][iconName]
  1098. };
  1099. }
  1100. }
  1101. function toHtml(abstractNodes) {
  1102. var tag = abstractNodes.tag,
  1103. _abstractNodes$attrib = abstractNodes.attributes,
  1104. attributes = _abstractNodes$attrib === void 0 ? {} : _abstractNodes$attrib,
  1105. _abstractNodes$childr = abstractNodes.children,
  1106. children = _abstractNodes$childr === void 0 ? [] : _abstractNodes$childr;
  1107. if (typeof abstractNodes === 'string') {
  1108. return htmlEscape(abstractNodes);
  1109. } else {
  1110. return "<".concat(tag, " ").concat(joinAttributes(attributes), ">").concat(children.map(toHtml).join(''), "</").concat(tag, ">");
  1111. }
  1112. }
  1113. var noop$2 = function noop() {};
  1114. function isWatched(node) {
  1115. var i2svg = node.getAttribute ? node.getAttribute(DATA_FA_I2SVG) : null;
  1116. return typeof i2svg === 'string';
  1117. }
  1118. function getMutator() {
  1119. if (config.autoReplaceSvg === true) {
  1120. return mutators.replace;
  1121. }
  1122. var mutator = mutators[config.autoReplaceSvg];
  1123. return mutator || mutators.replace;
  1124. }
  1125. var mutators = {
  1126. replace: function replace(mutation) {
  1127. var node = mutation[0];
  1128. var abstract = mutation[1];
  1129. var newOuterHTML = abstract.map(function (a) {
  1130. return toHtml(a);
  1131. }).join('\n');
  1132. if (node.parentNode && node.outerHTML) {
  1133. node.outerHTML = newOuterHTML + (config.keepOriginalSource && node.tagName.toLowerCase() !== 'svg' ? "<!-- ".concat(node.outerHTML, " -->") : '');
  1134. } else if (node.parentNode) {
  1135. var newNode = document.createElement('span');
  1136. node.parentNode.replaceChild(newNode, node);
  1137. newNode.outerHTML = newOuterHTML;
  1138. }
  1139. },
  1140. nest: function nest(mutation) {
  1141. var node = mutation[0];
  1142. var abstract = mutation[1]; // If we already have a replaced node we do not want to continue nesting within it.
  1143. // Short-circuit to the standard replacement
  1144. if (~classArray(node).indexOf(config.replacementClass)) {
  1145. return mutators.replace(mutation);
  1146. }
  1147. var forSvg = new RegExp("".concat(config.familyPrefix, "-.*"));
  1148. delete abstract[0].attributes.style;
  1149. var splitClasses = abstract[0].attributes.class.split(' ').reduce(function (acc, cls) {
  1150. if (cls === config.replacementClass || cls.match(forSvg)) {
  1151. acc.toSvg.push(cls);
  1152. } else {
  1153. acc.toNode.push(cls);
  1154. }
  1155. return acc;
  1156. }, {
  1157. toNode: [],
  1158. toSvg: []
  1159. });
  1160. abstract[0].attributes.class = splitClasses.toSvg.join(' ');
  1161. var newInnerHTML = abstract.map(function (a) {
  1162. return toHtml(a);
  1163. }).join('\n');
  1164. node.setAttribute('class', splitClasses.toNode.join(' '));
  1165. node.setAttribute(DATA_FA_I2SVG, '');
  1166. node.innerHTML = newInnerHTML;
  1167. }
  1168. };
  1169. function performOperationSync(op) {
  1170. op();
  1171. }
  1172. function perform(mutations, callback) {
  1173. var callbackFunction = typeof callback === 'function' ? callback : noop$2;
  1174. if (mutations.length === 0) {
  1175. callbackFunction();
  1176. } else {
  1177. var frame = performOperationSync;
  1178. if (config.mutateApproach === MUTATION_APPROACH_ASYNC) {
  1179. frame = WINDOW.requestAnimationFrame || performOperationSync;
  1180. }
  1181. frame(function () {
  1182. var mutator = getMutator();
  1183. var mark = perf.begin('mutate');
  1184. mutations.map(mutator);
  1185. mark();
  1186. callbackFunction();
  1187. });
  1188. }
  1189. }
  1190. var disabled = false;
  1191. function disableObservation() {
  1192. disabled = true;
  1193. }
  1194. function enableObservation() {
  1195. disabled = false;
  1196. }
  1197. var mo = null;
  1198. function observe(options) {
  1199. if (!MUTATION_OBSERVER) {
  1200. return;
  1201. }
  1202. if (!config.observeMutations) {
  1203. return;
  1204. }
  1205. var treeCallback = options.treeCallback,
  1206. nodeCallback = options.nodeCallback,
  1207. pseudoElementsCallback = options.pseudoElementsCallback,
  1208. _options$observeMutat = options.observeMutationsRoot,
  1209. observeMutationsRoot = _options$observeMutat === void 0 ? DOCUMENT : _options$observeMutat;
  1210. mo = new MUTATION_OBSERVER(function (objects) {
  1211. if (disabled) return;
  1212. toArray(objects).forEach(function (mutationRecord) {
  1213. if (mutationRecord.type === 'childList' && mutationRecord.addedNodes.length > 0 && !isWatched(mutationRecord.addedNodes[0])) {
  1214. if (config.searchPseudoElements) {
  1215. pseudoElementsCallback(mutationRecord.target);
  1216. }
  1217. treeCallback(mutationRecord.target);
  1218. }
  1219. if (mutationRecord.type === 'attributes' && mutationRecord.target.parentNode && config.searchPseudoElements) {
  1220. pseudoElementsCallback(mutationRecord.target.parentNode);
  1221. }
  1222. if (mutationRecord.type === 'attributes' && isWatched(mutationRecord.target) && ~ATTRIBUTES_WATCHED_FOR_MUTATION.indexOf(mutationRecord.attributeName)) {
  1223. if (mutationRecord.attributeName === 'class') {
  1224. var _getCanonicalIcon = getCanonicalIcon(classArray(mutationRecord.target)),
  1225. prefix = _getCanonicalIcon.prefix,
  1226. iconName = _getCanonicalIcon.iconName;
  1227. if (prefix) mutationRecord.target.setAttribute('data-prefix', prefix);
  1228. if (iconName) mutationRecord.target.setAttribute('data-icon', iconName);
  1229. } else {
  1230. nodeCallback(mutationRecord.target);
  1231. }
  1232. }
  1233. });
  1234. });
  1235. if (!IS_DOM) return;
  1236. mo.observe(observeMutationsRoot, {
  1237. childList: true,
  1238. attributes: true,
  1239. characterData: true,
  1240. subtree: true
  1241. });
  1242. }
  1243. function disconnect() {
  1244. if (!mo) return;
  1245. mo.disconnect();
  1246. }
  1247. function styleParser (node) {
  1248. var style = node.getAttribute('style');
  1249. var val = [];
  1250. if (style) {
  1251. val = style.split(';').reduce(function (acc, style) {
  1252. var styles = style.split(':');
  1253. var prop = styles[0];
  1254. var value = styles.slice(1);
  1255. if (prop && value.length > 0) {
  1256. acc[prop] = value.join(':').trim();
  1257. }
  1258. return acc;
  1259. }, {});
  1260. }
  1261. return val;
  1262. }
  1263. function classParser (node) {
  1264. var existingPrefix = node.getAttribute('data-prefix');
  1265. var existingIconName = node.getAttribute('data-icon');
  1266. var innerText = node.innerText !== undefined ? node.innerText.trim() : '';
  1267. var val = getCanonicalIcon(classArray(node));
  1268. if (existingPrefix && existingIconName) {
  1269. val.prefix = existingPrefix;
  1270. val.iconName = existingIconName;
  1271. }
  1272. if (val.prefix && innerText.length > 1) {
  1273. val.iconName = byLigature(val.prefix, node.innerText);
  1274. } else if (val.prefix && innerText.length === 1) {
  1275. val.iconName = byUnicode(val.prefix, toHex(node.innerText));
  1276. }
  1277. return val;
  1278. }
  1279. var parseTransformString = function parseTransformString(transformString) {
  1280. var transform = {
  1281. size: 16,
  1282. x: 0,
  1283. y: 0,
  1284. flipX: false,
  1285. flipY: false,
  1286. rotate: 0
  1287. };
  1288. if (!transformString) {
  1289. return transform;
  1290. } else {
  1291. return transformString.toLowerCase().split(' ').reduce(function (acc, n) {
  1292. var parts = n.toLowerCase().split('-');
  1293. var first = parts[0];
  1294. var rest = parts.slice(1).join('-');
  1295. if (first && rest === 'h') {
  1296. acc.flipX = true;
  1297. return acc;
  1298. }
  1299. if (first && rest === 'v') {
  1300. acc.flipY = true;
  1301. return acc;
  1302. }
  1303. rest = parseFloat(rest);
  1304. if (isNaN(rest)) {
  1305. return acc;
  1306. }
  1307. switch (first) {
  1308. case 'grow':
  1309. acc.size = acc.size + rest;
  1310. break;
  1311. case 'shrink':
  1312. acc.size = acc.size - rest;
  1313. break;
  1314. case 'left':
  1315. acc.x = acc.x - rest;
  1316. break;
  1317. case 'right':
  1318. acc.x = acc.x + rest;
  1319. break;
  1320. case 'up':
  1321. acc.y = acc.y - rest;
  1322. break;
  1323. case 'down':
  1324. acc.y = acc.y + rest;
  1325. break;
  1326. case 'rotate':
  1327. acc.rotate = acc.rotate + rest;
  1328. break;
  1329. }
  1330. return acc;
  1331. }, transform);
  1332. }
  1333. };
  1334. function transformParser (node) {
  1335. return parseTransformString(node.getAttribute('data-fa-transform'));
  1336. }
  1337. function symbolParser (node) {
  1338. var symbol = node.getAttribute('data-fa-symbol');
  1339. return symbol === null ? false : symbol === '' ? true : symbol;
  1340. }
  1341. function attributesParser (node) {
  1342. var extraAttributes = toArray(node.attributes).reduce(function (acc, attr) {
  1343. if (acc.name !== 'class' && acc.name !== 'style') {
  1344. acc[attr.name] = attr.value;
  1345. }
  1346. return acc;
  1347. }, {});
  1348. var title = node.getAttribute('title');
  1349. if (config.autoA11y) {
  1350. if (title) {
  1351. extraAttributes['aria-labelledby'] = "".concat(config.replacementClass, "-title-").concat(nextUniqueId());
  1352. } else {
  1353. extraAttributes['aria-hidden'] = 'true';
  1354. extraAttributes['focusable'] = 'false';
  1355. }
  1356. }
  1357. return extraAttributes;
  1358. }
  1359. function maskParser (node) {
  1360. var mask = node.getAttribute('data-fa-mask');
  1361. if (!mask) {
  1362. return emptyCanonicalIcon();
  1363. } else {
  1364. return getCanonicalIcon(mask.split(' ').map(function (i) {
  1365. return i.trim();
  1366. }));
  1367. }
  1368. }
  1369. function blankMeta() {
  1370. return {
  1371. iconName: null,
  1372. title: null,
  1373. prefix: null,
  1374. transform: meaninglessTransform,
  1375. symbol: false,
  1376. mask: null,
  1377. extra: {
  1378. classes: [],
  1379. styles: {},
  1380. attributes: {}
  1381. }
  1382. };
  1383. }
  1384. function parseMeta(node) {
  1385. var _classParser = classParser(node),
  1386. iconName = _classParser.iconName,
  1387. prefix = _classParser.prefix,
  1388. extraClasses = _classParser.rest;
  1389. var extraStyles = styleParser(node);
  1390. var transform = transformParser(node);
  1391. var symbol = symbolParser(node);
  1392. var extraAttributes = attributesParser(node);
  1393. var mask = maskParser(node);
  1394. return {
  1395. iconName: iconName,
  1396. title: node.getAttribute('title'),
  1397. prefix: prefix,
  1398. transform: transform,
  1399. symbol: symbol,
  1400. mask: mask,
  1401. extra: {
  1402. classes: extraClasses,
  1403. styles: extraStyles,
  1404. attributes: extraAttributes
  1405. }
  1406. };
  1407. }
  1408. function MissingIcon(error) {
  1409. this.name = 'MissingIcon';
  1410. this.message = error || 'Icon unavailable';
  1411. this.stack = new Error().stack;
  1412. }
  1413. MissingIcon.prototype = Object.create(Error.prototype);
  1414. MissingIcon.prototype.constructor = MissingIcon;
  1415. var FILL = {
  1416. fill: 'currentColor'
  1417. };
  1418. var ANIMATION_BASE = {
  1419. attributeType: 'XML',
  1420. repeatCount: 'indefinite',
  1421. dur: '2s'
  1422. };
  1423. var RING = {
  1424. tag: 'path',
  1425. attributes: _objectSpread({}, FILL, {
  1426. d: 'M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z'
  1427. })
  1428. };
  1429. var OPACITY_ANIMATE = _objectSpread({}, ANIMATION_BASE, {
  1430. attributeName: 'opacity'
  1431. });
  1432. var DOT = {
  1433. tag: 'circle',
  1434. attributes: _objectSpread({}, FILL, {
  1435. cx: '256',
  1436. cy: '364',
  1437. r: '28'
  1438. }),
  1439. children: [{
  1440. tag: 'animate',
  1441. attributes: _objectSpread({}, ANIMATION_BASE, {
  1442. attributeName: 'r',
  1443. values: '28;14;28;28;14;28;'
  1444. })
  1445. }, {
  1446. tag: 'animate',
  1447. attributes: _objectSpread({}, OPACITY_ANIMATE, {
  1448. values: '1;0;1;1;0;1;'
  1449. })
  1450. }]
  1451. };
  1452. var QUESTION = {
  1453. tag: 'path',
  1454. attributes: _objectSpread({}, FILL, {
  1455. opacity: '1',
  1456. d: 'M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z'
  1457. }),
  1458. children: [{
  1459. tag: 'animate',
  1460. attributes: _objectSpread({}, OPACITY_ANIMATE, {
  1461. values: '1;0;0;0;0;1;'
  1462. })
  1463. }]
  1464. };
  1465. var EXCLAMATION = {
  1466. tag: 'path',
  1467. attributes: _objectSpread({}, FILL, {
  1468. opacity: '0',
  1469. d: 'M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z'
  1470. }),
  1471. children: [{
  1472. tag: 'animate',
  1473. attributes: _objectSpread({}, OPACITY_ANIMATE, {
  1474. values: '0;0;1;1;0;0;'
  1475. })
  1476. }]
  1477. };
  1478. var missing = {
  1479. tag: 'g',
  1480. children: [RING, DOT, QUESTION, EXCLAMATION]
  1481. };
  1482. var styles$2 = namespace.styles;
  1483. function findIcon(iconName, prefix) {
  1484. return new picked(function (resolve, reject) {
  1485. var val = {
  1486. found: false,
  1487. width: 512,
  1488. height: 512,
  1489. icon: missing
  1490. };
  1491. if (iconName && prefix && styles$2[prefix] && styles$2[prefix][iconName]) {
  1492. var icon = styles$2[prefix][iconName];
  1493. var width = icon[0];
  1494. var height = icon[1];
  1495. var vectorData = icon.slice(4);
  1496. val = {
  1497. found: true,
  1498. width: width,
  1499. height: height,
  1500. icon: {
  1501. tag: 'path',
  1502. attributes: {
  1503. fill: 'currentColor',
  1504. d: vectorData[0]
  1505. }
  1506. }
  1507. };
  1508. return resolve(val);
  1509. }
  1510. if (iconName && prefix && !config.showMissingIcons) {
  1511. reject(new MissingIcon("Icon is missing for prefix ".concat(prefix, " with icon name ").concat(iconName)));
  1512. } else {
  1513. resolve(val);
  1514. }
  1515. });
  1516. }
  1517. var styles$3 = namespace.styles;
  1518. function generateSvgReplacementMutation(node, nodeMeta) {
  1519. var iconName = nodeMeta.iconName,
  1520. title = nodeMeta.title,
  1521. prefix = nodeMeta.prefix,
  1522. transform = nodeMeta.transform,
  1523. symbol = nodeMeta.symbol,
  1524. mask = nodeMeta.mask,
  1525. extra = nodeMeta.extra;
  1526. return new picked(function (resolve, reject) {
  1527. picked.all([findIcon(iconName, prefix), findIcon(mask.iconName, mask.prefix)]).then(function (_ref) {
  1528. var _ref2 = _slicedToArray(_ref, 2),
  1529. main = _ref2[0],
  1530. mask = _ref2[1];
  1531. resolve([node, makeInlineSvgAbstract({
  1532. icons: {
  1533. main: main,
  1534. mask: mask
  1535. },
  1536. prefix: prefix,
  1537. iconName: iconName,
  1538. transform: transform,
  1539. symbol: symbol,
  1540. mask: mask,
  1541. title: title,
  1542. extra: extra,
  1543. watchable: true
  1544. })]);
  1545. });
  1546. });
  1547. }
  1548. function generateLayersText(node, nodeMeta) {
  1549. var title = nodeMeta.title,
  1550. transform = nodeMeta.transform,
  1551. extra = nodeMeta.extra;
  1552. var width = null;
  1553. var height = null;
  1554. if (IS_IE) {
  1555. var computedFontSize = parseInt(getComputedStyle(node).fontSize, 10);
  1556. var boundingClientRect = node.getBoundingClientRect();
  1557. width = boundingClientRect.width / computedFontSize;
  1558. height = boundingClientRect.height / computedFontSize;
  1559. }
  1560. if (config.autoA11y && !title) {
  1561. extra.attributes['aria-hidden'] = 'true';
  1562. }
  1563. return picked.resolve([node, makeLayersTextAbstract({
  1564. content: node.innerHTML,
  1565. width: width,
  1566. height: height,
  1567. transform: transform,
  1568. title: title,
  1569. extra: extra,
  1570. watchable: true
  1571. })]);
  1572. }
  1573. function generateMutation(node) {
  1574. var nodeMeta = parseMeta(node);
  1575. if (~nodeMeta.extra.classes.indexOf(LAYERS_TEXT_CLASSNAME)) {
  1576. return generateLayersText(node, nodeMeta);
  1577. } else {
  1578. return generateSvgReplacementMutation(node, nodeMeta);
  1579. }
  1580. }
  1581. function onTree(root) {
  1582. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1583. if (!IS_DOM) return;
  1584. var htmlClassList = DOCUMENT.documentElement.classList;
  1585. var hclAdd = function hclAdd(suffix) {
  1586. return htmlClassList.add("".concat(HTML_CLASS_I2SVG_BASE_CLASS, "-").concat(suffix));
  1587. };
  1588. var hclRemove = function hclRemove(suffix) {
  1589. return htmlClassList.remove("".concat(HTML_CLASS_I2SVG_BASE_CLASS, "-").concat(suffix));
  1590. };
  1591. var prefixes = config.autoFetchSvg ? Object.keys(PREFIX_TO_STYLE) : Object.keys(styles$3);
  1592. var prefixesDomQuery = [".".concat(LAYERS_TEXT_CLASSNAME, ":not([").concat(DATA_FA_I2SVG, "])")].concat(prefixes.map(function (p) {
  1593. return ".".concat(p, ":not([").concat(DATA_FA_I2SVG, "])");
  1594. })).join(', ');
  1595. if (prefixesDomQuery.length === 0) {
  1596. return;
  1597. }
  1598. var candidates = [];
  1599. try {
  1600. candidates = toArray(root.querySelectorAll(prefixesDomQuery));
  1601. } catch (e) {// noop
  1602. }
  1603. if (candidates.length > 0) {
  1604. hclAdd('pending');
  1605. hclRemove('complete');
  1606. } else {
  1607. return;
  1608. }
  1609. var mark = perf.begin('onTree');
  1610. var mutations = candidates.reduce(function (acc, node) {
  1611. try {
  1612. var mutation = generateMutation(node);
  1613. if (mutation) {
  1614. acc.push(mutation);
  1615. }
  1616. } catch (e) {
  1617. if (!PRODUCTION) {
  1618. if (e instanceof MissingIcon) {
  1619. console.error(e);
  1620. }
  1621. }
  1622. }
  1623. return acc;
  1624. }, []);
  1625. return new picked(function (resolve, reject) {
  1626. picked.all(mutations).then(function (resolvedMutations) {
  1627. perform(resolvedMutations, function () {
  1628. hclAdd('active');
  1629. hclAdd('complete');
  1630. hclRemove('pending');
  1631. if (typeof callback === 'function') callback();
  1632. mark();
  1633. resolve();
  1634. });
  1635. }).catch(function () {
  1636. mark();
  1637. reject();
  1638. });
  1639. });
  1640. }
  1641. function onNode(node) {
  1642. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1643. generateMutation(node).then(function (mutation) {
  1644. if (mutation) {
  1645. perform([mutation], callback);
  1646. }
  1647. });
  1648. }
  1649. function replaceForPosition(node, position) {
  1650. var pendingAttribute = "".concat(DATA_FA_PSEUDO_ELEMENT_PENDING).concat(position.replace(':', '-'));
  1651. return new picked(function (resolve, reject) {
  1652. if (node.getAttribute(pendingAttribute) !== null) {
  1653. // This node is already being processed
  1654. return resolve();
  1655. }
  1656. var children = toArray(node.children);
  1657. var alreadyProcessedPseudoElement = children.filter(function (c) {
  1658. return c.getAttribute(DATA_FA_PSEUDO_ELEMENT) === position;
  1659. })[0];
  1660. var styles = WINDOW.getComputedStyle(node, position);
  1661. var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
  1662. var fontWeight = styles.getPropertyValue('font-weight');
  1663. if (alreadyProcessedPseudoElement && !fontFamily) {
  1664. // If we've already processed it but the current computed style does not result in a font-family,
  1665. // that probably means that a class name that was previously present to make the icon has been
  1666. // removed. So we now should delete the icon.
  1667. node.removeChild(alreadyProcessedPseudoElement);
  1668. return resolve();
  1669. } else if (fontFamily) {
  1670. var content = styles.getPropertyValue('content');
  1671. var prefix = ~['Light', 'Regular', 'Solid', 'Brands'].indexOf(fontFamily[1]) ? STYLE_TO_PREFIX[fontFamily[1].toLowerCase()] : FONT_WEIGHT_TO_PREFIX[fontWeight];
  1672. var hexValue = toHex(content.length === 3 ? content.substr(1, 1) : content);
  1673. var iconName = byUnicode(prefix, hexValue);
  1674. var iconIdentifier = iconName; // Only convert the pseudo element in this :before/:after position into an icon if we haven't
  1675. // already done so with the same prefix and iconName
  1676. if (iconName && (!alreadyProcessedPseudoElement || alreadyProcessedPseudoElement.getAttribute(DATA_PREFIX) !== prefix || alreadyProcessedPseudoElement.getAttribute(DATA_ICON) !== iconIdentifier)) {
  1677. node.setAttribute(pendingAttribute, iconIdentifier);
  1678. if (alreadyProcessedPseudoElement) {
  1679. // Delete the old one, since we're replacing it with a new one
  1680. node.removeChild(alreadyProcessedPseudoElement);
  1681. }
  1682. var meta = blankMeta();
  1683. var extra = meta.extra;
  1684. extra.attributes[DATA_FA_PSEUDO_ELEMENT] = position;
  1685. findIcon(iconName, prefix).then(function (main) {
  1686. var abstract = makeInlineSvgAbstract(_objectSpread({}, meta, {
  1687. icons: {
  1688. main: main,
  1689. mask: emptyCanonicalIcon()
  1690. },
  1691. prefix: prefix,
  1692. iconName: iconIdentifier,
  1693. extra: extra,
  1694. watchable: true
  1695. }));
  1696. var element = DOCUMENT.createElement('svg');
  1697. if (position === ':before') {
  1698. node.insertBefore(element, node.firstChild);
  1699. } else {
  1700. node.appendChild(element);
  1701. }
  1702. element.outerHTML = abstract.map(function (a) {
  1703. return toHtml(a);
  1704. }).join('\n');
  1705. node.removeAttribute(pendingAttribute);
  1706. resolve();
  1707. }).catch(reject);
  1708. } else {
  1709. resolve();
  1710. }
  1711. } else {
  1712. resolve();
  1713. }
  1714. });
  1715. }
  1716. function replace(node) {
  1717. return picked.all([replaceForPosition(node, ':before'), replaceForPosition(node, ':after')]);
  1718. }
  1719. function processable(node) {
  1720. return node.parentNode !== document.head && !~TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS.indexOf(node.tagName.toUpperCase()) && !node.getAttribute(DATA_FA_PSEUDO_ELEMENT) && (!node.parentNode || node.parentNode.tagName !== 'svg');
  1721. }
  1722. function searchPseudoElements (root) {
  1723. if (!IS_DOM) return;
  1724. return new picked(function (resolve, reject) {
  1725. var operations = toArray(root.querySelectorAll('*')).filter(processable).map(replace);
  1726. var end = perf.begin('searchPseudoElements');
  1727. disableObservation();
  1728. picked.all(operations).then(function () {
  1729. end();
  1730. enableObservation();
  1731. resolve();
  1732. }).catch(function () {
  1733. end();
  1734. enableObservation();
  1735. reject();
  1736. });
  1737. });
  1738. }
  1739. var baseStyles = "svg:not(:root).svg-inline--fa{overflow:visible}.svg-inline--fa{display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em}.svg-inline--fa.fa-lg{vertical-align:-.225em}.svg-inline--fa.fa-w-1{width:.0625em}.svg-inline--fa.fa-w-2{width:.125em}.svg-inline--fa.fa-w-3{width:.1875em}.svg-inline--fa.fa-w-4{width:.25em}.svg-inline--fa.fa-w-5{width:.3125em}.svg-inline--fa.fa-w-6{width:.375em}.svg-inline--fa.fa-w-7{width:.4375em}.svg-inline--fa.fa-w-8{width:.5em}.svg-inline--fa.fa-w-9{width:.5625em}.svg-inline--fa.fa-w-10{width:.625em}.svg-inline--fa.fa-w-11{width:.6875em}.svg-inline--fa.fa-w-12{width:.75em}.svg-inline--fa.fa-w-13{width:.8125em}.svg-inline--fa.fa-w-14{width:.875em}.svg-inline--fa.fa-w-15{width:.9375em}.svg-inline--fa.fa-w-16{width:1em}.svg-inline--fa.fa-w-17{width:1.0625em}.svg-inline--fa.fa-w-18{width:1.125em}.svg-inline--fa.fa-w-19{width:1.1875em}.svg-inline--fa.fa-w-20{width:1.25em}.svg-inline--fa.fa-pull-left{margin-right:.3em;width:auto}.svg-inline--fa.fa-pull-right{margin-left:.3em;width:auto}.svg-inline--fa.fa-border{height:1.5em}.svg-inline--fa.fa-li{width:2em}.svg-inline--fa.fa-fw{width:1.25em}.fa-layers svg.svg-inline--fa{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}.fa-layers{display:inline-block;height:1em;position:relative;text-align:center;vertical-align:-.125em;width:1em}.fa-layers svg.svg-inline--fa{-webkit-transform-origin:center center;transform-origin:center center}.fa-layers-counter,.fa-layers-text{display:inline-block;position:absolute;text-align:center}.fa-layers-text{left:50%;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);-webkit-transform-origin:center center;transform-origin:center center}.fa-layers-counter{background-color:#ff253a;border-radius:1em;-webkit-box-sizing:border-box;box-sizing:border-box;color:#fff;height:1.5em;line-height:1;max-width:5em;min-width:1.5em;overflow:hidden;padding:.25em;right:0;text-overflow:ellipsis;top:0;-webkit-transform:scale(.25);transform:scale(.25);-webkit-transform-origin:top right;transform-origin:top right}.fa-layers-bottom-right{bottom:0;right:0;top:auto;-webkit-transform:scale(.25);transform:scale(.25);-webkit-transform-origin:bottom right;transform-origin:bottom right}.fa-layers-bottom-left{bottom:0;left:0;right:auto;top:auto;-webkit-transform:scale(.25);transform:scale(.25);-webkit-transform-origin:bottom left;transform-origin:bottom left}.fa-layers-top-right{right:0;top:0;-webkit-transform:scale(.25);transform:scale(.25);-webkit-transform-origin:top right;transform-origin:top right}.fa-layers-top-left{left:0;right:auto;top:0;-webkit-transform:scale(.25);transform:scale(.25);-webkit-transform-origin:top left;transform-origin:top left}.fa-lg{font-size:1.3333333333em;line-height:.75em;vertical-align:-.0667em}.fa-xs{font-size:.75em}.fa-sm{font-size:.875em}.fa-1x{font-size:1em}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-6x{font-size:6em}.fa-7x{font-size:7em}.fa-8x{font-size:8em}.fa-9x{font-size:9em}.fa-10x{font-size:10em}.fa-fw{text-align:center;width:1.25em}.fa-ul{list-style-type:none;margin-left:2.5em;padding-left:0}.fa-ul>li{position:relative}.fa-li{left:-2em;position:absolute;text-align:center;width:2em;line-height:inherit}.fa-border{border:solid .08em #eee;border-radius:.1em;padding:.2em .25em .15em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left,.fab.fa-pull-left,.fal.fa-pull-left,.far.fa-pull-left,.fas.fa-pull-left{margin-right:.3em}.fa.fa-pull-right,.fab.fa-pull-right,.fal.fa-pull-right,.far.fa-pull-right,.fas.fa-pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.fa-rotate-90{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-webkit-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-webkit-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{-webkit-transform:scale(1,-1);transform:scale(1,-1)}.fa-flip-both,.fa-flip-horizontal.fa-flip-vertical{-webkit-transform:scale(-1,-1);transform:scale(-1,-1)}:root .fa-flip-both,:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-rotate-90{-webkit-filter:none;filter:none}.fa-stack{display:inline-block;height:2em;position:relative;width:2.5em}.fa-stack-1x,.fa-stack-2x{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0}.svg-inline--fa.fa-stack-1x{height:1em;width:1.25em}.svg-inline--fa.fa-stack-2x{height:2em;width:2.5em}.fa-inverse{color:#fff}.sr-only{border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.sr-only-focusable:active,.sr-only-focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}";
  1740. function css () {
  1741. var dfp = DEFAULT_FAMILY_PREFIX;
  1742. var drc = DEFAULT_REPLACEMENT_CLASS;
  1743. var fp = config.familyPrefix;
  1744. var rc = config.replacementClass;
  1745. var s = baseStyles;
  1746. if (fp !== dfp || rc !== drc) {
  1747. var dPatt = new RegExp("\\.".concat(dfp, "\\-"), 'g');
  1748. var rPatt = new RegExp("\\.".concat(drc), 'g');
  1749. s = s.replace(dPatt, ".".concat(fp, "-")).replace(rPatt, ".".concat(rc));
  1750. }
  1751. return s;
  1752. }
  1753. var Library =
  1754. /*#__PURE__*/
  1755. function () {
  1756. function Library() {
  1757. _classCallCheck(this, Library);
  1758. this.definitions = {};
  1759. }
  1760. _createClass(Library, [{
  1761. key: "add",
  1762. value: function add() {
  1763. var _this = this;
  1764. for (var _len = arguments.length, definitions = new Array(_len), _key = 0; _key < _len; _key++) {
  1765. definitions[_key] = arguments[_key];
  1766. }
  1767. var additions = definitions.reduce(this._pullDefinitions, {});
  1768. Object.keys(additions).forEach(function (key) {
  1769. _this.definitions[key] = _objectSpread({}, _this.definitions[key] || {}, additions[key]);
  1770. defineIcons(key, additions[key]);
  1771. build();
  1772. });
  1773. }
  1774. }, {
  1775. key: "reset",
  1776. value: function reset() {
  1777. this.definitions = {};
  1778. }
  1779. }, {
  1780. key: "_pullDefinitions",
  1781. value: function _pullDefinitions(additions, definition) {
  1782. var normalized = definition.prefix && definition.iconName && definition.icon ? {
  1783. 0: definition
  1784. } : definition;
  1785. Object.keys(normalized).map(function (key) {
  1786. var _normalized$key = normalized[key],
  1787. prefix = _normalized$key.prefix,
  1788. iconName = _normalized$key.iconName,
  1789. icon = _normalized$key.icon;
  1790. if (!additions[prefix]) additions[prefix] = {};
  1791. additions[prefix][iconName] = icon;
  1792. });
  1793. return additions;
  1794. }
  1795. }]);
  1796. return Library;
  1797. }();
  1798. function prepIcon(icon) {
  1799. var width = icon[0];
  1800. var height = icon[1];
  1801. var vectorData = icon.slice(4);
  1802. return {
  1803. found: true,
  1804. width: width,
  1805. height: height,
  1806. icon: {
  1807. tag: 'path',
  1808. attributes: {
  1809. fill: 'currentColor',
  1810. d: vectorData[0]
  1811. }
  1812. }
  1813. };
  1814. }
  1815. function ensureCss() {
  1816. if (config.autoAddCss && !_cssInserted) {
  1817. insertCss(css());
  1818. _cssInserted = true;
  1819. }
  1820. }
  1821. function apiObject(val, abstractCreator) {
  1822. Object.defineProperty(val, 'abstract', {
  1823. get: abstractCreator
  1824. });
  1825. Object.defineProperty(val, 'html', {
  1826. get: function get() {
  1827. return val.abstract.map(function (a) {
  1828. return toHtml(a);
  1829. });
  1830. }
  1831. });
  1832. Object.defineProperty(val, 'node', {
  1833. get: function get() {
  1834. if (!IS_DOM) return;
  1835. var container = DOCUMENT.createElement('div');
  1836. container.innerHTML = val.html;
  1837. return container.children;
  1838. }
  1839. });
  1840. return val;
  1841. }
  1842. function findIconDefinition(iconLookup) {
  1843. var _iconLookup$prefix = iconLookup.prefix,
  1844. prefix = _iconLookup$prefix === void 0 ? 'fa' : _iconLookup$prefix,
  1845. iconName = iconLookup.iconName;
  1846. if (!iconName) return;
  1847. return iconFromMapping(library.definitions, prefix, iconName) || iconFromMapping(namespace.styles, prefix, iconName);
  1848. }
  1849. function resolveIcons(next) {
  1850. return function (maybeIconDefinition) {
  1851. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1852. var iconDefinition = (maybeIconDefinition || {}).icon ? maybeIconDefinition : findIconDefinition(maybeIconDefinition || {});
  1853. var mask = params.mask;
  1854. if (mask) {
  1855. mask = (mask || {}).icon ? mask : findIconDefinition(mask || {});
  1856. }
  1857. return next(iconDefinition, _objectSpread({}, params, {
  1858. mask: mask
  1859. }));
  1860. };
  1861. }
  1862. var library = new Library();
  1863. var noAuto = function noAuto() {
  1864. config.autoReplaceSvg = false;
  1865. config.observeMutations = false;
  1866. disconnect();
  1867. };
  1868. var _cssInserted = false;
  1869. var dom = {
  1870. i2svg: function i2svg() {
  1871. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1872. if (IS_DOM) {
  1873. ensureCss();
  1874. var _params$node = params.node,
  1875. node = _params$node === void 0 ? DOCUMENT : _params$node,
  1876. _params$callback = params.callback,
  1877. callback = _params$callback === void 0 ? function () {} : _params$callback;
  1878. if (config.searchPseudoElements) {
  1879. searchPseudoElements(node);
  1880. }
  1881. return onTree(node, callback);
  1882. } else {
  1883. return picked.reject('Operation requires a DOM of some kind.');
  1884. }
  1885. },
  1886. css: css,
  1887. insertCss: function insertCss$$1() {
  1888. if (!_cssInserted) {
  1889. insertCss(css());
  1890. _cssInserted = true;
  1891. }
  1892. },
  1893. watch: function watch() {
  1894. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1895. var autoReplaceSvgRoot = params.autoReplaceSvgRoot,
  1896. observeMutationsRoot = params.observeMutationsRoot;
  1897. if (config.autoReplaceSvg === false) {
  1898. config.autoReplaceSvg = true;
  1899. }
  1900. config.observeMutations = true;
  1901. domready(function () {
  1902. autoReplace({
  1903. autoReplaceSvgRoot: autoReplaceSvgRoot
  1904. });
  1905. observe({
  1906. treeCallback: onTree,
  1907. nodeCallback: onNode,
  1908. pseudoElementsCallback: searchPseudoElements,
  1909. observeMutationsRoot: observeMutationsRoot
  1910. });
  1911. });
  1912. }
  1913. };
  1914. var parse = {
  1915. transform: function transform(transformString) {
  1916. return parseTransformString(transformString);
  1917. }
  1918. };
  1919. var icon = resolveIcons(function (iconDefinition) {
  1920. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1921. var _params$transform = params.transform,
  1922. transform = _params$transform === void 0 ? meaninglessTransform : _params$transform,
  1923. _params$symbol = params.symbol,
  1924. symbol = _params$symbol === void 0 ? false : _params$symbol,
  1925. _params$mask = params.mask,
  1926. mask = _params$mask === void 0 ? null : _params$mask,
  1927. _params$title = params.title,
  1928. title = _params$title === void 0 ? null : _params$title,
  1929. _params$classes = params.classes,
  1930. classes = _params$classes === void 0 ? [] : _params$classes,
  1931. _params$attributes = params.attributes,
  1932. attributes = _params$attributes === void 0 ? {} : _params$attributes,
  1933. _params$styles = params.styles,
  1934. styles = _params$styles === void 0 ? {} : _params$styles;
  1935. if (!iconDefinition) return;
  1936. var prefix = iconDefinition.prefix,
  1937. iconName = iconDefinition.iconName,
  1938. icon = iconDefinition.icon;
  1939. return apiObject(_objectSpread({
  1940. type: 'icon'
  1941. }, iconDefinition), function () {
  1942. ensureCss();
  1943. if (config.autoA11y) {
  1944. if (title) {
  1945. attributes['aria-labelledby'] = "".concat(config.replacementClass, "-title-").concat(nextUniqueId());
  1946. } else {
  1947. attributes['aria-hidden'] = 'true';
  1948. attributes['focusable'] = 'false';
  1949. }
  1950. }
  1951. return makeInlineSvgAbstract({
  1952. icons: {
  1953. main: prepIcon(icon),
  1954. mask: mask ? prepIcon(mask.icon) : {
  1955. found: false,
  1956. width: null,
  1957. height: null,
  1958. icon: {}
  1959. }
  1960. },
  1961. prefix: prefix,
  1962. iconName: iconName,
  1963. transform: _objectSpread({}, meaninglessTransform, transform),
  1964. symbol: symbol,
  1965. title: title,
  1966. extra: {
  1967. attributes: attributes,
  1968. styles: styles,
  1969. classes: classes
  1970. }
  1971. });
  1972. });
  1973. });
  1974. var text = function text(content) {
  1975. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1976. var _params$transform2 = params.transform,
  1977. transform = _params$transform2 === void 0 ? meaninglessTransform : _params$transform2,
  1978. _params$title2 = params.title,
  1979. title = _params$title2 === void 0 ? null : _params$title2,
  1980. _params$classes2 = params.classes,
  1981. classes = _params$classes2 === void 0 ? [] : _params$classes2,
  1982. _params$attributes2 = params.attributes,
  1983. attributes = _params$attributes2 === void 0 ? {} : _params$attributes2,
  1984. _params$styles2 = params.styles,
  1985. styles = _params$styles2 === void 0 ? {} : _params$styles2;
  1986. return apiObject({
  1987. type: 'text',
  1988. content: content
  1989. }, function () {
  1990. ensureCss();
  1991. return makeLayersTextAbstract({
  1992. content: content,
  1993. transform: _objectSpread({}, meaninglessTransform, transform),
  1994. title: title,
  1995. extra: {
  1996. attributes: attributes,
  1997. styles: styles,
  1998. classes: ["".concat(config.familyPrefix, "-layers-text")].concat(_toConsumableArray(classes))
  1999. }
  2000. });
  2001. });
  2002. };
  2003. var counter = function counter(content) {
  2004. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  2005. var _params$title3 = params.title,
  2006. title = _params$title3 === void 0 ? null : _params$title3,
  2007. _params$classes3 = params.classes,
  2008. classes = _params$classes3 === void 0 ? [] : _params$classes3,
  2009. _params$attributes3 = params.attributes,
  2010. attributes = _params$attributes3 === void 0 ? {} : _params$attributes3,
  2011. _params$styles3 = params.styles,
  2012. styles = _params$styles3 === void 0 ? {} : _params$styles3;
  2013. return apiObject({
  2014. type: 'counter',
  2015. content: content
  2016. }, function () {
  2017. ensureCss();
  2018. return makeLayersCounterAbstract({
  2019. content: content.toString(),
  2020. title: title,
  2021. extra: {
  2022. attributes: attributes,
  2023. styles: styles,
  2024. classes: ["".concat(config.familyPrefix, "-layers-counter")].concat(_toConsumableArray(classes))
  2025. }
  2026. });
  2027. });
  2028. };
  2029. var layer = function layer(assembler) {
  2030. return apiObject({
  2031. type: 'layer'
  2032. }, function () {
  2033. ensureCss();
  2034. var children = [];
  2035. assembler(function (args) {
  2036. Array.isArray(args) ? args.map(function (a) {
  2037. children = children.concat(a.abstract);
  2038. }) : children = children.concat(args.abstract);
  2039. });
  2040. return [{
  2041. tag: 'span',
  2042. attributes: {
  2043. class: "".concat(config.familyPrefix, "-layers")
  2044. },
  2045. children: children
  2046. }];
  2047. });
  2048. };
  2049. var api = {
  2050. noAuto: noAuto,
  2051. config: config,
  2052. dom: dom,
  2053. library: library,
  2054. parse: parse,
  2055. findIconDefinition: findIconDefinition,
  2056. icon: icon,
  2057. text: text,
  2058. counter: counter,
  2059. layer: layer,
  2060. toHtml: toHtml
  2061. };
  2062. var autoReplace = function autoReplace() {
  2063. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2064. var _params$autoReplaceSv = params.autoReplaceSvgRoot,
  2065. autoReplaceSvgRoot = _params$autoReplaceSv === void 0 ? DOCUMENT : _params$autoReplaceSv;
  2066. if ((Object.keys(namespace.styles).length > 0 || config.autoFetchSvg) && IS_DOM && config.autoReplaceSvg) api.dom.i2svg({
  2067. node: autoReplaceSvgRoot
  2068. });
  2069. };
  2070. function bootstrap() {
  2071. if (IS_BROWSER) {
  2072. if (!WINDOW.FontAwesome) {
  2073. WINDOW.FontAwesome = api;
  2074. }
  2075. domready(function () {
  2076. autoReplace();
  2077. observe({
  2078. treeCallback: onTree,
  2079. nodeCallback: onNode,
  2080. pseudoElementsCallback: searchPseudoElements
  2081. });
  2082. });
  2083. }
  2084. namespace.hooks = _objectSpread({}, namespace.hooks, {
  2085. addPack: function addPack(prefix, icons) {
  2086. namespace.styles[prefix] = _objectSpread({}, namespace.styles[prefix] || {}, icons);
  2087. build();
  2088. autoReplace();
  2089. },
  2090. addShims: function addShims(shims) {
  2091. var _namespace$shims;
  2092. (_namespace$shims = namespace.shims).push.apply(_namespace$shims, _toConsumableArray(shims));
  2093. build();
  2094. autoReplace();
  2095. }
  2096. });
  2097. }
  2098. bunker(bootstrap);
  2099. }());