sw-ui-controls
Version:
SW UI controls for rapid development
1,435 lines (1,270 loc) • 1.11 MB
JavaScript
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React$1 = require('react');
var React$1__default = _interopDefault(React$1);
var reactFontawesome = require('@fortawesome/react-fontawesome');
var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
var moment = _interopDefault(require('moment'));
var faFolderOpen = require('@fortawesome/free-solid-svg-icons/faFolderOpen');
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
t && (r = t);
var o = 0;
return function () {
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _objectWithoutPropertiesLoose(r, e) {
if (null == r) return {};
var t = {};
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
if (e.includes(n)) continue;
t[n] = r[n];
}
return t;
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
var ButtonStyle = {"swbutton":"_1GaQl","spinner_icon":"_RHwR3","spin":"_1308w"};
var _excluded = ["isLoading"];
var Button = React$1.forwardRef(function (props, ref) {
var isLoading = props.isLoading,
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
return /*#__PURE__*/React$1__default.createElement("button", _extends({}, otherProps, {
className: props.className + " " + ButtonStyle.swbutton,
ref: ref,
disabled: isLoading ? true : props === null || props === void 0 ? void 0 : props.disabled
}), props.children, isLoading && /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faSpinner,
className: ButtonStyle.spinner_icon
}));
});
var CardStyle = {"sw_card":"_2WMWq","sw_card_header":"_1uqqJ","sw_card_footer":"___NBr","sw_card_body":"_XcDw_","sw_card_media":"_2Xf_W"};
var Card = React$1.forwardRef(function (props, ref) {
return /*#__PURE__*/React$1__default.createElement("div", _extends({
className: CardStyle.sw_card,
ref: ref
}, props), props.children);
});
function CardBody(props) {
return /*#__PURE__*/React$1__default.createElement("div", _extends({
className: CardStyle.sw_card_body
}, props), props.children);
}
function CardFooter(props) {
return /*#__PURE__*/React$1__default.createElement("div", _extends({
className: CardStyle.sw_card_footer
}, props), props.children);
}
function CardHeader(props) {
return /*#__PURE__*/React$1__default.createElement("div", _extends({
className: CardStyle.sw_card_header
}, props), props.children);
}
function CardMedia(props) {
return /*#__PURE__*/React$1__default.createElement("div", _extends({
className: CardStyle.sw_card_media
}, props), props.children);
}
var CheckBoxStyle = {"sw_checkbox":"_3j-Fv"};
var _excluded$1 = ["label", "icon"];
var CheckBox = React$1.forwardRef(function (props, ref) {
var label = props.label,
icon = props.icon,
otherprops = _objectWithoutPropertiesLoose(props, _excluded$1);
var style = otherprops.style;
if (style && icon) {
style["display"] = "none";
otherprops["style"] = style;
}
if (!style && icon) {
style = {
display: "none"
};
otherprops["style"] = style;
}
var id = React$1.useId();
return /*#__PURE__*/React$1__default.createElement("div", {
className: CheckBoxStyle.sw_checkbox
}, /*#__PURE__*/React$1__default.createElement("label", {
htmlFor: id
}, label, icon && /*#__PURE__*/React$1__default.createElement(React$1.Fragment, null, "\xA0 ", /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: icon
}))), /*#__PURE__*/React$1__default.createElement("input", _extends({
type: "checkbox"
}, otherprops, {
ref: ref,
id: id
})));
});
function validator(_ref) {
var required = _ref.required,
min = _ref.min,
max = _ref.max,
pattern = _ref.pattern,
minLength = _ref.minLength,
maxLength = _ref.maxLength,
value = _ref.value;
var errors = {
required: false,
pattern: false,
min: false,
max: false,
minLength: false,
maxLength: false
};
var isString = function isString() {
return isNaN(value);
};
var isNumber = function isNumber() {
return !isNaN(value);
};
var validate = function validate() {
if (required) {
errors.required = !value ? true : false;
}
if (pattern && value) {
var p = pattern.replace("/", "'");
if (isString()) {
errors.pattern = !value.match(new RegExp(p)) ? true : false;
}
}
if (min) {
errors.min = isNumber() && value < min ? true : false;
}
if (max) {
errors.max = isNumber() && value > max ? true : false;
}
if (minLength) {
errors.minLength = isString() && !value || value.length < minLength ? true : false;
}
if (maxLength) {
errors.maxLength = isString() && (value === null || value === void 0 ? void 0 : value.length) > maxLength ? true : false;
}
return errors;
};
return validate();
}
var _excluded$2 = ["value"];
function useFormGroup(props) {
var _useState = React$1.useState({}),
form = _useState[0],
updateForm = _useState[1];
var formvalidator = props.formvalidator;
var formValue = React$1.useMemo(function () {
return Object.keys(form).map(function (control) {
var _form$control$value, _form$control, _ref;
return _ref = {}, _ref[control] = (_form$control$value = (_form$control = form[control]) === null || _form$control === void 0 ? void 0 : _form$control.value) != null ? _form$control$value : "", _ref;
}).reduce(function (prev, item) {
return _extends({}, prev, item);
}, {});
}, [form]);
var formError = React$1.useMemo(function () {
if (!formvalidator) return null;
if (formvalidator instanceof Array && (formvalidator === null || formvalidator === void 0 ? void 0 : formvalidator.length) === 0) return null;
for (var _iterator = _createForOfIteratorHelperLoose(formvalidator), _step; !(_step = _iterator()).done;) {
var _validator = _step.value;
var error = _validator(formValue);
if (error && error instanceof Array && (error === null || error === void 0 ? void 0 : error.length) >= 1) {
return error[1];
}
}
return null;
}, [formValue, formvalidator]);
var valid = React$1.useMemo(function () {
var isValid = Object.keys(form).every(function (control) {
var errors = form[control].errors;
if (errors) {
return Object.values(errors).every(function (error) {
return error === false;
});
}
return true;
});
return isValid && !formError;
}, [form, formError]);
var updateControlValidation = function updateControlValidation(v, props) {
if (v === void 0) {
v = "";
}
var otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
return {
value: v,
errors: validator(_extends({
value: v
}, otherProps))
};
};
React$1.useEffect(function () {
var children = props.children;
var formState = {};
React$1__default.Children.forEach(children, function (child, index) {
var _child$props = child.props,
name = _child$props.name,
value = _child$props.value;
if (name) {
formState[name] = updateControlValidation(value != null ? value : "", child.props);
}
});
updateForm(_extends({}, formState));
}, [props]);
var updateFormValidation = function updateFormValidation(props, value) {
form[props.name] = updateControlValidation(value, props);
updateForm(_extends({}, form));
};
return _extends({}, props, {
form: form,
updateForm: updateFormValidation,
valid: valid,
formValue: formValue,
formError: formError
});
}
var FormContext = React$1.createContext();
function FormButton(buttonProps) {
var _useContext = React$1.useContext(FormContext),
valid = _useContext.valid;
return /*#__PURE__*/React$1__default.createElement("div", {
className: "flex-row center-items"
}, /*#__PURE__*/React$1__default.createElement(Button, _extends({}, buttonProps, {
disabled: !valid,
type: "submit"
})));
}
function FormGroup(props) {
var updatedProps = useFormGroup(props);
var _onSubmit = updatedProps.onSubmit,
children = updatedProps.children,
formValue = updatedProps.formValue,
formError = updatedProps.formError;
return /*#__PURE__*/React$1__default.createElement(FormContext.Provider, {
value: updatedProps
}, /*#__PURE__*/React$1__default.createElement("form", _extends({}, props, {
onSubmit: function onSubmit(e) {
e.preventDefault();
_onSubmit(formValue);
}
}), children, /*#__PURE__*/React$1__default.createElement("p", {
className: "error"
}, formError)));
}
var InputStyle = {"error":"_50bpz","sw_input_control":"_RQhoA","focused":"_Rter0","blurred":"_2trDv","pass_icon":"_3ln_B"};
var _excluded$3 = ["label"];
var Input = React$1.forwardRef(function (props, ref) {
if (!ref) {
ref = React$1.createRef();
}
var label = props.label,
otherprops = _objectWithoutPropertiesLoose(props, _excluded$3);
var errors = validator(otherprops);
var error = Object.keys(errors).find(function (key) {
return !!errors[key];
});
var _useState = React$1.useState(false),
isTouched = _useState[0],
markAsTouched = _useState[1];
var _useState2 = React$1.useState(false),
showPassword = _useState2[0],
togglePassword = _useState2[1];
React$1.useEffect(function () {
if (ref && ref.current) {
var _ref, _ref$current2;
var _handleKeyDown = function handleKeyDown() {
var _ref$current;
markAsTouched(true);
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.removeEventListener("keydown", _handleKeyDown);
};
(_ref = ref) === null || _ref === void 0 ? void 0 : (_ref$current2 = _ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.addEventListener("keydown", _handleKeyDown);
}
}, [ref]);
return /*#__PURE__*/React$1__default.createElement("div", {
className: InputStyle.sw_input_control + " " + (error && isTouched ? error + "_error error" : "")
}, /*#__PURE__*/React$1__default.createElement("label", null, label), /*#__PURE__*/React$1__default.createElement("div", {
style: {
position: "relative"
}
}, (otherprops === null || otherprops === void 0 ? void 0 : otherprops.type) !== "password" && otherprops.type !== "textarea" && /*#__PURE__*/React$1__default.createElement("input", _extends({}, otherprops, {
ref: ref
})), (otherprops === null || otherprops === void 0 ? void 0 : otherprops.type) === "textarea" && /*#__PURE__*/React$1__default.createElement("textarea", _extends({}, otherprops, {
ref: ref
})), (otherprops === null || otherprops === void 0 ? void 0 : otherprops.type) === "password" && /*#__PURE__*/React$1__default.createElement("input", _extends({}, otherprops, {
type: showPassword ? "text" : "password",
ref: ref
})), (otherprops === null || otherprops === void 0 ? void 0 : otherprops.type) === "password" && (showPassword ? /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faEyeSlash,
className: InputStyle.pass_icon,
onClick: function onClick() {
return togglePassword(!showPassword);
}
}) : /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faEye,
className: InputStyle.pass_icon,
onClick: function onClick() {
return togglePassword(!showPassword);
}
}))), error && isTouched && /*#__PURE__*/React$1__default.createElement("p", {
className: "error control-error"
}, "Error : ", error));
});
var SelectStyle = {"error":"_scIHa","sw_select":"_3vfOT","focused":"_2ZqVg","blurred":"_Q4Tsd"};
var _excluded$4 = ["label", "config"];
var Select = React$1.forwardRef(function (props, ref) {
if (!ref) {
ref = React$1.createRef();
}
var label = props.label,
config = props.config,
otherprops = _objectWithoutPropertiesLoose(props, _excluded$4);
var errors = validator(otherprops);
var error = Object.keys(errors).find(function (key) {
return !!errors[key];
});
var _useState = React$1.useState(false),
isTouched = _useState[0],
markAsTouched = _useState[1];
React$1.useEffect(function () {
if (ref && ref.current) {
var _ref, _ref$current2;
var _handleKeyDown = function handleKeyDown() {
var _ref$current;
markAsTouched(true);
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.removeEventListener("keydown", _handleKeyDown);
};
(_ref = ref) === null || _ref === void 0 ? void 0 : (_ref$current2 = _ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.addEventListener("keydown", _handleKeyDown);
}
}, [ref]);
var items = props.items;
var displayName = null,
value = null;
if (config) {
displayName = config.displayName;
value = config.value;
}
var nullValueOption = /*#__PURE__*/React$1__default.createElement("option", {
value: ""
}, "None");
var optionTemplate = /*#__PURE__*/React$1__default.createElement(React$1.Fragment, null, nullValueOption, props.children);
if (items && items instanceof Array && config && displayName && value) {
optionTemplate = items.map(function (item) {
return /*#__PURE__*/React$1__default.createElement("option", {
key: item[value],
value: item[value]
}, item[displayName]);
});
optionTemplate = [nullValueOption].concat(optionTemplate);
} else if (items && items instanceof Array && items.length >= 0) {
optionTemplate = items.map(function (item) {
return /*#__PURE__*/React$1__default.createElement("option", {
key: item,
value: item
}, item);
});
optionTemplate = [nullValueOption].concat(optionTemplate);
}
return /*#__PURE__*/React$1__default.createElement("div", {
className: SelectStyle.sw_select + " " + (error && isTouched ? error + "_error error" : "")
}, /*#__PURE__*/React$1__default.createElement("label", null, label), /*#__PURE__*/React$1__default.createElement("div", {
style: {
position: "relative"
}
}, /*#__PURE__*/React$1__default.createElement("select", _extends({}, otherprops, {
ref: ref
}), optionTemplate)), error && isTouched && /*#__PURE__*/React$1__default.createElement("p", {
className: "error control-error"
}, "Error : ", error));
});
var HtmlEditorStyle = {"sw_html_editor":"_21lFc","toolbar":"_3Rz-G","window":"_sP5yG","editor":"_qP5kt","preview":"_2MWdB","sw_html_editor_label":"_2VAj8"};
var _excluded$5 = ["getContents"];
var HtmlEditor = React$1.forwardRef(function (props, ref) {
var getContents = props.getContents,
otherProps = _objectWithoutPropertiesLoose(props, _excluded$5);
var label = otherProps.label,
value = otherProps.value;
if (!ref) {
ref = React$1.createRef();
}
React$1.useEffect(function () {
if (value) {
ref.current.innerHTML = value;
}
}, [value]);
var _useState = React$1.useState(value),
content = _useState[0],
setContent = _useState[1];
var handleInputChange = function handleInputChange(e) {
var _e$currentTarget;
setContent(e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.innerHTML);
};
React$1.useEffect(function () {
if (getContents && typeof getContents === "function") {
getContents(content);
}
}, [content]);
var handleCommand = function handleCommand(command, value) {
if (value === void 0) {
value = null;
}
document.execCommand(command, false, value);
setContent(ref.current.innerHTML);
};
return /*#__PURE__*/React$1__default.createElement(React$1.Fragment, null, /*#__PURE__*/React$1__default.createElement("label", {
className: HtmlEditorStyle.sw_html_editor_label
}, label), /*#__PURE__*/React$1__default.createElement("div", _extends({
className: HtmlEditorStyle.sw_html_editor
}, otherProps), /*#__PURE__*/React$1__default.createElement("div", {
className: HtmlEditorStyle.toolbar
}, /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("bold");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faBold
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("italic");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faItalic
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("underline");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faUnderline
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("insertOrderedList");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faList12
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("insertUnorderedList");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faList
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("justifyLeft");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faAlignLeft
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("justifyCenter");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faAlignCenter
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("justifyRight");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faAlignRight
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("foreColor", "red");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faBrush
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("createLink", prompt("Enter the URL:"));
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faLink
})), /*#__PURE__*/React$1__default.createElement(Button, {
onClick: function onClick() {
return handleCommand("unlink");
},
type: "button"
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faUnlink
}))), /*#__PURE__*/React$1__default.createElement("div", {
className: HtmlEditorStyle.window
}, /*#__PURE__*/React$1__default.createElement("div", {
className: HtmlEditorStyle.editor,
ref: ref,
contentEditable: true,
onInput: handleInputChange
}))));
});
var RatingStyle = {"sw_star_rating":"_Wqqt4","completed":"_2sUzu"};
var StarRating = function StarRating(props) {
var setRating = props.setRating,
rating = props.rating,
min = props.min,
max = props.max,
label = props.label;
var numberOfStars = React$1.useMemo(function () {
var stars = [];
for (var i = min; i <= max; i++) {
stars.push(i);
}
return stars;
}, [min, max]);
var updateRating = function updateRating(rate) {
if (setRating && typeof setRating === "function") {
setRating(rate);
}
};
return /*#__PURE__*/React$1__default.createElement(React$1.Fragment, null, label && /*#__PURE__*/React$1__default.createElement("div", {
style: {
marginBottom: "8px"
}
}, /*#__PURE__*/React$1__default.createElement("label", null, label), /*#__PURE__*/React$1__default.createElement("br", null)), /*#__PURE__*/React$1__default.createElement("div", {
className: RatingStyle.sw_star_rating
}, numberOfStars.map(function (star, index) {
return /*#__PURE__*/React$1__default.createElement(React$1__default.Fragment, {
key: "" + star
}, /*#__PURE__*/React$1__default.createElement(reactFontawesome.FontAwesomeIcon, {
icon: freeSolidSvgIcons.faStar,
onClick: function onClick() {
return updateRating(star);
},
className: star <= rating ? RatingStyle.completed : "",
title: "" + star
}), "\xA0");
})));
};
var FileUploaderStyle = {"sw_file_uploader":"_2qzJ5","sw_file_uploader_drag_drop":"_2owhk","sw_preview_images":"_30Se6","sw_file_list":"_22Keb","sw_drop_zone":"_1Afe-","sw_preview_image":"_I3tU2"};
var ModalStyle = {"MODAL_STYLES":"_1ej_m","OVERLAY_STYLES":"_1lTGa","CONTENT_WRAPPER_STYLES":"_SwBYy","BACKGROUND_STYLES":"_BUAhm"};
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
var scheduler_production_min = createCommonjsModule(function (module, exports) {
var f,g,h,k,l;
if("undefined"===typeof window||"function"!==typeof MessageChannel){var p=null,q=null,t=function(){if(null!==p)try{var a=exports.unstable_now();p(!0,a);p=null;}catch(b){throw setTimeout(t,0),b;}},u=Date.now();exports.unstable_now=function(){return Date.now()-u};f=function(a){null!==p?setTimeout(f,0,a):(p=a,setTimeout(t,0));};g=function(a,b){q=setTimeout(a,b);};h=function(){clearTimeout(q);};k=function(){return !1};l=exports.unstable_forceFrameRate=function(){};}else {var w=window.performance,x=window.Date,
y=window.setTimeout,z=window.clearTimeout;if("undefined"!==typeof console){var A=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills");"function"!==typeof A&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills");}if("object"===
typeof w&&"function"===typeof w.now)exports.unstable_now=function(){return w.now()};else {var B=x.now();exports.unstable_now=function(){return x.now()-B};}var C=!1,D=null,E=-1,F=5,G=0;k=function(){return exports.unstable_now()>=G};l=function(){};exports.unstable_forceFrameRate=function(a){0>a||125<a?console.error("forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported"):F=0<a?Math.floor(1E3/a):5;};var H=new MessageChannel,I=H.port2;H.port1.onmessage=
function(){if(null!==D){var a=exports.unstable_now();G=a+F;try{D(!0,a)?I.postMessage(null):(C=!1,D=null);}catch(b){throw I.postMessage(null),b;}}else C=!1;};f=function(a){D=a;C||(C=!0,I.postMessage(null));};g=function(a,b){E=y(function(){a(exports.unstable_now());},b);};h=function(){z(E);E=-1;};}function J(a,b){var c=a.length;a.push(b);a:for(;;){var d=c-1>>>1,e=a[d];if(void 0!==e&&0<K(e,b))a[d]=b,a[c]=e,c=d;else break a}}function L(a){a=a[0];return void 0===a?null:a}
function M(a){var b=a[0];if(void 0!==b){var c=a.pop();if(c!==b){a[0]=c;a:for(var d=0,e=a.length;d<e;){var m=2*(d+1)-1,n=a[m],v=m+1,r=a[v];if(void 0!==n&&0>K(n,c))void 0!==r&&0>K(r,n)?(a[d]=r,a[v]=c,d=v):(a[d]=n,a[m]=c,d=m);else if(void 0!==r&&0>K(r,c))a[d]=r,a[v]=c,d=v;else break a}}return b}return null}function K(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}var N=[],O=[],P=1,Q=null,R=3,S=!1,T=!1,U=!1;
function V(a){for(var b=L(O);null!==b;){if(null===b.callback)M(O);else if(b.startTime<=a)M(O),b.sortIndex=b.expirationTime,J(N,b);else break;b=L(O);}}function W(a){U=!1;V(a);if(!T)if(null!==L(N))T=!0,f(X);else {var b=L(O);null!==b&&g(W,b.startTime-a);}}
function X(a,b){T=!1;U&&(U=!1,h());S=!0;var c=R;try{V(b);for(Q=L(N);null!==Q&&(!(Q.expirationTime>b)||a&&!k());){var d=Q.callback;if(null!==d){Q.callback=null;R=Q.priorityLevel;var e=d(Q.expirationTime<=b);b=exports.unstable_now();"function"===typeof e?Q.callback=e:Q===L(N)&&M(N);V(b);}else M(N);Q=L(N);}if(null!==Q)var m=!0;else {var n=L(O);null!==n&&g(W,n.startTime-b);m=!1;}return m}finally{Q=null,R=c,S=!1;}}
function Y(a){switch(a){case 1:return -1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}var Z=l;exports.unstable_IdlePriority=5;exports.unstable_ImmediatePriority=1;exports.unstable_LowPriority=4;exports.unstable_NormalPriority=3;exports.unstable_Profiling=null;exports.unstable_UserBlockingPriority=2;exports.unstable_cancelCallback=function(a){a.callback=null;};exports.unstable_continueExecution=function(){T||S||(T=!0,f(X));};
exports.unstable_getCurrentPriorityLevel=function(){return R};exports.unstable_getFirstCallbackNode=function(){return L(N)};exports.unstable_next=function(a){switch(R){case 1:case 2:case 3:var b=3;break;default:b=R;}var c=R;R=b;try{return a()}finally{R=c;}};exports.unstable_pauseExecution=function(){};exports.unstable_requestPaint=Z;exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3;}var c=R;R=a;try{return b()}finally{R=c;}};
exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();if("object"===typeof c&&null!==c){var e=c.delay;e="number"===typeof e&&0<e?d+e:d;c="number"===typeof c.timeout?c.timeout:Y(a);}else c=Y(a),e=d;c=e+c;a={id:P++,callback:b,priorityLevel:a,startTime:e,expirationTime:c,sortIndex:-1};e>d?(a.sortIndex=e,J(O,a),null===L(N)&&a===L(O)&&(U?h():U=!0,g(W,e-d))):(a.sortIndex=c,J(N,a),T||S||(T=!0,f(X)));return a};
exports.unstable_shouldYield=function(){var a=exports.unstable_now();V(a);var b=L(N);return b!==Q&&null!==Q&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime<Q.expirationTime||k()};exports.unstable_wrapCallback=function(a){var b=R;return function(){var c=R;R=b;try{return a.apply(this,arguments)}finally{R=c;}}};
});
var scheduler_development = createCommonjsModule(function (module, exports) {
if (process.env.NODE_ENV !== "production") {
(function() {
var enableSchedulerDebugging = false;
var enableProfiling = true;
var requestHostCallback;
var requestHostTimeout;
var cancelHostTimeout;
var shouldYieldToHost;
var requestPaint;
if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive
// implementation using setTimeout.
typeof window === 'undefined' || // Check if MessageChannel is supported, too.
typeof MessageChannel !== 'function') {
// If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
// fallback to a naive implementation.
var _callback = null;
var _timeoutID = null;
var _flushCallback = function () {
if (_callback !== null) {
try {
var currentTime = exports.unstable_now();
var hasRemainingTime = true;
_callback(hasRemainingTime, currentTime);
_callback = null;
} catch (e) {
setTimeout(_flushCallback, 0);
throw e;
}
}
};
var initialTime = Date.now();
exports.unstable_now = function () {
return Date.now() - initialTime;
};
requestHostCallback = function (cb) {
if (_callback !== null) {
// Protect against re-entrancy.
setTimeout(requestHostCallback, 0, cb);
} else {
_callback = cb;
setTimeout(_flushCallback, 0);
}
};
requestHostTimeout = function (cb, ms) {
_timeoutID = setTimeout(cb, ms);
};
cancelHostTimeout = function () {
clearTimeout(_timeoutID);
};
shouldYieldToHost = function () {
return false;
};
requestPaint = exports.unstable_forceFrameRate = function () {};
} else {
// Capture local references to native APIs, in case a polyfill overrides them.
var performance = window.performance;
var _Date = window.Date;
var _setTimeout = window.setTimeout;
var _clearTimeout = window.clearTimeout;
if (typeof console !== 'undefined') {
// TODO: Scheduler no longer requires these methods to be polyfilled. But
// maybe we want to continue warning if they don't exist, to preserve the
// option to rely on it in the future?
var requestAnimationFrame = window.requestAnimationFrame;
var cancelAnimationFrame = window.cancelAnimationFrame; // TODO: Remove fb.me link
if (typeof requestAnimationFrame !== 'function') {
// Using console['error'] to evade Babel and ESLint
console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
if (typeof cancelAnimationFrame !== 'function') {
// Using console['error'] to evade Babel and ESLint
console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
}
if (typeof performance === 'object' && typeof performance.now === 'function') {
exports.unstable_now = function () {
return performance.now();
};
} else {
var _initialTime = _Date.now();
exports.unstable_now = function () {
return _Date.now() - _initialTime;
};
}
var isMessageLoopRunning = false;
var scheduledHostCallback = null;
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
// thread, like user events. By default, it yields multiple times per frame.
// It does not attempt to align with frame boundaries, since most tasks don't
// need to be frame aligned; for those that do, use requestAnimationFrame.
var yieldInterval = 5;
var deadline = 0; // TODO: Make this configurable
{
// `isInputPending` is not available. Since we have no way of knowing if
// there's pending input, always yield at the end of the frame.
shouldYieldToHost = function () {
return exports.unstable_now() >= deadline;
}; // Since we yield every frame regardless, `requestPaint` has no effect.
requestPaint = function () {};
}
exports.unstable_forceFrameRate = function (fps) {
if (fps < 0 || fps > 125) {
// Using console['error'] to evade Babel and ESLint
console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported');
return;
}
if (fps > 0) {
yieldInterval = Math.floor(1000 / fps);
} else {
// reset the framerate
yieldInterval = 5;
}
};
var performWorkUntilDeadline = function () {
if (scheduledHostCallback !== null) {
var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync
// cycle. This means there's always time remaining at the beginning of
// the message event.
deadline = currentTime + yieldInterval;
var hasTimeRemaining = true;
try {
var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
if (!hasMoreWork) {
isMessageLoopRunning = false;
scheduledHostCallback = null;
} else {
// If there's more work, schedule the next message event at the end
// of the preceding one.
port.postMessage(null);
}
} catch (error) {
// If a scheduler task throws, exit the current browser task so the
// error can be observed.
port.postMessage(null);
throw error;
}
} else {
isMessageLoopRunning = false;
} // Yielding to the browser will give it a chance to paint, so we can
};
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = performWorkUntilDeadline;
requestHostCallback = function (callback) {
scheduledHostCallback = callback;
if (!isMessageLoopRunning) {
isMessageLoopRunning = true;
port.postMessage(null);
}
};
requestHostTimeout = function (callback, ms) {
taskTimeoutID = _setTimeout(function () {
callback(exports.unstable_now());
}, ms);
};
cancelHostTimeout = function () {
_clearTimeout(taskTimeoutID);
taskTimeoutID = -1;
};
}
function push(heap, node) {
var index = heap.length;
heap.push(node);
siftUp(heap, node, index);
}
function peek(heap) {
var first = heap[0];
return first === undefined ? null : first;
}
function pop(heap) {
var first = heap[0];
if (first !== undefined) {
var last = heap.pop();
if (last !== first) {
heap[0] = last;
siftDown(heap, last, 0);
}
return first;
} else {
return null;
}
}
function siftUp(heap, node, i) {
var index = i;
while (true) {
var parentIndex = index - 1 >>> 1;
var parent = heap[parentIndex];
if (parent !== undefined && compare(parent, node) > 0) {
// The parent is larger. Swap positions.
heap[parentIndex] = node;
heap[index] = parent;
index = parentIndex;
} else {
// The parent is smaller. Exit.
return;
}
}
}
function siftDown(heap, node, i) {
var index = i;
var length = heap.length;
while (index < length) {
var leftIndex = (index + 1) * 2 - 1;
var left = heap[leftIndex];
var rightIndex = leftIndex + 1;
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
if (left !== undefined && compare(left, node) < 0) {
if (right !== undefined && compare(right, left) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
heap[index] = left;
heap[leftIndex] = node;
index = leftIndex;
}
} else if (right !== undefined && compare(right, node) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
// Neither child is smaller. Exit.
return;
}
}
}
function compare(a, b) {
// Compare sort index first, then task id.
var diff = a.sortIndex - b.sortIndex;
return diff !== 0 ? diff : a.id - b.id;
}
// TODO: Use symbols?
var NoPriority = 0;
var ImmediatePriority = 1;
var UserBlockingPriority = 2;
var NormalPriority = 3;
var LowPriority = 4;
var IdlePriority = 5;
var runIdCounter = 0;
var mainThreadIdCounter = 0;
var profilingStateSize = 4;
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
;
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
var PRIORITY = 0;
var CURRENT_TASK_ID = 1;
var CURRENT_RUN_ID = 2;
var QUEUE_SIZE = 3;
{
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
// array might include canceled tasks.
profilingState[QUEUE_SIZE] = 0;
profilingState[CURRENT_TASK_ID] = 0;
} // Bytes per element is 4
var INITIAL_EVENT_LOG_SIZE = 131072;
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
var eventLogSize = 0;
var eventLogBuffer = null;
var eventLog = null;
var eventLogIndex = 0;
var TaskStartEvent = 1;
var TaskCompleteEvent = 2;
var TaskErrorEvent = 3;
var TaskCancelEvent = 4;
var TaskRunEvent = 5;
var TaskYieldEvent = 6;
var SchedulerSuspendEvent = 7;
var SchedulerResumeEvent = 8;
function logEvent(entries) {
if (eventLog !== null) {
var offset = eventLogIndex;
eventLogIndex += entries.length;
if (eventLogIndex + 1 > eventLogSize) {
eventLogSize *= 2;
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
// Using console['error'] to evade Babel and ESLint
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
stopLoggingProfilingEvents();
return;
}
var newEventLog = new Int32Array(eventLogSize * 4);
newEventLog.set(eventLog);
eventLogBuffer = newEventLog.buffer;
eventLog = newEventLog;
}
eventLog.set(entries, offset);
}
}
function startLoggingProfilingEvents() {
eventLogSize = INITIAL_EVENT_LOG_SIZE;
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
eventLog = new Int32Array(eventLogBuffer);
eventLogIndex = 0;
}
function stopLoggingProfilingEvents() {
var buffer = eventLogBuffer;
eventLogSize = 0;
eventLogBuffer = null;
eventLog = null;
eventLogIndex = 0;
return buffer;
}
function markTaskStart(task, ms) {
{
profilingState[QUEUE_SIZE]++;
if (eventLog !== null) {
// performance.now returns a float, representing milliseconds. When the
// event is logged, it's coerced to an int. Convert to microseconds to
// maintain extra degrees of precision.
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
}
}
}
function markTaskCompleted(task, ms) {
{
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
}
}
}
function markTaskCanceled(task, ms) {
{
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCancelEvent, ms * 1000, task.id]);
}
}
}
function markTaskErrored(task, ms) {
{
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskErrorEvent, ms * 1000, task.id]);
}
}
}
function markTaskRun(task, ms) {
{
runIdCounter++;
profilingState[PRIORITY] = task.priorityLevel;
profilingState[CURRENT_TASK_ID] = task.id;
profilingState[CURRENT_RUN_ID] = runIdCounter;
if (eventLog !== null) {
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markTaskYield(task, ms) {
{
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[CURRENT_RUN_ID] = 0;
if (eventLog !== null) {
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markSchedulerSuspended(ms) {
{
mainThreadIdCounter++;
if (eventLog !== null) {
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
function markSchedulerUnsuspended(ms) {
{
if (eventLog !== null) {
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
/* eslint-disable no-var */
// Math.pow(2, 30) - 1
// 0b111111111111111111111111111111
var maxSigned31BitInt = 1073741823; // Times out immediately
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
var USER_BLOCKING_PRIORITY = 250;
var NORMAL_PRIORITY_TIMEOUT = 5000;
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
var taskQueue = [];
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
var currentTask = null;
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
var isPerformingWork = false;
var isHostCallbackScheduled = false;
var isHostTimeoutScheduled = false;
function advanceTimers(currentTime) {
// Check for tasks that are no longer delayed and add them to the queue.
var timer = peek(timerQueue);
while (timer !== null) {
if (timer.callback === null) {
// Timer was cancelled.
pop(timerQueue);
} else if (timer.startTime <= currentTime) {
// Timer fired. Transfer to the task queue.
pop(timerQueue);
timer.sortIndex = timer.expirationTime;
push(taskQueue, timer);
{
markTaskStart(timer, currentTime);
timer.isQueued = true;
}
} else {
// Remaining timers are pending.
return;
}
timer = peek(timerQueue);
}
}
function handleTimeout(currentTime) {
isHostTimeoutScheduled = false;
advanceTimers(currentTime);
if (!isHostCallbackScheduled) {
if (peek(taskQueue) !== null) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
} else {
var firstTimer = peek(timerQueue);
if (firstTimer !== null) {
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
}
}
}
}
function flushWork(hasTimeRemaining, initialTime) {
{
markSchedulerUnsuspended(initialTime);
} // We'll need a host callback the next time work is scheduled.
isHostCallbackScheduled = false;
if (isHostTimeoutScheduled) {
// We scheduled a timeout but it's no longer needed. Cancel it.
isHostTimeoutScheduled = false;
cancelHostTimeout();
}
isPerformingWork = true;
var previousPriorityLevel = currentPriorityLevel;
try {
if (enableProfiling) {
try {
return workLoop(hasTimeRemaining, initialTime);
} catch (error) {
if (currentTask !== null) {
var currentTime = exports.unstable_now();
markTaskErrored(currentTask, currentTime);
currentTask.isQueued = false;
}
throw error;
}
} else {
// No catch in prod codepath.
return workLoop(hasTimeRemaining, initialTime);
}
} finally {
currentTask = null;
currentPriorityLevel = previousPriorityLevel;
isPerformingWork = false;
{
var _currentTime = exports.unstable_now();
markSchedulerSuspended(_currentTime);
}
}
}
function workLoop(hasTimeRemaining, initialTime) {
var currentTime = initialTime;
advanceTimers(currentTime);
currentTask = peek(taskQueue);
while (currentTask !== null && !(enableSchedulerDebugging )) {
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
// This currentTask hasn't expired, and we've reached the deadline.
break;
}
var callback = currentTask.callback;
if (callback !== null) {
currentTask.callback = null;
currentPriorityLevel = currentTask.priorityLevel;
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
markTaskRun(currentTask, currentTime);
var continuationCallback = callback(didUserCallbackTimeout);
currentTime = exports.unstable_now();
if (typeof continuationCallback === 'function') {
currentTask.callback = continuationCallback;
markTaskYield(currentTask, currentTime);
} else {
{
markTaskCompleted(currentTask, currentTime);
currentTask.isQueued = false;
}
if (currentTask === peek(taskQueue)) {
pop(taskQueue);
}
}
advanceTimers(currentTime);
} else {
pop(taskQueue);
}
currentTask = peek(taskQueue);
} // Return whether there's additional work
if (currentTask !== null) {
return true;
} else {
var firstTimer = peek(timerQueue);
if (firstTimer !== null) {
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
}
return false;
}
}
function unstable_runWithPriority(priorityLevel, eventHandler) {
switch (priorityLevel) {
case ImmediatePriority:
case UserBlockingPriority:
case NormalPriority:
case LowPriority:
case IdlePriority:
break;
default:
priorityLevel = NormalPriority;
}
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally {
currentPriorityLevel = previousPriorityLevel;
}
}
function unstable_next(eventHandler) {
var priorityLevel;
switch (currentPriorityLevel) {
case ImmediatePriority:
case UserBlockingPriority:
case NormalPriority:
// Shift down to normal priority
priorityLevel = NormalPriority;
break;
default:
// Anything lower than normal priority should remain at the current level.
priorityLevel = currentPriorityLevel;
break;
}
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally {
currentPriorityLevel = previousPriorityLevel;
}
}
function unstable_wrapCallback(callback) {
var parentPriorityLevel = currentPriorityLevel;
return function () {
// This is a fork of runWithPriority, inlined for performance.
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = parentPriorityLevel;
try {
return callback.apply(this, arguments);
} finally {
currentPriorityLevel = previousPriorityLevel;
}
};
}
function timeoutForPriorityLevel(priorityLevel) {
switch (priorityLevel) {
case ImmediatePriority:
return IMMEDIATE_PRIORITY_TIMEOUT;
case UserBlockingPriority:
return USER_BLOCKING_PRIORITY;
case IdlePriority:
return IDLE_PRIORITY;
case LowPriority:
return LOW_PRIORITY_TIMEOUT;
case NormalPriority:
default:
return NORMAL_PRIORITY_TIMEOUT;
}
}
function unstable_scheduleCallback(priorityLevel, callback, options) {
var currentTime = exports.unstable_now();
var startTime;
var timeout;
if (typeof options === 'object' && options !== null) {
var delay = options.delay;
if (typeof delay === 'number' && delay > 0) {
startTime = currentTime + delay;
} else {
startTime = currentTime;
}
timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
} else {
timeout = timeoutForPriorityLevel(priorityLevel);
startTime = currentTime;
}
var expirationTime = startTime + timeout;
var newTask = {
id: taskIdCounter++,
callback: callback,
priorityLevel: priorityLevel,
startTime: startTime,
expir