UNPKG

77.1 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _typeof(obj) {
6 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
7 _typeof = function (obj) {
8 return typeof obj;
9 };
10 } else {
11 _typeof = function (obj) {
12 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
13 };
14 }
15
16 return _typeof(obj);
17}
18
19function _defineProperty(obj, key, value) {
20 if (key in obj) {
21 Object.defineProperty(obj, key, {
22 value: value,
23 enumerable: true,
24 configurable: true,
25 writable: true
26 });
27 } else {
28 obj[key] = value;
29 }
30
31 return obj;
32}
33
34function _objectSpread(target) {
35 for (var i = 1; i < arguments.length; i++) {
36 var source = arguments[i] != null ? arguments[i] : {};
37 var ownKeys = Object.keys(source);
38
39 if (typeof Object.getOwnPropertySymbols === 'function') {
40 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
41 return Object.getOwnPropertyDescriptor(source, sym).enumerable;
42 }));
43 }
44
45 ownKeys.forEach(function (key) {
46 _defineProperty(target, key, source[key]);
47 });
48 }
49
50 return target;
51}
52
53function _toConsumableArray(arr) {
54 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
55}
56
57function _arrayWithoutHoles(arr) {
58 if (Array.isArray(arr)) {
59 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
60
61 return arr2;
62 }
63}
64
65function _iterableToArray(iter) {
66 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
67}
68
69function _nonIterableSpread() {
70 throw new TypeError("Invalid attempt to spread non-iterable instance");
71}
72
73function hash(str) {
74 var hash = 5381,
75 i = str.length;
76
77 while(i) {
78 hash = (hash * 33) ^ str.charCodeAt(--i);
79 }
80
81 /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
82 * integers. Since we want the results to be always positive, convert the
83 * signed int to an unsigned by doing an unsigned bitshift. */
84 return hash >>> 0;
85}
86
87var stringHash = hash;
88
89/* @flow */
90/* ::
91type ObjectMap = { [id:string]: any };
92*/
93
94var UPPERCASE_RE = /([A-Z])/g;
95
96var UPPERCASE_RE_TO_KEBAB = function UPPERCASE_RE_TO_KEBAB(match
97/* : string */
98) {
99 return (
100 /* : string */
101 "-".concat(match.toLowerCase())
102 );
103};
104
105var kebabifyStyleName = function kebabifyStyleName(string
106/* : string */
107)
108/* : string */
109{
110 var result = string.replace(UPPERCASE_RE, UPPERCASE_RE_TO_KEBAB);
111
112 if (result[0] === 'm' && result[1] === 's' && result[2] === '-') {
113 return "-".concat(result);
114 }
115
116 return result;
117};
118/**
119 * CSS properties which accept numbers but are not in units of "px".
120 * Taken from React's CSSProperty.js
121 */
122
123var isUnitlessNumber = {
124 animationIterationCount: true,
125 borderImageOutset: true,
126 borderImageSlice: true,
127 borderImageWidth: true,
128 boxFlex: true,
129 boxFlexGroup: true,
130 boxOrdinalGroup: true,
131 columnCount: true,
132 flex: true,
133 flexGrow: true,
134 flexPositive: true,
135 flexShrink: true,
136 flexNegative: true,
137 flexOrder: true,
138 gridRow: true,
139 gridColumn: true,
140 fontWeight: true,
141 lineClamp: true,
142 lineHeight: true,
143 opacity: true,
144 order: true,
145 orphans: true,
146 tabSize: true,
147 widows: true,
148 zIndex: true,
149 zoom: true,
150 // SVG-related properties
151 fillOpacity: true,
152 floodOpacity: true,
153 stopOpacity: true,
154 strokeDasharray: true,
155 strokeDashoffset: true,
156 strokeMiterlimit: true,
157 strokeOpacity: true,
158 strokeWidth: true
159};
160/**
161 * Taken from React's CSSProperty.js
162 *
163 * @param {string} prefix vendor-specific prefix, eg: Webkit
164 * @param {string} key style name, eg: transitionDuration
165 * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
166 * WebkitTransitionDuration
167 */
168
169function prefixKey(prefix, key) {
170 return prefix + key.charAt(0).toUpperCase() + key.substring(1);
171}
172/**
173 * Support style names that may come passed in prefixed by adding permutations
174 * of vendor prefixes.
175 * Taken from React's CSSProperty.js
176 */
177
178
179var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
180// infinite loop, because it iterates over the newly added props too.
181// Taken from React's CSSProperty.js
182
183Object.keys(isUnitlessNumber).forEach(function (prop) {
184 prefixes.forEach(function (prefix) {
185 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
186 });
187});
188var stringifyValue = function stringifyValue(key
189/* : string */
190, prop
191/* : any */
192)
193/* : string */
194{
195 if (typeof prop === "number") {
196 if (isUnitlessNumber[key]) {
197 return "" + prop;
198 } else {
199 return prop + "px";
200 }
201 } else {
202 return '' + prop;
203 }
204};
205var stringifyAndImportantifyValue = function stringifyAndImportantifyValue(key
206/* : string */
207, prop
208/* : any */
209) {
210 return (
211 /* : string */
212 importantify(stringifyValue(key, prop))
213 );
214}; // Turn a string into a hash string of base-36 values (using letters and numbers)
215// eslint-disable-next-line no-unused-vars
216
217var hashString = function hashString(string
218/* : string */
219, key
220/* : ?string */
221) {
222 return (
223 /* string */
224 stringHash(string).toString(36)
225 );
226}; // Hash a javascript object using JSON.stringify. This is very fast, about 3
227// microseconds on my computer for a sample object:
228// http://jsperf.com/test-hashfnv32a-hash/5
229//
230// Note that this uses JSON.stringify to stringify the objects so in order for
231// this to produce consistent hashes browsers need to have a consistent
232// ordering of objects. Ben Alpert says that Facebook depends on this, so we
233// can probably depend on this too.
234
235var hashObject = function hashObject(object
236/* : ObjectMap */
237) {
238 return (
239 /* : string */
240 hashString(JSON.stringify(object))
241 );
242}; // Given a single style value string like the "b" from "a: b;", adds !important
243// to generate "b !important".
244
245var importantify = function importantify(string
246/* : string */
247) {
248 return (
249 /* : string */
250 // Bracket string character access is very fast, and in the default case we
251 // normally don't expect there to be "!important" at the end of the string
252 // so we can use this simple check to take an optimized path. If there
253 // happens to be a "!" in this position, we follow up with a more thorough
254 // check.
255 string[string.length - 10] === '!' && string.slice(-11) === ' !important' ? string : "".concat(string, " !important")
256 );
257};
258
259var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
260
261function unwrapExports (x) {
262 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
263}
264
265function createCommonjsModule(fn, module) {
266 return module = { exports: {} }, fn(module, module.exports), module.exports;
267}
268
269function getCjsExportFromNamespace (n) {
270 return n && n.default || n;
271}
272
273// Use the fastest means possible to execute a task in its own turn, with
274// priority over other events including IO, animation, reflow, and redraw
275// events in browsers.
276//
277// An exception thrown by a task will permanently interrupt the processing of
278// subsequent tasks. The higher level `asap` function ensures that if an
279// exception is thrown by a task, that the task queue will continue flushing as
280// soon as possible, but if you use `rawAsap` directly, you are responsible to
281// either ensure that no exceptions are thrown from your task, or to manually
282// call `rawAsap.requestFlush` if an exception is thrown.
283var browserRaw = rawAsap;
284function rawAsap(task) {
285 if (!queue.length) {
286 requestFlush();
287 }
288 // Equivalent to push, but avoids a function call.
289 queue[queue.length] = task;
290}
291
292var queue = [];
293// `requestFlush` is an implementation-specific method that attempts to kick
294// off a `flush` event as quickly as possible. `flush` will attempt to exhaust
295// the event queue before yielding to the browser's own event loop.
296var requestFlush;
297// The position of the next task to execute in the task queue. This is
298// preserved between calls to `flush` so that it can be resumed if
299// a task throws an exception.
300var index = 0;
301// If a task schedules additional tasks recursively, the task queue can grow
302// unbounded. To prevent memory exhaustion, the task queue will periodically
303// truncate already-completed tasks.
304var capacity = 1024;
305
306// The flush function processes all tasks that have been scheduled with
307// `rawAsap` unless and until one of those tasks throws an exception.
308// If a task throws an exception, `flush` ensures that its state will remain
309// consistent and will resume where it left off when called again.
310// However, `flush` does not make any arrangements to be called again if an
311// exception is thrown.
312function flush() {
313 while (index < queue.length) {
314 var currentIndex = index;
315 // Advance the index before calling the task. This ensures that we will
316 // begin flushing on the next task the task throws an error.
317 index = index + 1;
318 queue[currentIndex].call();
319 // Prevent leaking memory for long chains of recursive calls to `asap`.
320 // If we call `asap` within tasks scheduled by `asap`, the queue will
321 // grow, but to avoid an O(n) walk for every task we execute, we don't
322 // shift tasks off the queue after they have been executed.
323 // Instead, we periodically shift 1024 tasks off the queue.
324 if (index > capacity) {
325 // Manually shift all values starting at the index back to the
326 // beginning of the queue.
327 for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {
328 queue[scan] = queue[scan + index];
329 }
330 queue.length -= index;
331 index = 0;
332 }
333 }
334 queue.length = 0;
335 index = 0;
336}
337
338// `requestFlush` is implemented using a strategy based on data collected from
339// every available SauceLabs Selenium web driver worker at time of writing.
340// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593
341
342// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
343// have WebKitMutationObserver but not un-prefixed MutationObserver.
344// Must use `global` or `self` instead of `window` to work in both frames and web
345// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
346
347/* globals self */
348var scope = typeof commonjsGlobal !== "undefined" ? commonjsGlobal : self;
349var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
350
351// MutationObservers are desirable because they have high priority and work
352// reliably everywhere they are implemented.
353// They are implemented in all modern browsers.
354//
355// - Android 4-4.3
356// - Chrome 26-34
357// - Firefox 14-29
358// - Internet Explorer 11
359// - iPad Safari 6-7.1
360// - iPhone Safari 7-7.1
361// - Safari 6-7
362if (typeof BrowserMutationObserver === "function") {
363 requestFlush = makeRequestCallFromMutationObserver(flush);
364
365// MessageChannels are desirable because they give direct access to the HTML
366// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera
367// 11-12, and in web workers in many engines.
368// Although message channels yield to any queued rendering and IO tasks, they
369// would be better than imposing the 4ms delay of timers.
370// However, they do not work reliably in Internet Explorer or Safari.
371
372// Internet Explorer 10 is the only browser that has setImmediate but does
373// not have MutationObservers.
374// Although setImmediate yields to the browser's renderer, it would be
375// preferrable to falling back to setTimeout since it does not have
376// the minimum 4ms penalty.
377// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and
378// Desktop to a lesser extent) that renders both setImmediate and
379// MessageChannel useless for the purposes of ASAP.
380// https://github.com/kriskowal/q/issues/396
381
382// Timers are implemented universally.
383// We fall back to timers in workers in most engines, and in foreground
384// contexts in the following browsers.
385// However, note that even this simple case requires nuances to operate in a
386// broad spectrum of browsers.
387//
388// - Firefox 3-13
389// - Internet Explorer 6-9
390// - iPad Safari 4.3
391// - Lynx 2.8.7
392} else {
393 requestFlush = makeRequestCallFromTimer(flush);
394}
395
396// `requestFlush` requests that the high priority event queue be flushed as
397// soon as possible.
398// This is useful to prevent an error thrown in a task from stalling the event
399// queue if the exception handled by Node.js’s
400// `process.on("uncaughtException")` or by a domain.
401rawAsap.requestFlush = requestFlush;
402
403// To request a high priority event, we induce a mutation observer by toggling
404// the text of a text node between "1" and "-1".
405function makeRequestCallFromMutationObserver(callback) {
406 var toggle = 1;
407 var observer = new BrowserMutationObserver(callback);
408 var node = document.createTextNode("");
409 observer.observe(node, {characterData: true});
410 return function requestCall() {
411 toggle = -toggle;
412 node.data = toggle;
413 };
414}
415
416// The message channel technique was discovered by Malte Ubl and was the
417// original foundation for this library.
418// http://www.nonblocking.io/2011/06/windownexttick.html
419
420// Safari 6.0.5 (at least) intermittently fails to create message ports on a
421// page's first load. Thankfully, this version of Safari supports
422// MutationObservers, so we don't need to fall back in that case.
423
424// function makeRequestCallFromMessageChannel(callback) {
425// var channel = new MessageChannel();
426// channel.port1.onmessage = callback;
427// return function requestCall() {
428// channel.port2.postMessage(0);
429// };
430// }
431
432// For reasons explained above, we are also unable to use `setImmediate`
433// under any circumstances.
434// Even if we were, there is another bug in Internet Explorer 10.
435// It is not sufficient to assign `setImmediate` to `requestFlush` because
436// `setImmediate` must be called *by name* and therefore must be wrapped in a
437// closure.
438// Never forget.
439
440// function makeRequestCallFromSetImmediate(callback) {
441// return function requestCall() {
442// setImmediate(callback);
443// };
444// }
445
446// Safari 6.0 has a problem where timers will get lost while the user is
447// scrolling. This problem does not impact ASAP because Safari 6.0 supports
448// mutation observers, so that implementation is used instead.
449// However, if we ever elect to use timers in Safari, the prevalent work-around
450// is to add a scroll event listener that calls for a flush.
451
452// `setTimeout` does not call the passed callback if the delay is less than
453// approximately 7 in web workers in Firefox 8 through 18, and sometimes not
454// even then.
455
456function makeRequestCallFromTimer(callback) {
457 return function requestCall() {
458 // We dispatch a timeout with a specified delay of 0 for engines that
459 // can reliably accommodate that request. This will usually be snapped
460 // to a 4 milisecond delay, but once we're flushing, there's no delay
461 // between events.
462 var timeoutHandle = setTimeout(handleTimer, 0);
463 // However, since this timer gets frequently dropped in Firefox
464 // workers, we enlist an interval handle that will try to fire
465 // an event 20 times per second until it succeeds.
466 var intervalHandle = setInterval(handleTimer, 50);
467
468 function handleTimer() {
469 // Whichever timer succeeds will cancel both timers and
470 // execute the callback.
471 clearTimeout(timeoutHandle);
472 clearInterval(intervalHandle);
473 callback();
474 }
475 };
476}
477
478// This is for `asap.js` only.
479// Its name will be periodically randomized to break any code that depends on
480// its existence.
481rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
482
483// rawAsap provides everything we need except exception management.
484
485// RawTasks are recycled to reduce GC churn.
486var freeTasks = [];
487// We queue errors to ensure they are thrown in right order (FIFO).
488// Array-as-queue is good enough here, since we are just dealing with exceptions.
489var pendingErrors = [];
490var requestErrorThrow = browserRaw.makeRequestCallFromTimer(throwFirstError);
491
492function throwFirstError() {
493 if (pendingErrors.length) {
494 throw pendingErrors.shift();
495 }
496}
497
498/**
499 * Calls a task as soon as possible after returning, in its own event, with priority
500 * over other events like animation, reflow, and repaint. An error thrown from an
501 * event will not interrupt, nor even substantially slow down the processing of
502 * other events, but will be rather postponed to a lower priority event.
503 * @param {{call}} task A callable object, typically a function that takes no
504 * arguments.
505 */
506var browserAsap = asap;
507function asap(task) {
508 var rawTask;
509 if (freeTasks.length) {
510 rawTask = freeTasks.pop();
511 } else {
512 rawTask = new RawTask();
513 }
514 rawTask.task = task;
515 browserRaw(rawTask);
516}
517
518// We wrap tasks with recyclable task objects. A task object implements
519// `call`, just like a function.
520function RawTask() {
521 this.task = null;
522}
523
524// The sole purpose of wrapping the task is to catch the exception and recycle
525// the task object after its single use.
526RawTask.prototype.call = function () {
527 try {
528 this.task.call();
529 } catch (error) {
530 if (asap.onerror) {
531 // This hook exists purely for testing purposes.
532 // Its name will be periodically randomized to break any code that
533 // depends on its existence.
534 asap.onerror(error);
535 } else {
536 // In a web browser, exceptions are not fatal. However, to avoid
537 // slowing down the queue of pending tasks, we rethrow the error in a
538 // lower priority turn.
539 pendingErrors.push(error);
540 requestErrorThrow();
541 }
542 } finally {
543 this.task = null;
544 freeTasks[freeTasks.length] = this;
545 }
546};
547
548/* @flow */
549var MAP_EXISTS = typeof Map !== 'undefined';
550
551var OrderedElements =
552/*#__PURE__*/
553function () {
554 /* ::
555 elements: {[string]: any};
556 keyOrder: string[];
557 */
558 function OrderedElements() {
559 this.elements = {};
560 this.keyOrder = [];
561 }
562
563 var _proto = OrderedElements.prototype;
564
565 _proto.forEach = function forEach(callback
566 /* : (string, any) => void */
567 ) {
568 for (var i = 0; i < this.keyOrder.length; i++) {
569 // (value, key) to match Map's API
570 callback(this.elements[this.keyOrder[i]], this.keyOrder[i]);
571 }
572 };
573
574 _proto.set = function set(key
575 /* : string */
576 , value
577 /* : any */
578 , shouldReorder
579 /* : ?boolean */
580 ) {
581 if (!this.elements.hasOwnProperty(key)) {
582 this.keyOrder.push(key);
583 } else if (shouldReorder) {
584 var index = this.keyOrder.indexOf(key);
585 this.keyOrder.splice(index, 1);
586 this.keyOrder.push(key);
587 }
588
589 if (value == null) {
590 this.elements[key] = value;
591 return;
592 }
593
594 if (MAP_EXISTS && value instanceof Map || value instanceof OrderedElements) {
595 // We have found a nested Map, so we need to recurse so that all
596 // of the nested objects and Maps are merged properly.
597 var nested = this.elements.hasOwnProperty(key) ? this.elements[key] : new OrderedElements();
598 value.forEach(function (value, key) {
599 nested.set(key, value, shouldReorder);
600 });
601 this.elements[key] = nested;
602 return;
603 }
604
605 if (!Array.isArray(value) && _typeof(value) === 'object') {
606 // We have found a nested object, so we need to recurse so that all
607 // of the nested objects and Maps are merged properly.
608 var _nested = this.elements.hasOwnProperty(key) ? this.elements[key] : new OrderedElements();
609
610 var keys = Object.keys(value);
611
612 for (var i = 0; i < keys.length; i += 1) {
613 _nested.set(keys[i], value[keys[i]], shouldReorder);
614 }
615
616 this.elements[key] = _nested;
617 return;
618 }
619
620 this.elements[key] = value;
621 };
622
623 _proto.get = function get(key
624 /* : string */
625 )
626 /* : any */
627 {
628 return this.elements[key];
629 };
630
631 _proto.has = function has(key
632 /* : string */
633 )
634 /* : boolean */
635 {
636 return this.elements.hasOwnProperty(key);
637 };
638
639 _proto.addStyleType = function addStyleType(styleType
640 /* : any */
641 )
642 /* : void */
643 {
644 var _this = this;
645
646 if (MAP_EXISTS && styleType instanceof Map || styleType instanceof OrderedElements) {
647 styleType.forEach(function (value, key) {
648 _this.set(key, value, true);
649 });
650 } else {
651 var keys = Object.keys(styleType);
652
653 for (var i = 0; i < keys.length; i++) {
654 this.set(keys[i], styleType[keys[i]], true);
655 }
656 }
657 };
658
659 return OrderedElements;
660}();
661
662var capitalizeString_1 = createCommonjsModule(function (module, exports) {
663
664Object.defineProperty(exports, "__esModule", {
665 value: true
666});
667exports.default = capitalizeString;
668function capitalizeString(str) {
669 return str.charAt(0).toUpperCase() + str.slice(1);
670}
671});
672
673unwrapExports(capitalizeString_1);
674
675var prefixProperty_1 = createCommonjsModule(function (module, exports) {
676
677Object.defineProperty(exports, "__esModule", {
678 value: true
679});
680exports.default = prefixProperty;
681
682
683
684var _capitalizeString2 = _interopRequireDefault(capitalizeString_1);
685
686function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
687
688function prefixProperty(prefixProperties, property, style) {
689 if (prefixProperties.hasOwnProperty(property)) {
690 var newStyle = {};
691 var requiredPrefixes = prefixProperties[property];
692 var capitalizedProperty = (0, _capitalizeString2.default)(property);
693 var keys = Object.keys(style);
694 for (var i = 0; i < keys.length; i++) {
695 var styleProperty = keys[i];
696 if (styleProperty === property) {
697 for (var j = 0; j < requiredPrefixes.length; j++) {
698 newStyle[requiredPrefixes[j] + capitalizedProperty] = style[property];
699 }
700 }
701 newStyle[styleProperty] = style[styleProperty];
702 }
703 return newStyle;
704 }
705 return style;
706}
707});
708
709unwrapExports(prefixProperty_1);
710
711var prefixValue_1 = createCommonjsModule(function (module, exports) {
712
713Object.defineProperty(exports, "__esModule", {
714 value: true
715});
716exports.default = prefixValue;
717function prefixValue(plugins, property, value, style, metaData) {
718 for (var i = 0, len = plugins.length; i < len; ++i) {
719 var processedValue = plugins[i](property, value, style, metaData);
720
721 // we can stop processing if a value is returned
722 // as all plugin criteria are unique
723 if (processedValue) {
724 return processedValue;
725 }
726 }
727}
728});
729
730unwrapExports(prefixValue_1);
731
732var addNewValuesOnly_1 = createCommonjsModule(function (module, exports) {
733
734Object.defineProperty(exports, "__esModule", {
735 value: true
736});
737exports.default = addNewValuesOnly;
738function addIfNew(list, value) {
739 if (list.indexOf(value) === -1) {
740 list.push(value);
741 }
742}
743
744function addNewValuesOnly(list, values) {
745 if (Array.isArray(values)) {
746 for (var i = 0, len = values.length; i < len; ++i) {
747 addIfNew(list, values[i]);
748 }
749 } else {
750 addIfNew(list, values);
751 }
752}
753});
754
755unwrapExports(addNewValuesOnly_1);
756
757var isObject_1 = createCommonjsModule(function (module, exports) {
758
759Object.defineProperty(exports, "__esModule", {
760 value: true
761});
762exports.default = isObject;
763function isObject(value) {
764 return value instanceof Object && !Array.isArray(value);
765}
766});
767
768unwrapExports(isObject_1);
769
770var createPrefixer_1 = createCommonjsModule(function (module, exports) {
771
772Object.defineProperty(exports, "__esModule", {
773 value: true
774});
775exports.default = createPrefixer;
776
777
778
779var _prefixProperty2 = _interopRequireDefault(prefixProperty_1);
780
781
782
783var _prefixValue2 = _interopRequireDefault(prefixValue_1);
784
785
786
787var _addNewValuesOnly2 = _interopRequireDefault(addNewValuesOnly_1);
788
789
790
791var _isObject2 = _interopRequireDefault(isObject_1);
792
793function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
794
795function createPrefixer(_ref) {
796 var prefixMap = _ref.prefixMap,
797 plugins = _ref.plugins;
798
799 return function prefix(style) {
800 for (var property in style) {
801 var value = style[property];
802
803 // handle nested objects
804 if ((0, _isObject2.default)(value)) {
805 style[property] = prefix(value);
806 // handle array values
807 } else if (Array.isArray(value)) {
808 var combinedValue = [];
809
810 for (var i = 0, len = value.length; i < len; ++i) {
811 var processedValue = (0, _prefixValue2.default)(plugins, property, value[i], style, prefixMap);
812 (0, _addNewValuesOnly2.default)(combinedValue, processedValue || value[i]);
813 }
814
815 // only modify the value if it was touched
816 // by any plugin to prevent unnecessary mutations
817 if (combinedValue.length > 0) {
818 style[property] = combinedValue;
819 }
820 } else {
821 var _processedValue = (0, _prefixValue2.default)(plugins, property, value, style, prefixMap);
822
823 // only modify the value if it was touched
824 // by any plugin to prevent unnecessary mutations
825 if (_processedValue) {
826 style[property] = _processedValue;
827 }
828
829 style = (0, _prefixProperty2.default)(prefixMap, property, style);
830 }
831 }
832
833 return style;
834 };
835}
836});
837
838var createPrefixer = unwrapExports(createPrefixer_1);
839
840var backgroundClip_1 = createCommonjsModule(function (module, exports) {
841
842Object.defineProperty(exports, "__esModule", {
843 value: true
844});
845exports.default = backgroundClip;
846
847// https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip#Browser_compatibility
848function backgroundClip(property, value) {
849 if (typeof value === 'string' && value === 'text') {
850 return ['-webkit-text', 'text'];
851 }
852}
853});
854
855var backgroundClip = unwrapExports(backgroundClip_1);
856
857var isPrefixedValue_1 = createCommonjsModule(function (module, exports) {
858
859Object.defineProperty(exports, "__esModule", {
860 value: true
861});
862exports.default = isPrefixedValue;
863var regex = /-webkit-|-moz-|-ms-/;
864
865function isPrefixedValue(value) {
866 return typeof value === 'string' && regex.test(value);
867}
868module.exports = exports['default'];
869});
870
871unwrapExports(isPrefixedValue_1);
872
873var calc_1 = createCommonjsModule(function (module, exports) {
874
875Object.defineProperty(exports, "__esModule", {
876 value: true
877});
878exports.default = calc;
879
880
881
882var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
883
884function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
885
886var prefixes = ['-webkit-', '-moz-', ''];
887function calc(property, value) {
888 if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('calc(') > -1) {
889 return prefixes.map(function (prefix) {
890 return value.replace(/calc\(/g, prefix + 'calc(');
891 });
892 }
893}
894});
895
896var calc = unwrapExports(calc_1);
897
898var crossFade_1 = createCommonjsModule(function (module, exports) {
899
900Object.defineProperty(exports, "__esModule", {
901 value: true
902});
903exports.default = crossFade;
904
905
906
907var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
908
909function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
910
911// http://caniuse.com/#search=cross-fade
912var prefixes = ['-webkit-', ''];
913function crossFade(property, value) {
914 if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('cross-fade(') > -1) {
915 return prefixes.map(function (prefix) {
916 return value.replace(/cross-fade\(/g, prefix + 'cross-fade(');
917 });
918 }
919}
920});
921
922var crossFade = unwrapExports(crossFade_1);
923
924var cursor_1 = createCommonjsModule(function (module, exports) {
925
926Object.defineProperty(exports, "__esModule", {
927 value: true
928});
929exports.default = cursor;
930var prefixes = ['-webkit-', '-moz-', ''];
931
932var values = {
933 'zoom-in': true,
934 'zoom-out': true,
935 grab: true,
936 grabbing: true
937};
938
939function cursor(property, value) {
940 if (property === 'cursor' && values.hasOwnProperty(value)) {
941 return prefixes.map(function (prefix) {
942 return prefix + value;
943 });
944 }
945}
946});
947
948var cursor = unwrapExports(cursor_1);
949
950var filter_1 = createCommonjsModule(function (module, exports) {
951
952Object.defineProperty(exports, "__esModule", {
953 value: true
954});
955exports.default = filter;
956
957
958
959var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
960
961function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
962
963// http://caniuse.com/#feat=css-filter-function
964var prefixes = ['-webkit-', ''];
965function filter(property, value) {
966 if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('filter(') > -1) {
967 return prefixes.map(function (prefix) {
968 return value.replace(/filter\(/g, prefix + 'filter(');
969 });
970 }
971}
972});
973
974var filter = unwrapExports(filter_1);
975
976var flex_1 = createCommonjsModule(function (module, exports) {
977
978Object.defineProperty(exports, "__esModule", {
979 value: true
980});
981exports.default = flex;
982var values = {
983 flex: ['-webkit-box', '-moz-box', '-ms-flexbox', '-webkit-flex', 'flex'],
984 'inline-flex': ['-webkit-inline-box', '-moz-inline-box', '-ms-inline-flexbox', '-webkit-inline-flex', 'inline-flex']
985};
986
987function flex(property, value) {
988 if (property === 'display' && values.hasOwnProperty(value)) {
989 return values[value];
990 }
991}
992});
993
994var flex = unwrapExports(flex_1);
995
996var flexboxIE_1 = createCommonjsModule(function (module, exports) {
997
998Object.defineProperty(exports, "__esModule", {
999 value: true
1000});
1001exports.default = flexboxIE;
1002var alternativeValues = {
1003 'space-around': 'distribute',
1004 'space-between': 'justify',
1005 'flex-start': 'start',
1006 'flex-end': 'end'
1007};
1008var alternativeProps = {
1009 alignContent: 'msFlexLinePack',
1010 alignSelf: 'msFlexItemAlign',
1011 alignItems: 'msFlexAlign',
1012 justifyContent: 'msFlexPack',
1013 order: 'msFlexOrder',
1014 flexGrow: 'msFlexPositive',
1015 flexShrink: 'msFlexNegative',
1016 flexBasis: 'msFlexPreferredSize'
1017 // Full expanded syntax is flex-grow | flex-shrink | flex-basis.
1018};var flexShorthandMappings = {
1019 auto: '1 1 auto',
1020 inherit: 'inherit',
1021 initial: '0 1 auto',
1022 none: '0 0 auto',
1023 unset: 'unset'
1024};
1025var isUnitlessNumber = /^\d+(\.\d+)?$/;
1026
1027function flexboxIE(property, value, style) {
1028 if (Object.prototype.hasOwnProperty.call(alternativeProps, property)) {
1029 style[alternativeProps[property]] = alternativeValues[value] || value;
1030 }
1031 if (property === 'flex') {
1032 // For certain values we can do straight mappings based on the spec
1033 // for the expansions.
1034 if (Object.prototype.hasOwnProperty.call(flexShorthandMappings, value)) {
1035 style.msFlex = flexShorthandMappings[value];
1036 return;
1037 }
1038 // Here we have no direct mapping, so we favor looking for a
1039 // unitless positive number as that will be the most common use-case.
1040 if (isUnitlessNumber.test(value)) {
1041 style.msFlex = value + ' 1 0%';
1042 return;
1043 }
1044
1045 // The next thing we can look for is if there are multiple values.
1046 var flexValues = value.split(/\s/);
1047 // If we only have a single value that wasn't a positive unitless
1048 // or a pre-mapped value, then we can assume it is a unit value.
1049 switch (flexValues.length) {
1050 case 1:
1051 style.msFlex = '1 1 ' + value;
1052 return;
1053 case 2:
1054 // If we have 2 units, then we expect that the first will
1055 // always be a unitless number and represents flex-grow.
1056 // The second unit will represent flex-shrink for a unitless
1057 // value, or flex-basis otherwise.
1058 if (isUnitlessNumber.test(flexValues[1])) {
1059 style.msFlex = flexValues[0] + ' ' + flexValues[1] + ' 0%';
1060 } else {
1061 style.msFlex = flexValues[0] + ' 1 ' + flexValues[1];
1062 }
1063 return;
1064 default:
1065 style.msFlex = value;
1066 }
1067 }
1068}
1069});
1070
1071var flexboxIE = unwrapExports(flexboxIE_1);
1072
1073var flexboxOld_1 = createCommonjsModule(function (module, exports) {
1074
1075Object.defineProperty(exports, "__esModule", {
1076 value: true
1077});
1078exports.default = flexboxOld;
1079var alternativeValues = {
1080 'space-around': 'justify',
1081 'space-between': 'justify',
1082 'flex-start': 'start',
1083 'flex-end': 'end',
1084 'wrap-reverse': 'multiple',
1085 wrap: 'multiple'
1086};
1087
1088var alternativeProps = {
1089 alignItems: 'WebkitBoxAlign',
1090 justifyContent: 'WebkitBoxPack',
1091 flexWrap: 'WebkitBoxLines',
1092 flexGrow: 'WebkitBoxFlex'
1093};
1094
1095function flexboxOld(property, value, style) {
1096 if (property === 'flexDirection' && typeof value === 'string') {
1097 if (value.indexOf('column') > -1) {
1098 style.WebkitBoxOrient = 'vertical';
1099 } else {
1100 style.WebkitBoxOrient = 'horizontal';
1101 }
1102 if (value.indexOf('reverse') > -1) {
1103 style.WebkitBoxDirection = 'reverse';
1104 } else {
1105 style.WebkitBoxDirection = 'normal';
1106 }
1107 }
1108 if (alternativeProps.hasOwnProperty(property)) {
1109 style[alternativeProps[property]] = alternativeValues[value] || value;
1110 }
1111}
1112});
1113
1114var flexboxOld = unwrapExports(flexboxOld_1);
1115
1116var gradient_1 = createCommonjsModule(function (module, exports) {
1117
1118Object.defineProperty(exports, "__esModule", {
1119 value: true
1120});
1121exports.default = gradient;
1122
1123
1124
1125var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
1126
1127function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1128
1129var prefixes = ['-webkit-', '-moz-', ''];
1130
1131var values = /linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/gi;
1132
1133function gradient(property, value) {
1134 if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && values.test(value)) {
1135 return prefixes.map(function (prefix) {
1136 return value.replace(values, function (grad) {
1137 return prefix + grad;
1138 });
1139 });
1140 }
1141}
1142});
1143
1144var gradient = unwrapExports(gradient_1);
1145
1146var grid_1 = createCommonjsModule(function (module, exports) {
1147
1148Object.defineProperty(exports, "__esModule", {
1149 value: true
1150});
1151
1152var _slicedToArray = function () { function sliceIterator(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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
1153
1154exports.default = grid;
1155function isSimplePositionValue(value) {
1156 return typeof value === 'number' && !isNaN(value);
1157}
1158
1159var alignmentValues = ['center', 'end', 'start', 'stretch'];
1160
1161var displayValues = {
1162 'inline-grid': ['-ms-inline-grid', 'inline-grid'],
1163 grid: ['-ms-grid', 'grid']
1164};
1165
1166var propertyConverters = {
1167 alignSelf: function alignSelf(value, style) {
1168 if (alignmentValues.indexOf(value) > -1) {
1169 style.msGridRowAlign = value;
1170 }
1171 },
1172
1173 gridColumn: function gridColumn(value, style) {
1174 if (isSimplePositionValue(value)) {
1175 style.msGridColumn = value;
1176 } else {
1177 var _value$split$map = value.split('/').map(function (position) {
1178 return +position;
1179 }),
1180 _value$split$map2 = _slicedToArray(_value$split$map, 2),
1181 start = _value$split$map2[0],
1182 end = _value$split$map2[1];
1183
1184 propertyConverters.gridColumnStart(start, style);
1185 propertyConverters.gridColumnEnd(end, style);
1186 }
1187 },
1188
1189 gridColumnEnd: function gridColumnEnd(value, style) {
1190 var msGridColumn = style.msGridColumn;
1191
1192 if (isSimplePositionValue(value) && isSimplePositionValue(msGridColumn)) {
1193 style.msGridColumnSpan = value - msGridColumn;
1194 }
1195 },
1196
1197 gridColumnStart: function gridColumnStart(value, style) {
1198 if (isSimplePositionValue(value)) {
1199 style.msGridColumn = value;
1200 }
1201 },
1202
1203 gridRow: function gridRow(value, style) {
1204 if (isSimplePositionValue(value)) {
1205 style.msGridRow = value;
1206 } else {
1207 var _value$split$map3 = value.split('/').map(function (position) {
1208 return +position;
1209 }),
1210 _value$split$map4 = _slicedToArray(_value$split$map3, 2),
1211 start = _value$split$map4[0],
1212 end = _value$split$map4[1];
1213
1214 propertyConverters.gridRowStart(start, style);
1215 propertyConverters.gridRowEnd(end, style);
1216 }
1217 },
1218
1219 gridRowEnd: function gridRowEnd(value, style) {
1220 var msGridRow = style.msGridRow;
1221
1222 if (isSimplePositionValue(value) && isSimplePositionValue(msGridRow)) {
1223 style.msGridRowSpan = value - msGridRow;
1224 }
1225 },
1226
1227 gridRowStart: function gridRowStart(value, style) {
1228 if (isSimplePositionValue(value)) {
1229 style.msGridRow = value;
1230 }
1231 },
1232
1233 gridTemplateColumns: function gridTemplateColumns(value, style) {
1234 style.msGridColumns = value;
1235 },
1236
1237 gridTemplateRows: function gridTemplateRows(value, style) {
1238 style.msGridRows = value;
1239 },
1240
1241 justifySelf: function justifySelf(value, style) {
1242 if (alignmentValues.indexOf(value) > -1) {
1243 style.msGridColumnAlign = value;
1244 }
1245 }
1246};
1247
1248function grid(property, value, style) {
1249 if (property === 'display' && value in displayValues) {
1250 return displayValues[value];
1251 }
1252
1253 if (property in propertyConverters) {
1254 var propertyConverter = propertyConverters[property];
1255 propertyConverter(value, style);
1256 }
1257}
1258});
1259
1260var grid = unwrapExports(grid_1);
1261
1262var imageSet_1 = createCommonjsModule(function (module, exports) {
1263
1264Object.defineProperty(exports, "__esModule", {
1265 value: true
1266});
1267exports.default = imageSet;
1268
1269
1270
1271var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
1272
1273function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1274
1275// http://caniuse.com/#feat=css-image-set
1276var prefixes = ['-webkit-', ''];
1277function imageSet(property, value) {
1278 if (typeof value === 'string' && !(0, _isPrefixedValue2.default)(value) && value.indexOf('image-set(') > -1) {
1279 return prefixes.map(function (prefix) {
1280 return value.replace(/image-set\(/g, prefix + 'image-set(');
1281 });
1282 }
1283}
1284});
1285
1286var imageSet = unwrapExports(imageSet_1);
1287
1288var logical_1 = createCommonjsModule(function (module, exports) {
1289
1290Object.defineProperty(exports, "__esModule", {
1291 value: true
1292});
1293exports.default = logical;
1294var alternativeProps = {
1295 marginBlockStart: ['WebkitMarginBefore'],
1296 marginBlockEnd: ['WebkitMarginAfter'],
1297 marginInlineStart: ['WebkitMarginStart', 'MozMarginStart'],
1298 marginInlineEnd: ['WebkitMarginEnd', 'MozMarginEnd'],
1299 paddingBlockStart: ['WebkitPaddingBefore'],
1300 paddingBlockEnd: ['WebkitPaddingAfter'],
1301 paddingInlineStart: ['WebkitPaddingStart', 'MozPaddingStart'],
1302 paddingInlineEnd: ['WebkitPaddingEnd', 'MozPaddingEnd'],
1303 borderBlockStart: ['WebkitBorderBefore'],
1304 borderBlockStartColor: ['WebkitBorderBeforeColor'],
1305 borderBlockStartStyle: ['WebkitBorderBeforeStyle'],
1306 borderBlockStartWidth: ['WebkitBorderBeforeWidth'],
1307 borderBlockEnd: ['WebkitBorderAfter'],
1308 borderBlockEndColor: ['WebkitBorderAfterColor'],
1309 borderBlockEndStyle: ['WebkitBorderAfterStyle'],
1310 borderBlockEndWidth: ['WebkitBorderAfterWidth'],
1311 borderInlineStart: ['WebkitBorderStart', 'MozBorderStart'],
1312 borderInlineStartColor: ['WebkitBorderStartColor', 'MozBorderStartColor'],
1313 borderInlineStartStyle: ['WebkitBorderStartStyle', 'MozBorderStartStyle'],
1314 borderInlineStartWidth: ['WebkitBorderStartWidth', 'MozBorderStartWidth'],
1315 borderInlineEnd: ['WebkitBorderEnd', 'MozBorderEnd'],
1316 borderInlineEndColor: ['WebkitBorderEndColor', 'MozBorderEndColor'],
1317 borderInlineEndStyle: ['WebkitBorderEndStyle', 'MozBorderEndStyle'],
1318 borderInlineEndWidth: ['WebkitBorderEndWidth', 'MozBorderEndWidth']
1319};
1320
1321function logical(property, value, style) {
1322 if (Object.prototype.hasOwnProperty.call(alternativeProps, property)) {
1323 var alternativePropList = alternativeProps[property];
1324 for (var i = 0, len = alternativePropList.length; i < len; ++i) {
1325 style[alternativePropList[i]] = value;
1326 }
1327 }
1328}
1329});
1330
1331var logical = unwrapExports(logical_1);
1332
1333var position_1 = createCommonjsModule(function (module, exports) {
1334
1335Object.defineProperty(exports, "__esModule", {
1336 value: true
1337});
1338exports.default = position;
1339function position(property, value) {
1340 if (property === 'position' && value === 'sticky') {
1341 return ['-webkit-sticky', 'sticky'];
1342 }
1343}
1344});
1345
1346var position = unwrapExports(position_1);
1347
1348var sizing_1 = createCommonjsModule(function (module, exports) {
1349
1350Object.defineProperty(exports, "__esModule", {
1351 value: true
1352});
1353exports.default = sizing;
1354var prefixes = ['-webkit-', '-moz-', ''];
1355
1356var properties = {
1357 maxHeight: true,
1358 maxWidth: true,
1359 width: true,
1360 height: true,
1361 columnWidth: true,
1362 minWidth: true,
1363 minHeight: true
1364};
1365var values = {
1366 'min-content': true,
1367 'max-content': true,
1368 'fill-available': true,
1369 'fit-content': true,
1370 'contain-floats': true
1371};
1372
1373function sizing(property, value) {
1374 if (properties.hasOwnProperty(property) && values.hasOwnProperty(value)) {
1375 return prefixes.map(function (prefix) {
1376 return prefix + value;
1377 });
1378 }
1379}
1380});
1381
1382var sizing = unwrapExports(sizing_1);
1383
1384/* eslint-disable no-var, prefer-template */
1385var uppercasePattern = /[A-Z]/g;
1386var msPattern = /^ms-/;
1387var cache = {};
1388
1389function toHyphenLower(match) {
1390 return '-' + match.toLowerCase()
1391}
1392
1393function hyphenateStyleName(name) {
1394 if (cache.hasOwnProperty(name)) {
1395 return cache[name]
1396 }
1397
1398 var hName = name.replace(uppercasePattern, toHyphenLower);
1399 return (cache[name] = msPattern.test(hName) ? '-' + hName : hName)
1400}
1401
1402var hyphenateStyleName$1 = /*#__PURE__*/Object.freeze({
1403 default: hyphenateStyleName
1404});
1405
1406var _hyphenateStyleName = getCjsExportFromNamespace(hyphenateStyleName$1);
1407
1408var hyphenateProperty_1 = createCommonjsModule(function (module, exports) {
1409
1410Object.defineProperty(exports, "__esModule", {
1411 value: true
1412});
1413exports.default = hyphenateProperty;
1414
1415
1416
1417var _hyphenateStyleName2 = _interopRequireDefault(_hyphenateStyleName);
1418
1419function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1420
1421function hyphenateProperty(property) {
1422 return (0, _hyphenateStyleName2.default)(property);
1423}
1424module.exports = exports['default'];
1425});
1426
1427unwrapExports(hyphenateProperty_1);
1428
1429var transition_1 = createCommonjsModule(function (module, exports) {
1430
1431Object.defineProperty(exports, "__esModule", {
1432 value: true
1433});
1434exports.default = transition;
1435
1436
1437
1438var _hyphenateProperty2 = _interopRequireDefault(hyphenateProperty_1);
1439
1440
1441
1442var _isPrefixedValue2 = _interopRequireDefault(isPrefixedValue_1);
1443
1444
1445
1446var _capitalizeString2 = _interopRequireDefault(capitalizeString_1);
1447
1448function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1449
1450var properties = {
1451 transition: true,
1452 transitionProperty: true,
1453 WebkitTransition: true,
1454 WebkitTransitionProperty: true,
1455 MozTransition: true,
1456 MozTransitionProperty: true
1457};
1458
1459
1460var prefixMapping = {
1461 Webkit: '-webkit-',
1462 Moz: '-moz-',
1463 ms: '-ms-'
1464};
1465
1466function prefixValue(value, propertyPrefixMap) {
1467 if ((0, _isPrefixedValue2.default)(value)) {
1468 return value;
1469 }
1470
1471 // only split multi values, not cubic beziers
1472 var multipleValues = value.split(/,(?![^()]*(?:\([^()]*\))?\))/g);
1473
1474 for (var i = 0, len = multipleValues.length; i < len; ++i) {
1475 var singleValue = multipleValues[i];
1476 var values = [singleValue];
1477 for (var property in propertyPrefixMap) {
1478 var dashCaseProperty = (0, _hyphenateProperty2.default)(property);
1479
1480 if (singleValue.indexOf(dashCaseProperty) > -1 && dashCaseProperty !== 'order') {
1481 var prefixes = propertyPrefixMap[property];
1482 for (var j = 0, pLen = prefixes.length; j < pLen; ++j) {
1483 // join all prefixes and create a new value
1484 values.unshift(singleValue.replace(dashCaseProperty, prefixMapping[prefixes[j]] + dashCaseProperty));
1485 }
1486 }
1487 }
1488
1489 multipleValues[i] = values.join(',');
1490 }
1491
1492 return multipleValues.join(',');
1493}
1494
1495function transition(property, value, style, propertyPrefixMap) {
1496 // also check for already prefixed transitions
1497 if (typeof value === 'string' && properties.hasOwnProperty(property)) {
1498 var outputValue = prefixValue(value, propertyPrefixMap);
1499 // if the property is already prefixed
1500 var webkitOutput = outputValue.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function (val) {
1501 return !/-moz-|-ms-/.test(val);
1502 }).join(',');
1503
1504 if (property.indexOf('Webkit') > -1) {
1505 return webkitOutput;
1506 }
1507
1508 var mozOutput = outputValue.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function (val) {
1509 return !/-webkit-|-ms-/.test(val);
1510 }).join(',');
1511
1512 if (property.indexOf('Moz') > -1) {
1513 return mozOutput;
1514 }
1515
1516 style['Webkit' + (0, _capitalizeString2.default)(property)] = webkitOutput;
1517 style['Moz' + (0, _capitalizeString2.default)(property)] = mozOutput;
1518 return outputValue;
1519 }
1520}
1521});
1522
1523var transition = unwrapExports(transition_1);
1524
1525var w = ["Webkit"];
1526var m = ["Moz"];
1527var ms = ["ms"];
1528var wm = ["Webkit", "Moz"];
1529var wms = ["Webkit", "ms"];
1530var wmms = ["Webkit", "Moz", "ms"];
1531var staticData = {
1532 plugins: [backgroundClip, calc, crossFade, cursor, filter, flex, flexboxIE, flexboxOld, gradient, grid, imageSet, logical, position, sizing, transition],
1533 prefixMap: {
1534 "transform": wms,
1535 "transformOrigin": wms,
1536 "transformOriginX": wms,
1537 "transformOriginY": wms,
1538 "backfaceVisibility": w,
1539 "perspective": w,
1540 "perspectiveOrigin": w,
1541 "transformStyle": w,
1542 "transformOriginZ": w,
1543 "animation": w,
1544 "animationDelay": w,
1545 "animationDirection": w,
1546 "animationFillMode": w,
1547 "animationDuration": w,
1548 "animationIterationCount": w,
1549 "animationName": w,
1550 "animationPlayState": w,
1551 "animationTimingFunction": w,
1552 "appearance": wm,
1553 "userSelect": wmms,
1554 "fontKerning": w,
1555 "textEmphasisPosition": w,
1556 "textEmphasis": w,
1557 "textEmphasisStyle": w,
1558 "textEmphasisColor": w,
1559 "boxDecorationBreak": w,
1560 "clipPath": w,
1561 "maskImage": w,
1562 "maskMode": w,
1563 "maskRepeat": w,
1564 "maskPosition": w,
1565 "maskClip": w,
1566 "maskOrigin": w,
1567 "maskSize": w,
1568 "maskComposite": w,
1569 "mask": w,
1570 "maskBorderSource": w,
1571 "maskBorderMode": w,
1572 "maskBorderSlice": w,
1573 "maskBorderWidth": w,
1574 "maskBorderOutset": w,
1575 "maskBorderRepeat": w,
1576 "maskBorder": w,
1577 "maskType": w,
1578 "textDecorationStyle": wm,
1579 "textDecorationSkip": wm,
1580 "textDecorationLine": wm,
1581 "textDecorationColor": wm,
1582 "filter": w,
1583 "fontFeatureSettings": wm,
1584 "breakAfter": wmms,
1585 "breakBefore": wmms,
1586 "breakInside": wmms,
1587 "columnCount": wm,
1588 "columnFill": wm,
1589 "columnGap": wm,
1590 "columnRule": wm,
1591 "columnRuleColor": wm,
1592 "columnRuleStyle": wm,
1593 "columnRuleWidth": wm,
1594 "columns": wm,
1595 "columnSpan": wm,
1596 "columnWidth": wm,
1597 "writingMode": wms,
1598 "flex": wms,
1599 "flexBasis": w,
1600 "flexDirection": wms,
1601 "flexGrow": w,
1602 "flexFlow": wms,
1603 "flexShrink": w,
1604 "flexWrap": wms,
1605 "alignContent": w,
1606 "alignItems": w,
1607 "alignSelf": w,
1608 "justifyContent": w,
1609 "order": w,
1610 "transitionDelay": w,
1611 "transitionDuration": w,
1612 "transitionProperty": w,
1613 "transitionTimingFunction": w,
1614 "backdropFilter": w,
1615 "scrollSnapType": wms,
1616 "scrollSnapPointsX": wms,
1617 "scrollSnapPointsY": wms,
1618 "scrollSnapDestination": wms,
1619 "scrollSnapCoordinate": wms,
1620 "shapeImageThreshold": w,
1621 "shapeImageMargin": w,
1622 "shapeImageOutside": w,
1623 "hyphens": wmms,
1624 "flowInto": wms,
1625 "flowFrom": wms,
1626 "regionFragment": wms,
1627 "textOrientation": w,
1628 "boxSizing": m,
1629 "textAlignLast": m,
1630 "tabSize": m,
1631 "wrapFlow": ms,
1632 "wrapThrough": ms,
1633 "wrapMargin": ms,
1634 "touchAction": ms,
1635 "textSizeAdjust": wms,
1636 "borderImage": w,
1637 "borderImageOutset": w,
1638 "borderImageRepeat": w,
1639 "borderImageSlice": w,
1640 "borderImageSource": w,
1641 "borderImageWidth": w
1642 }
1643};
1644
1645var prefixAll = createPrefixer(staticData);
1646/* ::
1647import type { SheetDefinition } from './index.js';
1648type StringHandlers = { [id:string]: Function };
1649type SelectorCallback = (selector: string) => string[];
1650export type SelectorHandler = (
1651 selector: string,
1652 baseSelector: string,
1653 callback: SelectorCallback
1654) => string[] | string | null;
1655*/
1656
1657/**
1658 * `selectorHandlers` are functions which handle special selectors which act
1659 * differently than normal style definitions. These functions look at the
1660 * current selector and can generate CSS for the styles in their subtree by
1661 * calling the callback with a new selector.
1662 *
1663 * For example, when generating styles with a base selector of '.foo' and the
1664 * following styles object:
1665 *
1666 * {
1667 * ':nth-child(2n)': {
1668 * ':hover': {
1669 * color: 'red'
1670 * }
1671 * }
1672 * }
1673 *
1674 * when we reach the ':hover' style, we would call our selector handlers like
1675 *
1676 * handler(':hover', '.foo:nth-child(2n)', callback)
1677 *
1678 * Since our `pseudoSelectors` handles ':hover' styles, that handler would call
1679 * the callback like
1680 *
1681 * callback('.foo:nth-child(2n):hover')
1682 *
1683 * to generate its subtree `{ color: 'red' }` styles with a
1684 * '.foo:nth-child(2n):hover' selector. The callback would return an array of CSS
1685 * rules like
1686 *
1687 * ['.foo:nth-child(2n):hover{color:red !important;}']
1688 *
1689 * and the handler would then return that resulting CSS.
1690 *
1691 * `defaultSelectorHandlers` is the list of default handlers used in a call to
1692 * `generateCSS`.
1693 *
1694 * @name SelectorHandler
1695 * @function
1696 * @param {string} selector: The currently inspected selector. ':hover' in the
1697 * example above.
1698 * @param {string} baseSelector: The selector of the parent styles.
1699 * '.foo:nth-child(2n)' in the example above.
1700 * @param {function} generateSubtreeStyles: A function which can be called to
1701 * generate CSS for the subtree of styles corresponding to the selector.
1702 * Accepts a new baseSelector to use for generating those styles.
1703 * @returns {string[] | string | null} The generated CSS for this selector, or
1704 * null if we don't handle this selector.
1705 */
1706
1707var defaultSelectorHandlers
1708/* : SelectorHandler[] */
1709= [// Handle pseudo-selectors, like :hover and :nth-child(3n)
1710function pseudoSelectors(selector, baseSelector, generateSubtreeStyles) {
1711 if (selector[0] !== ":") {
1712 return null;
1713 }
1714
1715 return generateSubtreeStyles(baseSelector + selector);
1716}, // Handle media queries (or font-faces)
1717function mediaQueries(selector, baseSelector, generateSubtreeStyles) {
1718 if (selector[0] !== "@") {
1719 return null;
1720 } // Generate the styles normally, and then wrap them in the media query.
1721
1722
1723 var generated = generateSubtreeStyles(baseSelector);
1724 return ["".concat(selector, "{").concat(generated.join(''), "}")];
1725}];
1726/**
1727 * Generate CSS for a selector and some styles.
1728 *
1729 * This function handles the media queries and pseudo selectors that can be used
1730 * in aphrodite styles.
1731 *
1732 * @param {string} selector: A base CSS selector for the styles to be generated
1733 * with.
1734 * @param {Object} styleTypes: A list of properties of the return type of
1735 * StyleSheet.create, e.g. [styles.red, styles.blue].
1736 * @param {Array.<SelectorHandler>} selectorHandlers: A list of selector
1737 * handlers to use for handling special selectors. See
1738 * `defaultSelectorHandlers`.
1739 * @param stringHandlers: See `generateCSSRuleset`
1740 * @param useImportant: See `generateCSSRuleset`
1741 *
1742 * To actually generate the CSS special-construct-less styles are passed to
1743 * `generateCSSRuleset`.
1744 *
1745 * For instance, a call to
1746 *
1747 * generateCSS(".foo", [{
1748 * color: "red",
1749 * "@media screen": {
1750 * height: 20,
1751 * ":hover": {
1752 * backgroundColor: "black"
1753 * }
1754 * },
1755 * ":active": {
1756 * fontWeight: "bold"
1757 * }
1758 * }], defaultSelectorHandlers);
1759 *
1760 * with the default `selectorHandlers` will make 5 calls to
1761 * `generateCSSRuleset`:
1762 *
1763 * generateCSSRuleset(".foo", { color: "red" }, ...)
1764 * generateCSSRuleset(".foo:active", { fontWeight: "bold" }, ...)
1765 * // These 2 will be wrapped in @media screen {}
1766 * generateCSSRuleset(".foo", { height: 20 }, ...)
1767 * generateCSSRuleset(".foo:hover", { backgroundColor: "black" }, ...)
1768 */
1769
1770var generateCSS = function generateCSS(selector
1771/* : string */
1772, styleTypes
1773/* : SheetDefinition[] */
1774, selectorHandlers
1775/* : SelectorHandler[] */
1776, stringHandlers
1777/* : StringHandlers */
1778, useImportant
1779/* : boolean */
1780)
1781/* : string[] */
1782{
1783 var merged = new OrderedElements();
1784
1785 for (var i = 0; i < styleTypes.length; i++) {
1786 merged.addStyleType(styleTypes[i]);
1787 }
1788
1789 var plainDeclarations = new OrderedElements();
1790 var generatedStyles = []; // TODO(emily): benchmark this to see if a plain for loop would be faster.
1791
1792 merged.forEach(function (val, key) {
1793 // For each key, see if one of the selector handlers will handle these
1794 // styles.
1795 var foundHandler = selectorHandlers.some(function (handler) {
1796 var result = handler(key, selector, function (newSelector) {
1797 return generateCSS(newSelector, [val], selectorHandlers, stringHandlers, useImportant);
1798 });
1799
1800 if (result != null) {
1801 // If the handler returned something, add it to the generated
1802 // CSS and stop looking for another handler.
1803 if (Array.isArray(result)) {
1804 generatedStyles.push.apply(generatedStyles, _toConsumableArray(result));
1805 } else {
1806 // eslint-disable-next-line
1807 console.warn('WARNING: Selector handlers should return an array of rules.' + 'Returning a string containing multiple rules is deprecated.', handler);
1808 generatedStyles.push("@media all {".concat(result, "}"));
1809 }
1810
1811 return true;
1812 }
1813 }); // If none of the handlers handled it, add it to the list of plain
1814 // style declarations.
1815
1816 if (!foundHandler) {
1817 plainDeclarations.set(key, val, true);
1818 }
1819 });
1820 var generatedRuleset = generateCSSRuleset(selector, plainDeclarations, stringHandlers, useImportant, selectorHandlers);
1821
1822 if (generatedRuleset) {
1823 generatedStyles.unshift(generatedRuleset);
1824 }
1825
1826 return generatedStyles;
1827};
1828/**
1829 * Helper method of generateCSSRuleset to facilitate custom handling of certain
1830 * CSS properties. Used for e.g. font families.
1831 *
1832 * See generateCSSRuleset for usage and documentation of paramater types.
1833 */
1834
1835var runStringHandlers = function runStringHandlers(declarations
1836/* : OrderedElements */
1837, stringHandlers
1838/* : StringHandlers */
1839, selectorHandlers
1840/* : SelectorHandler[] */
1841)
1842/* : void */
1843{
1844 if (!stringHandlers) {
1845 return;
1846 }
1847
1848 var stringHandlerKeys = Object.keys(stringHandlers);
1849
1850 for (var i = 0; i < stringHandlerKeys.length; i++) {
1851 var key = stringHandlerKeys[i];
1852
1853 if (declarations.has(key)) {
1854 // A declaration exists for this particular string handler, so we
1855 // need to let the string handler interpret the declaration first
1856 // before proceeding.
1857 //
1858 // TODO(emily): Pass in a callback which generates CSS, similar to
1859 // how our selector handlers work, instead of passing in
1860 // `selectorHandlers` and have them make calls to `generateCSS`
1861 // themselves. Right now, this is impractical because our string
1862 // handlers are very specialized and do complex things.
1863 declarations.set(key, stringHandlers[key](declarations.get(key), selectorHandlers), // Preserve order here, since we are really replacing an
1864 // unprocessed style with a processed style, not overriding an
1865 // earlier style
1866 false);
1867 }
1868 }
1869};
1870
1871var transformRule = function transformRule(key
1872/* : string */
1873, value
1874/* : string */
1875, transformValue
1876/* : function */
1877) {
1878 return (
1879 /* : string */
1880 "".concat(kebabifyStyleName(key), ":").concat(transformValue(key, value), ";")
1881 );
1882};
1883
1884var arrayToObjectKeysReducer = function arrayToObjectKeysReducer(acc, val) {
1885 acc[val] = true;
1886 return acc;
1887};
1888/**
1889 * Generate a CSS ruleset with the selector and containing the declarations.
1890 *
1891 * This function assumes that the given declarations don't contain any special
1892 * children (such as media queries, pseudo-selectors, or descendant styles).
1893 *
1894 * Note that this method does not deal with nesting used for e.g.
1895 * psuedo-selectors or media queries. That responsibility is left to the
1896 * `generateCSS` function.
1897 *
1898 * @param {string} selector: the selector associated with the ruleset
1899 * @param {Object} declarations: a map from camelCased CSS property name to CSS
1900 * property value.
1901 * @param {Object.<string, function>} stringHandlers: a map from camelCased CSS
1902 * property name to a function which will map the given value to the value
1903 * that is output.
1904 * @param {bool} useImportant: A boolean saying whether to append "!important"
1905 * to each of the CSS declarations.
1906 * @returns {string} A string of raw CSS.
1907 *
1908 * Examples:
1909 *
1910 * generateCSSRuleset(".blah", { color: "red" })
1911 * -> ".blah{color: red !important;}"
1912 * generateCSSRuleset(".blah", { color: "red" }, {}, false)
1913 * -> ".blah{color: red}"
1914 * generateCSSRuleset(".blah", { color: "red" }, {color: c => c.toUpperCase})
1915 * -> ".blah{color: RED}"
1916 * generateCSSRuleset(".blah:hover", { color: "red" })
1917 * -> ".blah:hover{color: red}"
1918 */
1919
1920
1921var generateCSSRuleset = function generateCSSRuleset(selector
1922/* : string */
1923, declarations
1924/* : OrderedElements */
1925, stringHandlers
1926/* : StringHandlers */
1927, useImportant
1928/* : boolean */
1929, selectorHandlers
1930/* : SelectorHandler[] */
1931)
1932/* : string */
1933{
1934 // Mutates declarations
1935 runStringHandlers(declarations, stringHandlers, selectorHandlers);
1936 var originalElements = Object.keys(declarations.elements).reduce(arrayToObjectKeysReducer, Object.create(null)); // NOTE(emily): This mutates handledDeclarations.elements.
1937
1938 var prefixedElements = prefixAll(declarations.elements);
1939 var elementNames = Object.keys(prefixedElements);
1940
1941 if (elementNames.length !== declarations.keyOrder.length) {
1942 // There are some prefixed values, so we need to figure out how to sort
1943 // them.
1944 //
1945 // Loop through prefixedElements, looking for anything that is not in
1946 // sortOrder, which means it was added by prefixAll. This means that we
1947 // need to figure out where it should appear in the sortOrder.
1948 for (var i = 0; i < elementNames.length; i++) {
1949 if (!originalElements[elementNames[i]]) {
1950 // This element is not in the sortOrder, which means it is a prefixed
1951 // value that was added by prefixAll. Let's try to figure out where it
1952 // goes.
1953 var originalStyle = void 0;
1954
1955 if (elementNames[i][0] === 'W') {
1956 // This is a Webkit-prefixed style, like "WebkitTransition". Let's
1957 // find its original style's sort order.
1958 originalStyle = elementNames[i][6].toLowerCase() + elementNames[i].slice(7);
1959 } else if (elementNames[i][1] === 'o') {
1960 // This is a Moz-prefixed style, like "MozTransition". We check
1961 // the second character to avoid colliding with Ms-prefixed
1962 // styles. Let's find its original style's sort order.
1963 originalStyle = elementNames[i][3].toLowerCase() + elementNames[i].slice(4);
1964 } else {
1965 // if (elementNames[i][1] === 's') {
1966 // This is a Ms-prefixed style, like "MsTransition".
1967 originalStyle = elementNames[i][2].toLowerCase() + elementNames[i].slice(3);
1968 }
1969
1970 if (originalStyle && originalElements[originalStyle]) {
1971 var originalIndex = declarations.keyOrder.indexOf(originalStyle);
1972 declarations.keyOrder.splice(originalIndex, 0, elementNames[i]);
1973 } else {
1974 // We don't know what the original style was, so sort it to
1975 // top. This can happen for styles that are added that don't
1976 // have the same base name as the original style.
1977 declarations.keyOrder.unshift(elementNames[i]);
1978 }
1979 }
1980 }
1981 }
1982
1983 var transformValue = useImportant === false ? stringifyValue : stringifyAndImportantifyValue;
1984 var rules = [];
1985
1986 for (var _i = 0; _i < declarations.keyOrder.length; _i++) {
1987 var key = declarations.keyOrder[_i];
1988 var value = prefixedElements[key];
1989
1990 if (Array.isArray(value)) {
1991 // inline-style-prefixer returns an array when there should be
1992 // multiple rules for the same key. Here we flatten to multiple
1993 // pairs with the same key.
1994 for (var j = 0; j < value.length; j++) {
1995 rules.push(transformRule(key, value[j], transformValue));
1996 }
1997 } else {
1998 rules.push(transformRule(key, value, transformValue));
1999 }
2000 }
2001
2002 if (rules.length) {
2003 return "".concat(selector, "{").concat(rules.join(""), "}");
2004 } else {
2005 return "";
2006 }
2007};
2008
2009/* ::
2010import type { SheetDefinition, SheetDefinitions } from './index.js';
2011import type { MaybeSheetDefinition } from './exports.js';
2012import type { SelectorHandler } from './generate.js';
2013*/
2014// The current <style> tag we are inserting into, or null if we haven't
2015// inserted anything yet. We could find this each time using
2016// `document.querySelector("style[data-aphrodite"])`, but holding onto it is
2017// faster.
2018
2019var styleTag
2020/* : ?HTMLStyleElement */
2021= null; // Inject a set of rules into a <style> tag in the head of the document. This
2022// will automatically create a style tag and then continue to use it for
2023// multiple injections. It will also use a style tag with the `data-aphrodite`
2024// tag on it if that exists in the DOM. This could be used for e.g. reusing the
2025// same style tag that server-side rendering inserts.
2026
2027var injectStyleTag = function injectStyleTag(cssRules
2028/* : string[] */
2029) {
2030 if (styleTag == null) {
2031 // Try to find a style tag with the `data-aphrodite` attribute first.
2032 styleTag = document.querySelector("style[data-aphrodite]")
2033 /* : any */
2034 ; // If that doesn't work, generate a new style tag.
2035
2036 if (styleTag == null) {
2037 // Taken from
2038 // http://stackoverflow.com/questions/524696/how-to-create-a-style-tag-with-javascript
2039 var head = document.head || document.getElementsByTagName('head')[0];
2040 styleTag = document.createElement('style');
2041 styleTag.type = 'text/css';
2042 styleTag.setAttribute("data-aphrodite", "");
2043 head.appendChild(styleTag);
2044 }
2045 } // $FlowFixMe
2046
2047
2048 var sheet = styleTag.styleSheet || styleTag.sheet
2049 /* : any */
2050 ;
2051
2052 if (sheet.insertRule) {
2053 var numRules = sheet.cssRules.length;
2054 cssRules.forEach(function (rule) {
2055 try {
2056 sheet.insertRule(rule, numRules);
2057 numRules += 1;
2058 } catch (e) {// The selector for this rule wasn't compatible with the browser
2059 }
2060 });
2061 } else {
2062 styleTag.innerText = (styleTag.innerText || '') + cssRules.join('');
2063 }
2064}; // Custom handlers for stringifying CSS values that have side effects
2065// (such as fontFamily, which can cause @font-face rules to be injected)
2066
2067
2068var stringHandlers = {
2069 // With fontFamily we look for objects that are passed in and interpret
2070 // them as @font-face rules that we need to inject. The value of fontFamily
2071 // can either be a string (as normal), an object (a single font face), or
2072 // an array of objects and strings.
2073 fontFamily: function fontFamily(val) {
2074 if (Array.isArray(val)) {
2075 var nameMap = {};
2076 val.forEach(function (v) {
2077 nameMap[fontFamily(v)] = true;
2078 });
2079 return Object.keys(nameMap).join(",");
2080 } else if (_typeof(val) === "object") {
2081 injectStyleOnce(val.src, "@font-face", [val], false);
2082 return "\"".concat(val.fontFamily, "\"");
2083 } else {
2084 return val;
2085 }
2086 },
2087 // With animationName we look for an object that contains keyframes and
2088 // inject them as an `@keyframes` block, returning a uniquely generated
2089 // name. The keyframes object should look like
2090 // animationName: {
2091 // from: {
2092 // left: 0,
2093 // top: 0,
2094 // },
2095 // '50%': {
2096 // left: 15,
2097 // top: 5,
2098 // },
2099 // to: {
2100 // left: 20,
2101 // top: 20,
2102 // }
2103 // }
2104 // TODO(emily): `stringHandlers` doesn't let us rename the key, so I have
2105 // to use `animationName` here. Improve that so we can call this
2106 // `animation` instead of `animationName`.
2107 animationName: function animationName(val, selectorHandlers) {
2108 if (Array.isArray(val)) {
2109 return val.map(function (v) {
2110 return animationName(v, selectorHandlers);
2111 }).join(",");
2112 } else if (_typeof(val) === "object") {
2113 // Generate a unique name based on the hash of the object. We can't
2114 // just use the hash because the name can't start with a number.
2115 // TODO(emily): this probably makes debugging hard, allow a custom
2116 // name?
2117 var name = "keyframe_".concat(hashObject(val)); // Since keyframes need 3 layers of nesting, we use `generateCSS` to
2118 // build the inner layers and wrap it in `@keyframes` ourselves.
2119
2120 var finalVal = "@keyframes ".concat(name, "{"); // TODO see if we can find a way where checking for OrderedElements
2121 // here is not necessary. Alternatively, perhaps we should have a
2122 // utility method that can iterate over either a plain object, an
2123 // instance of OrderedElements, or a Map, and then use that here and
2124 // elsewhere.
2125
2126 if (val instanceof OrderedElements) {
2127 val.forEach(function (valVal, valKey) {
2128 finalVal += generateCSS(valKey, [valVal], selectorHandlers, stringHandlers, false).join('');
2129 });
2130 } else {
2131 Object.keys(val).forEach(function (key) {
2132 finalVal += generateCSS(key, [val[key]], selectorHandlers, stringHandlers, false).join('');
2133 });
2134 }
2135
2136 finalVal += '}';
2137 injectGeneratedCSSOnce(name, [finalVal]);
2138 return name;
2139 } else {
2140 return val;
2141 }
2142 }
2143}; // This is a map from Aphrodite's generated class names to `true` (acting as a
2144// set of class names)
2145
2146var alreadyInjected = {}; // This is the buffer of styles which have not yet been flushed.
2147
2148var injectionBuffer
2149/* : string[] */
2150= []; // A flag to tell if we are already buffering styles. This could happen either
2151// because we scheduled a flush call already, so newly added styles will
2152// already be flushed, or because we are statically buffering on the server.
2153
2154var isBuffering = false;
2155
2156var injectGeneratedCSSOnce = function injectGeneratedCSSOnce(key, generatedCSS) {
2157 var _injectionBuffer;
2158
2159 if (alreadyInjected[key]) {
2160 return;
2161 }
2162
2163 if (!isBuffering) {
2164 // We should never be automatically buffering on the server (or any
2165 // place without a document), so guard against that.
2166 if (typeof document === "undefined") {
2167 throw new Error("Cannot automatically buffer without a document");
2168 } // If we're not already buffering, schedule a call to flush the
2169 // current styles.
2170
2171
2172 isBuffering = true;
2173 browserAsap(flushToStyleTag);
2174 }
2175
2176 (_injectionBuffer = injectionBuffer).push.apply(_injectionBuffer, _toConsumableArray(generatedCSS));
2177
2178 alreadyInjected[key] = true;
2179};
2180
2181var injectStyleOnce = function injectStyleOnce(key
2182/* : string */
2183, selector
2184/* : string */
2185, definitions
2186/* : SheetDefinition[] */
2187, useImportant
2188/* : boolean */
2189) {
2190 var selectorHandlers
2191 /* : SelectorHandler[] */
2192 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
2193
2194 if (alreadyInjected[key]) {
2195 return;
2196 }
2197
2198 var generated = generateCSS(selector, definitions, selectorHandlers, stringHandlers, useImportant);
2199 injectGeneratedCSSOnce(key, generated);
2200};
2201var reset = function reset() {
2202 injectionBuffer = [];
2203 alreadyInjected = {};
2204 isBuffering = false;
2205 styleTag = null;
2206};
2207var resetInjectedStyle = function resetInjectedStyle(key
2208/* : string */
2209) {
2210 delete alreadyInjected[key];
2211};
2212var startBuffering = function startBuffering() {
2213 if (isBuffering) {
2214 throw new Error("Cannot buffer while already buffering");
2215 }
2216
2217 isBuffering = true;
2218};
2219
2220var flushToArray = function flushToArray() {
2221 isBuffering = false;
2222 var ret = injectionBuffer;
2223 injectionBuffer = [];
2224 return ret;
2225};
2226
2227var flushToString = function flushToString() {
2228 return flushToArray().join('');
2229};
2230var flushToStyleTag = function flushToStyleTag() {
2231 var cssRules = flushToArray();
2232
2233 if (cssRules.length > 0) {
2234 injectStyleTag(cssRules);
2235 }
2236};
2237var getRenderedClassNames = function getRenderedClassNames()
2238/* : string[] */
2239{
2240 return Object.keys(alreadyInjected);
2241};
2242var addRenderedClassNames = function addRenderedClassNames(classNames
2243/* : string[] */
2244) {
2245 classNames.forEach(function (className) {
2246 alreadyInjected[className] = true;
2247 });
2248};
2249
2250var isValidStyleDefinition = function isValidStyleDefinition(def
2251/* : Object */
2252) {
2253 return "_definition" in def && "_name" in def && "_len" in def;
2254};
2255
2256var processStyleDefinitions = function processStyleDefinitions(styleDefinitions
2257/* : any[] */
2258, classNameBits
2259/* : string[] */
2260, definitionBits
2261/* : Object[] */
2262, length
2263/* : number */
2264)
2265/* : number */
2266{
2267 for (var i = 0; i < styleDefinitions.length; i += 1) {
2268 // Filter out falsy values from the input, to allow for
2269 // `css(a, test && c)`
2270 if (styleDefinitions[i]) {
2271 if (Array.isArray(styleDefinitions[i])) {
2272 // We've encountered an array, so let's recurse
2273 length += processStyleDefinitions(styleDefinitions[i], classNameBits, definitionBits, length);
2274 } else if (isValidStyleDefinition(styleDefinitions[i])) {
2275 classNameBits.push(styleDefinitions[i]._name);
2276 definitionBits.push(styleDefinitions[i]._definition);
2277 length += styleDefinitions[i]._len;
2278 } else {
2279 throw new Error("Invalid Style Definition: Styles should be defined using the StyleSheet.create method.");
2280 }
2281 }
2282 }
2283
2284 return length;
2285};
2286/**
2287 * Inject styles associated with the passed style definition objects, and return
2288 * an associated CSS class name.
2289 *
2290 * @param {boolean} useImportant If true, will append !important to generated
2291 * CSS output. e.g. {color: red} -> "color: red !important".
2292 * @param {(Object|Object[])[]} styleDefinitions style definition objects, or
2293 * arbitrarily nested arrays of them, as returned as properties of the
2294 * return value of StyleSheet.create().
2295 */
2296
2297
2298var injectAndGetClassName = function injectAndGetClassName(useImportant
2299/* : boolean */
2300, styleDefinitions
2301/* : MaybeSheetDefinition[] */
2302, selectorHandlers
2303/* : SelectorHandler[] */
2304)
2305/* : string */
2306{
2307 var classNameBits = [];
2308 var definitionBits = []; // Mutates classNameBits and definitionBits and returns a length which we
2309 // will append to the hash to decrease the chance of hash collisions.
2310
2311 var length = processStyleDefinitions(styleDefinitions, classNameBits, definitionBits, 0); // Break if there aren't any valid styles.
2312
2313 if (classNameBits.length === 0) {
2314 return "";
2315 }
2316
2317 var className;
2318
2319 {
2320 className = classNameBits.length === 1 ? "_".concat(classNameBits[0]) : "_".concat(hashString(classNameBits.join())).concat((length % 36).toString(36));
2321 }
2322
2323 injectStyleOnce(className, ".".concat(className), definitionBits, useImportant, selectorHandlers);
2324 return className;
2325};
2326
2327/* ::
2328import type { SelectorHandler } from './generate.js';
2329export type SheetDefinition = { [id:string]: any };
2330export type SheetDefinitions = SheetDefinition | SheetDefinition[];
2331type RenderFunction = () => string;
2332type Extension = {
2333 selectorHandler: SelectorHandler
2334};
2335export type MaybeSheetDefinition = SheetDefinition | false | null | void
2336*/
2337
2338var unminifiedHashFn = function unminifiedHashFn(str
2339/* : string */
2340, key
2341/* : string */
2342) {
2343 return "".concat(key, "_").concat(hashString(str));
2344}; // StyleSheet.create is in a hot path so we want to keep as much logic out of it
2345// as possible. So, we figure out which hash function to use once, and only
2346// switch it out via minify() as necessary.
2347//
2348// This is in an exported function to make it easier to test.
2349
2350
2351var initialHashFn = function initialHashFn() {
2352 return hashString;
2353};
2354var hashFn = initialHashFn();
2355var StyleSheet = {
2356 create: function create(sheetDefinition
2357 /* : SheetDefinition */
2358 )
2359 /* : Object */
2360 {
2361 var mappedSheetDefinition = {};
2362 var keys = Object.keys(sheetDefinition);
2363
2364 for (var i = 0; i < keys.length; i += 1) {
2365 var key = keys[i];
2366 var val = sheetDefinition[key];
2367 var stringVal = JSON.stringify(val);
2368 mappedSheetDefinition[key] = {
2369 _len: stringVal.length,
2370 _name: hashFn(stringVal, key),
2371 _definition: val
2372 };
2373 }
2374
2375 return mappedSheetDefinition;
2376 },
2377 rehydrate: function rehydrate() {
2378 var renderedClassNames
2379 /* : string[] */
2380 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2381 addRenderedClassNames(renderedClassNames);
2382 }
2383};
2384/**
2385 * Utilities for using Aphrodite server-side.
2386 *
2387 * This can be minified out in client-only bundles by replacing `typeof window`
2388 * with `"object"`, e.g. via Webpack's DefinePlugin:
2389 *
2390 * new webpack.DefinePlugin({
2391 * "typeof window": JSON.stringify("object")
2392 * })
2393 */
2394
2395var StyleSheetServer = typeof window !== 'undefined' ? null : {
2396 renderStatic: function renderStatic(renderFunc
2397 /* : RenderFunction */
2398 ) {
2399 reset();
2400 startBuffering();
2401 var html = renderFunc();
2402 var cssContent = flushToString();
2403 return {
2404 html: html,
2405 css: {
2406 content: cssContent,
2407 renderedClassNames: getRenderedClassNames()
2408 }
2409 };
2410 }
2411};
2412/**
2413 * Utilities for using Aphrodite in tests.
2414 *
2415 * Not meant to be used in production.
2416 */
2417
2418var StyleSheetTestUtils = null;
2419/**
2420 * Generate the Aphrodite API exports, with given `selectorHandlers` and
2421 * `useImportant` state.
2422 */
2423
2424function makeExports(useImportant
2425/* : boolean */
2426) {
2427 var selectorHandlers
2428 /* : SelectorHandler[] */
2429 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultSelectorHandlers;
2430 return {
2431 StyleSheet: _objectSpread({}, StyleSheet, {
2432 /**
2433 * Returns a version of the exports of Aphrodite (i.e. an object
2434 * with `css` and `StyleSheet` properties) which have some
2435 * extensions included.
2436 *
2437 * @param {Array.<Object>} extensions: An array of extensions to
2438 * add to this instance of Aphrodite. Each object should have a
2439 * single property on it, defining which kind of extension to
2440 * add.
2441 * @param {SelectorHandler} [extensions[].selectorHandler]: A
2442 * selector handler extension. See `defaultSelectorHandlers` in
2443 * generate.js.
2444 *
2445 * @returns {Object} An object containing the exports of the new
2446 * instance of Aphrodite.
2447 */
2448 extend: function extend(extensions
2449 /* : Extension[] */
2450 ) {
2451 var extensionSelectorHandlers = extensions // Pull out extensions with a selectorHandler property
2452 .map(function (extension) {
2453 return extension.selectorHandler;
2454 }) // Remove nulls (i.e. extensions without a selectorHandler property).
2455 .filter(function (handler) {
2456 return handler;
2457 });
2458 return makeExports(useImportant, selectorHandlers.concat(extensionSelectorHandlers));
2459 }
2460 }),
2461 StyleSheetServer: StyleSheetServer,
2462 StyleSheetTestUtils: StyleSheetTestUtils,
2463 minify: function minify(shouldMinify
2464 /* : boolean */
2465 ) {
2466 hashFn = shouldMinify ? hashString : unminifiedHashFn;
2467 },
2468 css: function css()
2469 /* : MaybeSheetDefinition[] */
2470 {
2471 for (var _len = arguments.length, styleDefinitions = new Array(_len), _key = 0; _key < _len; _key++) {
2472 styleDefinitions[_key] = arguments[_key];
2473 }
2474
2475 return injectAndGetClassName(useImportant, styleDefinitions, selectorHandlers);
2476 },
2477 flushToStyleTag: flushToStyleTag,
2478 injectAndGetClassName: injectAndGetClassName,
2479 defaultSelectorHandlers: defaultSelectorHandlers,
2480 reset: reset,
2481 resetInjectedStyle: resetInjectedStyle
2482 };
2483}
2484
2485var useImportant = true; // Add !important to all style definitions
2486
2487var Aphrodite = makeExports(useImportant);
2488var StyleSheet$1 = Aphrodite.StyleSheet,
2489 StyleSheetServer$1 = Aphrodite.StyleSheetServer,
2490 StyleSheetTestUtils$1 = Aphrodite.StyleSheetTestUtils,
2491 css = Aphrodite.css,
2492 minify = Aphrodite.minify,
2493 flushToStyleTag$1 = Aphrodite.flushToStyleTag,
2494 injectAndGetClassName$1 = Aphrodite.injectAndGetClassName,
2495 defaultSelectorHandlers$1 = Aphrodite.defaultSelectorHandlers,
2496 reset$1 = Aphrodite.reset,
2497 resetInjectedStyle$1 = Aphrodite.resetInjectedStyle;
2498
2499exports.StyleSheet = StyleSheet$1;
2500exports.StyleSheetServer = StyleSheetServer$1;
2501exports.StyleSheetTestUtils = StyleSheetTestUtils$1;
2502exports.css = css;
2503exports.minify = minify;
2504exports.flushToStyleTag = flushToStyleTag$1;
2505exports.injectAndGetClassName = injectAndGetClassName$1;
2506exports.defaultSelectorHandlers = defaultSelectorHandlers$1;
2507exports.reset = reset$1;
2508exports.resetInjectedStyle = resetInjectedStyle$1;