fontawesome.js 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  1. /*!
  2. * Font Awesome Free 5.4.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. */
  5. (function () {
  6. 'use strict';
  7. var noop = function noop() {};
  8. var _WINDOW = {};
  9. var _DOCUMENT = {};
  10. var _MUTATION_OBSERVER$1 = null;
  11. var _PERFORMANCE = { mark: noop, measure: noop };
  12. try {
  13. if (typeof window !== 'undefined') _WINDOW = window;
  14. if (typeof document !== 'undefined') _DOCUMENT = document;
  15. if (typeof MutationObserver !== 'undefined') _MUTATION_OBSERVER$1 = MutationObserver;
  16. if (typeof performance !== 'undefined') _PERFORMANCE = performance;
  17. } catch (e) {}
  18. var _ref = _WINDOW.navigator || {};
  19. var _ref$userAgent = _ref.userAgent;
  20. var userAgent = _ref$userAgent === undefined ? '' : _ref$userAgent;
  21. var WINDOW = _WINDOW;
  22. var DOCUMENT = _DOCUMENT;
  23. var MUTATION_OBSERVER = _MUTATION_OBSERVER$1;
  24. var PERFORMANCE = _PERFORMANCE;
  25. var IS_BROWSER = !!WINDOW.document;
  26. var IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
  27. var IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
  28. var NAMESPACE_IDENTIFIER = '___FONT_AWESOME___';
  29. var UNITS_IN_GRID = 16;
  30. var DEFAULT_FAMILY_PREFIX = 'fa';
  31. var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
  32. var DATA_FA_I2SVG = 'data-fa-i2svg';
  33. var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
  34. var DATA_PREFIX = 'data-prefix';
  35. var DATA_ICON = 'data-icon';
  36. var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
  37. var TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS = ['HTML', 'HEAD', 'STYLE', 'SCRIPT'];
  38. var PRODUCTION = function () {
  39. try {
  40. return "production" === 'production';
  41. } catch (e) {
  42. return false;
  43. }
  44. }();
  45. var oneToTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  46. var oneToTwenty = oneToTen.concat([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
  47. var ATTRIBUTES_WATCHED_FOR_MUTATION = ['class', 'data-prefix', 'data-icon', 'data-fa-transform', 'data-fa-mask'];
  48. 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', 'stack', 'stack-1x', 'stack-2x', 'inverse', 'layers', 'layers-text', 'layers-counter'].concat(oneToTen.map(function (n) {
  49. return n + 'x';
  50. })).concat(oneToTwenty.map(function (n) {
  51. return 'w-' + n;
  52. }));
  53. var classCallCheck = function (instance, Constructor) {
  54. if (!(instance instanceof Constructor)) {
  55. throw new TypeError("Cannot call a class as a function");
  56. }
  57. };
  58. var createClass = function () {
  59. function defineProperties(target, props) {
  60. for (var i = 0; i < props.length; i++) {
  61. var descriptor = props[i];
  62. descriptor.enumerable = descriptor.enumerable || false;
  63. descriptor.configurable = true;
  64. if ("value" in descriptor) descriptor.writable = true;
  65. Object.defineProperty(target, descriptor.key, descriptor);
  66. }
  67. }
  68. return function (Constructor, protoProps, staticProps) {
  69. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  70. if (staticProps) defineProperties(Constructor, staticProps);
  71. return Constructor;
  72. };
  73. }();
  74. var _extends = Object.assign || function (target) {
  75. for (var i = 1; i < arguments.length; i++) {
  76. var source = arguments[i];
  77. for (var key in source) {
  78. if (Object.prototype.hasOwnProperty.call(source, key)) {
  79. target[key] = source[key];
  80. }
  81. }
  82. }
  83. return target;
  84. };
  85. var slicedToArray = function () {
  86. function sliceIterator(arr, i) {
  87. var _arr = [];
  88. var _n = true;
  89. var _d = false;
  90. var _e = undefined;
  91. try {
  92. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  93. _arr.push(_s.value);
  94. if (i && _arr.length === i) break;
  95. }
  96. } catch (err) {
  97. _d = true;
  98. _e = err;
  99. } finally {
  100. try {
  101. if (!_n && _i["return"]) _i["return"]();
  102. } finally {
  103. if (_d) throw _e;
  104. }
  105. }
  106. return _arr;
  107. }
  108. return function (arr, i) {
  109. if (Array.isArray(arr)) {
  110. return arr;
  111. } else if (Symbol.iterator in Object(arr)) {
  112. return sliceIterator(arr, i);
  113. } else {
  114. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  115. }
  116. };
  117. }();
  118. var toConsumableArray = function (arr) {
  119. if (Array.isArray(arr)) {
  120. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  121. return arr2;
  122. } else {
  123. return Array.from(arr);
  124. }
  125. };
  126. var initial = WINDOW.FontAwesomeConfig || {};
  127. function getAttrConfig(attr) {
  128. var element = DOCUMENT.querySelector('script[' + attr + ']');
  129. if (element) {
  130. return element.getAttribute(attr);
  131. }
  132. }
  133. function coerce(val) {
  134. // Getting an empty string will occur if the attribute is set on the HTML tag but without a value
  135. // We'll assume that this is an indication that it should be toggled to true
  136. // For example <script data-search-pseudo-elements src="..."></script>
  137. if (val === '') return true;
  138. if (val === 'false') return false;
  139. if (val === 'true') return true;
  140. return val;
  141. }
  142. if (DOCUMENT && typeof DOCUMENT.querySelector === 'function') {
  143. 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-keep-original-source', 'keepOriginalSource'], ['data-measure-performance', 'measurePerformance'], ['data-show-missing-icons', 'showMissingIcons']];
  144. attrs.forEach(function (_ref) {
  145. var _ref2 = slicedToArray(_ref, 2),
  146. attr = _ref2[0],
  147. key = _ref2[1];
  148. var val = coerce(getAttrConfig(attr));
  149. if (val !== undefined && val !== null) {
  150. initial[key] = val;
  151. }
  152. });
  153. }
  154. var _default = _extends({
  155. familyPrefix: DEFAULT_FAMILY_PREFIX,
  156. replacementClass: DEFAULT_REPLACEMENT_CLASS,
  157. autoReplaceSvg: true,
  158. autoAddCss: true,
  159. autoA11y: true,
  160. searchPseudoElements: false,
  161. observeMutations: true,
  162. keepOriginalSource: true,
  163. measurePerformance: false,
  164. showMissingIcons: true
  165. }, initial);
  166. if (!_default.autoReplaceSvg) _default.observeMutations = false;
  167. var config = _extends({}, _default);
  168. WINDOW.FontAwesomeConfig = config;
  169. var w = WINDOW || {};
  170. if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
  171. if (!w[NAMESPACE_IDENTIFIER].styles) w[NAMESPACE_IDENTIFIER].styles = {};
  172. if (!w[NAMESPACE_IDENTIFIER].hooks) w[NAMESPACE_IDENTIFIER].hooks = {};
  173. if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
  174. var namespace = w[NAMESPACE_IDENTIFIER];
  175. var functions = [];
  176. var listener = function listener() {
  177. DOCUMENT.removeEventListener('DOMContentLoaded', listener);
  178. loaded = 1;
  179. functions.map(function (fn) {
  180. return fn();
  181. });
  182. };
  183. var loaded = false;
  184. if (IS_DOM) {
  185. loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
  186. if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
  187. }
  188. var domready = function (fn) {
  189. if (!IS_DOM) return;
  190. loaded ? setTimeout(fn, 0) : functions.push(fn);
  191. };
  192. var d = UNITS_IN_GRID;
  193. var meaninglessTransform = {
  194. size: 16,
  195. x: 0,
  196. y: 0,
  197. rotate: 0,
  198. flipX: false,
  199. flipY: false
  200. };
  201. function isReserved(name) {
  202. return ~RESERVED_CLASSES.indexOf(name);
  203. }
  204. function bunker(fn) {
  205. try {
  206. fn();
  207. } catch (e) {
  208. if (!PRODUCTION) {
  209. throw e;
  210. }
  211. }
  212. }
  213. function insertCss(css) {
  214. if (!css || !IS_DOM) {
  215. return;
  216. }
  217. var style = DOCUMENT.createElement('style');
  218. style.setAttribute('type', 'text/css');
  219. style.innerHTML = css;
  220. var headChildren = DOCUMENT.head.childNodes;
  221. var beforeChild = null;
  222. for (var i = headChildren.length - 1; i > -1; i--) {
  223. var child = headChildren[i];
  224. var tagName = (child.tagName || '').toUpperCase();
  225. if (['STYLE', 'LINK'].indexOf(tagName) > -1) {
  226. beforeChild = child;
  227. }
  228. }
  229. DOCUMENT.head.insertBefore(style, beforeChild);
  230. return css;
  231. }
  232. var idPool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  233. function nextUniqueId() {
  234. var size = 12;
  235. var id = '';
  236. while (size-- > 0) {
  237. id += idPool[Math.random() * 62 | 0];
  238. }
  239. return id;
  240. }
  241. function toArray(obj) {
  242. var array = [];
  243. for (var i = (obj || []).length >>> 0; i--;) {
  244. array[i] = obj[i];
  245. }
  246. return array;
  247. }
  248. function classArray(node) {
  249. if (node.classList) {
  250. return toArray(node.classList);
  251. } else {
  252. return (node.getAttribute('class') || '').split(' ').filter(function (i) {
  253. return i;
  254. });
  255. }
  256. }
  257. function getIconName(familyPrefix, cls) {
  258. var parts = cls.split('-');
  259. var prefix = parts[0];
  260. var iconName = parts.slice(1).join('-');
  261. if (prefix === familyPrefix && iconName !== '' && !isReserved(iconName)) {
  262. return iconName;
  263. } else {
  264. return null;
  265. }
  266. }
  267. function htmlEscape(str) {
  268. return ('' + str).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  269. }
  270. function joinAttributes(attributes) {
  271. return Object.keys(attributes || {}).reduce(function (acc, attributeName) {
  272. return acc + (attributeName + '="' + htmlEscape(attributes[attributeName]) + '" ');
  273. }, '').trim();
  274. }
  275. function joinStyles(styles) {
  276. return Object.keys(styles || {}).reduce(function (acc, styleName) {
  277. return acc + (styleName + ': ' + styles[styleName] + ';');
  278. }, '');
  279. }
  280. function transformIsMeaningful(transform) {
  281. return transform.size !== meaninglessTransform.size || transform.x !== meaninglessTransform.x || transform.y !== meaninglessTransform.y || transform.rotate !== meaninglessTransform.rotate || transform.flipX || transform.flipY;
  282. }
  283. function transformForSvg(_ref) {
  284. var transform = _ref.transform,
  285. containerWidth = _ref.containerWidth,
  286. iconWidth = _ref.iconWidth;
  287. var outer = {
  288. transform: 'translate(' + containerWidth / 2 + ' 256)'
  289. };
  290. var innerTranslate = 'translate(' + transform.x * 32 + ', ' + transform.y * 32 + ') ';
  291. var innerScale = 'scale(' + transform.size / 16 * (transform.flipX ? -1 : 1) + ', ' + transform.size / 16 * (transform.flipY ? -1 : 1) + ') ';
  292. var innerRotate = 'rotate(' + transform.rotate + ' 0 0)';
  293. var inner = {
  294. transform: innerTranslate + ' ' + innerScale + ' ' + innerRotate
  295. };
  296. var path = {
  297. transform: 'translate(' + iconWidth / 2 * -1 + ' -256)'
  298. };
  299. return {
  300. outer: outer,
  301. inner: inner,
  302. path: path
  303. };
  304. }
  305. function transformForCss(_ref2) {
  306. var transform = _ref2.transform,
  307. _ref2$width = _ref2.width,
  308. width = _ref2$width === undefined ? UNITS_IN_GRID : _ref2$width,
  309. _ref2$height = _ref2.height,
  310. height = _ref2$height === undefined ? UNITS_IN_GRID : _ref2$height,
  311. _ref2$startCentered = _ref2.startCentered,
  312. startCentered = _ref2$startCentered === undefined ? false : _ref2$startCentered;
  313. var val = '';
  314. if (startCentered && IS_IE) {
  315. val += 'translate(' + (transform.x / d - width / 2) + 'em, ' + (transform.y / d - height / 2) + 'em) ';
  316. } else if (startCentered) {
  317. val += 'translate(calc(-50% + ' + transform.x / d + 'em), calc(-50% + ' + transform.y / d + 'em)) ';
  318. } else {
  319. val += 'translate(' + transform.x / d + 'em, ' + transform.y / d + 'em) ';
  320. }
  321. val += 'scale(' + transform.size / d * (transform.flipX ? -1 : 1) + ', ' + transform.size / d * (transform.flipY ? -1 : 1) + ') ';
  322. val += 'rotate(' + transform.rotate + 'deg) ';
  323. return val;
  324. }
  325. var ALL_SPACE = {
  326. x: 0,
  327. y: 0,
  328. width: '100%',
  329. height: '100%'
  330. };
  331. var makeIconMasking = function (_ref) {
  332. var children = _ref.children,
  333. attributes = _ref.attributes,
  334. main = _ref.main,
  335. mask = _ref.mask,
  336. transform = _ref.transform;
  337. var mainWidth = main.width,
  338. mainPath = main.icon;
  339. var maskWidth = mask.width,
  340. maskPath = mask.icon;
  341. var trans = transformForSvg({ transform: transform, containerWidth: maskWidth, iconWidth: mainWidth });
  342. var maskRect = {
  343. tag: 'rect',
  344. attributes: _extends({}, ALL_SPACE, {
  345. fill: 'white'
  346. })
  347. };
  348. var maskInnerGroup = {
  349. tag: 'g',
  350. attributes: _extends({}, trans.inner),
  351. children: [{ tag: 'path', attributes: _extends({}, mainPath.attributes, trans.path, { fill: 'black' }) }]
  352. };
  353. var maskOuterGroup = {
  354. tag: 'g',
  355. attributes: _extends({}, trans.outer),
  356. children: [maskInnerGroup]
  357. };
  358. var maskId = 'mask-' + nextUniqueId();
  359. var clipId = 'clip-' + nextUniqueId();
  360. var maskTag = {
  361. tag: 'mask',
  362. attributes: _extends({}, ALL_SPACE, {
  363. id: maskId,
  364. maskUnits: 'userSpaceOnUse',
  365. maskContentUnits: 'userSpaceOnUse'
  366. }),
  367. children: [maskRect, maskOuterGroup]
  368. };
  369. var defs = {
  370. tag: 'defs',
  371. children: [{ tag: 'clipPath', attributes: { id: clipId }, children: [maskPath] }, maskTag]
  372. };
  373. children.push(defs, { tag: 'rect', attributes: _extends({ fill: 'currentColor', 'clip-path': 'url(#' + clipId + ')', mask: 'url(#' + maskId + ')' }, ALL_SPACE) });
  374. return {
  375. children: children,
  376. attributes: attributes
  377. };
  378. };
  379. var makeIconStandard = function (_ref) {
  380. var children = _ref.children,
  381. attributes = _ref.attributes,
  382. main = _ref.main,
  383. transform = _ref.transform,
  384. styles = _ref.styles;
  385. var styleString = joinStyles(styles);
  386. if (styleString.length > 0) {
  387. attributes['style'] = styleString;
  388. }
  389. if (transformIsMeaningful(transform)) {
  390. var trans = transformForSvg({ transform: transform, containerWidth: main.width, iconWidth: main.width });
  391. children.push({
  392. tag: 'g',
  393. attributes: _extends({}, trans.outer),
  394. children: [{
  395. tag: 'g',
  396. attributes: _extends({}, trans.inner),
  397. children: [{
  398. tag: main.icon.tag,
  399. children: main.icon.children,
  400. attributes: _extends({}, main.icon.attributes, trans.path)
  401. }]
  402. }]
  403. });
  404. } else {
  405. children.push(main.icon);
  406. }
  407. return {
  408. children: children,
  409. attributes: attributes
  410. };
  411. };
  412. var asIcon = function (_ref) {
  413. var children = _ref.children,
  414. main = _ref.main,
  415. mask = _ref.mask,
  416. attributes = _ref.attributes,
  417. styles = _ref.styles,
  418. transform = _ref.transform;
  419. if (transformIsMeaningful(transform) && main.found && !mask.found) {
  420. var width = main.width,
  421. height = main.height;
  422. var offset = {
  423. x: width / height / 2,
  424. y: 0.5
  425. };
  426. attributes['style'] = joinStyles(_extends({}, styles, {
  427. 'transform-origin': offset.x + transform.x / 16 + 'em ' + (offset.y + transform.y / 16) + 'em'
  428. }));
  429. }
  430. return [{
  431. tag: 'svg',
  432. attributes: attributes,
  433. children: children
  434. }];
  435. };
  436. var asSymbol = function (_ref) {
  437. var prefix = _ref.prefix,
  438. iconName = _ref.iconName,
  439. children = _ref.children,
  440. attributes = _ref.attributes,
  441. symbol = _ref.symbol;
  442. var id = symbol === true ? prefix + '-' + config.familyPrefix + '-' + iconName : symbol;
  443. return [{
  444. tag: 'svg',
  445. attributes: {
  446. style: 'display: none;'
  447. },
  448. children: [{
  449. tag: 'symbol',
  450. attributes: _extends({}, attributes, { id: id }),
  451. children: children
  452. }]
  453. }];
  454. };
  455. function makeInlineSvgAbstract(params) {
  456. var _params$icons = params.icons,
  457. main = _params$icons.main,
  458. mask = _params$icons.mask,
  459. prefix = params.prefix,
  460. iconName = params.iconName,
  461. transform = params.transform,
  462. symbol = params.symbol,
  463. title = params.title,
  464. extra = params.extra,
  465. _params$watchable = params.watchable,
  466. watchable = _params$watchable === undefined ? false : _params$watchable;
  467. var _ref = mask.found ? mask : main,
  468. width = _ref.width,
  469. height = _ref.height;
  470. var widthClass = 'fa-w-' + Math.ceil(width / height * 16);
  471. var attrClass = [config.replacementClass, iconName ? config.familyPrefix + '-' + iconName : '', widthClass].filter(function (c) {
  472. return extra.classes.indexOf(c) === -1;
  473. }).concat(extra.classes).join(' ');
  474. var content = {
  475. children: [],
  476. attributes: _extends({}, extra.attributes, {
  477. 'data-prefix': prefix,
  478. 'data-icon': iconName,
  479. 'class': attrClass,
  480. 'role': 'img',
  481. 'xmlns': 'http://www.w3.org/2000/svg',
  482. 'viewBox': '0 0 ' + width + ' ' + height
  483. })
  484. };
  485. if (watchable) {
  486. content.attributes[DATA_FA_I2SVG] = '';
  487. }
  488. if (title) content.children.push({ tag: 'title', attributes: { id: content.attributes['aria-labelledby'] || 'title-' + nextUniqueId() }, children: [title] });
  489. var args = _extends({}, content, {
  490. prefix: prefix,
  491. iconName: iconName,
  492. main: main,
  493. mask: mask,
  494. transform: transform,
  495. symbol: symbol,
  496. styles: extra.styles
  497. });
  498. var _ref2 = mask.found && main.found ? makeIconMasking(args) : makeIconStandard(args),
  499. children = _ref2.children,
  500. attributes = _ref2.attributes;
  501. args.children = children;
  502. args.attributes = attributes;
  503. if (symbol) {
  504. return asSymbol(args);
  505. } else {
  506. return asIcon(args);
  507. }
  508. }
  509. function makeLayersTextAbstract(params) {
  510. var content = params.content,
  511. width = params.width,
  512. height = params.height,
  513. transform = params.transform,
  514. title = params.title,
  515. extra = params.extra,
  516. _params$watchable2 = params.watchable,
  517. watchable = _params$watchable2 === undefined ? false : _params$watchable2;
  518. var attributes = _extends({}, extra.attributes, title ? { 'title': title } : {}, {
  519. 'class': extra.classes.join(' ')
  520. });
  521. if (watchable) {
  522. attributes[DATA_FA_I2SVG] = '';
  523. }
  524. var styles = _extends({}, extra.styles);
  525. if (transformIsMeaningful(transform)) {
  526. styles['transform'] = transformForCss({ transform: transform, startCentered: true, width: width, height: height });
  527. styles['-webkit-transform'] = styles['transform'];
  528. }
  529. var styleString = joinStyles(styles);
  530. if (styleString.length > 0) {
  531. attributes['style'] = styleString;
  532. }
  533. var val = [];
  534. val.push({
  535. tag: 'span',
  536. attributes: attributes,
  537. children: [content]
  538. });
  539. if (title) {
  540. val.push({ tag: 'span', attributes: { class: 'sr-only' }, children: [title] });
  541. }
  542. return val;
  543. }
  544. function makeLayersCounterAbstract(params) {
  545. var content = params.content,
  546. title = params.title,
  547. extra = params.extra;
  548. var attributes = _extends({}, extra.attributes, title ? { 'title': title } : {}, {
  549. 'class': extra.classes.join(' ')
  550. });
  551. var styleString = joinStyles(extra.styles);
  552. if (styleString.length > 0) {
  553. attributes['style'] = styleString;
  554. }
  555. var val = [];
  556. val.push({
  557. tag: 'span',
  558. attributes: attributes,
  559. children: [content]
  560. });
  561. if (title) {
  562. val.push({ tag: 'span', attributes: { class: 'sr-only' }, children: [title] });
  563. }
  564. return val;
  565. }
  566. var noop$2 = function noop() {};
  567. var p = config.measurePerformance && PERFORMANCE && PERFORMANCE.mark && PERFORMANCE.measure ? PERFORMANCE : { mark: noop$2, measure: noop$2 };
  568. var preamble = 'FA "5.4.0"';
  569. var begin = function begin(name) {
  570. p.mark(preamble + ' ' + name + ' begins');
  571. return function () {
  572. return end(name);
  573. };
  574. };
  575. var end = function end(name) {
  576. p.mark(preamble + ' ' + name + ' ends');
  577. p.measure(preamble + ' ' + name, preamble + ' ' + name + ' begins', preamble + ' ' + name + ' ends');
  578. };
  579. var perf = { begin: begin, end: end };
  580. 'use strict';
  581. /**
  582. * Internal helper to bind a function known to have 4 arguments
  583. * to a given context.
  584. */
  585. var bindInternal4 = function bindInternal4 (func, thisContext) {
  586. return function (a, b, c, d) {
  587. return func.call(thisContext, a, b, c, d);
  588. };
  589. };
  590. 'use strict';
  591. /**
  592. * # Reduce
  593. *
  594. * A fast object `.reduce()` implementation.
  595. *
  596. * @param {Object} subject The object to reduce over.
  597. * @param {Function} fn The reducer function.
  598. * @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
  599. * @param {Object} thisContext The context for the reducer.
  600. * @return {mixed} The final result.
  601. */
  602. var reduce = function fastReduceObject (subject, fn, initialValue, thisContext) {
  603. var keys = Object.keys(subject),
  604. length = keys.length,
  605. iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
  606. i, key, result;
  607. if (initialValue === undefined) {
  608. i = 1;
  609. result = subject[keys[0]];
  610. }
  611. else {
  612. i = 0;
  613. result = initialValue;
  614. }
  615. for (; i < length; i++) {
  616. key = keys[i];
  617. result = iterator(result, subject[key], key, subject);
  618. }
  619. return result;
  620. };
  621. var styles$2 = namespace.styles;
  622. var shims = namespace.shims;
  623. var _byUnicode = {};
  624. var _byLigature = {};
  625. var _byOldName = {};
  626. var build = function build() {
  627. var lookup = function lookup(reducer) {
  628. return reduce(styles$2, function (o, style, prefix) {
  629. o[prefix] = reduce(style, reducer, {});
  630. return o;
  631. }, {});
  632. };
  633. _byUnicode = lookup(function (acc, icon, iconName) {
  634. acc[icon[3]] = iconName;
  635. return acc;
  636. });
  637. _byLigature = lookup(function (acc, icon, iconName) {
  638. var ligatures = icon[2];
  639. acc[iconName] = iconName;
  640. ligatures.forEach(function (ligature) {
  641. acc[ligature] = iconName;
  642. });
  643. return acc;
  644. });
  645. var hasRegular = 'far' in styles$2;
  646. _byOldName = reduce(shims, function (acc, shim) {
  647. var oldName = shim[0];
  648. var prefix = shim[1];
  649. var iconName = shim[2];
  650. if (prefix === 'far' && !hasRegular) {
  651. prefix = 'fas';
  652. }
  653. acc[oldName] = { prefix: prefix, iconName: iconName };
  654. return acc;
  655. }, {});
  656. };
  657. build();
  658. function byUnicode(prefix, unicode) {
  659. return _byUnicode[prefix][unicode];
  660. }
  661. function byLigature(prefix, ligature) {
  662. return _byLigature[prefix][ligature];
  663. }
  664. function byOldName(name) {
  665. return _byOldName[name] || { prefix: null, iconName: null };
  666. }
  667. var styles$1 = namespace.styles;
  668. var emptyCanonicalIcon = function emptyCanonicalIcon() {
  669. return { prefix: null, iconName: null, rest: [] };
  670. };
  671. function getCanonicalIcon(values) {
  672. return values.reduce(function (acc, cls) {
  673. var iconName = getIconName(config.familyPrefix, cls);
  674. if (styles$1[cls]) {
  675. acc.prefix = cls;
  676. } else if (iconName) {
  677. var shim = acc.prefix === 'fa' ? byOldName(iconName) : {};
  678. acc.iconName = shim.iconName || iconName;
  679. acc.prefix = shim.prefix || acc.prefix;
  680. } else if (cls !== config.replacementClass && cls.indexOf('fa-w-') !== 0) {
  681. acc.rest.push(cls);
  682. }
  683. return acc;
  684. }, emptyCanonicalIcon());
  685. }
  686. function iconFromMapping(mapping, prefix, iconName) {
  687. if (mapping && mapping[prefix] && mapping[prefix][iconName]) {
  688. return {
  689. prefix: prefix,
  690. iconName: iconName,
  691. icon: mapping[prefix][iconName]
  692. };
  693. }
  694. }
  695. function toHtml(abstractNodes) {
  696. var tag = abstractNodes.tag,
  697. _abstractNodes$attrib = abstractNodes.attributes,
  698. attributes = _abstractNodes$attrib === undefined ? {} : _abstractNodes$attrib,
  699. _abstractNodes$childr = abstractNodes.children,
  700. children = _abstractNodes$childr === undefined ? [] : _abstractNodes$childr;
  701. if (typeof abstractNodes === 'string') {
  702. return htmlEscape(abstractNodes);
  703. } else {
  704. return '<' + tag + ' ' + joinAttributes(attributes) + '>' + children.map(toHtml).join('') + '</' + tag + '>';
  705. }
  706. }
  707. var noop$1 = function noop() {};
  708. function isWatched(node) {
  709. var i2svg = node.getAttribute ? node.getAttribute(DATA_FA_I2SVG) : null;
  710. return typeof i2svg === 'string';
  711. }
  712. function getMutator() {
  713. if (config.autoReplaceSvg === true) {
  714. return mutators.replace;
  715. }
  716. var mutator = mutators[config.autoReplaceSvg];
  717. return mutator || mutators.replace;
  718. }
  719. var mutators = {
  720. replace: function replace(mutation) {
  721. var node = mutation[0];
  722. var abstract = mutation[1];
  723. var newOuterHTML = abstract.map(function (a) {
  724. return toHtml(a);
  725. }).join('\n');
  726. if (node.parentNode && node.outerHTML) {
  727. node.outerHTML = newOuterHTML + (config.keepOriginalSource && node.tagName.toLowerCase() !== 'svg' ? '<!-- ' + node.outerHTML + ' -->' : '');
  728. } else if (node.parentNode) {
  729. var newNode = document.createElement('span');
  730. node.parentNode.replaceChild(newNode, node);
  731. newNode.outerHTML = newOuterHTML;
  732. }
  733. },
  734. nest: function nest(mutation) {
  735. var node = mutation[0];
  736. var abstract = mutation[1];
  737. // If we already have a replaced node we do not want to continue nesting within it.
  738. // Short-circuit to the standard replacement
  739. if (~classArray(node).indexOf(config.replacementClass)) {
  740. return mutators.replace(mutation);
  741. }
  742. var forSvg = new RegExp(config.familyPrefix + '-.*');
  743. delete abstract[0].attributes.style;
  744. var splitClasses = abstract[0].attributes.class.split(' ').reduce(function (acc, cls) {
  745. if (cls === config.replacementClass || cls.match(forSvg)) {
  746. acc.toSvg.push(cls);
  747. } else {
  748. acc.toNode.push(cls);
  749. }
  750. return acc;
  751. }, { toNode: [], toSvg: [] });
  752. abstract[0].attributes.class = splitClasses.toSvg.join(' ');
  753. var newInnerHTML = abstract.map(function (a) {
  754. return toHtml(a);
  755. }).join('\n');
  756. node.setAttribute('class', splitClasses.toNode.join(' '));
  757. node.setAttribute(DATA_FA_I2SVG, '');
  758. node.innerHTML = newInnerHTML;
  759. }
  760. };
  761. function perform(mutations, callback) {
  762. var callbackFunction = typeof callback === 'function' ? callback : noop$1;
  763. if (mutations.length === 0) {
  764. callbackFunction();
  765. } else {
  766. var frame = WINDOW.requestAnimationFrame || function (op) {
  767. return op();
  768. };
  769. frame(function () {
  770. var mutator = getMutator();
  771. var mark = perf.begin('mutate');
  772. mutations.map(mutator);
  773. mark();
  774. callbackFunction();
  775. });
  776. }
  777. }
  778. var disabled = false;
  779. function disableObservation(operation) {
  780. disabled = true;
  781. operation();
  782. disabled = false;
  783. }
  784. var mo = null;
  785. function observe(options) {
  786. if (!MUTATION_OBSERVER) {
  787. return;
  788. }
  789. if (!config.observeMutations) {
  790. return;
  791. }
  792. var treeCallback = options.treeCallback,
  793. nodeCallback = options.nodeCallback,
  794. pseudoElementsCallback = options.pseudoElementsCallback,
  795. _options$observeMutat = options.observeMutationsRoot,
  796. observeMutationsRoot = _options$observeMutat === undefined ? DOCUMENT.body : _options$observeMutat;
  797. mo = new MUTATION_OBSERVER(function (objects) {
  798. if (disabled) return;
  799. toArray(objects).forEach(function (mutationRecord) {
  800. if (mutationRecord.type === 'childList' && mutationRecord.addedNodes.length > 0 && !isWatched(mutationRecord.addedNodes[0])) {
  801. if (config.searchPseudoElements) {
  802. pseudoElementsCallback(mutationRecord.target);
  803. }
  804. treeCallback(mutationRecord.target);
  805. }
  806. if (mutationRecord.type === 'attributes' && mutationRecord.target.parentNode && config.searchPseudoElements) {
  807. pseudoElementsCallback(mutationRecord.target.parentNode);
  808. }
  809. if (mutationRecord.type === 'attributes' && isWatched(mutationRecord.target) && ~ATTRIBUTES_WATCHED_FOR_MUTATION.indexOf(mutationRecord.attributeName)) {
  810. if (mutationRecord.attributeName === 'class') {
  811. var _getCanonicalIcon = getCanonicalIcon(classArray(mutationRecord.target)),
  812. prefix = _getCanonicalIcon.prefix,
  813. iconName = _getCanonicalIcon.iconName;
  814. if (prefix) mutationRecord.target.setAttribute('data-prefix', prefix);
  815. if (iconName) mutationRecord.target.setAttribute('data-icon', iconName);
  816. } else {
  817. nodeCallback(mutationRecord.target);
  818. }
  819. }
  820. });
  821. });
  822. if (!IS_DOM) return;
  823. mo.observe(observeMutationsRoot, {
  824. childList: true, attributes: true, characterData: true, subtree: true
  825. });
  826. }
  827. function disconnect() {
  828. if (!mo) return;
  829. mo.disconnect();
  830. }
  831. var styleParser = function (node) {
  832. var style = node.getAttribute('style');
  833. var val = [];
  834. if (style) {
  835. val = style.split(';').reduce(function (acc, style) {
  836. var styles = style.split(':');
  837. var prop = styles[0];
  838. var value = styles.slice(1);
  839. if (prop && value.length > 0) {
  840. acc[prop] = value.join(':').trim();
  841. }
  842. return acc;
  843. }, {});
  844. }
  845. return val;
  846. };
  847. function toHex(unicode) {
  848. var result = '';
  849. for (var i = 0; i < unicode.length; i++) {
  850. var hex = unicode.charCodeAt(i).toString(16);
  851. result += ('000' + hex).slice(-4);
  852. }
  853. return result;
  854. }
  855. var classParser = function (node) {
  856. var existingPrefix = node.getAttribute('data-prefix');
  857. var existingIconName = node.getAttribute('data-icon');
  858. var innerText = node.innerText !== undefined ? node.innerText.trim() : '';
  859. var val = getCanonicalIcon(classArray(node));
  860. if (existingPrefix && existingIconName) {
  861. val.prefix = existingPrefix;
  862. val.iconName = existingIconName;
  863. }
  864. if (val.prefix && innerText.length > 1) {
  865. val.iconName = byLigature(val.prefix, node.innerText);
  866. } else if (val.prefix && innerText.length === 1) {
  867. val.iconName = byUnicode(val.prefix, toHex(node.innerText));
  868. }
  869. return val;
  870. };
  871. var parseTransformString = function parseTransformString(transformString) {
  872. var transform = {
  873. size: 16,
  874. x: 0,
  875. y: 0,
  876. flipX: false,
  877. flipY: false,
  878. rotate: 0
  879. };
  880. if (!transformString) {
  881. return transform;
  882. } else {
  883. return transformString.toLowerCase().split(' ').reduce(function (acc, n) {
  884. var parts = n.toLowerCase().split('-');
  885. var first = parts[0];
  886. var rest = parts.slice(1).join('-');
  887. if (first && rest === 'h') {
  888. acc.flipX = true;
  889. return acc;
  890. }
  891. if (first && rest === 'v') {
  892. acc.flipY = true;
  893. return acc;
  894. }
  895. rest = parseFloat(rest);
  896. if (isNaN(rest)) {
  897. return acc;
  898. }
  899. switch (first) {
  900. case 'grow':
  901. acc.size = acc.size + rest;
  902. break;
  903. case 'shrink':
  904. acc.size = acc.size - rest;
  905. break;
  906. case 'left':
  907. acc.x = acc.x - rest;
  908. break;
  909. case 'right':
  910. acc.x = acc.x + rest;
  911. break;
  912. case 'up':
  913. acc.y = acc.y - rest;
  914. break;
  915. case 'down':
  916. acc.y = acc.y + rest;
  917. break;
  918. case 'rotate':
  919. acc.rotate = acc.rotate + rest;
  920. break;
  921. }
  922. return acc;
  923. }, transform);
  924. }
  925. };
  926. var transformParser = function (node) {
  927. return parseTransformString(node.getAttribute('data-fa-transform'));
  928. };
  929. var symbolParser = function (node) {
  930. var symbol = node.getAttribute('data-fa-symbol');
  931. return symbol === null ? false : symbol === '' ? true : symbol;
  932. };
  933. var attributesParser = function (node) {
  934. var extraAttributes = toArray(node.attributes).reduce(function (acc, attr) {
  935. if (acc.name !== 'class' && acc.name !== 'style') {
  936. acc[attr.name] = attr.value;
  937. }
  938. return acc;
  939. }, {});
  940. var title = node.getAttribute('title');
  941. if (config.autoA11y) {
  942. if (title) {
  943. extraAttributes['aria-labelledby'] = config.replacementClass + '-title-' + nextUniqueId();
  944. } else {
  945. extraAttributes['aria-hidden'] = 'true';
  946. }
  947. }
  948. return extraAttributes;
  949. };
  950. var maskParser = function (node) {
  951. var mask = node.getAttribute('data-fa-mask');
  952. if (!mask) {
  953. return emptyCanonicalIcon();
  954. } else {
  955. return getCanonicalIcon(mask.split(' ').map(function (i) {
  956. return i.trim();
  957. }));
  958. }
  959. };
  960. var blankMeta = {
  961. iconName: null,
  962. title: null,
  963. prefix: null,
  964. transform: meaninglessTransform,
  965. symbol: false,
  966. mask: null,
  967. extra: { classes: [], styles: {}, attributes: {} }
  968. };
  969. function parseMeta(node) {
  970. var _classParser = classParser(node),
  971. iconName = _classParser.iconName,
  972. prefix = _classParser.prefix,
  973. extraClasses = _classParser.rest;
  974. var extraStyles = styleParser(node);
  975. var transform = transformParser(node);
  976. var symbol = symbolParser(node);
  977. var extraAttributes = attributesParser(node);
  978. var mask = maskParser(node);
  979. return {
  980. iconName: iconName,
  981. title: node.getAttribute('title'),
  982. prefix: prefix,
  983. transform: transform,
  984. symbol: symbol,
  985. mask: mask,
  986. extra: {
  987. classes: extraClasses,
  988. styles: extraStyles,
  989. attributes: extraAttributes
  990. }
  991. };
  992. }
  993. function MissingIcon(error) {
  994. this.name = 'MissingIcon';
  995. this.message = error || 'Icon unavailable';
  996. this.stack = new Error().stack;
  997. }
  998. MissingIcon.prototype = Object.create(Error.prototype);
  999. MissingIcon.prototype.constructor = MissingIcon;
  1000. var FILL = { fill: 'currentColor' };
  1001. var ANIMATION_BASE = {
  1002. attributeType: 'XML',
  1003. repeatCount: 'indefinite',
  1004. dur: '2s'
  1005. };
  1006. var RING = {
  1007. tag: 'path',
  1008. attributes: _extends({}, FILL, {
  1009. 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'
  1010. })
  1011. };
  1012. var OPACITY_ANIMATE = _extends({}, ANIMATION_BASE, {
  1013. attributeName: 'opacity'
  1014. });
  1015. var DOT = {
  1016. tag: 'circle',
  1017. attributes: _extends({}, FILL, {
  1018. cx: '256',
  1019. cy: '364',
  1020. r: '28'
  1021. }),
  1022. children: [{ tag: 'animate', attributes: _extends({}, ANIMATION_BASE, { attributeName: 'r', values: '28;14;28;28;14;28;' }) }, { tag: 'animate', attributes: _extends({}, OPACITY_ANIMATE, { values: '1;0;1;1;0;1;' }) }]
  1023. };
  1024. var QUESTION = {
  1025. tag: 'path',
  1026. attributes: _extends({}, FILL, {
  1027. opacity: '1',
  1028. 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'
  1029. }),
  1030. children: [{ tag: 'animate', attributes: _extends({}, OPACITY_ANIMATE, { values: '1;0;0;0;0;1;' }) }]
  1031. };
  1032. var EXCLAMATION = {
  1033. tag: 'path',
  1034. attributes: _extends({}, FILL, {
  1035. opacity: '0',
  1036. 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'
  1037. }),
  1038. children: [{ tag: 'animate', attributes: _extends({}, OPACITY_ANIMATE, { values: '0;0;1;1;0;0;' }) }]
  1039. };
  1040. var missing = { tag: 'g', children: [RING, DOT, QUESTION, EXCLAMATION] };
  1041. var styles = namespace.styles;
  1042. var LAYERS_TEXT_CLASSNAME = 'fa-layers-text';
  1043. var FONT_FAMILY_PATTERN = /Font Awesome 5 (Solid|Regular|Light|Brands|Free|Pro)/;
  1044. var STYLE_TO_PREFIX = {
  1045. 'Solid': 'fas',
  1046. 'Regular': 'far',
  1047. 'Light': 'fal',
  1048. 'Brands': 'fab'
  1049. };
  1050. var FONT_WEIGHT_TO_PREFIX = {
  1051. '900': 'fas',
  1052. '400': 'far',
  1053. '300': 'fal'
  1054. };
  1055. function findIcon(iconName, prefix) {
  1056. var val = {
  1057. found: false,
  1058. width: 512,
  1059. height: 512,
  1060. icon: missing
  1061. };
  1062. if (iconName && prefix && styles[prefix] && styles[prefix][iconName]) {
  1063. var icon = styles[prefix][iconName];
  1064. var width = icon[0];
  1065. var height = icon[1];
  1066. var vectorData = icon.slice(4);
  1067. val = {
  1068. found: true,
  1069. width: width,
  1070. height: height,
  1071. icon: { tag: 'path', attributes: { fill: 'currentColor', d: vectorData[0] } }
  1072. };
  1073. } else if (iconName && prefix && !config.showMissingIcons) {
  1074. throw new MissingIcon('Icon is missing for prefix ' + prefix + ' with icon name ' + iconName);
  1075. }
  1076. return val;
  1077. }
  1078. function generateSvgReplacementMutation(node, nodeMeta) {
  1079. var iconName = nodeMeta.iconName,
  1080. title = nodeMeta.title,
  1081. prefix = nodeMeta.prefix,
  1082. transform = nodeMeta.transform,
  1083. symbol = nodeMeta.symbol,
  1084. mask = nodeMeta.mask,
  1085. extra = nodeMeta.extra;
  1086. return [node, makeInlineSvgAbstract({
  1087. icons: {
  1088. main: findIcon(iconName, prefix),
  1089. mask: findIcon(mask.iconName, mask.prefix)
  1090. },
  1091. prefix: prefix,
  1092. iconName: iconName,
  1093. transform: transform,
  1094. symbol: symbol,
  1095. mask: mask,
  1096. title: title,
  1097. extra: extra,
  1098. watchable: true
  1099. })];
  1100. }
  1101. function generateLayersText(node, nodeMeta) {
  1102. var title = nodeMeta.title,
  1103. transform = nodeMeta.transform,
  1104. extra = nodeMeta.extra;
  1105. var width = null;
  1106. var height = null;
  1107. if (IS_IE) {
  1108. var computedFontSize = parseInt(getComputedStyle(node).fontSize, 10);
  1109. var boundingClientRect = node.getBoundingClientRect();
  1110. width = boundingClientRect.width / computedFontSize;
  1111. height = boundingClientRect.height / computedFontSize;
  1112. }
  1113. if (config.autoA11y && !title) {
  1114. extra.attributes['aria-hidden'] = 'true';
  1115. }
  1116. return [node, makeLayersTextAbstract({
  1117. content: node.innerHTML,
  1118. width: width,
  1119. height: height,
  1120. transform: transform,
  1121. title: title,
  1122. extra: extra,
  1123. watchable: true
  1124. })];
  1125. }
  1126. function generateMutation(node) {
  1127. var nodeMeta = parseMeta(node);
  1128. if (~nodeMeta.extra.classes.indexOf(LAYERS_TEXT_CLASSNAME)) {
  1129. return generateLayersText(node, nodeMeta);
  1130. } else {
  1131. return generateSvgReplacementMutation(node, nodeMeta);
  1132. }
  1133. }
  1134. function searchPseudoElements(root) {
  1135. if (!IS_DOM) return;
  1136. var end = perf.begin('searchPseudoElements');
  1137. disableObservation(function () {
  1138. toArray(root.querySelectorAll('*')).filter(function (n) {
  1139. return n.parentNode !== document.head && !~TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS.indexOf(n.tagName.toUpperCase()) && !n.getAttribute(DATA_FA_PSEUDO_ELEMENT) && (!n.parentNode || n.parentNode.tagName !== 'svg');
  1140. }).forEach(function (node) {
  1141. [':before', ':after'].forEach(function (pos) {
  1142. var children = toArray(node.children);
  1143. var alreadyProcessedPseudoElement = children.filter(function (c) {
  1144. return c.getAttribute(DATA_FA_PSEUDO_ELEMENT) === pos;
  1145. })[0];
  1146. var styles = WINDOW.getComputedStyle(node, pos);
  1147. var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
  1148. var fontWeight = styles.getPropertyValue('font-weight');
  1149. if (alreadyProcessedPseudoElement && !fontFamily) {
  1150. // If we've already processed it but the current computed style does not result in a font-family,
  1151. // that probably means that a class name that was previously present to make the icon has been
  1152. // removed. So we now should delete the icon.
  1153. node.removeChild(alreadyProcessedPseudoElement);
  1154. } else if (fontFamily) {
  1155. var content = styles.getPropertyValue('content');
  1156. var prefix = ~['Light', 'Regular', 'Solid', 'Brands'].indexOf(fontFamily[1]) ? STYLE_TO_PREFIX[fontFamily[1]] : FONT_WEIGHT_TO_PREFIX[fontWeight];
  1157. var iconName = byUnicode(prefix, toHex(content.length === 3 ? content.substr(1, 1) : content));
  1158. // Only convert the pseudo element in this :before/:after position into an icon if we haven't
  1159. // already done so with the same prefix and iconName
  1160. if (!alreadyProcessedPseudoElement || alreadyProcessedPseudoElement.getAttribute(DATA_PREFIX) !== prefix || alreadyProcessedPseudoElement.getAttribute(DATA_ICON) !== iconName) {
  1161. if (alreadyProcessedPseudoElement) {
  1162. // Delete the old one, since we're replacing it with a new one
  1163. node.removeChild(alreadyProcessedPseudoElement);
  1164. }
  1165. var extra = blankMeta.extra;
  1166. extra.attributes[DATA_FA_PSEUDO_ELEMENT] = pos;
  1167. var abstract = makeInlineSvgAbstract(_extends({}, blankMeta, {
  1168. icons: {
  1169. main: findIcon(iconName, prefix),
  1170. mask: emptyCanonicalIcon()
  1171. },
  1172. prefix: prefix,
  1173. iconName: iconName,
  1174. extra: extra,
  1175. watchable: true
  1176. }));
  1177. var element = DOCUMENT.createElement('svg');
  1178. if (pos === ':before') {
  1179. node.insertBefore(element, node.firstChild);
  1180. } else {
  1181. node.appendChild(element);
  1182. }
  1183. element.outerHTML = abstract.map(function (a) {
  1184. return toHtml(a);
  1185. }).join('\n');
  1186. }
  1187. }
  1188. });
  1189. });
  1190. });
  1191. end();
  1192. }
  1193. function onTree(root) {
  1194. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1195. if (!IS_DOM) return;
  1196. var htmlClassList = DOCUMENT.documentElement.classList;
  1197. var hclAdd = function hclAdd(suffix) {
  1198. return htmlClassList.add(HTML_CLASS_I2SVG_BASE_CLASS + '-' + suffix);
  1199. };
  1200. var hclRemove = function hclRemove(suffix) {
  1201. return htmlClassList.remove(HTML_CLASS_I2SVG_BASE_CLASS + '-' + suffix);
  1202. };
  1203. var prefixes = Object.keys(styles);
  1204. var prefixesDomQuery = ['.' + LAYERS_TEXT_CLASSNAME + ':not([' + DATA_FA_I2SVG + '])'].concat(prefixes.map(function (p) {
  1205. return '.' + p + ':not([' + DATA_FA_I2SVG + '])';
  1206. })).join(', ');
  1207. if (prefixesDomQuery.length === 0) {
  1208. return;
  1209. }
  1210. var candidates = toArray(root.querySelectorAll(prefixesDomQuery));
  1211. if (candidates.length > 0) {
  1212. hclAdd('pending');
  1213. hclRemove('complete');
  1214. } else {
  1215. return;
  1216. }
  1217. var mark = perf.begin('onTree');
  1218. var mutations = candidates.reduce(function (acc, node) {
  1219. try {
  1220. var mutation = generateMutation(node);
  1221. if (mutation) {
  1222. acc.push(mutation);
  1223. }
  1224. } catch (e) {
  1225. if (!PRODUCTION) {
  1226. if (e instanceof MissingIcon) {
  1227. console.error(e);
  1228. }
  1229. }
  1230. }
  1231. return acc;
  1232. }, []);
  1233. mark();
  1234. perform(mutations, function () {
  1235. hclAdd('active');
  1236. hclAdd('complete');
  1237. hclRemove('pending');
  1238. if (typeof callback === 'function') callback();
  1239. });
  1240. }
  1241. function onNode(node) {
  1242. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1243. var mutation = generateMutation(node);
  1244. if (mutation) {
  1245. perform([mutation], callback);
  1246. }
  1247. }
  1248. 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.33333em;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-horizontal.fa-flip-vertical{-webkit-transform:scale(-1,-1);transform:scale(-1,-1)}: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:2em}.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:1em}.svg-inline--fa.fa-stack-2x{height:2em;width:2em}.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}";
  1249. var css = function () {
  1250. var dfp = DEFAULT_FAMILY_PREFIX;
  1251. var drc = DEFAULT_REPLACEMENT_CLASS;
  1252. var fp = config.familyPrefix;
  1253. var rc = config.replacementClass;
  1254. var s = baseStyles;
  1255. if (fp !== dfp || rc !== drc) {
  1256. var dPatt = new RegExp('\\.' + dfp + '\\-', 'g');
  1257. var rPatt = new RegExp('\\.' + drc, 'g');
  1258. s = s.replace(dPatt, '.' + fp + '-').replace(rPatt, '.' + rc);
  1259. }
  1260. return s;
  1261. };
  1262. function define(prefix, icons) {
  1263. var normalized = Object.keys(icons).reduce(function (acc, iconName) {
  1264. var icon = icons[iconName];
  1265. var expanded = !!icon.icon;
  1266. if (expanded) {
  1267. acc[icon.iconName] = icon.icon;
  1268. } else {
  1269. acc[iconName] = icon;
  1270. }
  1271. return acc;
  1272. }, {});
  1273. if (typeof namespace.hooks.addPack === 'function') {
  1274. namespace.hooks.addPack(prefix, normalized);
  1275. } else {
  1276. namespace.styles[prefix] = _extends({}, namespace.styles[prefix] || {}, normalized);
  1277. }
  1278. /**
  1279. * Font Awesome 4 used the prefix of `fa` for all icons. With the introduction
  1280. * of new styles we needed to differentiate between them. Prefix `fa` is now an alias
  1281. * for `fas` so we'll easy the upgrade process for our users by automatically defining
  1282. * this as well.
  1283. */
  1284. if (prefix === 'fas') {
  1285. define('fa', icons);
  1286. }
  1287. }
  1288. var Library = function () {
  1289. function Library() {
  1290. classCallCheck(this, Library);
  1291. this.definitions = {};
  1292. }
  1293. createClass(Library, [{
  1294. key: 'add',
  1295. value: function add() {
  1296. var _this = this;
  1297. for (var _len = arguments.length, definitions = Array(_len), _key = 0; _key < _len; _key++) {
  1298. definitions[_key] = arguments[_key];
  1299. }
  1300. var additions = definitions.reduce(this._pullDefinitions, {});
  1301. Object.keys(additions).forEach(function (key) {
  1302. _this.definitions[key] = _extends({}, _this.definitions[key] || {}, additions[key]);
  1303. define(key, additions[key]);
  1304. build();
  1305. });
  1306. }
  1307. }, {
  1308. key: 'reset',
  1309. value: function reset() {
  1310. this.definitions = {};
  1311. }
  1312. }, {
  1313. key: '_pullDefinitions',
  1314. value: function _pullDefinitions(additions, definition) {
  1315. var normalized = definition.prefix && definition.iconName && definition.icon ? { 0: definition } : definition;
  1316. Object.keys(normalized).map(function (key) {
  1317. var _normalized$key = normalized[key],
  1318. prefix = _normalized$key.prefix,
  1319. iconName = _normalized$key.iconName,
  1320. icon = _normalized$key.icon;
  1321. if (!additions[prefix]) additions[prefix] = {};
  1322. additions[prefix][iconName] = icon;
  1323. });
  1324. return additions;
  1325. }
  1326. }]);
  1327. return Library;
  1328. }();
  1329. function prepIcon(icon) {
  1330. var width = icon[0];
  1331. var height = icon[1];
  1332. var vectorData = icon.slice(4);
  1333. return {
  1334. found: true,
  1335. width: width,
  1336. height: height,
  1337. icon: { tag: 'path', attributes: { fill: 'currentColor', d: vectorData[0] } }
  1338. };
  1339. }
  1340. function ensureCss() {
  1341. if (config.autoAddCss && !_cssInserted) {
  1342. insertCss(css());
  1343. _cssInserted = true;
  1344. }
  1345. }
  1346. function apiObject(val, abstractCreator) {
  1347. Object.defineProperty(val, 'abstract', {
  1348. get: abstractCreator
  1349. });
  1350. Object.defineProperty(val, 'html', {
  1351. get: function get() {
  1352. return val.abstract.map(function (a) {
  1353. return toHtml(a);
  1354. });
  1355. }
  1356. });
  1357. Object.defineProperty(val, 'node', {
  1358. get: function get() {
  1359. if (!IS_DOM) return;
  1360. var container = DOCUMENT.createElement('div');
  1361. container.innerHTML = val.html;
  1362. return container.children;
  1363. }
  1364. });
  1365. return val;
  1366. }
  1367. function findIconDefinition(params) {
  1368. var _params$prefix = params.prefix,
  1369. prefix = _params$prefix === undefined ? 'fa' : _params$prefix,
  1370. iconName = params.iconName;
  1371. if (!iconName) return;
  1372. return iconFromMapping(library.definitions, prefix, iconName) || iconFromMapping(namespace.styles, prefix, iconName);
  1373. }
  1374. function resolveIcons(next) {
  1375. return function (maybeIconDefinition) {
  1376. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1377. var iconDefinition = (maybeIconDefinition || {}).icon ? maybeIconDefinition : findIconDefinition(maybeIconDefinition || {});
  1378. var mask = params.mask;
  1379. if (mask) {
  1380. mask = (mask || {}).icon ? mask : findIconDefinition(mask || {});
  1381. }
  1382. return next(iconDefinition, _extends({}, params, { mask: mask }));
  1383. };
  1384. }
  1385. var library = new Library();
  1386. var noAuto = function noAuto() {
  1387. config.autoReplaceSvg = false;
  1388. config.observeMutations = false;
  1389. disconnect();
  1390. };
  1391. var _cssInserted = false;
  1392. var dom = {
  1393. i2svg: function i2svg() {
  1394. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1395. if (IS_DOM) {
  1396. ensureCss();
  1397. var _params$node = params.node,
  1398. node = _params$node === undefined ? DOCUMENT : _params$node,
  1399. _params$callback = params.callback,
  1400. callback = _params$callback === undefined ? function () {} : _params$callback;
  1401. if (config.searchPseudoElements) {
  1402. searchPseudoElements(node);
  1403. }
  1404. onTree(node, callback);
  1405. }
  1406. },
  1407. css: css,
  1408. insertCss: function insertCss$$1() {
  1409. if (!_cssInserted) {
  1410. insertCss(css());
  1411. _cssInserted = true;
  1412. }
  1413. },
  1414. watch: function watch() {
  1415. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1416. var autoReplaceSvgRoot = params.autoReplaceSvgRoot,
  1417. observeMutationsRoot = params.observeMutationsRoot;
  1418. if (config.autoReplaceSvg === false) {
  1419. config.autoReplaceSvg = true;
  1420. }
  1421. config.observeMutations = true;
  1422. domready(function () {
  1423. autoReplace({
  1424. autoReplaceSvgRoot: autoReplaceSvgRoot
  1425. });
  1426. observe({
  1427. treeCallback: onTree,
  1428. nodeCallback: onNode,
  1429. pseudoElementsCallback: searchPseudoElements,
  1430. observeMutationsRoot: observeMutationsRoot
  1431. });
  1432. });
  1433. }
  1434. };
  1435. var parse = {
  1436. transform: function transform(transformString) {
  1437. return parseTransformString(transformString);
  1438. }
  1439. };
  1440. var icon = resolveIcons(function (iconDefinition) {
  1441. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1442. var _params$transform = params.transform,
  1443. transform = _params$transform === undefined ? meaninglessTransform : _params$transform,
  1444. _params$symbol = params.symbol,
  1445. symbol = _params$symbol === undefined ? false : _params$symbol,
  1446. _params$mask = params.mask,
  1447. mask = _params$mask === undefined ? null : _params$mask,
  1448. _params$title = params.title,
  1449. title = _params$title === undefined ? null : _params$title,
  1450. _params$classes = params.classes,
  1451. classes = _params$classes === undefined ? [] : _params$classes,
  1452. _params$attributes = params.attributes,
  1453. attributes = _params$attributes === undefined ? {} : _params$attributes,
  1454. _params$styles = params.styles,
  1455. styles = _params$styles === undefined ? {} : _params$styles;
  1456. if (!iconDefinition) return;
  1457. var prefix = iconDefinition.prefix,
  1458. iconName = iconDefinition.iconName,
  1459. icon = iconDefinition.icon;
  1460. return apiObject(_extends({ type: 'icon' }, iconDefinition), function () {
  1461. ensureCss();
  1462. if (config.autoA11y) {
  1463. if (title) {
  1464. attributes['aria-labelledby'] = config.replacementClass + '-title-' + nextUniqueId();
  1465. } else {
  1466. attributes['aria-hidden'] = 'true';
  1467. }
  1468. }
  1469. return makeInlineSvgAbstract({
  1470. icons: {
  1471. main: prepIcon(icon),
  1472. mask: mask ? prepIcon(mask.icon) : { found: false, width: null, height: null, icon: {} }
  1473. },
  1474. prefix: prefix,
  1475. iconName: iconName,
  1476. transform: _extends({}, meaninglessTransform, transform),
  1477. symbol: symbol,
  1478. title: title,
  1479. extra: {
  1480. attributes: attributes,
  1481. styles: styles,
  1482. classes: classes
  1483. }
  1484. });
  1485. });
  1486. });
  1487. var text = function text(content) {
  1488. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1489. var _params$transform2 = params.transform,
  1490. transform = _params$transform2 === undefined ? meaninglessTransform : _params$transform2,
  1491. _params$title2 = params.title,
  1492. title = _params$title2 === undefined ? null : _params$title2,
  1493. _params$classes2 = params.classes,
  1494. classes = _params$classes2 === undefined ? [] : _params$classes2,
  1495. _params$attributes2 = params.attributes,
  1496. attributes = _params$attributes2 === undefined ? {} : _params$attributes2,
  1497. _params$styles2 = params.styles,
  1498. styles = _params$styles2 === undefined ? {} : _params$styles2;
  1499. return apiObject({ type: 'text', content: content }, function () {
  1500. ensureCss();
  1501. return makeLayersTextAbstract({
  1502. content: content,
  1503. transform: _extends({}, meaninglessTransform, transform),
  1504. title: title,
  1505. extra: {
  1506. attributes: attributes,
  1507. styles: styles,
  1508. classes: [config.familyPrefix + '-layers-text'].concat(toConsumableArray(classes))
  1509. }
  1510. });
  1511. });
  1512. };
  1513. var counter = function counter(content) {
  1514. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1515. var _params$title3 = params.title,
  1516. title = _params$title3 === undefined ? null : _params$title3,
  1517. _params$classes3 = params.classes,
  1518. classes = _params$classes3 === undefined ? [] : _params$classes3,
  1519. _params$attributes3 = params.attributes,
  1520. attributes = _params$attributes3 === undefined ? {} : _params$attributes3,
  1521. _params$styles3 = params.styles,
  1522. styles = _params$styles3 === undefined ? {} : _params$styles3;
  1523. return apiObject({ type: 'counter', content: content }, function () {
  1524. ensureCss();
  1525. return makeLayersCounterAbstract({
  1526. content: content.toString(),
  1527. title: title,
  1528. extra: {
  1529. attributes: attributes,
  1530. styles: styles,
  1531. classes: [config.familyPrefix + '-layers-counter'].concat(toConsumableArray(classes))
  1532. }
  1533. });
  1534. });
  1535. };
  1536. var layer = function layer(assembler) {
  1537. return apiObject({ type: 'layer' }, function () {
  1538. ensureCss();
  1539. var children = [];
  1540. assembler(function (args) {
  1541. Array.isArray(args) ? args.map(function (a) {
  1542. children = children.concat(a.abstract);
  1543. }) : children = children.concat(args.abstract);
  1544. });
  1545. return [{
  1546. tag: 'span',
  1547. attributes: { class: config.familyPrefix + '-layers' },
  1548. children: children
  1549. }];
  1550. });
  1551. };
  1552. var api = {
  1553. noAuto: noAuto,
  1554. config: config,
  1555. dom: dom,
  1556. library: library,
  1557. parse: parse,
  1558. findIconDefinition: findIconDefinition,
  1559. icon: icon,
  1560. text: text,
  1561. counter: counter,
  1562. layer: layer,
  1563. toHtml: toHtml
  1564. };
  1565. var autoReplace = function autoReplace() {
  1566. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1567. var _params$autoReplaceSv = params.autoReplaceSvgRoot,
  1568. autoReplaceSvgRoot = _params$autoReplaceSv === undefined ? DOCUMENT : _params$autoReplaceSv;
  1569. if (Object.keys(namespace.styles).length > 0 && IS_DOM && config.autoReplaceSvg) api.dom.i2svg({ node: autoReplaceSvgRoot });
  1570. };
  1571. function bootstrap() {
  1572. if (IS_BROWSER) {
  1573. if (!WINDOW.FontAwesome) {
  1574. WINDOW.FontAwesome = api;
  1575. }
  1576. domready(function () {
  1577. autoReplace();
  1578. observe({
  1579. treeCallback: onTree,
  1580. nodeCallback: onNode,
  1581. pseudoElementsCallback: searchPseudoElements
  1582. });
  1583. });
  1584. }
  1585. namespace.hooks = _extends({}, namespace.hooks, {
  1586. addPack: function addPack(prefix, icons) {
  1587. namespace.styles[prefix] = _extends({}, namespace.styles[prefix] || {}, icons);
  1588. build();
  1589. autoReplace();
  1590. },
  1591. addShims: function addShims(shims) {
  1592. var _namespace$shims;
  1593. (_namespace$shims = namespace.shims).push.apply(_namespace$shims, toConsumableArray(shims));
  1594. build();
  1595. autoReplace();
  1596. }
  1597. });
  1598. }
  1599. bunker(bootstrap);
  1600. }());