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