-
Notifications
You must be signed in to change notification settings - Fork 0
/
fontawesome.js
2478 lines (2163 loc) · 77.3 KB
/
fontawesome.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* Font Awesome Free 5.13.0 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
*/
(function () {
'use strict';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var noop = function noop() {};
var _WINDOW = {};
var _DOCUMENT = {};
var _MUTATION_OBSERVER = null;
var _PERFORMANCE = {
mark: noop,
measure: noop
};
try {
if (typeof window !== 'undefined') _WINDOW = window;
if (typeof document !== 'undefined') _DOCUMENT = document;
if (typeof MutationObserver !== 'undefined') _MUTATION_OBSERVER = MutationObserver;
if (typeof performance !== 'undefined') _PERFORMANCE = performance;
} catch (e) {}
var _ref = _WINDOW.navigator || {},
_ref$userAgent = _ref.userAgent,
userAgent = _ref$userAgent === void 0 ? '' : _ref$userAgent;
var WINDOW = _WINDOW;
var DOCUMENT = _DOCUMENT;
var MUTATION_OBSERVER = _MUTATION_OBSERVER;
var PERFORMANCE = _PERFORMANCE;
var IS_BROWSER = !!WINDOW.document;
var IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
var IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
var NAMESPACE_IDENTIFIER = '___FONT_AWESOME___';
var UNITS_IN_GRID = 16;
var DEFAULT_FAMILY_PREFIX = 'fa';
var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
var DATA_FA_I2SVG = 'data-fa-i2svg';
var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
var DATA_FA_PSEUDO_ELEMENT_PENDING = 'data-fa-pseudo-element-pending';
var DATA_PREFIX = 'data-prefix';
var DATA_ICON = 'data-icon';
var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
var MUTATION_APPROACH_ASYNC = 'async';
var TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS = ['HTML', 'HEAD', 'STYLE', 'SCRIPT'];
var PRODUCTION = function () {
try {
return "production" === 'production';
} catch (e) {
return false;
}
}();
var PREFIX_TO_STYLE = {
'fas': 'solid',
'far': 'regular',
'fal': 'light',
'fad': 'duotone',
'fab': 'brands',
'fa': 'solid'
};
var STYLE_TO_PREFIX = {
'solid': 'fas',
'regular': 'far',
'light': 'fal',
'duotone': 'fad',
'brands': 'fab'
};
var LAYERS_TEXT_CLASSNAME = 'fa-layers-text';
var FONT_FAMILY_PATTERN = /Font Awesome 5 (Solid|Regular|Light|Duotone|Brands|Free|Pro)/;
var FONT_WEIGHT_TO_PREFIX = {
'900': 'fas',
'400': 'far',
'normal': 'far',
'300': 'fal'
};
var oneToTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var oneToTwenty = oneToTen.concat([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
var ATTRIBUTES_WATCHED_FOR_MUTATION = ['class', 'data-prefix', 'data-icon', 'data-fa-transform', 'data-fa-mask'];
var DUOTONE_CLASSES = {
GROUP: 'group',
SWAP_OPACITY: 'swap-opacity',
PRIMARY: 'primary',
SECONDARY: 'secondary'
};
var RESERVED_CLASSES = ['xs', 'sm', 'lg', 'fw', 'ul', 'li', 'border', 'pull-left', 'pull-right', 'spin', 'pulse', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical', 'flip-both', 'stack', 'stack-1x', 'stack-2x', 'inverse', 'layers', 'layers-text', 'layers-counter', DUOTONE_CLASSES.GROUP, DUOTONE_CLASSES.SWAP_OPACITY, DUOTONE_CLASSES.PRIMARY, DUOTONE_CLASSES.SECONDARY].concat(oneToTen.map(function (n) {
return "".concat(n, "x");
})).concat(oneToTwenty.map(function (n) {
return "w-".concat(n);
}));
var initial = WINDOW.FontAwesomeConfig || {};
function getAttrConfig(attr) {
var element = DOCUMENT.querySelector('script[' + attr + ']');
if (element) {
return element.getAttribute(attr);
}
}
function coerce(val) {
// Getting an empty string will occur if the attribute is set on the HTML tag but without a value
// We'll assume that this is an indication that it should be toggled to true
// For example <script data-search-pseudo-elements src="..."></script>
if (val === '') return true;
if (val === 'false') return false;
if (val === 'true') return true;
return val;
}
if (DOCUMENT && typeof DOCUMENT.querySelector === 'function') {
var attrs = [['data-family-prefix', 'familyPrefix'], ['data-replacement-class', 'replacementClass'], ['data-auto-replace-svg', 'autoReplaceSvg'], ['data-auto-add-css', 'autoAddCss'], ['data-auto-a11y', 'autoA11y'], ['data-search-pseudo-elements', 'searchPseudoElements'], ['data-observe-mutations', 'observeMutations'], ['data-mutate-approach', 'mutateApproach'], ['data-keep-original-source', 'keepOriginalSource'], ['data-measure-performance', 'measurePerformance'], ['data-show-missing-icons', 'showMissingIcons']];
attrs.forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
attr = _ref2[0],
key = _ref2[1];
var val = coerce(getAttrConfig(attr));
if (val !== undefined && val !== null) {
initial[key] = val;
}
});
}
var _default = {
familyPrefix: DEFAULT_FAMILY_PREFIX,
replacementClass: DEFAULT_REPLACEMENT_CLASS,
autoReplaceSvg: true,
autoAddCss: true,
autoA11y: true,
searchPseudoElements: false,
observeMutations: true,
mutateApproach: 'async',
keepOriginalSource: true,
measurePerformance: false,
showMissingIcons: true
};
var _config = _objectSpread({}, _default, initial);
if (!_config.autoReplaceSvg) _config.observeMutations = false;
var config = _objectSpread({}, _config);
WINDOW.FontAwesomeConfig = config;
var w = WINDOW || {};
if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
if (!w[NAMESPACE_IDENTIFIER].styles) w[NAMESPACE_IDENTIFIER].styles = {};
if (!w[NAMESPACE_IDENTIFIER].hooks) w[NAMESPACE_IDENTIFIER].hooks = {};
if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
var namespace = w[NAMESPACE_IDENTIFIER];
var functions = [];
var listener = function listener() {
DOCUMENT.removeEventListener('DOMContentLoaded', listener);
loaded = 1;
functions.map(function (fn) {
return fn();
});
};
var loaded = false;
if (IS_DOM) {
loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
}
function domready (fn) {
if (!IS_DOM) return;
loaded ? setTimeout(fn, 0) : functions.push(fn);
}
var PENDING = 'pending';
var SETTLED = 'settled';
var FULFILLED = 'fulfilled';
var REJECTED = 'rejected';
var NOOP = function NOOP() {};
var isNode = typeof global !== 'undefined' && typeof global.process !== 'undefined' && typeof global.process.emit === 'function';
var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
var asyncQueue = [];
var asyncTimer;
function asyncFlush() {
// run promise callbacks
for (var i = 0; i < asyncQueue.length; i++) {
asyncQueue[i][0](asyncQueue[i][1]);
} // reset async asyncQueue
asyncQueue = [];
asyncTimer = false;
}
function asyncCall(callback, arg) {
asyncQueue.push([callback, arg]);
if (!asyncTimer) {
asyncTimer = true;
asyncSetTimer(asyncFlush, 0);
}
}
function invokeResolver(resolver, promise) {
function resolvePromise(value) {
resolve(promise, value);
}
function rejectPromise(reason) {
reject(promise, reason);
}
try {
resolver(resolvePromise, rejectPromise);
} catch (e) {
rejectPromise(e);
}
}
function invokeCallback(subscriber) {
var owner = subscriber.owner;
var settled = owner._state;
var value = owner._data;
var callback = subscriber[settled];
var promise = subscriber.then;
if (typeof callback === 'function') {
settled = FULFILLED;
try {
value = callback(value);
} catch (e) {
reject(promise, e);
}
}
if (!handleThenable(promise, value)) {
if (settled === FULFILLED) {
resolve(promise, value);
}
if (settled === REJECTED) {
reject(promise, value);
}
}
}
function handleThenable(promise, value) {
var resolved;
try {
if (promise === value) {
throw new TypeError('A promises callback cannot return that same promise.');
}
if (value && (typeof value === 'function' || _typeof(value) === 'object')) {
// then should be retrieved only once
var then = value.then;
if (typeof then === 'function') {
then.call(value, function (val) {
if (!resolved) {
resolved = true;
if (value === val) {
fulfill(promise, val);
} else {
resolve(promise, val);
}
}
}, function (reason) {
if (!resolved) {
resolved = true;
reject(promise, reason);
}
});
return true;
}
}
} catch (e) {
if (!resolved) {
reject(promise, e);
}
return true;
}
return false;
}
function resolve(promise, value) {
if (promise === value || !handleThenable(promise, value)) {
fulfill(promise, value);
}
}
function fulfill(promise, value) {
if (promise._state === PENDING) {
promise._state = SETTLED;
promise._data = value;
asyncCall(publishFulfillment, promise);
}
}
function reject(promise, reason) {
if (promise._state === PENDING) {
promise._state = SETTLED;
promise._data = reason;
asyncCall(publishRejection, promise);
}
}
function publish(promise) {
promise._then = promise._then.forEach(invokeCallback);
}
function publishFulfillment(promise) {
promise._state = FULFILLED;
publish(promise);
}
function publishRejection(promise) {
promise._state = REJECTED;
publish(promise);
if (!promise._handled && isNode) {
global.process.emit('unhandledRejection', promise._data, promise);
}
}
function notifyRejectionHandled(promise) {
global.process.emit('rejectionHandled', promise);
}
/**
* @class
*/
function P(resolver) {
if (typeof resolver !== 'function') {
throw new TypeError('Promise resolver ' + resolver + ' is not a function');
}
if (this instanceof P === false) {
throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
}
this._then = [];
invokeResolver(resolver, this);
}
P.prototype = {
constructor: P,
_state: PENDING,
_then: null,
_data: undefined,
_handled: false,
then: function then(onFulfillment, onRejection) {
var subscriber = {
owner: this,
then: new this.constructor(NOOP),
fulfilled: onFulfillment,
rejected: onRejection
};
if ((onRejection || onFulfillment) && !this._handled) {
this._handled = true;
if (this._state === REJECTED && isNode) {
asyncCall(notifyRejectionHandled, this);
}
}
if (this._state === FULFILLED || this._state === REJECTED) {
// already resolved, call callback async
asyncCall(invokeCallback, subscriber);
} else {
// subscribe
this._then.push(subscriber);
}
return subscriber.then;
},
catch: function _catch(onRejection) {
return this.then(null, onRejection);
}
};
P.all = function (promises) {
if (!Array.isArray(promises)) {
throw new TypeError('You must pass an array to Promise.all().');
}
return new P(function (resolve, reject) {
var results = [];
var remaining = 0;
function resolver(index) {
remaining++;
return function (value) {
results[index] = value;
if (! --remaining) {
resolve(results);
}
};
}
for (var i = 0, promise; i < promises.length; i++) {
promise = promises[i];
if (promise && typeof promise.then === 'function') {
promise.then(resolver(i), reject);
} else {
results[i] = promise;
}
}
if (!remaining) {
resolve(results);
}
});
};
P.race = function (promises) {
if (!Array.isArray(promises)) {
throw new TypeError('You must pass an array to Promise.race().');
}
return new P(function (resolve, reject) {
for (var i = 0, promise; i < promises.length; i++) {
promise = promises[i];
if (promise && typeof promise.then === 'function') {
promise.then(resolve, reject);
} else {
resolve(promise);
}
}
});
};
P.resolve = function (value) {
if (value && _typeof(value) === 'object' && value.constructor === P) {
return value;
}
return new P(function (resolve) {
resolve(value);
});
};
P.reject = function (reason) {
return new P(function (resolve, reject) {
reject(reason);
});
};
var picked = typeof Promise === 'function' ? Promise : P;
var d = UNITS_IN_GRID;
var meaninglessTransform = {
size: 16,
x: 0,
y: 0,
rotate: 0,
flipX: false,
flipY: false
};
function isReserved(name) {
return ~RESERVED_CLASSES.indexOf(name);
}
function bunker(fn) {
try {
fn();
} catch (e) {
if (!PRODUCTION) {
throw e;
}
}
}
function insertCss(css) {
if (!css || !IS_DOM) {
return;
}
var style = DOCUMENT.createElement('style');
style.setAttribute('type', 'text/css');
style.innerHTML = css;
var headChildren = DOCUMENT.head.childNodes;
var beforeChild = null;
for (var i = headChildren.length - 1; i > -1; i--) {
var child = headChildren[i];
var tagName = (child.tagName || '').toUpperCase();
if (['STYLE', 'LINK'].indexOf(tagName) > -1) {
beforeChild = child;
}
}
DOCUMENT.head.insertBefore(style, beforeChild);
return css;
}
var idPool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
function nextUniqueId() {
var size = 12;
var id = '';
while (size-- > 0) {
id += idPool[Math.random() * 62 | 0];
}
return id;
}
function toArray(obj) {
var array = [];
for (var i = (obj || []).length >>> 0; i--;) {
array[i] = obj[i];
}
return array;
}
function classArray(node) {
if (node.classList) {
return toArray(node.classList);
} else {
return (node.getAttribute('class') || '').split(' ').filter(function (i) {
return i;
});
}
}
function getIconName(familyPrefix, cls) {
var parts = cls.split('-');
var prefix = parts[0];
var iconName = parts.slice(1).join('-');
if (prefix === familyPrefix && iconName !== '' && !isReserved(iconName)) {
return iconName;
} else {
return null;
}
}
function htmlEscape(str) {
return "".concat(str).replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>');
}
function joinAttributes(attributes) {
return Object.keys(attributes || {}).reduce(function (acc, attributeName) {
return acc + "".concat(attributeName, "=\"").concat(htmlEscape(attributes[attributeName]), "\" ");
}, '').trim();
}
function joinStyles(styles) {
return Object.keys(styles || {}).reduce(function (acc, styleName) {
return acc + "".concat(styleName, ": ").concat(styles[styleName], ";");
}, '');
}
function transformIsMeaningful(transform) {
return transform.size !== meaninglessTransform.size || transform.x !== meaninglessTransform.x || transform.y !== meaninglessTransform.y || transform.rotate !== meaninglessTransform.rotate || transform.flipX || transform.flipY;
}
function transformForSvg(_ref) {
var transform = _ref.transform,
containerWidth = _ref.containerWidth,
iconWidth = _ref.iconWidth;
var outer = {
transform: "translate(".concat(containerWidth / 2, " 256)")
};
var innerTranslate = "translate(".concat(transform.x * 32, ", ").concat(transform.y * 32, ") ");
var innerScale = "scale(".concat(transform.size / 16 * (transform.flipX ? -1 : 1), ", ").concat(transform.size / 16 * (transform.flipY ? -1 : 1), ") ");
var innerRotate = "rotate(".concat(transform.rotate, " 0 0)");
var inner = {
transform: "".concat(innerTranslate, " ").concat(innerScale, " ").concat(innerRotate)
};
var path = {
transform: "translate(".concat(iconWidth / 2 * -1, " -256)")
};
return {
outer: outer,
inner: inner,
path: path
};
}
function transformForCss(_ref2) {
var transform = _ref2.transform,
_ref2$width = _ref2.width,
width = _ref2$width === void 0 ? UNITS_IN_GRID : _ref2$width,
_ref2$height = _ref2.height,
height = _ref2$height === void 0 ? UNITS_IN_GRID : _ref2$height,
_ref2$startCentered = _ref2.startCentered,
startCentered = _ref2$startCentered === void 0 ? false : _ref2$startCentered;
var val = '';
if (startCentered && IS_IE) {
val += "translate(".concat(transform.x / d - width / 2, "em, ").concat(transform.y / d - height / 2, "em) ");
} else if (startCentered) {
val += "translate(calc(-50% + ".concat(transform.x / d, "em), calc(-50% + ").concat(transform.y / d, "em)) ");
} else {
val += "translate(".concat(transform.x / d, "em, ").concat(transform.y / d, "em) ");
}
val += "scale(".concat(transform.size / d * (transform.flipX ? -1 : 1), ", ").concat(transform.size / d * (transform.flipY ? -1 : 1), ") ");
val += "rotate(".concat(transform.rotate, "deg) ");
return val;
}
var ALL_SPACE = {
x: 0,
y: 0,
width: '100%',
height: '100%'
};
function fillBlack(abstract) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (abstract.attributes && (abstract.attributes.fill || force)) {
abstract.attributes.fill = 'black';
}
return abstract;
}
function deGroup(abstract) {
if (abstract.tag === 'g') {
return abstract.children;
} else {
return [abstract];
}
}
function makeIconMasking (_ref) {
var children = _ref.children,
attributes = _ref.attributes,
main = _ref.main,
mask = _ref.mask,
explicitMaskId = _ref.maskId,
transform = _ref.transform;
var mainWidth = main.width,
mainPath = main.icon;
var maskWidth = mask.width,
maskPath = mask.icon;
var trans = transformForSvg({
transform: transform,
containerWidth: maskWidth,
iconWidth: mainWidth
});
var maskRect = {
tag: 'rect',
attributes: _objectSpread({}, ALL_SPACE, {
fill: 'white'
})
};
var maskInnerGroupChildrenMixin = mainPath.children ? {
children: mainPath.children.map(fillBlack)
} : {};
var maskInnerGroup = {
tag: 'g',
attributes: _objectSpread({}, trans.inner),
children: [fillBlack(_objectSpread({
tag: mainPath.tag,
attributes: _objectSpread({}, mainPath.attributes, trans.path)
}, maskInnerGroupChildrenMixin))]
};
var maskOuterGroup = {
tag: 'g',
attributes: _objectSpread({}, trans.outer),
children: [maskInnerGroup]
};
var maskId = "mask-".concat(explicitMaskId || nextUniqueId());
var clipId = "clip-".concat(explicitMaskId || nextUniqueId());
var maskTag = {
tag: 'mask',
attributes: _objectSpread({}, ALL_SPACE, {
id: maskId,
maskUnits: 'userSpaceOnUse',
maskContentUnits: 'userSpaceOnUse'
}),
children: [maskRect, maskOuterGroup]
};
var defs = {
tag: 'defs',
children: [{
tag: 'clipPath',
attributes: {
id: clipId
},
children: deGroup(maskPath)
}, maskTag]
};
children.push(defs, {
tag: 'rect',
attributes: _objectSpread({
fill: 'currentColor',
'clip-path': "url(#".concat(clipId, ")"),
mask: "url(#".concat(maskId, ")")
}, ALL_SPACE)
});
return {
children: children,
attributes: attributes
};
}
function makeIconStandard (_ref) {
var children = _ref.children,
attributes = _ref.attributes,
main = _ref.main,
transform = _ref.transform,
styles = _ref.styles;
var styleString = joinStyles(styles);
if (styleString.length > 0) {
attributes['style'] = styleString;
}
if (transformIsMeaningful(transform)) {
var trans = transformForSvg({
transform: transform,
containerWidth: main.width,
iconWidth: main.width
});
children.push({
tag: 'g',
attributes: _objectSpread({}, trans.outer),
children: [{
tag: 'g',
attributes: _objectSpread({}, trans.inner),
children: [{
tag: main.icon.tag,
children: main.icon.children,
attributes: _objectSpread({}, main.icon.attributes, trans.path)
}]
}]
});
} else {
children.push(main.icon);
}
return {
children: children,
attributes: attributes
};
}
function asIcon (_ref) {
var children = _ref.children,
main = _ref.main,
mask = _ref.mask,
attributes = _ref.attributes,
styles = _ref.styles,
transform = _ref.transform;
if (transformIsMeaningful(transform) && main.found && !mask.found) {
var width = main.width,
height = main.height;
var offset = {
x: width / height / 2,
y: 0.5
};
attributes['style'] = joinStyles(_objectSpread({}, styles, {
'transform-origin': "".concat(offset.x + transform.x / 16, "em ").concat(offset.y + transform.y / 16, "em")
}));
}
return [{
tag: 'svg',
attributes: attributes,
children: children
}];
}
function asSymbol (_ref) {
var prefix = _ref.prefix,
iconName = _ref.iconName,
children = _ref.children,
attributes = _ref.attributes,
symbol = _ref.symbol;
var id = symbol === true ? "".concat(prefix, "-").concat(config.familyPrefix, "-").concat(iconName) : symbol;
return [{
tag: 'svg',
attributes: {
style: 'display: none;'
},
children: [{
tag: 'symbol',
attributes: _objectSpread({}, attributes, {
id: id
}),
children: children
}]
}];
}
function makeInlineSvgAbstract(params) {
var _params$icons = params.icons,
main = _params$icons.main,
mask = _params$icons.mask,
prefix = params.prefix,
iconName = params.iconName,
transform = params.transform,
symbol = params.symbol,
title = params.title,
maskId = params.maskId,
titleId = params.titleId,
extra = params.extra,
_params$watchable = params.watchable,
watchable = _params$watchable === void 0 ? false : _params$watchable;
var _ref = mask.found ? mask : main,
width = _ref.width,
height = _ref.height;
var widthClass = "fa-w-".concat(Math.ceil(width / height * 16));
var attrClass = [config.replacementClass, iconName ? "".concat(config.familyPrefix, "-").concat(iconName) : '', widthClass].filter(function (c) {
return extra.classes.indexOf(c) === -1;
}).concat(extra.classes).join(' ');
var content = {
children: [],
attributes: _objectSpread({}, extra.attributes, {
'data-prefix': prefix,
'data-icon': iconName,
'class': attrClass,
'role': extra.attributes.role || 'img',
'xmlns': 'http://www.w3.org/2000/svg',
'viewBox': "0 0 ".concat(width, " ").concat(height)
})
};
if (watchable) {
content.attributes[DATA_FA_I2SVG] = '';
}
if (title) content.children.push({
tag: 'title',
attributes: {
id: content.attributes['aria-labelledby'] || "title-".concat(titleId || nextUniqueId())
},
children: [title]
});
var args = _objectSpread({}, content, {
prefix: prefix,
iconName: iconName,
main: main,
mask: mask,
maskId: maskId,
transform: transform,
symbol: symbol,
styles: extra.styles
});
var _ref2 = mask.found && main.found ? makeIconMasking(args) : makeIconStandard(args),
children = _ref2.children,
attributes = _ref2.attributes;
args.children = children;
args.attributes = attributes;
if (symbol) {
return asSymbol(args);
} else {
return asIcon(args);