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