Skip to content

Instantly share code, notes, and snippets.

@KennyLisc
Last active April 21, 2017 23:02
Show Gist options
  • Save KennyLisc/2d2f3f025958d9581f3b5cbabc160020 to your computer and use it in GitHub Desktop.
Save KennyLisc/2d2f3f025958d9581f3b5cbabc160020 to your computer and use it in GitHub Desktop.
fix antd input-number
/*!
* antd v2.9.1
*
* Copyright 2015-present, Alipay, Inc.
* All rights reserved.
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react-dom"));
else if(typeof define === 'function' && define.amd)
define(["react", "react-dom"], factory);
else if(typeof exports === 'object')
exports["antd"] = factory(require("react"), require("react-dom"));
else
root["antd"] = factory(root["React"], root["ReactDOM"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_9__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ((function(modules) {
// Check all modules for deduplicated modules
for(var i in modules) {
if(Object.prototype.hasOwnProperty.call(modules, i)) {
switch(typeof modules[i]) {
case "function": break;
case "object":
// Module can be created from a template
modules[i] = (function(_m) {
var args = _m.slice(1), fn = modules[_m[0]];
return function (a,b,c) {
fn.apply(this, [a,b,c].concat(args));
};
}(modules[i]));
break;
default:
// Module is a copy of another module
modules[i] = modules[modules[i]];
break;
}
}
}
return modules;
}([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var antd = __webpack_require__(305);
var req = __webpack_require__(723);
antd.locales = {};
req.keys().forEach(function (mod) {
var match = mod.match(/\/([^/]+).tsx$/);
antd.locales[match[1]] = req(mod);
});
module.exports = antd;
/***/ },
/* 1 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
Copyright (c) 2016 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/* global define */
(function () {
'use strict';
var hasOwn = {}.hasOwnProperty;
function classNames () {
var classes = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg) continue;
var argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg)) {
classes.push(classNames.apply(null, arg));
} else if (argType === 'object') {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = classNames;
} else if (true) {
// register as 'classnames', consistent with npm package name
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
return classNames;
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {
window.classNames = classNames;
}
}());
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _assign = __webpack_require__(366);
var _assign2 = _interopRequireDefault(_assign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = _assign2["default"] || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
/***/ },
/* 4 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
exports["default"] = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _setPrototypeOf = __webpack_require__(369);
var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf);
var _create = __webpack_require__(367);
var _create2 = _interopRequireDefault(_create);
var _typeof2 = __webpack_require__(26);
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3["default"])(superClass)));
}
subClass.prototype = (0, _create2["default"])(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf2["default"] ? (0, _setPrototypeOf2["default"])(subClass, superClass) : subClass.__proto__ = superClass;
};
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _typeof2 = __webpack_require__(26);
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3["default"])(call)) === "object" || typeof call === "function") ? call : self;
};
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _defineProperty = __webpack_require__(368);
var _defineProperty2 = _interopRequireDefault(_defineProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = function (obj, key, value) {
if (key in obj) {
(0, _defineProperty2["default"])(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
/***/ },
/* 8 */
/***/ function(module, exports) {
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
'use strict';
/* 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;
}
}
module.exports = 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;
};
/***/ },
/* 9 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_9__;
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule EditorState
*
*/
'use strict';
var _assign = __webpack_require__(8);
var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var BlockTree = __webpack_require__(173);
var ContentState = __webpack_require__(74);
var EditorBidiService = __webpack_require__(441);
var Immutable = __webpack_require__(11);
var SelectionState = __webpack_require__(49);
var OrderedSet = Immutable.OrderedSet;
var Record = Immutable.Record;
var Stack = Immutable.Stack;
var defaultRecord = {
allowUndo: true,
currentContent: null,
decorator: null,
directionMap: null,
forceSelection: false,
inCompositionMode: false,
inlineStyleOverride: null,
lastChangeType: null,
nativelyRenderedContent: null,
redoStack: Stack(),
selection: null,
treeMap: null,
undoStack: Stack()
};
var EditorStateRecord = Record(defaultRecord);
var EditorState = function () {
EditorState.createEmpty = function createEmpty(decorator) {
return EditorState.createWithContent(ContentState.createFromText(''), decorator);
};
EditorState.createWithContent = function createWithContent(contentState, decorator) {
var firstKey = contentState.getBlockMap().first().getKey();
return EditorState.create({
currentContent: contentState,
undoStack: Stack(),
redoStack: Stack(),
decorator: decorator || null,
selection: SelectionState.createEmpty(firstKey)
});
};
EditorState.create = function create(config) {
var currentContent = config.currentContent;
var decorator = config.decorator;
var recordConfig = _extends({}, config, {
treeMap: generateNewTreeMap(currentContent, decorator),
directionMap: EditorBidiService.getDirectionMap(currentContent)
});
return new EditorState(new EditorStateRecord(recordConfig));
};
EditorState.set = function set(editorState, put) {
var map = editorState.getImmutable().withMutations(function (state) {
var existingDecorator = state.get('decorator');
var decorator = existingDecorator;
if (put.decorator === null) {
decorator = null;
} else if (put.decorator) {
decorator = put.decorator;
}
var newContent = put.currentContent || editorState.getCurrentContent();
if (decorator !== existingDecorator) {
var treeMap = state.get('treeMap');
var newTreeMap;
if (decorator && existingDecorator) {
newTreeMap = regenerateTreeForNewDecorator(newContent, newContent.getBlockMap(), treeMap, decorator, existingDecorator);
} else {
newTreeMap = generateNewTreeMap(newContent, decorator);
}
state.merge({
decorator: decorator,
treeMap: newTreeMap,
nativelyRenderedContent: null
});
return;
}
var existingContent = editorState.getCurrentContent();
if (newContent !== existingContent) {
state.set('treeMap', regenerateTreeForNewBlocks(editorState, newContent.getBlockMap(), newContent.getEntityMap(), decorator));
}
state.merge(put);
});
return new EditorState(map);
};
EditorState.prototype.toJS = function toJS() {
return this.getImmutable().toJS();
};
EditorState.prototype.getAllowUndo = function getAllowUndo() {
return this.getImmutable().get('allowUndo');
};
EditorState.prototype.getCurrentContent = function getCurrentContent() {
return this.getImmutable().get('currentContent');
};
EditorState.prototype.getUndoStack = function getUndoStack() {
return this.getImmutable().get('undoStack');
};
EditorState.prototype.getRedoStack = function getRedoStack() {
return this.getImmutable().get('redoStack');
};
EditorState.prototype.getSelection = function getSelection() {
return this.getImmutable().get('selection');
};
EditorState.prototype.getDecorator = function getDecorator() {
return this.getImmutable().get('decorator');
};
EditorState.prototype.isInCompositionMode = function isInCompositionMode() {
return this.getImmutable().get('inCompositionMode');
};
EditorState.prototype.mustForceSelection = function mustForceSelection() {
return this.getImmutable().get('forceSelection');
};
EditorState.prototype.getNativelyRenderedContent = function getNativelyRenderedContent() {
return this.getImmutable().get('nativelyRenderedContent');
};
EditorState.prototype.getLastChangeType = function getLastChangeType() {
return this.getImmutable().get('lastChangeType');
};
/**
* While editing, the user may apply inline style commands with a collapsed
* cursor, intending to type text that adopts the specified style. In this
* case, we track the specified style as an "override" that takes precedence
* over the inline style of the text adjacent to the cursor.
*
* If null, there is no override in place.
*/
EditorState.prototype.getInlineStyleOverride = function getInlineStyleOverride() {
return this.getImmutable().get('inlineStyleOverride');
};
EditorState.setInlineStyleOverride = function setInlineStyleOverride(editorState, inlineStyleOverride) {
return EditorState.set(editorState, { inlineStyleOverride: inlineStyleOverride });
};
/**
* Get the appropriate inline style for the editor state. If an
* override is in place, use it. Otherwise, the current style is
* based on the location of the selection state.
*/
EditorState.prototype.getCurrentInlineStyle = function getCurrentInlineStyle() {
var override = this.getInlineStyleOverride();
if (override != null) {
return override;
}
var content = this.getCurrentContent();
var selection = this.getSelection();
if (selection.isCollapsed()) {
return getInlineStyleForCollapsedSelection(content, selection);
}
return getInlineStyleForNonCollapsedSelection(content, selection);
};
EditorState.prototype.getBlockTree = function getBlockTree(blockKey) {
return this.getImmutable().getIn(['treeMap', blockKey]);
};
EditorState.prototype.isSelectionAtStartOfContent = function isSelectionAtStartOfContent() {
var firstKey = this.getCurrentContent().getBlockMap().first().getKey();
return this.getSelection().hasEdgeWithin(firstKey, 0, 0);
};
EditorState.prototype.isSelectionAtEndOfContent = function isSelectionAtEndOfContent() {
var content = this.getCurrentContent();
var blockMap = content.getBlockMap();
var last = blockMap.last();
var end = last.getLength();
return this.getSelection().hasEdgeWithin(last.getKey(), end, end);
};
EditorState.prototype.getDirectionMap = function getDirectionMap() {
return this.getImmutable().get('directionMap');
};
/**
* Incorporate native DOM selection changes into the EditorState. This
* method can be used when we simply want to accept whatever the DOM
* has given us to represent selection, and we do not need to re-render
* the editor.
*
* To forcibly move the DOM selection, see `EditorState.forceSelection`.
*/
EditorState.acceptSelection = function acceptSelection(editorState, selection) {
return updateSelection(editorState, selection, false);
};
/**
* At times, we need to force the DOM selection to be where we
* need it to be. This can occur when the anchor or focus nodes
* are non-text nodes, for instance. In this case, we want to trigger
* a re-render of the editor, which in turn forces selection into
* the correct place in the DOM. The `forceSelection` method
* accomplishes this.
*
* This method should be used in cases where you need to explicitly
* move the DOM selection from one place to another without a change
* in ContentState.
*/
EditorState.forceSelection = function forceSelection(editorState, selection) {
if (!selection.getHasFocus()) {
selection = selection.set('hasFocus', true);
}
return updateSelection(editorState, selection, true);
};
/**
* Move selection to the end of the editor without forcing focus.
*/
EditorState.moveSelectionToEnd = function moveSelectionToEnd(editorState) {
var content = editorState.getCurrentContent();
var lastBlock = content.getLastBlock();
var lastKey = lastBlock.getKey();
var length = lastBlock.getLength();
return EditorState.acceptSelection(editorState, new SelectionState({
anchorKey: lastKey,
anchorOffset: length,
focusKey: lastKey,
focusOffset: length,
isBackward: false
}));
};
/**
* Force focus to the end of the editor. This is useful in scenarios
* where we want to programmatically focus the input and it makes sense
* to allow the user to continue working seamlessly.
*/
EditorState.moveFocusToEnd = function moveFocusToEnd(editorState) {
var afterSelectionMove = EditorState.moveSelectionToEnd(editorState);
return EditorState.forceSelection(afterSelectionMove, afterSelectionMove.getSelection());
};
/**
* Push the current ContentState onto the undo stack if it should be
* considered a boundary state, and set the provided ContentState as the
* new current content.
*/
EditorState.push = function push(editorState, contentState, changeType) {
if (editorState.getCurrentContent() === contentState) {
return editorState;
}
var forceSelection = changeType !== 'insert-characters';
var directionMap = EditorBidiService.getDirectionMap(contentState, editorState.getDirectionMap());
if (!editorState.getAllowUndo()) {
return EditorState.set(editorState, {
currentContent: contentState,
directionMap: directionMap,
lastChangeType: changeType,
selection: contentState.getSelectionAfter(),
forceSelection: forceSelection,
inlineStyleOverride: null
});
}
var selection = editorState.getSelection();
var currentContent = editorState.getCurrentContent();
var undoStack = editorState.getUndoStack();
var newContent = contentState;
if (selection !== currentContent.getSelectionAfter() || mustBecomeBoundary(editorState, changeType)) {
undoStack = undoStack.push(currentContent);
newContent = newContent.set('selectionBefore', selection);
} else if (changeType === 'insert-characters' || changeType === 'backspace-character' || changeType === 'delete-character') {
// Preserve the previous selection.
newContent = newContent.set('selectionBefore', currentContent.getSelectionBefore());
}
var inlineStyleOverride = editorState.getInlineStyleOverride();
// Don't discard inline style overrides on block type or depth changes.
if (changeType !== 'adjust-depth' && changeType !== 'change-block-type') {
inlineStyleOverride = null;
}
var editorStateChanges = {
currentContent: newContent,
directionMap: directionMap,
undoStack: undoStack,
redoStack: Stack(),
lastChangeType: changeType,
selection: contentState.getSelectionAfter(),
forceSelection: forceSelection,
inlineStyleOverride: inlineStyleOverride
};
return EditorState.set(editorState, editorStateChanges);
};
/**
* Make the top ContentState in the undo stack the new current content and
* push the current content onto the redo stack.
*/
EditorState.undo = function undo(editorState) {
if (!editorState.getAllowUndo()) {
return editorState;
}
var undoStack = editorState.getUndoStack();
var newCurrentContent = undoStack.peek();
if (!newCurrentContent) {
return editorState;
}
var currentContent = editorState.getCurrentContent();
var directionMap = EditorBidiService.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
return EditorState.set(editorState, {
currentContent: newCurrentContent,
directionMap: directionMap,
undoStack: undoStack.shift(),
redoStack: editorState.getRedoStack().push(currentContent),
forceSelection: true,
inlineStyleOverride: null,
lastChangeType: 'undo',
nativelyRenderedContent: null,
selection: currentContent.getSelectionBefore()
});
};
/**
* Make the top ContentState in the redo stack the new current content and
* push the current content onto the undo stack.
*/
EditorState.redo = function redo(editorState) {
if (!editorState.getAllowUndo()) {
return editorState;
}
var redoStack = editorState.getRedoStack();
var newCurrentContent = redoStack.peek();
if (!newCurrentContent) {
return editorState;
}
var currentContent = editorState.getCurrentContent();
var directionMap = EditorBidiService.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
return EditorState.set(editorState, {
currentContent: newCurrentContent,
directionMap: directionMap,
undoStack: editorState.getUndoStack().push(currentContent),
redoStack: redoStack.shift(),
forceSelection: true,
inlineStyleOverride: null,
lastChangeType: 'redo',
nativelyRenderedContent: null,
selection: newCurrentContent.getSelectionAfter()
});
};
/**
* Not for public consumption.
*/
function EditorState(immutable) {
_classCallCheck(this, EditorState);
this._immutable = immutable;
}
/**
* Not for public consumption.
*/
EditorState.prototype.getImmutable = function getImmutable() {
return this._immutable;
};
return EditorState;
}();
/**
* Set the supplied SelectionState as the new current selection, and set
* the `force` flag to trigger manual selection placement by the view.
*/
function updateSelection(editorState, selection, forceSelection) {
return EditorState.set(editorState, {
selection: selection,
forceSelection: forceSelection,
nativelyRenderedContent: null,
inlineStyleOverride: null
});
}
/**
* Regenerate the entire tree map for a given ContentState and decorator.
* Returns an OrderedMap that maps all available ContentBlock objects.
*/
function generateNewTreeMap(contentState, decorator) {
return contentState.getBlockMap().map(function (block) {
return BlockTree.generate(contentState, block, decorator);
}).toOrderedMap();
}
/**
* Regenerate tree map objects for all ContentBlocks that have changed
* between the current editorState and newContent. Returns an OrderedMap
* with only changed regenerated tree map objects.
*/
function regenerateTreeForNewBlocks(editorState, newBlockMap, newEntityMap, decorator) {
var contentState = editorState.getCurrentContent().set('entityMap', newEntityMap);
var prevBlockMap = contentState.getBlockMap();
var prevTreeMap = editorState.getImmutable().get('treeMap');
return prevTreeMap.merge(newBlockMap.toSeq().filter(function (block, key) {
return block !== prevBlockMap.get(key);
}).map(function (block) {
return BlockTree.generate(contentState, block, decorator);
}));
}
/**
* Generate tree map objects for a new decorator object, preserving any
* decorations that are unchanged from the previous decorator.
*
* Note that in order for this to perform optimally, decoration Lists for
* decorators should be preserved when possible to allow for direct immutable
* List comparison.
*/
function regenerateTreeForNewDecorator(content, blockMap, previousTreeMap, decorator, existingDecorator) {
return previousTreeMap.merge(blockMap.toSeq().filter(function (block) {
return decorator.getDecorations(block, content) !== existingDecorator.getDecorations(block, content);
}).map(function (block) {
return BlockTree.generate(content, block, decorator);
}));
}
/**
* Return whether a change should be considered a boundary state, given
* the previous change type. Allows us to discard potential boundary states
* during standard typing or deletion behavior.
*/
function mustBecomeBoundary(editorState, changeType) {
var lastChangeType = editorState.getLastChangeType();
return changeType !== lastChangeType || changeType !== 'insert-characters' && changeType !== 'backspace-character' && changeType !== 'delete-character';
}
function getInlineStyleForCollapsedSelection(content, selection) {
var startKey = selection.getStartKey();
var startOffset = selection.getStartOffset();
var startBlock = content.getBlockForKey(startKey);
// If the cursor is not at the start of the block, look backward to
// preserve the style of the preceding character.
if (startOffset > 0) {
return startBlock.getInlineStyleAt(startOffset - 1);
}
// The caret is at position zero in this block. If the block has any
// text at all, use the style of the first character.
if (startBlock.getLength()) {
return startBlock.getInlineStyleAt(0);
}
// Otherwise, look upward in the document to find the closest character.
return lookUpwardForInlineStyle(content, startKey);
}
function getInlineStyleForNonCollapsedSelection(content, selection) {
var startKey = selection.getStartKey();
var startOffset = selection.getStartOffset();
var startBlock = content.getBlockForKey(startKey);
// If there is a character just inside the selection, use its style.
if (startOffset < startBlock.getLength()) {
return startBlock.getInlineStyleAt(startOffset);
}
// Check if the selection at the end of a non-empty block. Use the last
// style in the block.
if (startOffset > 0) {
return startBlock.getInlineStyleAt(startOffset - 1);
}
// Otherwise, look upward in the document to find the closest character.
return lookUpwardForInlineStyle(content, startKey);
}
function lookUpwardForInlineStyle(content, fromKey) {
var previousBlock = content.getBlockBefore(fromKey);
var previousLength;
while (previousBlock) {
previousLength = previousBlock.getLength();
if (previousLength) {
return previousBlock.getInlineStyleAt(previousLength - 1);
}
previousBlock = content.getBlockBefore(previousBlock.getKey());
}
return OrderedSet();
}
module.exports = EditorState;
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
(function (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.Immutable = factory();
}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;
function createClass(ctor, superClass) {
if (superClass) {
ctor.prototype = Object.create(superClass.prototype);
}
ctor.prototype.constructor = ctor;
}
function Iterable(value) {
return isIterable(value) ? value : Seq(value);
}
createClass(KeyedIterable, Iterable);
function KeyedIterable(value) {
return isKeyed(value) ? value : KeyedSeq(value);
}
createClass(IndexedIterable, Iterable);
function IndexedIterable(value) {
return isIndexed(value) ? value : IndexedSeq(value);
}
createClass(SetIterable, Iterable);
function SetIterable(value) {
return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
}
function isIterable(maybeIterable) {
return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
}
function isKeyed(maybeKeyed) {
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
}
function isIndexed(maybeIndexed) {
return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
}
function isAssociative(maybeAssociative) {
return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
}
function isOrdered(maybeOrdered) {
return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
}
Iterable.isIterable = isIterable;
Iterable.isKeyed = isKeyed;
Iterable.isIndexed = isIndexed;
Iterable.isAssociative = isAssociative;
Iterable.isOrdered = isOrdered;
Iterable.Keyed = KeyedIterable;
Iterable.Indexed = IndexedIterable;
Iterable.Set = SetIterable;
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
// Used for setting prototype methods that IE8 chokes on.
var DELETE = 'delete';
// Constants describing the size of trie nodes.
var SHIFT = 5; // Resulted in best performance after ______?
var SIZE = 1 << SHIFT;
var MASK = SIZE - 1;
// A consistent shared value representing "not set" which equals nothing other
// than itself, and nothing that could be provided externally.
var NOT_SET = {};
// Boolean references, Rough equivalent of `bool &`.
var CHANGE_LENGTH = { value: false };
var DID_ALTER = { value: false };
function MakeRef(ref) {
ref.value = false;
return ref;
}
function SetRef(ref) {
ref && (ref.value = true);
}
// A function which returns a value representing an "owner" for transient writes
// to tries. The return value will only ever equal itself, and will not equal
// the return of any subsequent call of this function.
function OwnerID() {}
// http://jsperf.com/copy-array-inline
function arrCopy(arr, offset) {
offset = offset || 0;
var len = Math.max(0, arr.length - offset);
var newArr = new Array(len);
for (var ii = 0; ii < len; ii++) {
newArr[ii] = arr[ii + offset];
}
return newArr;
}
function ensureSize(iter) {
if (iter.size === undefined) {
iter.size = iter.__iterate(returnTrue);
}
return iter.size;
}
function wrapIndex(iter, index) {
// This implements "is array index" which the ECMAString spec defines as:
//
// A String property name P is an array index if and only if
// ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
// to 2^32−1.
//
// http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
if (typeof index !== 'number') {
var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
if ('' + uint32Index !== index || uint32Index === 4294967295) {
return NaN;
}
index = uint32Index;
}
return index < 0 ? ensureSize(iter) + index : index;
}
function returnTrue() {
return true;
}
function wholeSlice(begin, end, size) {
return (begin === 0 || (size !== undefined && begin <= -size)) &&
(end === undefined || (size !== undefined && end >= size));
}
function resolveBegin(begin, size) {
return resolveIndex(begin, size, 0);
}
function resolveEnd(end, size) {
return resolveIndex(end, size, size);
}
function resolveIndex(index, size, defaultIndex) {
return index === undefined ?
defaultIndex :
index < 0 ?
Math.max(0, size + index) :
size === undefined ?
index :
Math.min(size, index);
}
/* global Symbol */
var ITERATE_KEYS = 0;
var ITERATE_VALUES = 1;
var ITERATE_ENTRIES = 2;
var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator';
var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
function Iterator(next) {
this.next = next;
}
Iterator.prototype.toString = function() {
return '[Iterator]';
};
Iterator.KEYS = ITERATE_KEYS;
Iterator.VALUES = ITERATE_VALUES;
Iterator.ENTRIES = ITERATE_ENTRIES;
Iterator.prototype.inspect =
Iterator.prototype.toSource = function () { return this.toString(); }
Iterator.prototype[ITERATOR_SYMBOL] = function () {
return this;
};
function iteratorValue(type, k, v, iteratorResult) {
var value = type === 0 ? k : type === 1 ? v : [k, v];
iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
value: value, done: false
});
return iteratorResult;
}
function iteratorDone() {
return { value: undefined, done: true };
}
function hasIterator(maybeIterable) {
return !!getIteratorFn(maybeIterable);
}
function isIterator(maybeIterator) {
return maybeIterator && typeof maybeIterator.next === 'function';
}
function getIterator(iterable) {
var iteratorFn = getIteratorFn(iterable);
return iteratorFn && iteratorFn.call(iterable);
}
function getIteratorFn(iterable) {
var iteratorFn = iterable && (
(REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
iterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
function isArrayLike(value) {
return value && typeof value.length === 'number';
}
createClass(Seq, Iterable);
function Seq(value) {
return value === null || value === undefined ? emptySequence() :
isIterable(value) ? value.toSeq() : seqFromValue(value);
}
Seq.of = function(/*...values*/) {
return Seq(arguments);
};
Seq.prototype.toSeq = function() {
return this;
};
Seq.prototype.toString = function() {
return this.__toString('Seq {', '}');
};
Seq.prototype.cacheResult = function() {
if (!this._cache && this.__iterateUncached) {
this._cache = this.entrySeq().toArray();
this.size = this._cache.length;
}
return this;
};
// abstract __iterateUncached(fn, reverse)
Seq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, true);
};
// abstract __iteratorUncached(type, reverse)
Seq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, true);
};
createClass(KeyedSeq, Seq);
function KeyedSeq(value) {
return value === null || value === undefined ?
emptySequence().toKeyedSeq() :
isIterable(value) ?
(isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
keyedSeqFromValue(value);
}
KeyedSeq.prototype.toKeyedSeq = function() {
return this;
};
createClass(IndexedSeq, Seq);
function IndexedSeq(value) {
return value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
}
IndexedSeq.of = function(/*...values*/) {
return IndexedSeq(arguments);
};
IndexedSeq.prototype.toIndexedSeq = function() {
return this;
};
IndexedSeq.prototype.toString = function() {
return this.__toString('Seq [', ']');
};
IndexedSeq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, false);
};
IndexedSeq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, false);
};
createClass(SetSeq, Seq);
function SetSeq(value) {
return (
value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value
).toSetSeq();
}
SetSeq.of = function(/*...values*/) {
return SetSeq(arguments);
};
SetSeq.prototype.toSetSeq = function() {
return this;
};
Seq.isSeq = isSeq;
Seq.Keyed = KeyedSeq;
Seq.Set = SetSeq;
Seq.Indexed = IndexedSeq;
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
Seq.prototype[IS_SEQ_SENTINEL] = true;
createClass(ArraySeq, IndexedSeq);
function ArraySeq(array) {
this._array = array;
this.size = array.length;
}
ArraySeq.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
};
ArraySeq.prototype.__iterate = function(fn, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
return ii + 1;
}
}
return ii;
};
ArraySeq.prototype.__iterator = function(type, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
var ii = 0;
return new Iterator(function()
{return ii > maxIndex ?
iteratorDone() :
iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
);
};
createClass(ObjectSeq, KeyedSeq);
function ObjectSeq(object) {
var keys = Object.keys(object);
this._object = object;
this._keys = keys;
this.size = keys.length;
}
ObjectSeq.prototype.get = function(key, notSetValue) {
if (notSetValue !== undefined && !this.has(key)) {
return notSetValue;
}
return this._object[key];
};
ObjectSeq.prototype.has = function(key) {
return this._object.hasOwnProperty(key);
};
ObjectSeq.prototype.__iterate = function(fn, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var key = keys[reverse ? maxIndex - ii : ii];
if (fn(object[key], key, this) === false) {
return ii + 1;
}
}
return ii;
};
ObjectSeq.prototype.__iterator = function(type, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
var ii = 0;
return new Iterator(function() {
var key = keys[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, key, object[key]);
});
};
ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
createClass(IterableSeq, IndexedSeq);
function IterableSeq(iterable) {
this._iterable = iterable;
this.size = iterable.length || iterable.size;
}
IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
var iterations = 0;
if (isIterator(iterator)) {
var step;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
}
return iterations;
};
IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
if (!isIterator(iterator)) {
return new Iterator(iteratorDone);
}
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step : iteratorValue(type, iterations++, step.value);
});
};
createClass(IteratorSeq, IndexedSeq);
function IteratorSeq(iterator) {
this._iterator = iterator;
this._iteratorCache = [];
}
IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
while (iterations < cache.length) {
if (fn(cache[iterations], iterations++, this) === false) {
return iterations;
}
}
var step;
while (!(step = iterator.next()).done) {
var val = step.value;
cache[iterations] = val;
if (fn(val, iterations++, this) === false) {
break;
}
}
return iterations;
};
IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
return new Iterator(function() {
if (iterations >= cache.length) {
var step = iterator.next();
if (step.done) {
return step;
}
cache[iterations] = step.value;
}
return iteratorValue(type, iterations, cache[iterations++]);
});
};
// # pragma Helper functions
function isSeq(maybeSeq) {
return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
}
var EMPTY_SEQ;
function emptySequence() {
return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
}
function keyedSeqFromValue(value) {
var seq =
Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
typeof value === 'object' ? new ObjectSeq(value) :
undefined;
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of [k, v] entries, '+
'or keyed object: ' + value
);
}
return seq;
}
function indexedSeqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value);
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values: ' + value
);
}
return seq;
}
function seqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value) ||
(typeof value === 'object' && new ObjectSeq(value));
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values, or keyed object: ' + value
);
}
return seq;
}
function maybeIndexedSeqFromValue(value) {
return (
isArrayLike(value) ? new ArraySeq(value) :
isIterator(value) ? new IteratorSeq(value) :
hasIterator(value) ? new IterableSeq(value) :
undefined
);
}
function seqIterate(seq, fn, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var entry = cache[reverse ? maxIndex - ii : ii];
if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
return ii + 1;
}
}
return ii;
}
return seq.__iterateUncached(fn, reverse);
}
function seqIterator(seq, type, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
var ii = 0;
return new Iterator(function() {
var entry = cache[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
});
}
return seq.__iteratorUncached(type, reverse);
}
function fromJS(json, converter) {
return converter ?
fromJSWith(converter, json, '', {'': json}) :
fromJSDefault(json);
}
function fromJSWith(converter, json, key, parentJSON) {
if (Array.isArray(json)) {
return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
if (isPlainObj(json)) {
return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
return json;
}
function fromJSDefault(json) {
if (Array.isArray(json)) {
return IndexedSeq(json).map(fromJSDefault).toList();
}
if (isPlainObj(json)) {
return KeyedSeq(json).map(fromJSDefault).toMap();
}
return json;
}
function isPlainObj(value) {
return value && (value.constructor === Object || value.constructor === undefined);
}
/**
* An extension of the "same-value" algorithm as [described for use by ES6 Map
* and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
*
* NaN is considered the same as NaN, however -0 and 0 are considered the same
* value, which is different from the algorithm described by
* [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
*
* This is extended further to allow Objects to describe the values they
* represent, by way of `valueOf` or `equals` (and `hashCode`).
*
* Note: because of this extension, the key equality of Immutable.Map and the
* value equality of Immutable.Set will differ from ES6 Map and Set.
*
* ### Defining custom values
*
* The easiest way to describe the value an object represents is by implementing
* `valueOf`. For example, `Date` represents a value by returning a unix
* timestamp for `valueOf`:
*
* var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
* var date2 = new Date(1234567890000);
* date1.valueOf(); // 1234567890000
* assert( date1 !== date2 );
* assert( Immutable.is( date1, date2 ) );
*
* Note: overriding `valueOf` may have other implications if you use this object
* where JavaScript expects a primitive, such as implicit string coercion.
*
* For more complex types, especially collections, implementing `valueOf` may
* not be performant. An alternative is to implement `equals` and `hashCode`.
*
* `equals` takes another object, presumably of similar type, and returns true
* if the it is equal. Equality is symmetrical, so the same result should be
* returned if this and the argument are flipped.
*
* assert( a.equals(b) === b.equals(a) );
*
* `hashCode` returns a 32bit integer number representing the object which will
* be used to determine how to store the value object in a Map or Set. You must
* provide both or neither methods, one must not exist without the other.
*
* Also, an important relationship between these methods must be upheld: if two
* values are equal, they *must* return the same hashCode. If the values are not
* equal, they might have the same hashCode; this is called a hash collision,
* and while undesirable for performance reasons, it is acceptable.
*
* if (a.equals(b)) {
* assert( a.hashCode() === b.hashCode() );
* }
*
* All Immutable collections implement `equals` and `hashCode`.
*
*/
function is(valueA, valueB) {
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
if (typeof valueA.valueOf === 'function' &&
typeof valueB.valueOf === 'function') {
valueA = valueA.valueOf();
valueB = valueB.valueOf();
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
}
if (typeof valueA.equals === 'function' &&
typeof valueB.equals === 'function' &&
valueA.equals(valueB)) {
return true;
}
return false;
}
function deepEqual(a, b) {
if (a === b) {
return true;
}
if (
!isIterable(b) ||
a.size !== undefined && b.size !== undefined && a.size !== b.size ||
a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
isKeyed(a) !== isKeyed(b) ||
isIndexed(a) !== isIndexed(b) ||
isOrdered(a) !== isOrdered(b)
) {
return false;
}
if (a.size === 0 && b.size === 0) {
return true;
}
var notAssociative = !isAssociative(a);
if (isOrdered(a)) {
var entries = a.entries();
return b.every(function(v, k) {
var entry = entries.next().value;
return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
}) && entries.next().done;
}
var flipped = false;
if (a.size === undefined) {
if (b.size === undefined) {
if (typeof a.cacheResult === 'function') {
a.cacheResult();
}
} else {
flipped = true;
var _ = a;
a = b;
b = _;
}
}
var allEqual = true;
var bSize = b.__iterate(function(v, k) {
if (notAssociative ? !a.has(v) :
flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
allEqual = false;
return false;
}
});
return allEqual && a.size === bSize;
}
createClass(Repeat, IndexedSeq);
function Repeat(value, times) {
if (!(this instanceof Repeat)) {
return new Repeat(value, times);
}
this._value = value;
this.size = times === undefined ? Infinity : Math.max(0, times);
if (this.size === 0) {
if (EMPTY_REPEAT) {
return EMPTY_REPEAT;
}
EMPTY_REPEAT = this;
}
}
Repeat.prototype.toString = function() {
if (this.size === 0) {
return 'Repeat []';
}
return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
};
Repeat.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._value : notSetValue;
};
Repeat.prototype.includes = function(searchValue) {
return is(this._value, searchValue);
};
Repeat.prototype.slice = function(begin, end) {
var size = this.size;
return wholeSlice(begin, end, size) ? this :
new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
};
Repeat.prototype.reverse = function() {
return this;
};
Repeat.prototype.indexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return 0;
}
return -1;
};
Repeat.prototype.lastIndexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return this.size;
}
return -1;
};
Repeat.prototype.__iterate = function(fn, reverse) {
for (var ii = 0; ii < this.size; ii++) {
if (fn(this._value, ii, this) === false) {
return ii + 1;
}
}
return ii;
};
Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
var ii = 0;
return new Iterator(function()
{return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
);
};
Repeat.prototype.equals = function(other) {
return other instanceof Repeat ?
is(this._value, other._value) :
deepEqual(other);
};
var EMPTY_REPEAT;
function invariant(condition, error) {
if (!condition) throw new Error(error);
}
createClass(Range, IndexedSeq);
function Range(start, end, step) {
if (!(this instanceof Range)) {
return new Range(start, end, step);
}
invariant(step !== 0, 'Cannot step a Range by 0');
start = start || 0;
if (end === undefined) {
end = Infinity;
}
step = step === undefined ? 1 : Math.abs(step);
if (end < start) {
step = -step;
}
this._start = start;
this._end = end;
this._step = step;
this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
if (this.size === 0) {
if (EMPTY_RANGE) {
return EMPTY_RANGE;
}
EMPTY_RANGE = this;
}
}
Range.prototype.toString = function() {
if (this.size === 0) {
return 'Range []';
}
return 'Range [ ' +
this._start + '...' + this._end +
(this._step > 1 ? ' by ' + this._step : '') +
' ]';
};
Range.prototype.get = function(index, notSetValue) {
return this.has(index) ?
this._start + wrapIndex(this, index) * this._step :
notSetValue;
};
Range.prototype.includes = function(searchValue) {
var possibleIndex = (searchValue - this._start) / this._step;
return possibleIndex >= 0 &&
possibleIndex < this.size &&
possibleIndex === Math.floor(possibleIndex);
};
Range.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
begin = resolveBegin(begin, this.size);
end = resolveEnd(end, this.size);
if (end <= begin) {
return new Range(0, 0);
}
return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
};
Range.prototype.indexOf = function(searchValue) {
var offsetValue = searchValue - this._start;
if (offsetValue % this._step === 0) {
var index = offsetValue / this._step;
if (index >= 0 && index < this.size) {
return index
}
}
return -1;
};
Range.prototype.lastIndexOf = function(searchValue) {
return this.indexOf(searchValue);
};
Range.prototype.__iterate = function(fn, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(value, ii, this) === false) {
return ii + 1;
}
value += reverse ? -step : step;
}
return ii;
};
Range.prototype.__iterator = function(type, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
var ii = 0;
return new Iterator(function() {
var v = value;
value += reverse ? -step : step;
return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
});
};
Range.prototype.equals = function(other) {
return other instanceof Range ?
this._start === other._start &&
this._end === other._end &&
this._step === other._step :
deepEqual(this, other);
};
var EMPTY_RANGE;
createClass(Collection, Iterable);
function Collection() {
throw TypeError('Abstract');
}
createClass(KeyedCollection, Collection);function KeyedCollection() {}
createClass(IndexedCollection, Collection);function IndexedCollection() {}
createClass(SetCollection, Collection);function SetCollection() {}
Collection.Keyed = KeyedCollection;
Collection.Indexed = IndexedCollection;
Collection.Set = SetCollection;
var imul =
typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
Math.imul :
function imul(a, b) {
a = a | 0; // int
b = b | 0; // int
var c = a & 0xffff;
var d = b & 0xffff;
// Shift by 0 fixes the sign on the high part.
return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
};
// v8 has an optimization for storing 31-bit signed numbers.
// Values which have either 00 or 11 as the high order bits qualify.
// This function drops the highest order bit in a signed number, maintaining
// the sign bit.
function smi(i32) {
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
}
function hash(o) {
if (o === false || o === null || o === undefined) {
return 0;
}
if (typeof o.valueOf === 'function') {
o = o.valueOf();
if (o === false || o === null || o === undefined) {
return 0;
}
}
if (o === true) {
return 1;
}
var type = typeof o;
if (type === 'number') {
var h = o | 0;
if (h !== o) {
h ^= o * 0xFFFFFFFF;
}
while (o > 0xFFFFFFFF) {
o /= 0xFFFFFFFF;
h ^= o;
}
return smi(h);
}
if (type === 'string') {
return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
}
if (typeof o.hashCode === 'function') {
return o.hashCode();
}
if (type === 'object') {
return hashJSObj(o);
}
if (typeof o.toString === 'function') {
return hashString(o.toString());
}
throw new Error('Value type ' + type + ' cannot be hashed.');
}
function cachedHashString(string) {
var hash = stringHashCache[string];
if (hash === undefined) {
hash = hashString(string);
if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
STRING_HASH_CACHE_SIZE = 0;
stringHashCache = {};
}
STRING_HASH_CACHE_SIZE++;
stringHashCache[string] = hash;
}
return hash;
}
// http://jsperf.com/hashing-strings
function hashString(string) {
// This is the hash from JVM
// The hash code for a string is computed as
// s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
// where s[i] is the ith character of the string and n is the length of
// the string. We "mod" the result to make it between 0 (inclusive) and 2^31
// (exclusive) by dropping high bits.
var hash = 0;
for (var ii = 0; ii < string.length; ii++) {
hash = 31 * hash + string.charCodeAt(ii) | 0;
}
return smi(hash);
}
function hashJSObj(obj) {
var hash;
if (usingWeakMap) {
hash = weakMap.get(obj);
if (hash !== undefined) {
return hash;
}
}
hash = obj[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
if (!canDefineProperty) {
hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
hash = getIENodeHash(obj);
if (hash !== undefined) {
return hash;
}
}
hash = ++objHashUID;
if (objHashUID & 0x40000000) {
objHashUID = 0;
}
if (usingWeakMap) {
weakMap.set(obj, hash);
} else if (isExtensible !== undefined && isExtensible(obj) === false) {
throw new Error('Non-extensible objects are not allowed as keys.');
} else if (canDefineProperty) {
Object.defineProperty(obj, UID_HASH_KEY, {
'enumerable': false,
'configurable': false,
'writable': false,
'value': hash
});
} else if (obj.propertyIsEnumerable !== undefined &&
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
// Since we can't define a non-enumerable property on the object
// we'll hijack one of the less-used non-enumerable properties to
// save our hash on it. Since this is a function it will not show up in
// `JSON.stringify` which is what we want.
obj.propertyIsEnumerable = function() {
return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
};
obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
} else if (obj.nodeType !== undefined) {
// At this point we couldn't get the IE `uniqueID` to use as a hash
// and we couldn't use a non-enumerable property to exploit the
// dontEnum bug so we simply add the `UID_HASH_KEY` on the node
// itself.
obj[UID_HASH_KEY] = hash;
} else {
throw new Error('Unable to set a non-enumerable property on object.');
}
return hash;
}
// Get references to ES5 object methods.
var isExtensible = Object.isExtensible;
// True if Object.defineProperty works as expected. IE8 fails this test.
var canDefineProperty = (function() {
try {
Object.defineProperty({}, '@', {});
return true;
} catch (e) {
return false;
}
}());
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
// and avoid memory leaks from the IE cloneNode bug.
function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
}
// If possible, use a WeakMap.
var usingWeakMap = typeof WeakMap === 'function';
var weakMap;
if (usingWeakMap) {
weakMap = new WeakMap();
}
var objHashUID = 0;
var UID_HASH_KEY = '__immutablehash__';
if (typeof Symbol === 'function') {
UID_HASH_KEY = Symbol(UID_HASH_KEY);
}
var STRING_HASH_CACHE_MIN_STRLEN = 16;
var STRING_HASH_CACHE_MAX_SIZE = 255;
var STRING_HASH_CACHE_SIZE = 0;
var stringHashCache = {};
function assertNotInfinite(size) {
invariant(
size !== Infinity,
'Cannot perform this action with an infinite size.'
);
}
createClass(Map, KeyedCollection);
// @pragma Construction
function Map(value) {
return value === null || value === undefined ? emptyMap() :
isMap(value) && !isOrdered(value) ? value :
emptyMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
Map.prototype.toString = function() {
return this.__toString('Map {', '}');
};
// @pragma Access
Map.prototype.get = function(k, notSetValue) {
return this._root ?
this._root.get(0, undefined, k, notSetValue) :
notSetValue;
};
// @pragma Modification
Map.prototype.set = function(k, v) {
return updateMap(this, k, v);
};
Map.prototype.setIn = function(keyPath, v) {
return this.updateIn(keyPath, NOT_SET, function() {return v});
};
Map.prototype.remove = function(k) {
return updateMap(this, k, NOT_SET);
};
Map.prototype.deleteIn = function(keyPath) {
return this.updateIn(keyPath, function() {return NOT_SET});
};
Map.prototype.update = function(k, notSetValue, updater) {
return arguments.length === 1 ?
k(this) :
this.updateIn([k], notSetValue, updater);
};
Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
if (!updater) {
updater = notSetValue;
notSetValue = undefined;
}
var updatedValue = updateInDeepMap(
this,
forceIterator(keyPath),
notSetValue,
updater
);
return updatedValue === NOT_SET ? undefined : updatedValue;
};
Map.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._root = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyMap();
};
// @pragma Composition
Map.prototype.merge = function(/*...iters*/) {
return mergeIntoMapWith(this, undefined, arguments);
};
Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, merger, iters);
};
Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.merge === 'function' ?
m.merge.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoMapWith(this, deepMerger, arguments);
};
Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
};
Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.mergeDeep === 'function' ?
m.mergeDeep.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.sort = function(comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator));
};
Map.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator, mapper));
};
// @pragma Mutability
Map.prototype.withMutations = function(fn) {
var mutable = this.asMutable();
fn(mutable);
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
};
Map.prototype.asMutable = function() {
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
};
Map.prototype.asImmutable = function() {
return this.__ensureOwner();
};
Map.prototype.wasAltered = function() {
return this.__altered;
};
Map.prototype.__iterator = function(type, reverse) {
return new MapIterator(this, type, reverse);
};
Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
this._root && this._root.iterate(function(entry ) {
iterations++;
return fn(entry[1], entry[0], this$0);
}, reverse);
return iterations;
};
Map.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeMap(this.size, this._root, ownerID, this.__hash);
};
function isMap(maybeMap) {
return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
}
Map.isMap = isMap;
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
var MapPrototype = Map.prototype;
MapPrototype[IS_MAP_SENTINEL] = true;
MapPrototype[DELETE] = MapPrototype.remove;
MapPrototype.removeIn = MapPrototype.deleteIn;
// #pragma Trie Nodes
function ArrayMapNode(ownerID, entries) {
this.ownerID = ownerID;
this.entries = entries;
}
ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && entries.length === 1) {
return; // undefined
}
if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
return createNodes(ownerID, entries, key, value);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new ArrayMapNode(ownerID, newEntries);
};
function BitmapIndexedNode(ownerID, bitmap, nodes) {
this.ownerID = ownerID;
this.bitmap = bitmap;
this.nodes = nodes;
}
BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
var bitmap = this.bitmap;
return (bitmap & bit) === 0 ? notSetValue :
this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
};
BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var bit = 1 << keyHashFrag;
var bitmap = this.bitmap;
var exists = (bitmap & bit) !== 0;
if (!exists && value === NOT_SET) {
return this;
}
var idx = popCount(bitmap & (bit - 1));
var nodes = this.nodes;
var node = exists ? nodes[idx] : undefined;
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
}
if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
return nodes[idx ^ 1];
}
if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
return newNode;
}
var isEditable = ownerID && ownerID === this.ownerID;
var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
var newNodes = exists ? newNode ?
setIn(nodes, idx, newNode, isEditable) :
spliceOut(nodes, idx, isEditable) :
spliceIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.bitmap = newBitmap;
this.nodes = newNodes;
return this;
}
return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
};
function HashArrayMapNode(ownerID, count, nodes) {
this.ownerID = ownerID;
this.count = count;
this.nodes = nodes;
}
HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var node = this.nodes[idx];
return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
};
HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var removed = value === NOT_SET;
var nodes = this.nodes;
var node = nodes[idx];
if (removed && !node) {
return this;
}
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
var newCount = this.count;
if (!node) {
newCount++;
} else if (!newNode) {
newCount--;
if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
return packNodes(ownerID, nodes, newCount, idx);
}
}
var isEditable = ownerID && ownerID === this.ownerID;
var newNodes = setIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.count = newCount;
this.nodes = newNodes;
return this;
}
return new HashArrayMapNode(ownerID, newCount, newNodes);
};
function HashCollisionNode(ownerID, keyHash, entries) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entries = entries;
}
HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var removed = value === NOT_SET;
if (keyHash !== this.keyHash) {
if (removed) {
return this;
}
SetRef(didAlter);
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
}
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && len === 2) {
return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new HashCollisionNode(ownerID, this.keyHash, newEntries);
};
function ValueNode(ownerID, keyHash, entry) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entry = entry;
}
ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
};
ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var keyMatch = is(key, this.entry[0]);
if (keyMatch ? value === this.entry[1] : removed) {
return this;
}
SetRef(didAlter);
if (removed) {
SetRef(didChangeSize);
return; // undefined
}
if (keyMatch) {
if (ownerID && ownerID === this.ownerID) {
this.entry[1] = value;
return this;
}
return new ValueNode(ownerID, this.keyHash, [key, value]);
}
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
};
// #pragma Iterators
ArrayMapNode.prototype.iterate =
HashCollisionNode.prototype.iterate = function (fn, reverse) {
var entries = this.entries;
for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
return false;
}
}
}
BitmapIndexedNode.prototype.iterate =
HashArrayMapNode.prototype.iterate = function (fn, reverse) {
var nodes = this.nodes;
for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
var node = nodes[reverse ? maxIndex - ii : ii];
if (node && node.iterate(fn, reverse) === false) {
return false;
}
}
}
ValueNode.prototype.iterate = function (fn, reverse) {
return fn(this.entry);
}
createClass(MapIterator, Iterator);
function MapIterator(map, type, reverse) {
this._type = type;
this._reverse = reverse;
this._stack = map._root && mapIteratorFrame(map._root);
}
MapIterator.prototype.next = function() {
var type = this._type;
var stack = this._stack;
while (stack) {
var node = stack.node;
var index = stack.index++;
var maxIndex;
if (node.entry) {
if (index === 0) {
return mapIteratorValue(type, node.entry);
}
} else if (node.entries) {
maxIndex = node.entries.length - 1;
if (index <= maxIndex) {
return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
}
} else {
maxIndex = node.nodes.length - 1;
if (index <= maxIndex) {
var subNode = node.nodes[this._reverse ? maxIndex - index : index];
if (subNode) {
if (subNode.entry) {
return mapIteratorValue(type, subNode.entry);
}
stack = this._stack = mapIteratorFrame(subNode, stack);
}
continue;
}
}
stack = this._stack = this._stack.__prev;
}
return iteratorDone();
};
function mapIteratorValue(type, entry) {
return iteratorValue(type, entry[0], entry[1]);
}
function mapIteratorFrame(node, prev) {
return {
node: node,
index: 0,
__prev: prev
};
}
function makeMap(size, root, ownerID, hash) {
var map = Object.create(MapPrototype);
map.size = size;
map._root = root;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_MAP;
function emptyMap() {
return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
}
function updateMap(map, k, v) {
var newRoot;
var newSize;
if (!map._root) {
if (v === NOT_SET) {
return map;
}
newSize = 1;
newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
} else {
var didChangeSize = MakeRef(CHANGE_LENGTH);
var didAlter = MakeRef(DID_ALTER);
newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
if (!didAlter.value) {
return map;
}
newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
}
if (map.__ownerID) {
map.size = newSize;
map._root = newRoot;
map.__hash = undefined;
map.__altered = true;
return map;
}
return newRoot ? makeMap(newSize, newRoot) : emptyMap();
}
function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (!node) {
if (value === NOT_SET) {
return node;
}
SetRef(didAlter);
SetRef(didChangeSize);
return new ValueNode(ownerID, keyHash, [key, value]);
}
return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
}
function isLeafNode(node) {
return node.constructor === ValueNode || node.constructor === HashCollisionNode;
}
function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
if (node.keyHash === keyHash) {
return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
}
var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var newNode;
var nodes = idx1 === idx2 ?
[mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
}
function createNodes(ownerID, entries, key, value) {
if (!ownerID) {
ownerID = new OwnerID();
}
var node = new ValueNode(ownerID, hash(key), [key, value]);
for (var ii = 0; ii < entries.length; ii++) {
var entry = entries[ii];
node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
}
return node;
}
function packNodes(ownerID, nodes, count, excluding) {
var bitmap = 0;
var packedII = 0;
var packedNodes = new Array(count);
for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
var node = nodes[ii];
if (node !== undefined && ii !== excluding) {
bitmap |= bit;
packedNodes[packedII++] = node;
}
}
return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
}
function expandNodes(ownerID, nodes, bitmap, including, node) {
var count = 0;
var expandedNodes = new Array(SIZE);
for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
}
expandedNodes[including] = node;
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
}
function mergeIntoMapWith(map, merger, iterables) {
var iters = [];
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = KeyedIterable(value);
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
return mergeIntoCollectionWith(map, merger, iters);
}
function deepMerger(existing, value, key) {
return existing && existing.mergeDeep && isIterable(value) ?
existing.mergeDeep(value) :
is(existing, value) ? existing : value;
}
function deepMergerWith(merger) {
return function(existing, value, key) {
if (existing && existing.mergeDeepWith && isIterable(value)) {
return existing.mergeDeepWith(merger, value);
}
var nextValue = merger(existing, value, key);
return is(existing, nextValue) ? existing : nextValue;
};
}
function mergeIntoCollectionWith(collection, merger, iters) {
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return collection;
}
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
return collection.constructor(iters[0]);
}
return collection.withMutations(function(collection ) {
var mergeIntoMap = merger ?
function(value, key) {
collection.update(key, NOT_SET, function(existing )
{return existing === NOT_SET ? value : merger(existing, value, key)}
);
} :
function(value, key) {
collection.set(key, value);
}
for (var ii = 0; ii < iters.length; ii++) {
iters[ii].forEach(mergeIntoMap);
}
});
}
function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
var isNotSet = existing === NOT_SET;
var step = keyPathIter.next();
if (step.done) {
var existingValue = isNotSet ? notSetValue : existing;
var newValue = updater(existingValue);
return newValue === existingValue ? existing : newValue;
}
invariant(
isNotSet || (existing && existing.set),
'invalid keyPath'
);
var key = step.value;
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
var nextUpdated = updateInDeepMap(
nextExisting,
keyPathIter,
notSetValue,
updater
);
return nextUpdated === nextExisting ? existing :
nextUpdated === NOT_SET ? existing.remove(key) :
(isNotSet ? emptyMap() : existing).set(key, nextUpdated);
}
function popCount(x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x7f;
}
function setIn(array, idx, val, canEdit) {
var newArray = canEdit ? array : arrCopy(array);
newArray[idx] = val;
return newArray;
}
function spliceIn(array, idx, val, canEdit) {
var newLen = array.length + 1;
if (canEdit && idx + 1 === newLen) {
array[idx] = val;
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
newArray[ii] = val;
after = -1;
} else {
newArray[ii] = array[ii + after];
}
}
return newArray;
}
function spliceOut(array, idx, canEdit) {
var newLen = array.length - 1;
if (canEdit && idx === newLen) {
array.pop();
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
after = 1;
}
newArray[ii] = array[ii + after];
}
return newArray;
}
var MAX_ARRAY_MAP_SIZE = SIZE / 4;
var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
createClass(List, IndexedCollection);
// @pragma Construction
function List(value) {
var empty = emptyList();
if (value === null || value === undefined) {
return empty;
}
if (isList(value)) {
return value;
}
var iter = IndexedIterable(value);
var size = iter.size;
if (size === 0) {
return empty;
}
assertNotInfinite(size);
if (size > 0 && size < SIZE) {
return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
}
return empty.withMutations(function(list ) {
list.setSize(size);
iter.forEach(function(v, i) {return list.set(i, v)});
});
}
List.of = function(/*...values*/) {
return this(arguments);
};
List.prototype.toString = function() {
return this.__toString('List [', ']');
};
// @pragma Access
List.prototype.get = function(index, notSetValue) {
index = wrapIndex(this, index);
if (index >= 0 && index < this.size) {
index += this._origin;
var node = listNodeFor(this, index);
return node && node.array[index & MASK];
}
return notSetValue;
};
// @pragma Modification
List.prototype.set = function(index, value) {
return updateList(this, index, value);
};
List.prototype.remove = function(index) {
return !this.has(index) ? this :
index === 0 ? this.shift() :
index === this.size - 1 ? this.pop() :
this.splice(index, 1);
};
List.prototype.insert = function(index, value) {
return this.splice(index, 0, value);
};
List.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = this._origin = this._capacity = 0;
this._level = SHIFT;
this._root = this._tail = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyList();
};
List.prototype.push = function(/*...values*/) {
var values = arguments;
var oldSize = this.size;
return this.withMutations(function(list ) {
setListBounds(list, 0, oldSize + values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(oldSize + ii, values[ii]);
}
});
};
List.prototype.pop = function() {
return setListBounds(this, 0, -1);
};
List.prototype.unshift = function(/*...values*/) {
var values = arguments;
return this.withMutations(function(list ) {
setListBounds(list, -values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(ii, values[ii]);
}
});
};
List.prototype.shift = function() {
return setListBounds(this, 1);
};
// @pragma Composition
List.prototype.merge = function(/*...iters*/) {
return mergeIntoListWith(this, undefined, arguments);
};
List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, merger, iters);
};
List.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoListWith(this, deepMerger, arguments);
};
List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, deepMergerWith(merger), iters);
};
List.prototype.setSize = function(size) {
return setListBounds(this, 0, size);
};
// @pragma Iteration
List.prototype.slice = function(begin, end) {
var size = this.size;
if (wholeSlice(begin, end, size)) {
return this;
}
return setListBounds(
this,
resolveBegin(begin, size),
resolveEnd(end, size)
);
};
List.prototype.__iterator = function(type, reverse) {
var index = 0;
var values = iterateList(this, reverse);
return new Iterator(function() {
var value = values();
return value === DONE ?
iteratorDone() :
iteratorValue(type, index++, value);
});
};
List.prototype.__iterate = function(fn, reverse) {
var index = 0;
var values = iterateList(this, reverse);
var value;
while ((value = values()) !== DONE) {
if (fn(value, index++, this) === false) {
break;
}
}
return index;
};
List.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
return this;
}
return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
};
function isList(maybeList) {
return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
}
List.isList = isList;
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
var ListPrototype = List.prototype;
ListPrototype[IS_LIST_SENTINEL] = true;
ListPrototype[DELETE] = ListPrototype.remove;
ListPrototype.setIn = MapPrototype.setIn;
ListPrototype.deleteIn =
ListPrototype.removeIn = MapPrototype.removeIn;
ListPrototype.update = MapPrototype.update;
ListPrototype.updateIn = MapPrototype.updateIn;
ListPrototype.mergeIn = MapPrototype.mergeIn;
ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
ListPrototype.withMutations = MapPrototype.withMutations;
ListPrototype.asMutable = MapPrototype.asMutable;
ListPrototype.asImmutable = MapPrototype.asImmutable;
ListPrototype.wasAltered = MapPrototype.wasAltered;
function VNode(array, ownerID) {
this.array = array;
this.ownerID = ownerID;
}
// TODO: seems like these methods are very similar
VNode.prototype.removeBefore = function(ownerID, level, index) {
if (index === level ? 1 << level : 0 || this.array.length === 0) {
return this;
}
var originIndex = (index >>> level) & MASK;
if (originIndex >= this.array.length) {
return new VNode([], ownerID);
}
var removingFirst = originIndex === 0;
var newChild;
if (level > 0) {
var oldChild = this.array[originIndex];
newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
if (newChild === oldChild && removingFirst) {
return this;
}
}
if (removingFirst && !newChild) {
return this;
}
var editable = editableVNode(this, ownerID);
if (!removingFirst) {
for (var ii = 0; ii < originIndex; ii++) {
editable.array[ii] = undefined;
}
}
if (newChild) {
editable.array[originIndex] = newChild;
}
return editable;
};
VNode.prototype.removeAfter = function(ownerID, level, index) {
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
return this;
}
var sizeIndex = ((index - 1) >>> level) & MASK;
if (sizeIndex >= this.array.length) {
return this;
}
var newChild;
if (level > 0) {
var oldChild = this.array[sizeIndex];
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
if (newChild === oldChild && sizeIndex === this.array.length - 1) {
return this;
}
}
var editable = editableVNode(this, ownerID);
editable.array.splice(sizeIndex + 1);
if (newChild) {
editable.array[sizeIndex] = newChild;
}
return editable;
};
var DONE = {};
function iterateList(list, reverse) {
var left = list._origin;
var right = list._capacity;
var tailPos = getTailOffset(right);
var tail = list._tail;
return iterateNodeOrLeaf(list._root, list._level, 0);
function iterateNodeOrLeaf(node, level, offset) {
return level === 0 ?
iterateLeaf(node, offset) :
iterateNode(node, level, offset);
}
function iterateLeaf(node, offset) {
var array = offset === tailPos ? tail && tail.array : node && node.array;
var from = offset > left ? 0 : left - offset;
var to = right - offset;
if (to > SIZE) {
to = SIZE;
}
return function() {
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
return array && array[idx];
};
}
function iterateNode(node, level, offset) {
var values;
var array = node && node.array;
var from = offset > left ? 0 : (left - offset) >> level;
var to = ((right - offset) >> level) + 1;
if (to > SIZE) {
to = SIZE;
}
return function() {
do {
if (values) {
var value = values();
if (value !== DONE) {
return value;
}
values = null;
}
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
values = iterateNodeOrLeaf(
array && array[idx], level - SHIFT, offset + (idx << level)
);
} while (true);
};
}
}
function makeList(origin, capacity, level, root, tail, ownerID, hash) {
var list = Object.create(ListPrototype);
list.size = capacity - origin;
list._origin = origin;
list._capacity = capacity;
list._level = level;
list._root = root;
list._tail = tail;
list.__ownerID = ownerID;
list.__hash = hash;
list.__altered = false;
return list;
}
var EMPTY_LIST;
function emptyList() {
return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
}
function updateList(list, index, value) {
index = wrapIndex(list, index);
if (index !== index) {
return list;
}
if (index >= list.size || index < 0) {
return list.withMutations(function(list ) {
index < 0 ?
setListBounds(list, index).set(0, value) :
setListBounds(list, 0, index + 1).set(index, value)
});
}
index += list._origin;
var newTail = list._tail;
var newRoot = list._root;
var didAlter = MakeRef(DID_ALTER);
if (index >= getTailOffset(list._capacity)) {
newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
} else {
newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
}
if (!didAlter.value) {
return list;
}
if (list.__ownerID) {
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
}
function updateVNode(node, ownerID, level, index, value, didAlter) {
var idx = (index >>> level) & MASK;
var nodeHas = node && idx < node.array.length;
if (!nodeHas && value === undefined) {
return node;
}
var newNode;
if (level > 0) {
var lowerNode = node && node.array[idx];
var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
if (newLowerNode === lowerNode) {
return node;
}
newNode = editableVNode(node, ownerID);
newNode.array[idx] = newLowerNode;
return newNode;
}
if (nodeHas && node.array[idx] === value) {
return node;
}
SetRef(didAlter);
newNode = editableVNode(node, ownerID);
if (value === undefined && idx === newNode.array.length - 1) {
newNode.array.pop();
} else {
newNode.array[idx] = value;
}
return newNode;
}
function editableVNode(node, ownerID) {
if (ownerID && node && ownerID === node.ownerID) {
return node;
}
return new VNode(node ? node.array.slice() : [], ownerID);
}
function listNodeFor(list, rawIndex) {
if (rawIndex >= getTailOffset(list._capacity)) {
return list._tail;
}
if (rawIndex < 1 << (list._level + SHIFT)) {
var node = list._root;
var level = list._level;
while (node && level > 0) {
node = node.array[(rawIndex >>> level) & MASK];
level -= SHIFT;
}
return node;
}
}
function setListBounds(list, begin, end) {
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
var owner = list.__ownerID || new OwnerID();
var oldOrigin = list._origin;
var oldCapacity = list._capacity;
var newOrigin = oldOrigin + begin;
var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
return list;
}
// If it's going to end after it starts, it's empty.
if (newOrigin >= newCapacity) {
return list.clear();
}
var newLevel = list._level;
var newRoot = list._root;
// New origin might need creating a higher root.
var offsetShift = 0;
while (newOrigin + offsetShift < 0) {
newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
newLevel += SHIFT;
offsetShift += 1 << newLevel;
}
if (offsetShift) {
newOrigin += offsetShift;
oldOrigin += offsetShift;
newCapacity += offsetShift;
oldCapacity += offsetShift;
}
var oldTailOffset = getTailOffset(oldCapacity);
var newTailOffset = getTailOffset(newCapacity);
// New size might need creating a higher root.
while (newTailOffset >= 1 << (newLevel + SHIFT)) {
newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
newLevel += SHIFT;
}
// Locate or create the new tail.
var oldTail = list._tail;
var newTail = newTailOffset < oldTailOffset ?
listNodeFor(list, newCapacity - 1) :
newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
// Merge Tail into tree.
if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
newRoot = editableVNode(newRoot, owner);
var node = newRoot;
for (var level = newLevel; level > SHIFT; level -= SHIFT) {
var idx = (oldTailOffset >>> level) & MASK;
node = node.array[idx] = editableVNode(node.array[idx], owner);
}
node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
}
// If the size has been reduced, there's a chance the tail needs to be trimmed.
if (newCapacity < oldCapacity) {
newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
}
// If the new origin is within the tail, then we do not need a root.
if (newOrigin >= newTailOffset) {
newOrigin -= newTailOffset;
newCapacity -= newTailOffset;
newLevel = SHIFT;
newRoot = null;
newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
// Otherwise, if the root has been trimmed, garbage collect.
} else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
offsetShift = 0;
// Identify the new top root node of the subtree of the old root.
while (newRoot) {
var beginIndex = (newOrigin >>> newLevel) & MASK;
if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
break;
}
if (beginIndex) {
offsetShift += (1 << newLevel) * beginIndex;
}
newLevel -= SHIFT;
newRoot = newRoot.array[beginIndex];
}
// Trim the new sides of the new root.
if (newRoot && newOrigin > oldOrigin) {
newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
}
if (newRoot && newTailOffset < oldTailOffset) {
newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
}
if (offsetShift) {
newOrigin -= offsetShift;
newCapacity -= offsetShift;
}
}
if (list.__ownerID) {
list.size = newCapacity - newOrigin;
list._origin = newOrigin;
list._capacity = newCapacity;
list._level = newLevel;
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
}
function mergeIntoListWith(list, merger, iterables) {
var iters = [];
var maxSize = 0;
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = IndexedIterable(value);
if (iter.size > maxSize) {
maxSize = iter.size;
}
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
if (maxSize > list.size) {
list = list.setSize(maxSize);
}
return mergeIntoCollectionWith(list, merger, iters);
}
function getTailOffset(size) {
return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
}
createClass(OrderedMap, Map);
// @pragma Construction
function OrderedMap(value) {
return value === null || value === undefined ? emptyOrderedMap() :
isOrderedMap(value) ? value :
emptyOrderedMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
OrderedMap.of = function(/*...values*/) {
return this(arguments);
};
OrderedMap.prototype.toString = function() {
return this.__toString('OrderedMap {', '}');
};
// @pragma Access
OrderedMap.prototype.get = function(k, notSetValue) {
var index = this._map.get(k);
return index !== undefined ? this._list.get(index)[1] : notSetValue;
};
// @pragma Modification
OrderedMap.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._map.clear();
this._list.clear();
return this;
}
return emptyOrderedMap();
};
OrderedMap.prototype.set = function(k, v) {
return updateOrderedMap(this, k, v);
};
OrderedMap.prototype.remove = function(k) {
return updateOrderedMap(this, k, NOT_SET);
};
OrderedMap.prototype.wasAltered = function() {
return this._map.wasAltered() || this._list.wasAltered();
};
OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._list.__iterate(
function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
reverse
);
};
OrderedMap.prototype.__iterator = function(type, reverse) {
return this._list.fromEntrySeq().__iterator(type, reverse);
};
OrderedMap.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
var newList = this._list.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
this._list = newList;
return this;
}
return makeOrderedMap(newMap, newList, ownerID, this.__hash);
};
function isOrderedMap(maybeOrderedMap) {
return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
}
OrderedMap.isOrderedMap = isOrderedMap;
OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
function makeOrderedMap(map, list, ownerID, hash) {
var omap = Object.create(OrderedMap.prototype);
omap.size = map ? map.size : 0;
omap._map = map;
omap._list = list;
omap.__ownerID = ownerID;
omap.__hash = hash;
return omap;
}
var EMPTY_ORDERED_MAP;
function emptyOrderedMap() {
return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
}
function updateOrderedMap(omap, k, v) {
var map = omap._map;
var list = omap._list;
var i = map.get(k);
var has = i !== undefined;
var newMap;
var newList;
if (v === NOT_SET) { // removed
if (!has) {
return omap;
}
if (list.size >= SIZE && list.size >= map.size * 2) {
newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
if (omap.__ownerID) {
newMap.__ownerID = newList.__ownerID = omap.__ownerID;
}
} else {
newMap = map.remove(k);
newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
}
} else {
if (has) {
if (v === list.get(i)[1]) {
return omap;
}
newMap = map;
newList = list.set(i, [k, v]);
} else {
newMap = map.set(k, list.size);
newList = list.set(list.size, [k, v]);
}
}
if (omap.__ownerID) {
omap.size = newMap.size;
omap._map = newMap;
omap._list = newList;
omap.__hash = undefined;
return omap;
}
return makeOrderedMap(newMap, newList);
}
createClass(ToKeyedSequence, KeyedSeq);
function ToKeyedSequence(indexed, useKeys) {
this._iter = indexed;
this._useKeys = useKeys;
this.size = indexed.size;
}
ToKeyedSequence.prototype.get = function(key, notSetValue) {
return this._iter.get(key, notSetValue);
};
ToKeyedSequence.prototype.has = function(key) {
return this._iter.has(key);
};
ToKeyedSequence.prototype.valueSeq = function() {
return this._iter.valueSeq();
};
ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
var reversedSequence = reverseFactory(this, true);
if (!this._useKeys) {
reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
}
return reversedSequence;
};
ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
var mappedSequence = mapFactory(this, mapper, context);
if (!this._useKeys) {
mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
}
return mappedSequence;
};
ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var ii;
return this._iter.__iterate(
this._useKeys ?
function(v, k) {return fn(v, k, this$0)} :
((ii = reverse ? resolveSize(this) : 0),
function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
reverse
);
};
ToKeyedSequence.prototype.__iterator = function(type, reverse) {
if (this._useKeys) {
return this._iter.__iterator(type, reverse);
}
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var ii = reverse ? resolveSize(this) : 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, reverse ? --ii : ii++, step.value, step);
});
};
ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
createClass(ToIndexedSequence, IndexedSeq);
function ToIndexedSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToIndexedSequence.prototype.includes = function(value) {
return this._iter.includes(value);
};
ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
};
ToIndexedSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, iterations++, step.value, step)
});
};
createClass(ToSetSequence, SetSeq);
function ToSetSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToSetSequence.prototype.has = function(key) {
return this._iter.includes(key);
};
ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
};
ToSetSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, step.value, step.value, step);
});
};
createClass(FromEntriesSequence, KeyedSeq);
function FromEntriesSequence(entries) {
this._iter = entries;
this.size = entries.size;
}
FromEntriesSequence.prototype.entrySeq = function() {
return this._iter.toSeq();
};
FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(entry ) {
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return fn(
indexedIterable ? entry.get(1) : entry[1],
indexedIterable ? entry.get(0) : entry[0],
this$0
);
}
}, reverse);
};
FromEntriesSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return iteratorValue(
type,
indexedIterable ? entry.get(0) : entry[0],
indexedIterable ? entry.get(1) : entry[1],
step
);
}
}
});
};
ToIndexedSequence.prototype.cacheResult =
ToKeyedSequence.prototype.cacheResult =
ToSetSequence.prototype.cacheResult =
FromEntriesSequence.prototype.cacheResult =
cacheResultThrough;
function flipFactory(iterable) {
var flipSequence = makeSequence(iterable);
flipSequence._iter = iterable;
flipSequence.size = iterable.size;
flipSequence.flip = function() {return iterable};
flipSequence.reverse = function () {
var reversedSequence = iterable.reverse.apply(this); // super.reverse()
reversedSequence.flip = function() {return iterable.reverse()};
return reversedSequence;
};
flipSequence.has = function(key ) {return iterable.includes(key)};
flipSequence.includes = function(key ) {return iterable.has(key)};
flipSequence.cacheResult = cacheResultThrough;
flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
}
flipSequence.__iteratorUncached = function(type, reverse) {
if (type === ITERATE_ENTRIES) {
var iterator = iterable.__iterator(type, reverse);
return new Iterator(function() {
var step = iterator.next();
if (!step.done) {
var k = step.value[0];
step.value[0] = step.value[1];
step.value[1] = k;
}
return step;
});
}
return iterable.__iterator(
type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
reverse
);
}
return flipSequence;
}
function mapFactory(iterable, mapper, context) {
var mappedSequence = makeSequence(iterable);
mappedSequence.size = iterable.size;
mappedSequence.has = function(key ) {return iterable.has(key)};
mappedSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v === NOT_SET ?
notSetValue :
mapper.call(context, v, key, iterable);
};
mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(
function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
reverse
);
}
mappedSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
return new Iterator(function() {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
return iteratorValue(
type,
key,
mapper.call(context, entry[1], key, iterable),
step
);
});
}
return mappedSequence;
}
function reverseFactory(iterable, useKeys) {
var reversedSequence = makeSequence(iterable);
reversedSequence._iter = iterable;
reversedSequence.size = iterable.size;
reversedSequence.reverse = function() {return iterable};
if (iterable.flip) {
reversedSequence.flip = function () {
var flipSequence = flipFactory(iterable);
flipSequence.reverse = function() {return iterable.flip()};
return flipSequence;
};
}
reversedSequence.get = function(key, notSetValue)
{return iterable.get(useKeys ? key : -1 - key, notSetValue)};
reversedSequence.has = function(key )
{return iterable.has(useKeys ? key : -1 - key)};
reversedSequence.includes = function(value ) {return iterable.includes(value)};
reversedSequence.cacheResult = cacheResultThrough;
reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
};
reversedSequence.__iterator =
function(type, reverse) {return iterable.__iterator(type, !reverse)};
return reversedSequence;
}
function filterFactory(iterable, predicate, context, useKeys) {
var filterSequence = makeSequence(iterable);
if (useKeys) {
filterSequence.has = function(key ) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
};
filterSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
v : notSetValue;
};
}
filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
}, reverse);
return iterations;
};
filterSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterations = 0;
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
var value = entry[1];
if (predicate.call(context, value, key, iterable)) {
return iteratorValue(type, useKeys ? key : iterations++, value, step);
}
}
});
}
return filterSequence;
}
function countByFactory(iterable, grouper, context) {
var groups = Map().asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
0,
function(a ) {return a + 1}
);
});
return groups.asImmutable();
}
function groupByFactory(iterable, grouper, context) {
var isKeyedIter = isKeyed(iterable);
var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
);
});
var coerce = iterableClass(iterable);
return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
}
function sliceFactory(iterable, begin, end, useKeys) {
var originalSize = iterable.size;
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
if (wholeSlice(begin, end, originalSize)) {
return iterable;
}
var resolvedBegin = resolveBegin(begin, originalSize);
var resolvedEnd = resolveEnd(end, originalSize);
// begin or end will be NaN if they were provided as negative numbers and
// this iterable's size is unknown. In that case, cache first so there is
// a known size and these do not resolve to NaN.
if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
}
// Note: resolvedEnd is undefined when the original sequence's length is
// unknown and this slice did not supply an end and should contain all
// elements after resolvedBegin.
// In that case, resolvedSize will be NaN and sliceSize will remain undefined.
var resolvedSize = resolvedEnd - resolvedBegin;
var sliceSize;
if (resolvedSize === resolvedSize) {
sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
}
var sliceSeq = makeSequence(iterable);
// If iterable.size is undefined, the size of the realized sliceSeq is
// unknown at this point unless the number of items to slice is 0
sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
sliceSeq.get = function (index, notSetValue) {
index = wrapIndex(this, index);
return index >= 0 && index < sliceSize ?
iterable.get(index + resolvedBegin, notSetValue) :
notSetValue;
}
}
sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (sliceSize === 0) {
return 0;
}
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var skipped = 0;
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k) {
if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
iterations !== sliceSize;
}
});
return iterations;
};
sliceSeq.__iteratorUncached = function(type, reverse) {
if (sliceSize !== 0 && reverse) {
return this.cacheResult().__iterator(type, reverse);
}
// Don't bother instantiating parent iterator if taking 0.
var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
var skipped = 0;
var iterations = 0;
return new Iterator(function() {
while (skipped++ < resolvedBegin) {
iterator.next();
}
if (++iterations > sliceSize) {
return iteratorDone();
}
var step = iterator.next();
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations - 1, undefined, step);
} else {
return iteratorValue(type, iterations - 1, step.value[1], step);
}
});
}
return sliceSeq;
}
function takeWhileFactory(iterable, predicate, context) {
var takeSequence = makeSequence(iterable);
takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterations = 0;
iterable.__iterate(function(v, k, c)
{return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
);
return iterations;
};
takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterating = true;
return new Iterator(function() {
if (!iterating) {
return iteratorDone();
}
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var k = entry[0];
var v = entry[1];
if (!predicate.call(context, v, k, this$0)) {
iterating = false;
return iteratorDone();
}
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return takeSequence;
}
function skipWhileFactory(iterable, predicate, context, useKeys) {
var skipSequence = makeSequence(iterable);
skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
});
return iterations;
};
skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var skipping = true;
var iterations = 0;
return new Iterator(function() {
var step, k, v;
do {
step = iterator.next();
if (step.done) {
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations++, undefined, step);
} else {
return iteratorValue(type, iterations++, step.value[1], step);
}
}
var entry = step.value;
k = entry[0];
v = entry[1];
skipping && (skipping = predicate.call(context, v, k, this$0));
} while (skipping);
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return skipSequence;
}
function concatFactory(iterable, values) {
var isKeyedIterable = isKeyed(iterable);
var iters = [iterable].concat(values).map(function(v ) {
if (!isIterable(v)) {
v = isKeyedIterable ?
keyedSeqFromValue(v) :
indexedSeqFromValue(Array.isArray(v) ? v : [v]);
} else if (isKeyedIterable) {
v = KeyedIterable(v);
}
return v;
}).filter(function(v ) {return v.size !== 0});
if (iters.length === 0) {
return iterable;
}
if (iters.length === 1) {
var singleton = iters[0];
if (singleton === iterable ||
isKeyedIterable && isKeyed(singleton) ||
isIndexed(iterable) && isIndexed(singleton)) {
return singleton;
}
}
var concatSeq = new ArraySeq(iters);
if (isKeyedIterable) {
concatSeq = concatSeq.toKeyedSeq();
} else if (!isIndexed(iterable)) {
concatSeq = concatSeq.toSetSeq();
}
concatSeq = concatSeq.flatten(true);
concatSeq.size = iters.reduce(
function(sum, seq) {
if (sum !== undefined) {
var size = seq.size;
if (size !== undefined) {
return sum + size;
}
}
},
0
);
return concatSeq;
}
function flattenFactory(iterable, depth, useKeys) {
var flatSequence = makeSequence(iterable);
flatSequence.__iterateUncached = function(fn, reverse) {
var iterations = 0;
var stopped = false;
function flatDeep(iter, currentDepth) {var this$0 = this;
iter.__iterate(function(v, k) {
if ((!depth || currentDepth < depth) && isIterable(v)) {
flatDeep(v, currentDepth + 1);
} else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
stopped = true;
}
return !stopped;
}, reverse);
}
flatDeep(iterable, 0);
return iterations;
}
flatSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(type, reverse);
var stack = [];
var iterations = 0;
return new Iterator(function() {
while (iterator) {
var step = iterator.next();
if (step.done !== false) {
iterator = stack.pop();
continue;
}
var v = step.value;
if (type === ITERATE_ENTRIES) {
v = v[1];
}
if ((!depth || stack.length < depth) && isIterable(v)) {
stack.push(iterator);
iterator = v.__iterator(type, reverse);
} else {
return useKeys ? step : iteratorValue(type, iterations++, v, step);
}
}
return iteratorDone();
});
}
return flatSequence;
}
function flatMapFactory(iterable, mapper, context) {
var coerce = iterableClass(iterable);
return iterable.toSeq().map(
function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
).flatten(true);
}
function interposeFactory(iterable, separator) {
var interposedSequence = makeSequence(iterable);
interposedSequence.size = iterable.size && iterable.size * 2 -1;
interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k)
{return (!iterations || fn(separator, iterations++, this$0) !== false) &&
fn(v, iterations++, this$0) !== false},
reverse
);
return iterations;
};
interposedSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
var step;
return new Iterator(function() {
if (!step || iterations % 2) {
step = iterator.next();
if (step.done) {
return step;
}
}
return iterations % 2 ?
iteratorValue(type, iterations++, separator) :
iteratorValue(type, iterations++, step.value, step);
});
};
return interposedSequence;
}
function sortFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
var isKeyedIterable = isKeyed(iterable);
var index = 0;
var entries = iterable.toSeq().map(
function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
).toArray();
entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
isKeyedIterable ?
function(v, i) { entries[i].length = 2; } :
function(v, i) { entries[i] = v[1]; }
);
return isKeyedIterable ? KeyedSeq(entries) :
isIndexed(iterable) ? IndexedSeq(entries) :
SetSeq(entries);
}
function maxFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
if (mapper) {
var entry = iterable.toSeq()
.map(function(v, k) {return [v, mapper(v, k, iterable)]})
.reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
return entry && entry[0];
} else {
return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
}
}
function maxCompare(comparator, a, b) {
var comp = comparator(b, a);
// b is considered the new max if the comparator declares them equal, but
// they are not equal and b is in fact a nullish value.
return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
}
function zipWithFactory(keyIter, zipper, iters) {
var zipSequence = makeSequence(keyIter);
zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
// Note: this a generic base implementation of __iterate in terms of
// __iterator which may be more generically useful in the future.
zipSequence.__iterate = function(fn, reverse) {
/* generic:
var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
iterations++;
if (fn(step.value[1], step.value[0], this) === false) {
break;
}
}
return iterations;
*/
// indexed:
var iterator = this.__iterator(ITERATE_VALUES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
return iterations;
};
zipSequence.__iteratorUncached = function(type, reverse) {
var iterators = iters.map(function(i )
{return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
);
var iterations = 0;
var isDone = false;
return new Iterator(function() {
var steps;
if (!isDone) {
steps = iterators.map(function(i ) {return i.next()});
isDone = steps.some(function(s ) {return s.done});
}
if (isDone) {
return iteratorDone();
}
return iteratorValue(
type,
iterations++,
zipper.apply(null, steps.map(function(s ) {return s.value}))
);
});
};
return zipSequence
}
// #pragma Helper Functions
function reify(iter, seq) {
return isSeq(iter) ? seq : iter.constructor(seq);
}
function validateEntry(entry) {
if (entry !== Object(entry)) {
throw new TypeError('Expected [K, V] tuple: ' + entry);
}
}
function resolveSize(iter) {
assertNotInfinite(iter.size);
return ensureSize(iter);
}
function iterableClass(iterable) {
return isKeyed(iterable) ? KeyedIterable :
isIndexed(iterable) ? IndexedIterable :
SetIterable;
}
function makeSequence(iterable) {
return Object.create(
(
isKeyed(iterable) ? KeyedSeq :
isIndexed(iterable) ? IndexedSeq :
SetSeq
).prototype
);
}
function cacheResultThrough() {
if (this._iter.cacheResult) {
this._iter.cacheResult();
this.size = this._iter.size;
return this;
} else {
return Seq.prototype.cacheResult.call(this);
}
}
function defaultComparator(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
function forceIterator(keyPath) {
var iter = getIterator(keyPath);
if (!iter) {
// Array might not be iterable in this environment, so we need a fallback
// to our wrapped type.
if (!isArrayLike(keyPath)) {
throw new TypeError('Expected iterable or array-like: ' + keyPath);
}
iter = getIterator(Iterable(keyPath));
}
return iter;
}
createClass(Record, KeyedCollection);
function Record(defaultValues, name) {
var hasInitialized;
var RecordType = function Record(values) {
if (values instanceof RecordType) {
return values;
}
if (!(this instanceof RecordType)) {
return new RecordType(values);
}
if (!hasInitialized) {
hasInitialized = true;
var keys = Object.keys(defaultValues);
setProps(RecordTypePrototype, keys);
RecordTypePrototype.size = keys.length;
RecordTypePrototype._name = name;
RecordTypePrototype._keys = keys;
RecordTypePrototype._defaultValues = defaultValues;
}
this._map = Map(values);
};
var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
RecordTypePrototype.constructor = RecordType;
return RecordType;
}
Record.prototype.toString = function() {
return this.__toString(recordName(this) + ' {', '}');
};
// @pragma Access
Record.prototype.has = function(k) {
return this._defaultValues.hasOwnProperty(k);
};
Record.prototype.get = function(k, notSetValue) {
if (!this.has(k)) {
return notSetValue;
}
var defaultVal = this._defaultValues[k];
return this._map ? this._map.get(k, defaultVal) : defaultVal;
};
// @pragma Modification
Record.prototype.clear = function() {
if (this.__ownerID) {
this._map && this._map.clear();
return this;
}
var RecordType = this.constructor;
return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
};
Record.prototype.set = function(k, v) {
if (!this.has(k)) {
throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
}
var newMap = this._map && this._map.set(k, v);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.remove = function(k) {
if (!this.has(k)) {
return this;
}
var newMap = this._map && this._map.remove(k);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
};
Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
};
Record.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map && this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return makeRecord(this, newMap, ownerID);
};
var RecordPrototype = Record.prototype;
RecordPrototype[DELETE] = RecordPrototype.remove;
RecordPrototype.deleteIn =
RecordPrototype.removeIn = MapPrototype.removeIn;
RecordPrototype.merge = MapPrototype.merge;
RecordPrototype.mergeWith = MapPrototype.mergeWith;
RecordPrototype.mergeIn = MapPrototype.mergeIn;
RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
RecordPrototype.setIn = MapPrototype.setIn;
RecordPrototype.update = MapPrototype.update;
RecordPrototype.updateIn = MapPrototype.updateIn;
RecordPrototype.withMutations = MapPrototype.withMutations;
RecordPrototype.asMutable = MapPrototype.asMutable;
RecordPrototype.asImmutable = MapPrototype.asImmutable;
function makeRecord(likeRecord, map, ownerID) {
var record = Object.create(Object.getPrototypeOf(likeRecord));
record._map = map;
record.__ownerID = ownerID;
return record;
}
function recordName(record) {
return record._name || record.constructor.name || 'Record';
}
function setProps(prototype, names) {
try {
names.forEach(setProp.bind(undefined, prototype));
} catch (error) {
// Object.defineProperty failed. Probably IE8.
}
}
function setProp(prototype, name) {
Object.defineProperty(prototype, name, {
get: function() {
return this.get(name);
},
set: function(value) {
invariant(this.__ownerID, 'Cannot set on an immutable record.');
this.set(name, value);
}
});
}
createClass(Set, SetCollection);
// @pragma Construction
function Set(value) {
return value === null || value === undefined ? emptySet() :
isSet(value) && !isOrdered(value) ? value :
emptySet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
Set.of = function(/*...values*/) {
return this(arguments);
};
Set.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
Set.prototype.toString = function() {
return this.__toString('Set {', '}');
};
// @pragma Access
Set.prototype.has = function(value) {
return this._map.has(value);
};
// @pragma Modification
Set.prototype.add = function(value) {
return updateSet(this, this._map.set(value, true));
};
Set.prototype.remove = function(value) {
return updateSet(this, this._map.remove(value));
};
Set.prototype.clear = function() {
return updateSet(this, this._map.clear());
};
// @pragma Composition
Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return this;
}
if (this.size === 0 && !this.__ownerID && iters.length === 1) {
return this.constructor(iters[0]);
}
return this.withMutations(function(set ) {
for (var ii = 0; ii < iters.length; ii++) {
SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
}
});
};
Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (!iters.every(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (iters.some(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.merge = function() {
return this.union.apply(this, arguments);
};
Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return this.union.apply(this, iters);
};
Set.prototype.sort = function(comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator));
};
Set.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator, mapper));
};
Set.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
};
Set.prototype.__iterator = function(type, reverse) {
return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
};
Set.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return this.__make(newMap, ownerID);
};
function isSet(maybeSet) {
return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
}
Set.isSet = isSet;
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
var SetPrototype = Set.prototype;
SetPrototype[IS_SET_SENTINEL] = true;
SetPrototype[DELETE] = SetPrototype.remove;
SetPrototype.mergeDeep = SetPrototype.merge;
SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
SetPrototype.withMutations = MapPrototype.withMutations;
SetPrototype.asMutable = MapPrototype.asMutable;
SetPrototype.asImmutable = MapPrototype.asImmutable;
SetPrototype.__empty = emptySet;
SetPrototype.__make = makeSet;
function updateSet(set, newMap) {
if (set.__ownerID) {
set.size = newMap.size;
set._map = newMap;
return set;
}
return newMap === set._map ? set :
newMap.size === 0 ? set.__empty() :
set.__make(newMap);
}
function makeSet(map, ownerID) {
var set = Object.create(SetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_SET;
function emptySet() {
return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
}
createClass(OrderedSet, Set);
// @pragma Construction
function OrderedSet(value) {
return value === null || value === undefined ? emptyOrderedSet() :
isOrderedSet(value) ? value :
emptyOrderedSet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
OrderedSet.of = function(/*...values*/) {
return this(arguments);
};
OrderedSet.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
OrderedSet.prototype.toString = function() {
return this.__toString('OrderedSet {', '}');
};
function isOrderedSet(maybeOrderedSet) {
return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
}
OrderedSet.isOrderedSet = isOrderedSet;
var OrderedSetPrototype = OrderedSet.prototype;
OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
OrderedSetPrototype.__empty = emptyOrderedSet;
OrderedSetPrototype.__make = makeOrderedSet;
function makeOrderedSet(map, ownerID) {
var set = Object.create(OrderedSetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_ORDERED_SET;
function emptyOrderedSet() {
return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
}
createClass(Stack, IndexedCollection);
// @pragma Construction
function Stack(value) {
return value === null || value === undefined ? emptyStack() :
isStack(value) ? value :
emptyStack().unshiftAll(value);
}
Stack.of = function(/*...values*/) {
return this(arguments);
};
Stack.prototype.toString = function() {
return this.__toString('Stack [', ']');
};
// @pragma Access
Stack.prototype.get = function(index, notSetValue) {
var head = this._head;
index = wrapIndex(this, index);
while (head && index--) {
head = head.next;
}
return head ? head.value : notSetValue;
};
Stack.prototype.peek = function() {
return this._head && this._head.value;
};
// @pragma Modification
Stack.prototype.push = function(/*...values*/) {
if (arguments.length === 0) {
return this;
}
var newSize = this.size + arguments.length;
var head = this._head;
for (var ii = arguments.length - 1; ii >= 0; ii--) {
head = {
value: arguments[ii],
next: head
};
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pushAll = function(iter) {
iter = IndexedIterable(iter);
if (iter.size === 0) {
return this;
}
assertNotInfinite(iter.size);
var newSize = this.size;
var head = this._head;
iter.reverse().forEach(function(value ) {
newSize++;
head = {
value: value,
next: head
};
});
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pop = function() {
return this.slice(1);
};
Stack.prototype.unshift = function(/*...values*/) {
return this.push.apply(this, arguments);
};
Stack.prototype.unshiftAll = function(iter) {
return this.pushAll(iter);
};
Stack.prototype.shift = function() {
return this.pop.apply(this, arguments);
};
Stack.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._head = undefined;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyStack();
};
Stack.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
var resolvedBegin = resolveBegin(begin, this.size);
var resolvedEnd = resolveEnd(end, this.size);
if (resolvedEnd !== this.size) {
// super.slice(begin, end);
return IndexedCollection.prototype.slice.call(this, begin, end);
}
var newSize = this.size - resolvedBegin;
var head = this._head;
while (resolvedBegin--) {
head = head.next;
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
// @pragma Mutability
Stack.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeStack(this.size, this._head, ownerID, this.__hash);
};
// @pragma Iteration
Stack.prototype.__iterate = function(fn, reverse) {
if (reverse) {
return this.reverse().__iterate(fn);
}
var iterations = 0;
var node = this._head;
while (node) {
if (fn(node.value, iterations++, this) === false) {
break;
}
node = node.next;
}
return iterations;
};
Stack.prototype.__iterator = function(type, reverse) {
if (reverse) {
return this.reverse().__iterator(type);
}
var iterations = 0;
var node = this._head;
return new Iterator(function() {
if (node) {
var value = node.value;
node = node.next;
return iteratorValue(type, iterations++, value);
}
return iteratorDone();
});
};
function isStack(maybeStack) {
return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
}
Stack.isStack = isStack;
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
var StackPrototype = Stack.prototype;
StackPrototype[IS_STACK_SENTINEL] = true;
StackPrototype.withMutations = MapPrototype.withMutations;
StackPrototype.asMutable = MapPrototype.asMutable;
StackPrototype.asImmutable = MapPrototype.asImmutable;
StackPrototype.wasAltered = MapPrototype.wasAltered;
function makeStack(size, head, ownerID, hash) {
var map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}
/**
* Contributes additional methods to a constructor
*/
function mixin(ctor, methods) {
var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
Object.keys(methods).forEach(keyCopier);
Object.getOwnPropertySymbols &&
Object.getOwnPropertySymbols(methods).forEach(keyCopier);
return ctor;
}
Iterable.Iterator = Iterator;
mixin(Iterable, {
// ### Conversion to other types
toArray: function() {
assertNotInfinite(this.size);
var array = new Array(this.size || 0);
this.valueSeq().__iterate(function(v, i) { array[i] = v; });
return array;
},
toIndexedSeq: function() {
return new ToIndexedSequence(this);
},
toJS: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
).__toJS();
},
toJSON: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
).__toJS();
},
toKeyedSeq: function() {
return new ToKeyedSequence(this, true);
},
toMap: function() {
// Use Late Binding here to solve the circular dependency.
return Map(this.toKeyedSeq());
},
toObject: function() {
assertNotInfinite(this.size);
var object = {};
this.__iterate(function(v, k) { object[k] = v; });
return object;
},
toOrderedMap: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedMap(this.toKeyedSeq());
},
toOrderedSet: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
},
toSet: function() {
// Use Late Binding here to solve the circular dependency.
return Set(isKeyed(this) ? this.valueSeq() : this);
},
toSetSeq: function() {
return new ToSetSequence(this);
},
toSeq: function() {
return isIndexed(this) ? this.toIndexedSeq() :
isKeyed(this) ? this.toKeyedSeq() :
this.toSetSeq();
},
toStack: function() {
// Use Late Binding here to solve the circular dependency.
return Stack(isKeyed(this) ? this.valueSeq() : this);
},
toList: function() {
// Use Late Binding here to solve the circular dependency.
return List(isKeyed(this) ? this.valueSeq() : this);
},
// ### Common JavaScript methods and properties
toString: function() {
return '[Iterable]';
},
__toString: function(head, tail) {
if (this.size === 0) {
return head + tail;
}
return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
},
// ### ES6 Collection methods (ES6 Array and Map)
concat: function() {var values = SLICE$0.call(arguments, 0);
return reify(this, concatFactory(this, values));
},
includes: function(searchValue) {
return this.some(function(value ) {return is(value, searchValue)});
},
entries: function() {
return this.__iterator(ITERATE_ENTRIES);
},
every: function(predicate, context) {
assertNotInfinite(this.size);
var returnValue = true;
this.__iterate(function(v, k, c) {
if (!predicate.call(context, v, k, c)) {
returnValue = false;
return false;
}
});
return returnValue;
},
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, true));
},
find: function(predicate, context, notSetValue) {
var entry = this.findEntry(predicate, context);
return entry ? entry[1] : notSetValue;
},
findEntry: function(predicate, context) {
var found;
this.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
found = [k, v];
return false;
}
});
return found;
},
findLastEntry: function(predicate, context) {
return this.toSeq().reverse().findEntry(predicate, context);
},
forEach: function(sideEffect, context) {
assertNotInfinite(this.size);
return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
},
join: function(separator) {
assertNotInfinite(this.size);
separator = separator !== undefined ? '' + separator : ',';
var joined = '';
var isFirst = true;
this.__iterate(function(v ) {
isFirst ? (isFirst = false) : (joined += separator);
joined += v !== null && v !== undefined ? v.toString() : '';
});
return joined;
},
keys: function() {
return this.__iterator(ITERATE_KEYS);
},
map: function(mapper, context) {
return reify(this, mapFactory(this, mapper, context));
},
reduce: function(reducer, initialReduction, context) {
assertNotInfinite(this.size);
var reduction;
var useFirst;
if (arguments.length < 2) {
useFirst = true;
} else {
reduction = initialReduction;
}
this.__iterate(function(v, k, c) {
if (useFirst) {
useFirst = false;
reduction = v;
} else {
reduction = reducer.call(context, reduction, v, k, c);
}
});
return reduction;
},
reduceRight: function(reducer, initialReduction, context) {
var reversed = this.toKeyedSeq().reverse();
return reversed.reduce.apply(reversed, arguments);
},
reverse: function() {
return reify(this, reverseFactory(this, true));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, true));
},
some: function(predicate, context) {
return !this.every(not(predicate), context);
},
sort: function(comparator) {
return reify(this, sortFactory(this, comparator));
},
values: function() {
return this.__iterator(ITERATE_VALUES);
},
// ### More sequential methods
butLast: function() {
return this.slice(0, -1);
},
isEmpty: function() {
return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
},
count: function(predicate, context) {
return ensureSize(
predicate ? this.toSeq().filter(predicate, context) : this
);
},
countBy: function(grouper, context) {
return countByFactory(this, grouper, context);
},
equals: function(other) {
return deepEqual(this, other);
},
entrySeq: function() {
var iterable = this;
if (iterable._cache) {
// We cache as an entries array, so we can just return the cache!
return new ArraySeq(iterable._cache);
}
var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
return entriesSequence;
},
filterNot: function(predicate, context) {
return this.filter(not(predicate), context);
},
findLast: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
},
first: function() {
return this.find(returnTrue);
},
flatMap: function(mapper, context) {
return reify(this, flatMapFactory(this, mapper, context));
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, true));
},
fromEntrySeq: function() {
return new FromEntriesSequence(this);
},
get: function(searchKey, notSetValue) {
return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
},
getIn: function(searchKeyPath, notSetValue) {
var nested = this;
// Note: in an ES6 environment, we would prefer:
// for (var key of searchKeyPath) {
var iter = forceIterator(searchKeyPath);
var step;
while (!(step = iter.next()).done) {
var key = step.value;
nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
if (nested === NOT_SET) {
return notSetValue;
}
}
return nested;
},
groupBy: function(grouper, context) {
return groupByFactory(this, grouper, context);
},
has: function(searchKey) {
return this.get(searchKey, NOT_SET) !== NOT_SET;
},
hasIn: function(searchKeyPath) {
return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
},
isSubset: function(iter) {
iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
return this.every(function(value ) {return iter.includes(value)});
},
isSuperset: function(iter) {
iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
return iter.isSubset(this);
},
keySeq: function() {
return this.toSeq().map(keyMapper).toIndexedSeq();
},
last: function() {
return this.toSeq().reverse().first();
},
max: function(comparator) {
return maxFactory(this, comparator);
},
maxBy: function(mapper, comparator) {
return maxFactory(this, comparator, mapper);
},
min: function(comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
},
minBy: function(mapper, comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
},
rest: function() {
return this.slice(1);
},
skip: function(amount) {
return this.slice(Math.max(0, amount));
},
skipLast: function(amount) {
return reify(this, this.toSeq().reverse().skip(amount).reverse());
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, true));
},
skipUntil: function(predicate, context) {
return this.skipWhile(not(predicate), context);
},
sortBy: function(mapper, comparator) {
return reify(this, sortFactory(this, comparator, mapper));
},
take: function(amount) {
return this.slice(0, Math.max(0, amount));
},
takeLast: function(amount) {
return reify(this, this.toSeq().reverse().take(amount).reverse());
},
takeWhile: function(predicate, context) {
return reify(this, takeWhileFactory(this, predicate, context));
},
takeUntil: function(predicate, context) {
return this.takeWhile(not(predicate), context);
},
valueSeq: function() {
return this.toIndexedSeq();
},
// ### Hashable Object
hashCode: function() {
return this.__hash || (this.__hash = hashIterable(this));
}
// ### Internal
// abstract __iterate(fn, reverse)
// abstract __iterator(type, reverse)
});
// var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
// var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
// var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
// var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
var IterablePrototype = Iterable.prototype;
IterablePrototype[IS_ITERABLE_SENTINEL] = true;
IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
IterablePrototype.__toJS = IterablePrototype.toArray;
IterablePrototype.__toStringMapper = quoteString;
IterablePrototype.inspect =
IterablePrototype.toSource = function() { return this.toString(); };
IterablePrototype.chain = IterablePrototype.flatMap;
IterablePrototype.contains = IterablePrototype.includes;
// Temporary warning about using length
(function () {
try {
Object.defineProperty(IterablePrototype, 'length', {
get: function () {
if (!Iterable.noLengthWarning) {
var stack;
try {
throw new Error();
} catch (error) {
stack = error.stack;
}
if (stack.indexOf('_wrapObject') === -1) {
console && console.warn && console.warn(
'iterable.length has been deprecated, '+
'use iterable.size or iterable.count(). '+
'This warning will become a silent error in a future version. ' +
stack
);
return this.size;
}
}
}
});
} catch (e) {}
})();
mixin(KeyedIterable, {
// ### More sequential methods
flip: function() {
return reify(this, flipFactory(this));
},
findKey: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},
findLastKey: function(predicate, context) {
return this.toSeq().reverse().findKey(predicate, context);
},
keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},
lastKeyOf: function(searchValue) {
return this.findLastKey(function(value ) {return is(value, searchValue)});
},
mapEntries: function(mapper, context) {var this$0 = this;
var iterations = 0;
return reify(this,
this.toSeq().map(
function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
).fromEntrySeq()
);
},
mapKeys: function(mapper, context) {var this$0 = this;
return reify(this,
this.toSeq().flip().map(
function(k, v) {return mapper.call(context, k, v, this$0)}
).flip()
);
}
});
var KeyedIterablePrototype = KeyedIterable.prototype;
KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
mixin(IndexedIterable, {
// ### Conversion to other types
toKeyedSeq: function() {
return new ToKeyedSequence(this, false);
},
// ### ES6 Collection methods (ES6 Array and Map)
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, false));
},
findIndex: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry ? entry[0] : -1;
},
indexOf: function(searchValue) {
var key = this.toKeyedSeq().keyOf(searchValue);
return key === undefined ? -1 : key;
},
lastIndexOf: function(searchValue) {
var key = this.toKeyedSeq().reverse().keyOf(searchValue);
return key === undefined ? -1 : key;
// var index =
// return this.toSeq().reverse().indexOf(searchValue);
},
reverse: function() {
return reify(this, reverseFactory(this, false));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, false));
},
splice: function(index, removeNum /*, ...values*/) {
var numArgs = arguments.length;
removeNum = Math.max(removeNum | 0, 0);
if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
return this;
}
// If index is negative, it should resolve relative to the size of the
// collection. However size may be expensive to compute if not cached, so
// only call count() if the number is in fact negative.
index = resolveBegin(index, index < 0 ? this.count() : this.size);
var spliced = this.slice(0, index);
return reify(
this,
numArgs === 1 ?
spliced :
spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
);
},
// ### More collection methods
findLastIndex: function(predicate, context) {
var key = this.toKeyedSeq().findLastKey(predicate, context);
return key === undefined ? -1 : key;
},
first: function() {
return this.get(0);
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, false));
},
get: function(index, notSetValue) {
index = wrapIndex(this, index);
return (index < 0 || (this.size === Infinity ||
(this.size !== undefined && index > this.size))) ?
notSetValue :
this.find(function(_, key) {return key === index}, undefined, notSetValue);
},
has: function(index) {
index = wrapIndex(this, index);
return index >= 0 && (this.size !== undefined ?
this.size === Infinity || index < this.size :
this.indexOf(index) !== -1
);
},
interpose: function(separator) {
return reify(this, interposeFactory(this, separator));
},
interleave: function(/*...iterables*/) {
var iterables = [this].concat(arrCopy(arguments));
var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
var interleaved = zipped.flatten(true);
if (zipped.size) {
interleaved.size = zipped.size * iterables.length;
}
return reify(this, interleaved);
},
last: function() {
return this.get(-1);
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, false));
},
zip: function(/*, ...iterables */) {
var iterables = [this].concat(arrCopy(arguments));
return reify(this, zipWithFactory(this, defaultZipper, iterables));
},
zipWith: function(zipper/*, ...iterables */) {
var iterables = arrCopy(arguments);
iterables[0] = this;
return reify(this, zipWithFactory(this, zipper, iterables));
}
});
IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
mixin(SetIterable, {
// ### ES6 Collection methods (ES6 Array and Map)
get: function(value, notSetValue) {
return this.has(value) ? value : notSetValue;
},
includes: function(value) {
return this.has(value);
},
// ### More sequential methods
keySeq: function() {
return this.valueSeq();
}
});
SetIterable.prototype.has = IterablePrototype.includes;
// Mixin subclasses
mixin(KeyedSeq, KeyedIterable.prototype);
mixin(IndexedSeq, IndexedIterable.prototype);
mixin(SetSeq, SetIterable.prototype);
mixin(KeyedCollection, KeyedIterable.prototype);
mixin(IndexedCollection, IndexedIterable.prototype);
mixin(SetCollection, SetIterable.prototype);
// #pragma Helper functions
function keyMapper(v, k) {
return k;
}
function entryMapper(v, k) {
return [k, v];
}
function not(predicate) {
return function() {
return !predicate.apply(this, arguments);
}
}
function neg(predicate) {
return function() {
return -predicate.apply(this, arguments);
}
}
function quoteString(value) {
return typeof value === 'string' ? JSON.stringify(value) : value;
}
function defaultZipper() {
return arrCopy(arguments);
}
function defaultNegComparator(a, b) {
return a < b ? 1 : a > b ? -1 : 0;
}
function hashIterable(iterable) {
if (iterable.size === Infinity) {
return 0;
}
var ordered = isOrdered(iterable);
var keyed = isKeyed(iterable);
var h = ordered ? 1 : 0;
var size = iterable.__iterate(
keyed ?
ordered ?
function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
ordered ?
function(v ) { h = 31 * h + hash(v) | 0; } :
function(v ) { h = h + hash(v) | 0; }
);
return murmurHashOfSize(size, h);
}
function murmurHashOfSize(size, h) {
h = imul(h, 0xCC9E2D51);
h = imul(h << 15 | h >>> -15, 0x1B873593);
h = imul(h << 13 | h >>> -13, 5);
h = (h + 0xE6546B64 | 0) ^ size;
h = imul(h ^ h >>> 16, 0x85EBCA6B);
h = imul(h ^ h >>> 13, 0xC2B2AE35);
h = smi(h ^ h >>> 16);
return h;
}
function hashMerge(a, b) {
return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
}
var Immutable = {
Iterable: Iterable,
Seq: Seq,
Collection: Collection,
Map: Map,
OrderedMap: OrderedMap,
List: List,
Stack: Stack,
Set: Set,
OrderedSet: OrderedSet,
Record: Record,
Range: Range,
Repeat: Repeat,
is: is,
fromJS: fromJS
};
return Immutable;
}));
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _react = __webpack_require__(1);
var React = _interopRequireWildcard(_react);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _omit = __webpack_require__(22);
var _omit2 = _interopRequireDefault(_omit);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = function (props) {
var type = props.type,
_props$className = props.className,
className = _props$className === undefined ? '' : _props$className,
spin = props.spin;
var classString = (0, _classnames2["default"])((0, _defineProperty3["default"])({
anticon: true,
'anticon-spin': !!spin || type === 'loading'
}, 'anticon-' + type, true), className);
return React.createElement('i', (0, _extends3["default"])({}, (0, _omit2["default"])(props, ['type', 'spin']), { className: classString }));
};
module.exports = exports['default'];
/***/ },
/* 13 */,
/* 14 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {//! moment.js
//! version : 2.18.1
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
;(function (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.moment = factory()
}(this, (function () { 'use strict';
var hookCallback;
function hooks () {
return hookCallback.apply(null, arguments);
}
// This is done to register the method called with moment()
// without creating circular dependencies.
function setHookCallback (callback) {
hookCallback = callback;
}
function isArray(input) {
return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
}
function isObject(input) {
// IE8 will treat undefined and null as object if it wasn't for
// input != null
return input != null && Object.prototype.toString.call(input) === '[object Object]';
}
function isObjectEmpty(obj) {
var k;
for (k in obj) {
// even if its not own property I'd still call it non-empty
return false;
}
return true;
}
function isUndefined(input) {
return input === void 0;
}
function isNumber(input) {
return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
}
function isDate(input) {
return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
}
function map(arr, fn) {
var res = [], i;
for (i = 0; i < arr.length; ++i) {
res.push(fn(arr[i], i));
}
return res;
}
function hasOwnProp(a, b) {
return Object.prototype.hasOwnProperty.call(a, b);
}
function extend(a, b) {
for (var i in b) {
if (hasOwnProp(b, i)) {
a[i] = b[i];
}
}
if (hasOwnProp(b, 'toString')) {
a.toString = b.toString;
}
if (hasOwnProp(b, 'valueOf')) {
a.valueOf = b.valueOf;
}
return a;
}
function createUTC (input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, true).utc();
}
function defaultParsingFlags() {
// We need to deep clone this object.
return {
empty : false,
unusedTokens : [],
unusedInput : [],
overflow : -2,
charsLeftOver : 0,
nullInput : false,
invalidMonth : null,
invalidFormat : false,
userInvalidated : false,
iso : false,
parsedDateParts : [],
meridiem : null,
rfc2822 : false,
weekdayMismatch : false
};
}
function getParsingFlags(m) {
if (m._pf == null) {
m._pf = defaultParsingFlags();
}
return m._pf;
}
var some;
if (Array.prototype.some) {
some = Array.prototype.some;
} else {
some = function (fun) {
var t = Object(this);
var len = t.length >>> 0;
for (var i = 0; i < len; i++) {
if (i in t && fun.call(this, t[i], i, t)) {
return true;
}
}
return false;
};
}
var some$1 = some;
function isValid(m) {
if (m._isValid == null) {
var flags = getParsingFlags(m);
var parsedParts = some$1.call(flags.parsedDateParts, function (i) {
return i != null;
});
var isNowValid = !isNaN(m._d.getTime()) &&
flags.overflow < 0 &&
!flags.empty &&
!flags.invalidMonth &&
!flags.invalidWeekday &&
!flags.nullInput &&
!flags.invalidFormat &&
!flags.userInvalidated &&
(!flags.meridiem || (flags.meridiem && parsedParts));
if (m._strict) {
isNowValid = isNowValid &&
flags.charsLeftOver === 0 &&
flags.unusedTokens.length === 0 &&
flags.bigHour === undefined;
}
if (Object.isFrozen == null || !Object.isFrozen(m)) {
m._isValid = isNowValid;
}
else {
return isNowValid;
}
}
return m._isValid;
}
function createInvalid (flags) {
var m = createUTC(NaN);
if (flags != null) {
extend(getParsingFlags(m), flags);
}
else {
getParsingFlags(m).userInvalidated = true;
}
return m;
}
// Plugins that add properties should also add the key here (null value),
// so we can properly clone ourselves.
var momentProperties = hooks.momentProperties = [];
function copyConfig(to, from) {
var i, prop, val;
if (!isUndefined(from._isAMomentObject)) {
to._isAMomentObject = from._isAMomentObject;
}
if (!isUndefined(from._i)) {
to._i = from._i;
}
if (!isUndefined(from._f)) {
to._f = from._f;
}
if (!isUndefined(from._l)) {
to._l = from._l;
}
if (!isUndefined(from._strict)) {
to._strict = from._strict;
}
if (!isUndefined(from._tzm)) {
to._tzm = from._tzm;
}
if (!isUndefined(from._isUTC)) {
to._isUTC = from._isUTC;
}
if (!isUndefined(from._offset)) {
to._offset = from._offset;
}
if (!isUndefined(from._pf)) {
to._pf = getParsingFlags(from);
}
if (!isUndefined(from._locale)) {
to._locale = from._locale;
}
if (momentProperties.length > 0) {
for (i = 0; i < momentProperties.length; i++) {
prop = momentProperties[i];
val = from[prop];
if (!isUndefined(val)) {
to[prop] = val;
}
}
}
return to;
}
var updateInProgress = false;
// Moment prototype object
function Moment(config) {
copyConfig(this, config);
this._d = new Date(config._d != null ? config._d.getTime() : NaN);
if (!this.isValid()) {
this._d = new Date(NaN);
}
// Prevent infinite loop in case updateOffset creates new moment
// objects.
if (updateInProgress === false) {
updateInProgress = true;
hooks.updateOffset(this);
updateInProgress = false;
}
}
function isMoment (obj) {
return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
}
function absFloor (number) {
if (number < 0) {
// -0 -> 0
return Math.ceil(number) || 0;
} else {
return Math.floor(number);
}
}
function toInt(argumentForCoercion) {
var coercedNumber = +argumentForCoercion,
value = 0;
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
value = absFloor(coercedNumber);
}
return value;
}
// compare two arrays, return the number of differences
function compareArrays(array1, array2, dontConvert) {
var len = Math.min(array1.length, array2.length),
lengthDiff = Math.abs(array1.length - array2.length),
diffs = 0,
i;
for (i = 0; i < len; i++) {
if ((dontConvert && array1[i] !== array2[i]) ||
(!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
diffs++;
}
}
return diffs + lengthDiff;
}
function warn(msg) {
if (hooks.suppressDeprecationWarnings === false &&
(typeof console !== 'undefined') && console.warn) {
console.warn('Deprecation warning: ' + msg);
}
}
function deprecate(msg, fn) {
var firstTime = true;
return extend(function () {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(null, msg);
}
if (firstTime) {
var args = [];
var arg;
for (var i = 0; i < arguments.length; i++) {
arg = '';
if (typeof arguments[i] === 'object') {
arg += '\n[' + i + '] ';
for (var key in arguments[0]) {
arg += key + ': ' + arguments[0][key] + ', ';
}
arg = arg.slice(0, -2); // Remove trailing comma and space
} else {
arg = arguments[i];
}
args.push(arg);
}
warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
firstTime = false;
}
return fn.apply(this, arguments);
}, fn);
}
var deprecations = {};
function deprecateSimple(name, msg) {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(name, msg);
}
if (!deprecations[name]) {
warn(msg);
deprecations[name] = true;
}
}
hooks.suppressDeprecationWarnings = false;
hooks.deprecationHandler = null;
function isFunction(input) {
return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
}
function set (config) {
var prop, i;
for (i in config) {
prop = config[i];
if (isFunction(prop)) {
this[i] = prop;
} else {
this['_' + i] = prop;
}
}
this._config = config;
// Lenient ordinal parsing accepts just a number in addition to
// number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
// TODO: Remove "ordinalParse" fallback in next major release.
this._dayOfMonthOrdinalParseLenient = new RegExp(
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
'|' + (/\d{1,2}/).source);
}
function mergeConfigs(parentConfig, childConfig) {
var res = extend({}, parentConfig), prop;
for (prop in childConfig) {
if (hasOwnProp(childConfig, prop)) {
if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
res[prop] = {};
extend(res[prop], parentConfig[prop]);
extend(res[prop], childConfig[prop]);
} else if (childConfig[prop] != null) {
res[prop] = childConfig[prop];
} else {
delete res[prop];
}
}
}
for (prop in parentConfig) {
if (hasOwnProp(parentConfig, prop) &&
!hasOwnProp(childConfig, prop) &&
isObject(parentConfig[prop])) {
// make sure changes to properties don't modify parent config
res[prop] = extend({}, res[prop]);
}
}
return res;
}
function Locale(config) {
if (config != null) {
this.set(config);
}
}
var keys;
if (Object.keys) {
keys = Object.keys;
} else {
keys = function (obj) {
var i, res = [];
for (i in obj) {
if (hasOwnProp(obj, i)) {
res.push(i);
}
}
return res;
};
}
var keys$1 = keys;
var defaultCalendar = {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
nextWeek : 'dddd [at] LT',
lastDay : '[Yesterday at] LT',
lastWeek : '[Last] dddd [at] LT',
sameElse : 'L'
};
function calendar (key, mom, now) {
var output = this._calendar[key] || this._calendar['sameElse'];
return isFunction(output) ? output.call(mom, now) : output;
}
var defaultLongDateFormat = {
LTS : 'h:mm:ss A',
LT : 'h:mm A',
L : 'MM/DD/YYYY',
LL : 'MMMM D, YYYY',
LLL : 'MMMM D, YYYY h:mm A',
LLLL : 'dddd, MMMM D, YYYY h:mm A'
};
function longDateFormat (key) {
var format = this._longDateFormat[key],
formatUpper = this._longDateFormat[key.toUpperCase()];
if (format || !formatUpper) {
return format;
}
this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
return val.slice(1);
});
return this._longDateFormat[key];
}
var defaultInvalidDate = 'Invalid date';
function invalidDate () {
return this._invalidDate;
}
var defaultOrdinal = '%d';
var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
function ordinal (number) {
return this._ordinal.replace('%d', number);
}
var defaultRelativeTime = {
future : 'in %s',
past : '%s ago',
s : 'a few seconds',
ss : '%d seconds',
m : 'a minute',
mm : '%d minutes',
h : 'an hour',
hh : '%d hours',
d : 'a day',
dd : '%d days',
M : 'a month',
MM : '%d months',
y : 'a year',
yy : '%d years'
};
function relativeTime (number, withoutSuffix, string, isFuture) {
var output = this._relativeTime[string];
return (isFunction(output)) ?
output(number, withoutSuffix, string, isFuture) :
output.replace(/%d/i, number);
}
function pastFuture (diff, output) {
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
}
var aliases = {};
function addUnitAlias (unit, shorthand) {
var lowerCase = unit.toLowerCase();
aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
}
function normalizeUnits(units) {
return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
}
function normalizeObjectUnits(inputObject) {
var normalizedInput = {},
normalizedProp,
prop;
for (prop in inputObject) {
if (hasOwnProp(inputObject, prop)) {
normalizedProp = normalizeUnits(prop);
if (normalizedProp) {
normalizedInput[normalizedProp] = inputObject[prop];
}
}
}
return normalizedInput;
}
var priorities = {};
function addUnitPriority(unit, priority) {
priorities[unit] = priority;
}
function getPrioritizedUnits(unitsObj) {
var units = [];
for (var u in unitsObj) {
units.push({unit: u, priority: priorities[u]});
}
units.sort(function (a, b) {
return a.priority - b.priority;
});
return units;
}
function makeGetSet (unit, keepTime) {
return function (value) {
if (value != null) {
set$1(this, unit, value);
hooks.updateOffset(this, keepTime);
return this;
} else {
return get(this, unit);
}
};
}
function get (mom, unit) {
return mom.isValid() ?
mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
}
function set$1 (mom, unit, value) {
if (mom.isValid()) {
mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
}
}
// MOMENTS
function stringGet (units) {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units]();
}
return this;
}
function stringSet (units, value) {
if (typeof units === 'object') {
units = normalizeObjectUnits(units);
var prioritized = getPrioritizedUnits(units);
for (var i = 0; i < prioritized.length; i++) {
this[prioritized[i].unit](units[prioritized[i].unit]);
}
} else {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units](value);
}
}
return this;
}
function zeroFill(number, targetLength, forceSign) {
var absNumber = '' + Math.abs(number),
zerosToFill = targetLength - absNumber.length,
sign = number >= 0;
return (sign ? (forceSign ? '+' : '') : '-') +
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
}
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
var formatFunctions = {};
var formatTokenFunctions = {};
// token: 'M'
// padded: ['MM', 2]
// ordinal: 'Mo'
// callback: function () { this.month() + 1 }
function addFormatToken (token, padded, ordinal, callback) {
var func = callback;
if (typeof callback === 'string') {
func = function () {
return this[callback]();
};
}
if (token) {
formatTokenFunctions[token] = func;
}
if (padded) {
formatTokenFunctions[padded[0]] = function () {
return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
};
}
if (ordinal) {
formatTokenFunctions[ordinal] = function () {
return this.localeData().ordinal(func.apply(this, arguments), token);
};
}
}
function removeFormattingTokens(input) {
if (input.match(/\[[\s\S]/)) {
return input.replace(/^\[|\]$/g, '');
}
return input.replace(/\\/g, '');
}
function makeFormatFunction(format) {
var array = format.match(formattingTokens), i, length;
for (i = 0, length = array.length; i < length; i++) {
if (formatTokenFunctions[array[i]]) {
array[i] = formatTokenFunctions[array[i]];
} else {
array[i] = removeFormattingTokens(array[i]);
}
}
return function (mom) {
var output = '', i;
for (i = 0; i < length; i++) {
output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
}
return output;
};
}
// format date using native date object
function formatMoment(m, format) {
if (!m.isValid()) {
return m.localeData().invalidDate();
}
format = expandFormat(format, m.localeData());
formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
return formatFunctions[format](m);
}
function expandFormat(format, locale) {
var i = 5;
function replaceLongDateFormatTokens(input) {
return locale.longDateFormat(input) || input;
}
localFormattingTokens.lastIndex = 0;
while (i >= 0 && localFormattingTokens.test(format)) {
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
localFormattingTokens.lastIndex = 0;
i -= 1;
}
return format;
}
var match1 = /\d/; // 0 - 9
var match2 = /\d\d/; // 00 - 99
var match3 = /\d{3}/; // 000 - 999
var match4 = /\d{4}/; // 0000 - 9999
var match6 = /[+-]?\d{6}/; // -999999 - 999999
var match1to2 = /\d\d?/; // 0 - 99
var match3to4 = /\d\d\d\d?/; // 999 - 9999
var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
var match1to3 = /\d{1,3}/; // 0 - 999
var match1to4 = /\d{1,4}/; // 0 - 9999
var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
var matchUnsigned = /\d+/; // 0 - inf
var matchSigned = /[+-]?\d+/; // -inf - inf
var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
var regexes = {};
function addRegexToken (token, regex, strictRegex) {
regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
return (isStrict && strictRegex) ? strictRegex : regex;
};
}
function getParseRegexForToken (token, config) {
if (!hasOwnProp(regexes, token)) {
return new RegExp(unescapeFormat(token));
}
return regexes[token](config._strict, config._locale);
}
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(s) {
return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
return p1 || p2 || p3 || p4;
}));
}
function regexEscape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
var tokens = {};
function addParseToken (token, callback) {
var i, func = callback;
if (typeof token === 'string') {
token = [token];
}
if (isNumber(callback)) {
func = function (input, array) {
array[callback] = toInt(input);
};
}
for (i = 0; i < token.length; i++) {
tokens[token[i]] = func;
}
}
function addWeekParseToken (token, callback) {
addParseToken(token, function (input, array, config, token) {
config._w = config._w || {};
callback(input, config._w, config, token);
});
}
function addTimeToArrayFromToken(token, input, config) {
if (input != null && hasOwnProp(tokens, token)) {
tokens[token](input, config._a, config, token);
}
}
var YEAR = 0;
var MONTH = 1;
var DATE = 2;
var HOUR = 3;
var MINUTE = 4;
var SECOND = 5;
var MILLISECOND = 6;
var WEEK = 7;
var WEEKDAY = 8;
var indexOf;
if (Array.prototype.indexOf) {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function (o) {
// I know
var i;
for (i = 0; i < this.length; ++i) {
if (this[i] === o) {
return i;
}
}
return -1;
};
}
var indexOf$1 = indexOf;
function daysInMonth(year, month) {
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
}
// FORMATTING
addFormatToken('M', ['MM', 2], 'Mo', function () {
return this.month() + 1;
});
addFormatToken('MMM', 0, 0, function (format) {
return this.localeData().monthsShort(this, format);
});
addFormatToken('MMMM', 0, 0, function (format) {
return this.localeData().months(this, format);
});
// ALIASES
addUnitAlias('month', 'M');
// PRIORITY
addUnitPriority('month', 8);
// PARSING
addRegexToken('M', match1to2);
addRegexToken('MM', match1to2, match2);
addRegexToken('MMM', function (isStrict, locale) {
return locale.monthsShortRegex(isStrict);
});
addRegexToken('MMMM', function (isStrict, locale) {
return locale.monthsRegex(isStrict);
});
addParseToken(['M', 'MM'], function (input, array) {
array[MONTH] = toInt(input) - 1;
});
addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
var month = config._locale.monthsParse(input, token, config._strict);
// if we didn't find a month name, mark the date as invalid.
if (month != null) {
array[MONTH] = month;
} else {
getParsingFlags(config).invalidMonth = input;
}
});
// LOCALES
var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
function localeMonths (m, format) {
if (!m) {
return isArray(this._months) ? this._months :
this._months['standalone'];
}
return isArray(this._months) ? this._months[m.month()] :
this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
}
var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
function localeMonthsShort (m, format) {
if (!m) {
return isArray(this._monthsShort) ? this._monthsShort :
this._monthsShort['standalone'];
}
return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
function handleStrictParse(monthName, format, strict) {
var i, ii, mom, llc = monthName.toLocaleLowerCase();
if (!this._monthsParse) {
// this is not used
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
for (i = 0; i < 12; ++i) {
mom = createUTC([2000, i]);
this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
}
}
if (strict) {
if (format === 'MMM') {
ii = indexOf$1.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf$1.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format === 'MMM') {
ii = indexOf$1.call(this._shortMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf$1.call(this._longMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeMonthsParse (monthName, format, strict) {
var i, mom, regex;
if (this._monthsParseExact) {
return handleStrictParse.call(this, monthName, format, strict);
}
if (!this._monthsParse) {
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
}
// TODO: add sorting
// Sorting makes sure if one month (or abbr) is a prefix of another
// see sorting in computeMonthsParse
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
if (strict && !this._longMonthsParse[i]) {
this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
}
if (!strict && !this._monthsParse[i]) {
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
return i;
} else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
return i;
} else if (!strict && this._monthsParse[i].test(monthName)) {
return i;
}
}
}
// MOMENTS
function setMonth (mom, value) {
var dayOfMonth;
if (!mom.isValid()) {
// No op
return mom;
}
if (typeof value === 'string') {
if (/^\d+$/.test(value)) {
value = toInt(value);
} else {
value = mom.localeData().monthsParse(value);
// TODO: Another silent failure?
if (!isNumber(value)) {
return mom;
}
}
}
dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
return mom;
}
function getSetMonth (value) {
if (value != null) {
setMonth(this, value);
hooks.updateOffset(this, true);
return this;
} else {
return get(this, 'Month');
}
}
function getDaysInMonth () {
return daysInMonth(this.year(), this.month());
}
var defaultMonthsShortRegex = matchWord;
function monthsShortRegex (isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsShortStrictRegex;
} else {
return this._monthsShortRegex;
}
} else {
if (!hasOwnProp(this, '_monthsShortRegex')) {
this._monthsShortRegex = defaultMonthsShortRegex;
}
return this._monthsShortStrictRegex && isStrict ?
this._monthsShortStrictRegex : this._monthsShortRegex;
}
}
var defaultMonthsRegex = matchWord;
function monthsRegex (isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsStrictRegex;
} else {
return this._monthsRegex;
}
} else {
if (!hasOwnProp(this, '_monthsRegex')) {
this._monthsRegex = defaultMonthsRegex;
}
return this._monthsStrictRegex && isStrict ?
this._monthsStrictRegex : this._monthsRegex;
}
}
function computeMonthsParse () {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var shortPieces = [], longPieces = [], mixedPieces = [],
i, mom;
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
shortPieces.push(this.monthsShort(mom, ''));
longPieces.push(this.months(mom, ''));
mixedPieces.push(this.months(mom, ''));
mixedPieces.push(this.monthsShort(mom, ''));
}
// Sorting makes sure if one month (or abbr) is a prefix of another it
// will match the longer piece.
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 12; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
}
for (i = 0; i < 24; i++) {
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._monthsShortRegex = this._monthsRegex;
this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
}
// FORMATTING
addFormatToken('Y', 0, 0, function () {
var y = this.year();
return y <= 9999 ? '' + y : '+' + y;
});
addFormatToken(0, ['YY', 2], 0, function () {
return this.year() % 100;
});
addFormatToken(0, ['YYYY', 4], 0, 'year');
addFormatToken(0, ['YYYYY', 5], 0, 'year');
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
// ALIASES
addUnitAlias('year', 'y');
// PRIORITIES
addUnitPriority('year', 1);
// PARSING
addRegexToken('Y', matchSigned);
addRegexToken('YY', match1to2, match2);
addRegexToken('YYYY', match1to4, match4);
addRegexToken('YYYYY', match1to6, match6);
addRegexToken('YYYYYY', match1to6, match6);
addParseToken(['YYYYY', 'YYYYYY'], YEAR);
addParseToken('YYYY', function (input, array) {
array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
});
addParseToken('YY', function (input, array) {
array[YEAR] = hooks.parseTwoDigitYear(input);
});
addParseToken('Y', function (input, array) {
array[YEAR] = parseInt(input, 10);
});
// HELPERS
function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}
// HOOKS
hooks.parseTwoDigitYear = function (input) {
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};
// MOMENTS
var getSetYear = makeGetSet('FullYear', true);
function getIsLeapYear () {
return isLeapYear(this.year());
}
function createDate (y, m, d, h, M, s, ms) {
// can't just apply() to create a date:
// https://stackoverflow.com/q/181348
var date = new Date(y, m, d, h, M, s, ms);
// the date constructor remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
date.setFullYear(y);
}
return date;
}
function createUTCDate (y) {
var date = new Date(Date.UTC.apply(null, arguments));
// the Date.UTC function remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
date.setUTCFullYear(y);
}
return date;
}
// start-of-first-week - start-of-year
function firstWeekOffset(year, dow, doy) {
var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
fwd = 7 + dow - doy,
// first-week day local weekday -- which local weekday is fwd
fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
return -fwdlw + fwd - 1;
}
// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
var localWeekday = (7 + weekday - dow) % 7,
weekOffset = firstWeekOffset(year, dow, doy),
dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
resYear, resDayOfYear;
if (dayOfYear <= 0) {
resYear = year - 1;
resDayOfYear = daysInYear(resYear) + dayOfYear;
} else if (dayOfYear > daysInYear(year)) {
resYear = year + 1;
resDayOfYear = dayOfYear - daysInYear(year);
} else {
resYear = year;
resDayOfYear = dayOfYear;
}
return {
year: resYear,
dayOfYear: resDayOfYear
};
}
function weekOfYear(mom, dow, doy) {
var weekOffset = firstWeekOffset(mom.year(), dow, doy),
week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
resWeek, resYear;
if (week < 1) {
resYear = mom.year() - 1;
resWeek = week + weeksInYear(resYear, dow, doy);
} else if (week > weeksInYear(mom.year(), dow, doy)) {
resWeek = week - weeksInYear(mom.year(), dow, doy);
resYear = mom.year() + 1;
} else {
resYear = mom.year();
resWeek = week;
}
return {
week: resWeek,
year: resYear
};
}
function weeksInYear(year, dow, doy) {
var weekOffset = firstWeekOffset(year, dow, doy),
weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
}
// FORMATTING
addFormatToken('w', ['ww', 2], 'wo', 'week');
addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
// ALIASES
addUnitAlias('week', 'w');
addUnitAlias('isoWeek', 'W');
// PRIORITIES
addUnitPriority('week', 5);
addUnitPriority('isoWeek', 5);
// PARSING
addRegexToken('w', match1to2);
addRegexToken('ww', match1to2, match2);
addRegexToken('W', match1to2);
addRegexToken('WW', match1to2, match2);
addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
week[token.substr(0, 1)] = toInt(input);
});
// HELPERS
// LOCALES
function localeWeek (mom) {
return weekOfYear(mom, this._week.dow, this._week.doy).week;
}
var defaultLocaleWeek = {
dow : 0, // Sunday is the first day of the week.
doy : 6 // The week that contains Jan 1st is the first week of the year.
};
function localeFirstDayOfWeek () {
return this._week.dow;
}
function localeFirstDayOfYear () {
return this._week.doy;
}
// MOMENTS
function getSetWeek (input) {
var week = this.localeData().week(this);
return input == null ? week : this.add((input - week) * 7, 'd');
}
function getSetISOWeek (input) {
var week = weekOfYear(this, 1, 4).week;
return input == null ? week : this.add((input - week) * 7, 'd');
}
// FORMATTING
addFormatToken('d', 0, 'do', 'day');
addFormatToken('dd', 0, 0, function (format) {
return this.localeData().weekdaysMin(this, format);
});
addFormatToken('ddd', 0, 0, function (format) {
return this.localeData().weekdaysShort(this, format);
});
addFormatToken('dddd', 0, 0, function (format) {
return this.localeData().weekdays(this, format);
});
addFormatToken('e', 0, 0, 'weekday');
addFormatToken('E', 0, 0, 'isoWeekday');
// ALIASES
addUnitAlias('day', 'd');
addUnitAlias('weekday', 'e');
addUnitAlias('isoWeekday', 'E');
// PRIORITY
addUnitPriority('day', 11);
addUnitPriority('weekday', 11);
addUnitPriority('isoWeekday', 11);
// PARSING
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
addRegexToken('dd', function (isStrict, locale) {
return locale.weekdaysMinRegex(isStrict);
});
addRegexToken('ddd', function (isStrict, locale) {
return locale.weekdaysShortRegex(isStrict);
});
addRegexToken('dddd', function (isStrict, locale) {
return locale.weekdaysRegex(isStrict);
});
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
var weekday = config._locale.weekdaysParse(input, token, config._strict);
// if we didn't get a weekday name, mark the date as invalid
if (weekday != null) {
week.d = weekday;
} else {
getParsingFlags(config).invalidWeekday = input;
}
});
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
week[token] = toInt(input);
});
// HELPERS
function parseWeekday(input, locale) {
if (typeof input !== 'string') {
return input;
}
if (!isNaN(input)) {
return parseInt(input, 10);
}
input = locale.weekdaysParse(input);
if (typeof input === 'number') {
return input;
}
return null;
}
function parseIsoWeekday(input, locale) {
if (typeof input === 'string') {
return locale.weekdaysParse(input) % 7 || 7;
}
return isNaN(input) ? null : input;
}
// LOCALES
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
function localeWeekdays (m, format) {
if (!m) {
return isArray(this._weekdays) ? this._weekdays :
this._weekdays['standalone'];
}
return isArray(this._weekdays) ? this._weekdays[m.day()] :
this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
}
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
function localeWeekdaysShort (m) {
return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
}
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
function localeWeekdaysMin (m) {
return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
}
function handleStrictParse$1(weekdayName, format, strict) {
var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._shortWeekdaysParse = [];
this._minWeekdaysParse = [];
for (i = 0; i < 7; ++i) {
mom = createUTC([2000, 1]).day(i);
this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
}
}
if (strict) {
if (format === 'dddd') {
ii = indexOf$1.call(this._weekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format === 'ddd') {
ii = indexOf$1.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf$1.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format === 'dddd') {
ii = indexOf$1.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format === 'ddd') {
ii = indexOf$1.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf$1.call(this._minWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf$1.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeWeekdaysParse (weekdayName, format, strict) {
var i, mom, regex;
if (this._weekdaysParseExact) {
return handleStrictParse$1.call(this, weekdayName, format, strict);
}
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._minWeekdaysParse = [];
this._shortWeekdaysParse = [];
this._fullWeekdaysParse = [];
}
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
}
if (!this._weekdaysParse[i]) {
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
return i;
}
}
}
// MOMENTS
function getSetDayOfWeek (input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
if (input != null) {
input = parseWeekday(input, this.localeData());
return this.add(input - day, 'd');
} else {
return day;
}
}
function getSetLocaleDayOfWeek (input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
return input == null ? weekday : this.add(input - weekday, 'd');
}
function getSetISODayOfWeek (input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
// behaves the same as moment#day except
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
// as a setter, sunday should belong to the previous week.
if (input != null) {
var weekday = parseIsoWeekday(input, this.localeData());
return this.day(this.day() % 7 ? weekday : weekday - 7);
} else {
return this.day() || 7;
}
}
var defaultWeekdaysRegex = matchWord;
function weekdaysRegex (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysStrictRegex;
} else {
return this._weekdaysRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysRegex')) {
this._weekdaysRegex = defaultWeekdaysRegex;
}
return this._weekdaysStrictRegex && isStrict ?
this._weekdaysStrictRegex : this._weekdaysRegex;
}
}
var defaultWeekdaysShortRegex = matchWord;
function weekdaysShortRegex (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysShortStrictRegex;
} else {
return this._weekdaysShortRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysShortRegex')) {
this._weekdaysShortRegex = defaultWeekdaysShortRegex;
}
return this._weekdaysShortStrictRegex && isStrict ?
this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
}
}
var defaultWeekdaysMinRegex = matchWord;
function weekdaysMinRegex (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysMinStrictRegex;
} else {
return this._weekdaysMinRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysMinRegex')) {
this._weekdaysMinRegex = defaultWeekdaysMinRegex;
}
return this._weekdaysMinStrictRegex && isStrict ?
this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
}
}
function computeWeekdaysParse () {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
i, mom, minp, shortp, longp;
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, 1]).day(i);
minp = this.weekdaysMin(mom, '');
shortp = this.weekdaysShort(mom, '');
longp = this.weekdays(mom, '');
minPieces.push(minp);
shortPieces.push(shortp);
longPieces.push(longp);
mixedPieces.push(minp);
mixedPieces.push(shortp);
mixedPieces.push(longp);
}
// Sorting makes sure if one weekday (or abbr) is a prefix of another it
// will match the longer piece.
minPieces.sort(cmpLenRev);
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 7; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._weekdaysShortRegex = this._weekdaysRegex;
this._weekdaysMinRegex = this._weekdaysRegex;
this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
}
// FORMATTING
function hFormat() {
return this.hours() % 12 || 12;
}
function kFormat() {
return this.hours() || 24;
}
addFormatToken('H', ['HH', 2], 0, 'hour');
addFormatToken('h', ['hh', 2], 0, hFormat);
addFormatToken('k', ['kk', 2], 0, kFormat);
addFormatToken('hmm', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
});
addFormatToken('hmmss', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
zeroFill(this.seconds(), 2);
});
addFormatToken('Hmm', 0, 0, function () {
return '' + this.hours() + zeroFill(this.minutes(), 2);
});
addFormatToken('Hmmss', 0, 0, function () {
return '' + this.hours() + zeroFill(this.minutes(), 2) +
zeroFill(this.seconds(), 2);
});
function meridiem (token, lowercase) {
addFormatToken(token, 0, 0, function () {
return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
});
}
meridiem('a', true);
meridiem('A', false);
// ALIASES
addUnitAlias('hour', 'h');
// PRIORITY
addUnitPriority('hour', 13);
// PARSING
function matchMeridiem (isStrict, locale) {
return locale._meridiemParse;
}
addRegexToken('a', matchMeridiem);
addRegexToken('A', matchMeridiem);
addRegexToken('H', match1to2);
addRegexToken('h', match1to2);
addRegexToken('k', match1to2);
addRegexToken('HH', match1to2, match2);
addRegexToken('hh', match1to2, match2);
addRegexToken('kk', match1to2, match2);
addRegexToken('hmm', match3to4);
addRegexToken('hmmss', match5to6);
addRegexToken('Hmm', match3to4);
addRegexToken('Hmmss', match5to6);
addParseToken(['H', 'HH'], HOUR);
addParseToken(['k', 'kk'], function (input, array, config) {
var kInput = toInt(input);
array[HOUR] = kInput === 24 ? 0 : kInput;
});
addParseToken(['a', 'A'], function (input, array, config) {
config._isPm = config._locale.isPM(input);
config._meridiem = input;
});
addParseToken(['h', 'hh'], function (input, array, config) {
array[HOUR] = toInt(input);
getParsingFlags(config).bigHour = true;
});
addParseToken('hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
getParsingFlags(config).bigHour = true;
});
addParseToken('hmmss', function (input, array, config) {
var pos1 = input.length - 4;
var pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
getParsingFlags(config).bigHour = true;
});
addParseToken('Hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
});
addParseToken('Hmmss', function (input, array, config) {
var pos1 = input.length - 4;
var pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
});
// LOCALES
function localeIsPM (input) {
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
// Using charAt should be more compatible.
return ((input + '').toLowerCase().charAt(0) === 'p');
}
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
function localeMeridiem (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'pm' : 'PM';
} else {
return isLower ? 'am' : 'AM';
}
}
// MOMENTS
// Setting the hour should keep the time, because the user explicitly
// specified which hour he wants. So trying to maintain the same hour (in
// a new timezone) makes sense. Adding/subtracting hours does not follow
// this rule.
var getSetHour = makeGetSet('Hours', true);
// months
// week
// weekdays
// meridiem
var baseConfig = {
calendar: defaultCalendar,
longDateFormat: defaultLongDateFormat,
invalidDate: defaultInvalidDate,
ordinal: defaultOrdinal,
dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
relativeTime: defaultRelativeTime,
months: defaultLocaleMonths,
monthsShort: defaultLocaleMonthsShort,
week: defaultLocaleWeek,
weekdays: defaultLocaleWeekdays,
weekdaysMin: defaultLocaleWeekdaysMin,
weekdaysShort: defaultLocaleWeekdaysShort,
meridiemParse: defaultLocaleMeridiemParse
};
// internal storage for locale config files
var locales = {};
var localeFamilies = {};
var globalLocale;
function normalizeLocale(key) {
return key ? key.toLowerCase().replace('_', '-') : key;
}
// pick the locale from the array
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
function chooseLocale(names) {
var i = 0, j, next, locale, split;
while (i < names.length) {
split = normalizeLocale(names[i]).split('-');
j = split.length;
next = normalizeLocale(names[i + 1]);
next = next ? next.split('-') : null;
while (j > 0) {
locale = loadLocale(split.slice(0, j).join('-'));
if (locale) {
return locale;
}
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
//the next array item is better than a shallower substring of this one
break;
}
j--;
}
i++;
}
return null;
}
function loadLocale(name) {
var oldLocale = null;
// TODO: Find a better way to register and load all the locales in Node
if (!locales[name] && (typeof module !== 'undefined') &&
module && module.exports) {
try {
oldLocale = globalLocale._abbr;
!(function webpackMissingModule() { var e = new Error("Cannot find module \"./locale\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());
// because defineLocale currently also sets the global locale, we
// want to undo that for lazy loaded locales
getSetGlobalLocale(oldLocale);
} catch (e) { }
}
return locales[name];
}
// This function will load locale and then set the global locale. If
// no arguments are passed in, it will simply return the current global
// locale key.
function getSetGlobalLocale (key, values) {
var data;
if (key) {
if (isUndefined(values)) {
data = getLocale(key);
}
else {
data = defineLocale(key, values);
}
if (data) {
// moment.duration._locale = moment._locale = data;
globalLocale = data;
}
}
return globalLocale._abbr;
}
function defineLocale (name, config) {
if (config !== null) {
var parentConfig = baseConfig;
config.abbr = name;
if (locales[name] != null) {
deprecateSimple('defineLocaleOverride',
'use moment.updateLocale(localeName, config) to change ' +
'an existing locale. moment.defineLocale(localeName, ' +
'config) should only be used for creating a new locale ' +
'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
parentConfig = locales[name]._config;
} else if (config.parentLocale != null) {
if (locales[config.parentLocale] != null) {
parentConfig = locales[config.parentLocale]._config;
} else {
if (!localeFamilies[config.parentLocale]) {
localeFamilies[config.parentLocale] = [];
}
localeFamilies[config.parentLocale].push({
name: name,
config: config
});
return null;
}
}
locales[name] = new Locale(mergeConfigs(parentConfig, config));
if (localeFamilies[name]) {
localeFamilies[name].forEach(function (x) {
defineLocale(x.name, x.config);
});
}
// backwards compat for now: also set the locale
// make sure we set the locale AFTER all child locales have been
// created, so we won't end up with the child locale set.
getSetGlobalLocale(name);
return locales[name];
} else {
// useful for testing
delete locales[name];
return null;
}
}
function updateLocale(name, config) {
if (config != null) {
var locale, parentConfig = baseConfig;
// MERGE
if (locales[name] != null) {
parentConfig = locales[name]._config;
}
config = mergeConfigs(parentConfig, config);
locale = new Locale(config);
locale.parentLocale = locales[name];
locales[name] = locale;
// backwards compat for now: also set the locale
getSetGlobalLocale(name);
} else {
// pass null for config to unupdate, useful for tests
if (locales[name] != null) {
if (locales[name].parentLocale != null) {
locales[name] = locales[name].parentLocale;
} else if (locales[name] != null) {
delete locales[name];
}
}
}
return locales[name];
}
// returns locale data
function getLocale (key) {
var locale;
if (key && key._locale && key._locale._abbr) {
key = key._locale._abbr;
}
if (!key) {
return globalLocale;
}
if (!isArray(key)) {
//short-circuit everything else
locale = loadLocale(key);
if (locale) {
return locale;
}
key = [key];
}
return chooseLocale(key);
}
function listLocales() {
return keys$1(locales);
}
function checkOverflow (m) {
var overflow;
var a = m._a;
if (a && getParsingFlags(m).overflow === -2) {
overflow =
a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
-1;
if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
overflow = DATE;
}
if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
overflow = WEEK;
}
if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
overflow = WEEKDAY;
}
getParsingFlags(m).overflow = overflow;
}
return m;
}
// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
var isoDates = [
['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
['GGGG-[W]WW', /\d{4}-W\d\d/, false],
['YYYY-DDD', /\d{4}-\d{3}/],
['YYYY-MM', /\d{4}-\d\d/, false],
['YYYYYYMMDD', /[+-]\d{10}/],
['YYYYMMDD', /\d{8}/],
// YYYYMM is NOT allowed by the standard
['GGGG[W]WWE', /\d{4}W\d{3}/],
['GGGG[W]WW', /\d{4}W\d{2}/, false],
['YYYYDDD', /\d{7}/]
];
// iso time formats and regexes
var isoTimes = [
['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
['HH:mm:ss', /\d\d:\d\d:\d\d/],
['HH:mm', /\d\d:\d\d/],
['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
['HHmmss', /\d\d\d\d\d\d/],
['HHmm', /\d\d\d\d/],
['HH', /\d\d/]
];
var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
// date from iso format
function configFromISO(config) {
var i, l,
string = config._i,
match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
allowTime, dateFormat, timeFormat, tzFormat;
if (match) {
getParsingFlags(config).iso = true;
for (i = 0, l = isoDates.length; i < l; i++) {
if (isoDates[i][1].exec(match[1])) {
dateFormat = isoDates[i][0];
allowTime = isoDates[i][2] !== false;
break;
}
}
if (dateFormat == null) {
config._isValid = false;
return;
}
if (match[3]) {
for (i = 0, l = isoTimes.length; i < l; i++) {
if (isoTimes[i][1].exec(match[3])) {
// match[2] should be 'T' or space
timeFormat = (match[2] || ' ') + isoTimes[i][0];
break;
}
}
if (timeFormat == null) {
config._isValid = false;
return;
}
}
if (!allowTime && timeFormat != null) {
config._isValid = false;
return;
}
if (match[4]) {
if (tzRegex.exec(match[4])) {
tzFormat = 'Z';
} else {
config._isValid = false;
return;
}
}
config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
configFromStringAndFormat(config);
} else {
config._isValid = false;
}
}
// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
var basicRfcRegex = /^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/;
// date and time from ref 2822 format
function configFromRFC2822(config) {
var string, match, dayFormat,
dateFormat, timeFormat, tzFormat;
var timezones = {
' GMT': ' +0000',
' EDT': ' -0400',
' EST': ' -0500',
' CDT': ' -0500',
' CST': ' -0600',
' MDT': ' -0600',
' MST': ' -0700',
' PDT': ' -0700',
' PST': ' -0800'
};
var military = 'YXWVUTSRQPONZABCDEFGHIKLM';
var timezone, timezoneIndex;
string = config._i
.replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace
.replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space
.replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces
match = basicRfcRegex.exec(string);
if (match) {
dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : '';
dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY ');
timeFormat = 'HH:mm' + (match[4] ? ':ss' : '');
// TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
if (match[1]) { // day of week given
var momentDate = new Date(match[2]);
var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()];
if (match[1].substr(0,3) !== momentDay) {
getParsingFlags(config).weekdayMismatch = true;
config._isValid = false;
return;
}
}
switch (match[5].length) {
case 2: // military
if (timezoneIndex === 0) {
timezone = ' +0000';
} else {
timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12;
timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
(('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
}
break;
case 4: // Zone
timezone = timezones[match[5]];
break;
default: // UT or +/-9999
timezone = timezones[' GMT'];
}
match[5] = timezone;
config._i = match.splice(1).join('');
tzFormat = ' ZZ';
config._f = dayFormat + dateFormat + timeFormat + tzFormat;
configFromStringAndFormat(config);
getParsingFlags(config).rfc2822 = true;
} else {
config._isValid = false;
}
}
// date from iso format or fallback
function configFromString(config) {
var matched = aspNetJsonRegex.exec(config._i);
if (matched !== null) {
config._d = new Date(+matched[1]);
return;
}
configFromISO(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
configFromRFC2822(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
// Final attempt, use Input Fallback
hooks.createFromInputFallback(config);
}
hooks.createFromInputFallback = deprecate(
'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
'discouraged and will be removed in an upcoming major release. Please refer to ' +
'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
function (config) {
config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
}
);
// Pick the first defined of two or three arguments.
function defaults(a, b, c) {
if (a != null) {
return a;
}
if (b != null) {
return b;
}
return c;
}
function currentDateArray(config) {
// hooks is actually the exported moment object
var nowValue = new Date(hooks.now());
if (config._useUTC) {
return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
}
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}
// convert an array to a date.
// the array should mirror the parameters below
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
function configFromArray (config) {
var i, date, input = [], currentDate, yearToUse;
if (config._d) {
return;
}
currentDate = currentDateArray(config);
//compute day of the year from weeks and weekdays
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
dayOfYearFromWeekInfo(config);
}
//if the day of the year is set, figure out what it is
if (config._dayOfYear != null) {
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
getParsingFlags(config)._overflowDayOfYear = true;
}
date = createUTCDate(yearToUse, 0, config._dayOfYear);
config._a[MONTH] = date.getUTCMonth();
config._a[DATE] = date.getUTCDate();
}
// Default to current date.
// * if no year, month, day of month are given, default to today
// * if day of month is given, default month and year
// * if month is given, default only year
// * if year is given, don't default anything
for (i = 0; i < 3 && config._a[i] == null; ++i) {
config._a[i] = input[i] = currentDate[i];
}
// Zero out whatever was not defaulted, including time
for (; i < 7; i++) {
config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
}
// Check for 24:00:00.000
if (config._a[HOUR] === 24 &&
config._a[MINUTE] === 0 &&
config._a[SECOND] === 0 &&
config._a[MILLISECOND] === 0) {
config._nextDay = true;
config._a[HOUR] = 0;
}
config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
// Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
}
if (config._nextDay) {
config._a[HOUR] = 24;
}
}
function dayOfYearFromWeekInfo(config) {
var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
w = config._w;
if (w.GG != null || w.W != null || w.E != null) {
dow = 1;
doy = 4;
// TODO: We need to take the current isoWeekYear, but that depends on
// how we interpret now (local, utc, fixed offset). So create
// a now version of current config (take local/utc/offset flags, and
// create now).
weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
week = defaults(w.W, 1);
weekday = defaults(w.E, 1);
if (weekday < 1 || weekday > 7) {
weekdayOverflow = true;
}
} else {
dow = config._locale._week.dow;
doy = config._locale._week.doy;
var curWeek = weekOfYear(createLocal(), dow, doy);
weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
// Default to current week.
week = defaults(w.w, curWeek.week);
if (w.d != null) {
// weekday -- low day numbers are considered next week
weekday = w.d;
if (weekday < 0 || weekday > 6) {
weekdayOverflow = true;
}
} else if (w.e != null) {
// local weekday -- counting starts from begining of week
weekday = w.e + dow;
if (w.e < 0 || w.e > 6) {
weekdayOverflow = true;
}
} else {
// default to begining of week
weekday = dow;
}
}
if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
getParsingFlags(config)._overflowWeeks = true;
} else if (weekdayOverflow != null) {
getParsingFlags(config)._overflowWeekday = true;
} else {
temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
config._a[YEAR] = temp.year;
config._dayOfYear = temp.dayOfYear;
}
}
// constant that refers to the ISO standard
hooks.ISO_8601 = function () {};
// constant that refers to the RFC 2822 form
hooks.RFC_2822 = function () {};
// date from string and format string
function configFromStringAndFormat(config) {
// TODO: Move this to another part of the creation flow to prevent circular deps
if (config._f === hooks.ISO_8601) {
configFromISO(config);
return;
}
if (config._f === hooks.RFC_2822) {
configFromRFC2822(config);
return;
}
config._a = [];
getParsingFlags(config).empty = true;
// This array is used to make a Date, either with `new Date` or `Date.UTC`
var string = '' + config._i,
i, parsedInput, tokens, token, skipped,
stringLength = string.length,
totalParsedInputLength = 0;
tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
// console.log('token', token, 'parsedInput', parsedInput,
// 'regex', getParseRegexForToken(token, config));
if (parsedInput) {
skipped = string.substr(0, string.indexOf(parsedInput));
if (skipped.length > 0) {
getParsingFlags(config).unusedInput.push(skipped);
}
string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
totalParsedInputLength += parsedInput.length;
}
// don't parse if it's not a known token
if (formatTokenFunctions[token]) {
if (parsedInput) {
getParsingFlags(config).empty = false;
}
else {
getParsingFlags(config).unusedTokens.push(token);
}
addTimeToArrayFromToken(token, parsedInput, config);
}
else if (config._strict && !parsedInput) {
getParsingFlags(config).unusedTokens.push(token);
}
}
// add remaining unparsed input length to the string
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
if (string.length > 0) {
getParsingFlags(config).unusedInput.push(string);
}
// clear _12h flag if hour is <= 12
if (config._a[HOUR] <= 12 &&
getParsingFlags(config).bigHour === true &&
config._a[HOUR] > 0) {
getParsingFlags(config).bigHour = undefined;
}
getParsingFlags(config).parsedDateParts = config._a.slice(0);
getParsingFlags(config).meridiem = config._meridiem;
// handle meridiem
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
configFromArray(config);
checkOverflow(config);
}
function meridiemFixWrap (locale, hour, meridiem) {
var isPm;
if (meridiem == null) {
// nothing to do
return hour;
}
if (locale.meridiemHour != null) {
return locale.meridiemHour(hour, meridiem);
} else if (locale.isPM != null) {
// Fallback
isPm = locale.isPM(meridiem);
if (isPm && hour < 12) {
hour += 12;
}
if (!isPm && hour === 12) {
hour = 0;
}
return hour;
} else {
// this is not supposed to happen
return hour;
}
}
// date from string and array of format strings
function configFromStringAndArray(config) {
var tempConfig,
bestMoment,
scoreToBeat,
i,
currentScore;
if (config._f.length === 0) {
getParsingFlags(config).invalidFormat = true;
config._d = new Date(NaN);
return;
}
for (i = 0; i < config._f.length; i++) {
currentScore = 0;
tempConfig = copyConfig({}, config);
if (config._useUTC != null) {
tempConfig._useUTC = config._useUTC;
}
tempConfig._f = config._f[i];
configFromStringAndFormat(tempConfig);
if (!isValid(tempConfig)) {
continue;
}
// if there is any input that was not parsed add a penalty for that format
currentScore += getParsingFlags(tempConfig).charsLeftOver;
//or tokens
currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
getParsingFlags(tempConfig).score = currentScore;
if (scoreToBeat == null || currentScore < scoreToBeat) {
scoreToBeat = currentScore;
bestMoment = tempConfig;
}
}
extend(config, bestMoment || tempConfig);
}
function configFromObject(config) {
if (config._d) {
return;
}
var i = normalizeObjectUnits(config._i);
config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
return obj && parseInt(obj, 10);
});
configFromArray(config);
}
function createFromConfig (config) {
var res = new Moment(checkOverflow(prepareConfig(config)));
if (res._nextDay) {
// Adding is smart enough around DST
res.add(1, 'd');
res._nextDay = undefined;
}
return res;
}
function prepareConfig (config) {
var input = config._i,
format = config._f;
config._locale = config._locale || getLocale(config._l);
if (input === null || (format === undefined && input === '')) {
return createInvalid({nullInput: true});
}
if (typeof input === 'string') {
config._i = input = config._locale.preparse(input);
}
if (isMoment(input)) {
return new Moment(checkOverflow(input));
} else if (isDate(input)) {
config._d = input;
} else if (isArray(format)) {
configFromStringAndArray(config);
} else if (format) {
configFromStringAndFormat(config);
} else {
configFromInput(config);
}
if (!isValid(config)) {
config._d = null;
}
return config;
}
function configFromInput(config) {
var input = config._i;
if (isUndefined(input)) {
config._d = new Date(hooks.now());
} else if (isDate(input)) {
config._d = new Date(input.valueOf());
} else if (typeof input === 'string') {
configFromString(config);
} else if (isArray(input)) {
config._a = map(input.slice(0), function (obj) {
return parseInt(obj, 10);
});
configFromArray(config);
} else if (isObject(input)) {
configFromObject(config);
} else if (isNumber(input)) {
// from milliseconds
config._d = new Date(input);
} else {
hooks.createFromInputFallback(config);
}
}
function createLocalOrUTC (input, format, locale, strict, isUTC) {
var c = {};
if (locale === true || locale === false) {
strict = locale;
locale = undefined;
}
if ((isObject(input) && isObjectEmpty(input)) ||
(isArray(input) && input.length === 0)) {
input = undefined;
}
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
c._isAMomentObject = true;
c._useUTC = c._isUTC = isUTC;
c._l = locale;
c._i = input;
c._f = format;
c._strict = strict;
return createFromConfig(c);
}
function createLocal (input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, false);
}
var prototypeMin = deprecate(
'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other < this ? this : other;
} else {
return createInvalid();
}
}
);
var prototypeMax = deprecate(
'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other > this ? this : other;
} else {
return createInvalid();
}
}
);
// Pick a moment m from moments so that m[fn](other) is true for all
// other. This relies on the function fn to be transitive.
//
// moments should either be an array of moment objects or an array, whose
// first element is an array of moment objects.
function pickBy(fn, moments) {
var res, i;
if (moments.length === 1 && isArray(moments[0])) {
moments = moments[0];
}
if (!moments.length) {
return createLocal();
}
res = moments[0];
for (i = 1; i < moments.length; ++i) {
if (!moments[i].isValid() || moments[i][fn](res)) {
res = moments[i];
}
}
return res;
}
// TODO: Use [].sort instead?
function min () {
var args = [].slice.call(arguments, 0);
return pickBy('isBefore', args);
}
function max () {
var args = [].slice.call(arguments, 0);
return pickBy('isAfter', args);
}
var now = function () {
return Date.now ? Date.now() : +(new Date());
};
var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
function isDurationValid(m) {
for (var key in m) {
if (!(ordering.indexOf(key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
return false;
}
}
var unitHasDecimal = false;
for (var i = 0; i < ordering.length; ++i) {
if (m[ordering[i]]) {
if (unitHasDecimal) {
return false; // only allow non-integers for smallest unit
}
if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
unitHasDecimal = true;
}
}
}
return true;
}
function isValid$1() {
return this._isValid;
}
function createInvalid$1() {
return createDuration(NaN);
}
function Duration (duration) {
var normalizedInput = normalizeObjectUnits(duration),
years = normalizedInput.year || 0,
quarters = normalizedInput.quarter || 0,
months = normalizedInput.month || 0,
weeks = normalizedInput.week || 0,
days = normalizedInput.day || 0,
hours = normalizedInput.hour || 0,
minutes = normalizedInput.minute || 0,
seconds = normalizedInput.second || 0,
milliseconds = normalizedInput.millisecond || 0;
this._isValid = isDurationValid(normalizedInput);
// representation for dateAddRemove
this._milliseconds = +milliseconds +
seconds * 1e3 + // 1000
minutes * 6e4 + // 1000 * 60
hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days +
weeks * 7;
// It is impossible translate months into days without knowing
// which months you are are talking about, so we have to store
// it separately.
this._months = +months +
quarters * 3 +
years * 12;
this._data = {};
this._locale = getLocale();
this._bubble();
}
function isDuration (obj) {
return obj instanceof Duration;
}
function absRound (number) {
if (number < 0) {
return Math.round(-1 * number) * -1;
} else {
return Math.round(number);
}
}
// FORMATTING
function offset (token, separator) {
addFormatToken(token, 0, 0, function () {
var offset = this.utcOffset();
var sign = '+';
if (offset < 0) {
offset = -offset;
sign = '-';
}
return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
});
}
offset('Z', ':');
offset('ZZ', '');
// PARSING
addRegexToken('Z', matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
config._useUTC = true;
config._tzm = offsetFromString(matchShortOffset, input);
});
// HELPERS
// timezone chunker
// '+10:00' > ['10', '00']
// '-1530' > ['-15', '30']
var chunkOffset = /([\+\-]|\d\d)/gi;
function offsetFromString(matcher, string) {
var matches = (string || '').match(matcher);
if (matches === null) {
return null;
}
var chunk = matches[matches.length - 1] || [];
var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
var minutes = +(parts[1] * 60) + toInt(parts[2]);
return minutes === 0 ?
0 :
parts[0] === '+' ? minutes : -minutes;
}
// Return a moment from input, that is local/utc/zone equivalent to model.
function cloneWithOffset(input, model) {
var res, diff;
if (model._isUTC) {
res = model.clone();
diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
// Use low-level api, because this fn is low-level api.
res._d.setTime(res._d.valueOf() + diff);
hooks.updateOffset(res, false);
return res;
} else {
return createLocal(input).local();
}
}
function getDateOffset (m) {
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
// https://github.com/moment/moment/pull/1871
return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
}
// HOOKS
// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
hooks.updateOffset = function () {};
// MOMENTS
// keepLocalTime = true means only change the timezone, without
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
//
// Keeping the time actually adds/subtracts (one hour)
// from the actual represented time. That is why we call updateOffset
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
function getSetOffset (input, keepLocalTime, keepMinutes) {
var offset = this._offset || 0,
localAdjust;
if (!this.isValid()) {
return input != null ? this : NaN;
}
if (input != null) {
if (typeof input === 'string') {
input = offsetFromString(matchShortOffset, input);
if (input === null) {
return this;
}
} else if (Math.abs(input) < 16 && !keepMinutes) {
input = input * 60;
}
if (!this._isUTC && keepLocalTime) {
localAdjust = getDateOffset(this);
}
this._offset = input;
this._isUTC = true;
if (localAdjust != null) {
this.add(localAdjust, 'm');
}
if (offset !== input) {
if (!keepLocalTime || this._changeInProgress) {
addSubtract(this, createDuration(input - offset, 'm'), 1, false);
} else if (!this._changeInProgress) {
this._changeInProgress = true;
hooks.updateOffset(this, true);
this._changeInProgress = null;
}
}
return this;
} else {
return this._isUTC ? offset : getDateOffset(this);
}
}
function getSetZone (input, keepLocalTime) {
if (input != null) {
if (typeof input !== 'string') {
input = -input;
}
this.utcOffset(input, keepLocalTime);
return this;
} else {
return -this.utcOffset();
}
}
function setOffsetToUTC (keepLocalTime) {
return this.utcOffset(0, keepLocalTime);
}
function setOffsetToLocal (keepLocalTime) {
if (this._isUTC) {
this.utcOffset(0, keepLocalTime);
this._isUTC = false;
if (keepLocalTime) {
this.subtract(getDateOffset(this), 'm');
}
}
return this;
}
function setOffsetToParsedOffset () {
if (this._tzm != null) {
this.utcOffset(this._tzm, false, true);
} else if (typeof this._i === 'string') {
var tZone = offsetFromString(matchOffset, this._i);
if (tZone != null) {
this.utcOffset(tZone);
}
else {
this.utcOffset(0, true);
}
}
return this;
}
function hasAlignedHourOffset (input) {
if (!this.isValid()) {
return false;
}
input = input ? createLocal(input).utcOffset() : 0;
return (this.utcOffset() - input) % 60 === 0;
}
function isDaylightSavingTime () {
return (
this.utcOffset() > this.clone().month(0).utcOffset() ||
this.utcOffset() > this.clone().month(5).utcOffset()
);
}
function isDaylightSavingTimeShifted () {
if (!isUndefined(this._isDSTShifted)) {
return this._isDSTShifted;
}
var c = {};
copyConfig(c, this);
c = prepareConfig(c);
if (c._a) {
var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
this._isDSTShifted = this.isValid() &&
compareArrays(c._a, other.toArray()) > 0;
} else {
this._isDSTShifted = false;
}
return this._isDSTShifted;
}
function isLocal () {
return this.isValid() ? !this._isUTC : false;
}
function isUtcOffset () {
return this.isValid() ? this._isUTC : false;
}
function isUtc () {
return this.isValid() ? this._isUTC && this._offset === 0 : false;
}
// ASP.NET json date format regex
var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
// and further modified to allow for strings containing both week and day
var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
function createDuration (input, key) {
var duration = input,
// matching against regexp is expensive, do it on demand
match = null,
sign,
ret,
diffRes;
if (isDuration(input)) {
duration = {
ms : input._milliseconds,
d : input._days,
M : input._months
};
} else if (isNumber(input)) {
duration = {};
if (key) {
duration[key] = input;
} else {
duration.milliseconds = input;
}
} else if (!!(match = aspNetRegex.exec(input))) {
sign = (match[1] === '-') ? -1 : 1;
duration = {
y : 0,
d : toInt(match[DATE]) * sign,
h : toInt(match[HOUR]) * sign,
m : toInt(match[MINUTE]) * sign,
s : toInt(match[SECOND]) * sign,
ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
};
} else if (!!(match = isoRegex.exec(input))) {
sign = (match[1] === '-') ? -1 : 1;
duration = {
y : parseIso(match[2], sign),
M : parseIso(match[3], sign),
w : parseIso(match[4], sign),
d : parseIso(match[5], sign),
h : parseIso(match[6], sign),
m : parseIso(match[7], sign),
s : parseIso(match[8], sign)
};
} else if (duration == null) {// checks for null or undefined
duration = {};
} else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
duration = {};
duration.ms = diffRes.milliseconds;
duration.M = diffRes.months;
}
ret = new Duration(duration);
if (isDuration(input) && hasOwnProp(input, '_locale')) {
ret._locale = input._locale;
}
return ret;
}
createDuration.fn = Duration.prototype;
createDuration.invalid = createInvalid$1;
function parseIso (inp, sign) {
// We'd normally use ~~inp for this, but unfortunately it also
// converts floats to ints.
// inp may be undefined, so careful calling replace on it.
var res = inp && parseFloat(inp.replace(',', '.'));
// apply sign while we're at it
return (isNaN(res) ? 0 : res) * sign;
}
function positiveMomentsDifference(base, other) {
var res = {milliseconds: 0, months: 0};
res.months = other.month() - base.month() +
(other.year() - base.year()) * 12;
if (base.clone().add(res.months, 'M').isAfter(other)) {
--res.months;
}
res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
return res;
}
function momentsDifference(base, other) {
var res;
if (!(base.isValid() && other.isValid())) {
return {milliseconds: 0, months: 0};
}
other = cloneWithOffset(other, base);
if (base.isBefore(other)) {
res = positiveMomentsDifference(base, other);
} else {
res = positiveMomentsDifference(other, base);
res.milliseconds = -res.milliseconds;
res.months = -res.months;
}
return res;
}
// TODO: remove 'name' arg after deprecation is removed
function createAdder(direction, name) {
return function (val, period) {
var dur, tmp;
//invert the arguments, but complain about it
if (period !== null && !isNaN(+period)) {
deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
tmp = val; val = period; period = tmp;
}
val = typeof val === 'string' ? +val : val;
dur = createDuration(val, period);
addSubtract(this, dur, direction);
return this;
};
}
function addSubtract (mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
days = absRound(duration._days),
months = absRound(duration._months);
if (!mom.isValid()) {
// No op
return;
}
updateOffset = updateOffset == null ? true : updateOffset;
if (milliseconds) {
mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
}
if (days) {
set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
}
if (months) {
setMonth(mom, get(mom, 'Month') + months * isAdding);
}
if (updateOffset) {
hooks.updateOffset(mom, days || months);
}
}
var add = createAdder(1, 'add');
var subtract = createAdder(-1, 'subtract');
function getCalendarFormat(myMoment, now) {
var diff = myMoment.diff(now, 'days', true);
return diff < -6 ? 'sameElse' :
diff < -1 ? 'lastWeek' :
diff < 0 ? 'lastDay' :
diff < 1 ? 'sameDay' :
diff < 2 ? 'nextDay' :
diff < 7 ? 'nextWeek' : 'sameElse';
}
function calendar$1 (time, formats) {
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're local/utc/offset or not.
var now = time || createLocal(),
sod = cloneWithOffset(now, this).startOf('day'),
format = hooks.calendarFormat(this, sod) || 'sameElse';
var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
}
function clone () {
return new Moment(this);
}
function isAfter (input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
return this.valueOf() > localInput.valueOf();
} else {
return localInput.valueOf() < this.clone().startOf(units).valueOf();
}
}
function isBefore (input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
return this.valueOf() < localInput.valueOf();
} else {
return this.clone().endOf(units).valueOf() < localInput.valueOf();
}
}
function isBetween (from, to, units, inclusivity) {
inclusivity = inclusivity || '()';
return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
(inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
}
function isSame (input, units) {
var localInput = isMoment(input) ? input : createLocal(input),
inputMs;
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units || 'millisecond');
if (units === 'millisecond') {
return this.valueOf() === localInput.valueOf();
} else {
inputMs = localInput.valueOf();
return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
}
}
function isSameOrAfter (input, units) {
return this.isSame(input, units) || this.isAfter(input,units);
}
function isSameOrBefore (input, units) {
return this.isSame(input, units) || this.isBefore(input,units);
}
function diff (input, units, asFloat) {
var that,
zoneDelta,
delta, output;
if (!this.isValid()) {
return NaN;
}
that = cloneWithOffset(input, this);
if (!that.isValid()) {
return NaN;
}
zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
units = normalizeUnits(units);
if (units === 'year' || units === 'month' || units === 'quarter') {
output = monthDiff(this, that);
if (units === 'quarter') {
output = output / 3;
} else if (units === 'year') {
output = output / 12;
}
} else {
delta = this - that;
output = units === 'second' ? delta / 1e3 : // 1000
units === 'minute' ? delta / 6e4 : // 1000 * 60
units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
delta;
}
return asFloat ? output : absFloor(output);
}
function monthDiff (a, b) {
// difference in months
var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
// b is in (anchor - 1 month, anchor + 1 month)
anchor = a.clone().add(wholeMonthDiff, 'months'),
anchor2, adjust;
if (b - anchor < 0) {
anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor - anchor2);
} else {
anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor2 - anchor);
}
//check for negative zero, return zero if negative zero
return -(wholeMonthDiff + adjust) || 0;
}
hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
function toString () {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
function toISOString() {
if (!this.isValid()) {
return null;
}
var m = this.clone().utc();
if (m.year() < 0 || m.year() > 9999) {
return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
}
if (isFunction(Date.prototype.toISOString)) {
// native implementation is ~50x faster, use it when we can
return this.toDate().toISOString();
}
return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
}
/**
* Return a human readable representation of a moment that can
* also be evaluated to get a new moment which is the same
*
* @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
*/
function inspect () {
if (!this.isValid()) {
return 'moment.invalid(/* ' + this._i + ' */)';
}
var func = 'moment';
var zone = '';
if (!this.isLocal()) {
func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
zone = 'Z';
}
var prefix = '[' + func + '("]';
var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
var datetime = '-MM-DD[T]HH:mm:ss.SSS';
var suffix = zone + '[")]';
return this.format(prefix + year + datetime + suffix);
}
function format (inputString) {
if (!inputString) {
inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
}
var output = formatMoment(this, inputString);
return this.localeData().postformat(output);
}
function from (time, withoutSuffix) {
if (this.isValid() &&
((isMoment(time) && time.isValid()) ||
createLocal(time).isValid())) {
return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function fromNow (withoutSuffix) {
return this.from(createLocal(), withoutSuffix);
}
function to (time, withoutSuffix) {
if (this.isValid() &&
((isMoment(time) && time.isValid()) ||
createLocal(time).isValid())) {
return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function toNow (withoutSuffix) {
return this.to(createLocal(), withoutSuffix);
}
// If passed a locale key, it will set the locale for this
// instance. Otherwise, it will return the locale configuration
// variables for this instance.
function locale (key) {
var newLocaleData;
if (key === undefined) {
return this._locale._abbr;
} else {
newLocaleData = getLocale(key);
if (newLocaleData != null) {
this._locale = newLocaleData;
}
return this;
}
}
var lang = deprecate(
'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
function (key) {
if (key === undefined) {
return this.localeData();
} else {
return this.locale(key);
}
}
);
function localeData () {
return this._locale;
}
function startOf (units) {
units = normalizeUnits(units);
// the following switch intentionally omits break keywords
// to utilize falling through the cases.
switch (units) {
case 'year':
this.month(0);
/* falls through */
case 'quarter':
case 'month':
this.date(1);
/* falls through */
case 'week':
case 'isoWeek':
case 'day':
case 'date':
this.hours(0);
/* falls through */
case 'hour':
this.minutes(0);
/* falls through */
case 'minute':
this.seconds(0);
/* falls through */
case 'second':
this.milliseconds(0);
}
// weeks are a special case
if (units === 'week') {
this.weekday(0);
}
if (units === 'isoWeek') {
this.isoWeekday(1);
}
// quarters are also special
if (units === 'quarter') {
this.month(Math.floor(this.month() / 3) * 3);
}
return this;
}
function endOf (units) {
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond') {
return this;
}
// 'date' is an alias for 'day', so it should be considered as such.
if (units === 'date') {
units = 'day';
}
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
}
function valueOf () {
return this._d.valueOf() - ((this._offset || 0) * 60000);
}
function unix () {
return Math.floor(this.valueOf() / 1000);
}
function toDate () {
return new Date(this.valueOf());
}
function toArray () {
var m = this;
return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
}
function toObject () {
var m = this;
return {
years: m.year(),
months: m.month(),
date: m.date(),
hours: m.hours(),
minutes: m.minutes(),
seconds: m.seconds(),
milliseconds: m.milliseconds()
};
}
function toJSON () {
// new Date(NaN).toJSON() === null
return this.isValid() ? this.toISOString() : null;
}
function isValid$2 () {
return isValid(this);
}
function parsingFlags () {
return extend({}, getParsingFlags(this));
}
function invalidAt () {
return getParsingFlags(this).overflow;
}
function creationData() {
return {
input: this._i,
format: this._f,
locale: this._locale,
isUTC: this._isUTC,
strict: this._strict
};
}
// FORMATTING
addFormatToken(0, ['gg', 2], 0, function () {
return this.weekYear() % 100;
});
addFormatToken(0, ['GG', 2], 0, function () {
return this.isoWeekYear() % 100;
});
function addWeekYearFormatToken (token, getter) {
addFormatToken(0, [token, token.length], 0, getter);
}
addWeekYearFormatToken('gggg', 'weekYear');
addWeekYearFormatToken('ggggg', 'weekYear');
addWeekYearFormatToken('GGGG', 'isoWeekYear');
addWeekYearFormatToken('GGGGG', 'isoWeekYear');
// ALIASES
addUnitAlias('weekYear', 'gg');
addUnitAlias('isoWeekYear', 'GG');
// PRIORITY
addUnitPriority('weekYear', 1);
addUnitPriority('isoWeekYear', 1);
// PARSING
addRegexToken('G', matchSigned);
addRegexToken('g', matchSigned);
addRegexToken('GG', match1to2, match2);
addRegexToken('gg', match1to2, match2);
addRegexToken('GGGG', match1to4, match4);
addRegexToken('gggg', match1to4, match4);
addRegexToken('GGGGG', match1to6, match6);
addRegexToken('ggggg', match1to6, match6);
addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
week[token.substr(0, 2)] = toInt(input);
});
addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
week[token] = hooks.parseTwoDigitYear(input);
});
// MOMENTS
function getSetWeekYear (input) {
return getSetWeekYearHelper.call(this,
input,
this.week(),
this.weekday(),
this.localeData()._week.dow,
this.localeData()._week.doy);
}
function getSetISOWeekYear (input) {
return getSetWeekYearHelper.call(this,
input, this.isoWeek(), this.isoWeekday(), 1, 4);
}
function getISOWeeksInYear () {
return weeksInYear(this.year(), 1, 4);
}
function getWeeksInYear () {
var weekInfo = this.localeData()._week;
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
}
function getSetWeekYearHelper(input, week, weekday, dow, doy) {
var weeksTarget;
if (input == null) {
return weekOfYear(this, dow, doy).year;
} else {
weeksTarget = weeksInYear(input, dow, doy);
if (week > weeksTarget) {
week = weeksTarget;
}
return setWeekAll.call(this, input, week, weekday, dow, doy);
}
}
function setWeekAll(weekYear, week, weekday, dow, doy) {
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
this.year(date.getUTCFullYear());
this.month(date.getUTCMonth());
this.date(date.getUTCDate());
return this;
}
// FORMATTING
addFormatToken('Q', 0, 'Qo', 'quarter');
// ALIASES
addUnitAlias('quarter', 'Q');
// PRIORITY
addUnitPriority('quarter', 7);
// PARSING
addRegexToken('Q', match1);
addParseToken('Q', function (input, array) {
array[MONTH] = (toInt(input) - 1) * 3;
});
// MOMENTS
function getSetQuarter (input) {
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
}
// FORMATTING
addFormatToken('D', ['DD', 2], 'Do', 'date');
// ALIASES
addUnitAlias('date', 'D');
// PRIOROITY
addUnitPriority('date', 9);
// PARSING
addRegexToken('D', match1to2);
addRegexToken('DD', match1to2, match2);
addRegexToken('Do', function (isStrict, locale) {
// TODO: Remove "ordinalParse" fallback in next major release.
return isStrict ?
(locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
locale._dayOfMonthOrdinalParseLenient;
});
addParseToken(['D', 'DD'], DATE);
addParseToken('Do', function (input, array) {
array[DATE] = toInt(input.match(match1to2)[0], 10);
});
// MOMENTS
var getSetDayOfMonth = makeGetSet('Date', true);
// FORMATTING
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
// ALIASES
addUnitAlias('dayOfYear', 'DDD');
// PRIORITY
addUnitPriority('dayOfYear', 4);
// PARSING
addRegexToken('DDD', match1to3);
addRegexToken('DDDD', match3);
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
config._dayOfYear = toInt(input);
});
// HELPERS
// MOMENTS
function getSetDayOfYear (input) {
var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
}
// FORMATTING
addFormatToken('m', ['mm', 2], 0, 'minute');
// ALIASES
addUnitAlias('minute', 'm');
// PRIORITY
addUnitPriority('minute', 14);
// PARSING
addRegexToken('m', match1to2);
addRegexToken('mm', match1to2, match2);
addParseToken(['m', 'mm'], MINUTE);
// MOMENTS
var getSetMinute = makeGetSet('Minutes', false);
// FORMATTING
addFormatToken('s', ['ss', 2], 0, 'second');
// ALIASES
addUnitAlias('second', 's');
// PRIORITY
addUnitPriority('second', 15);
// PARSING
addRegexToken('s', match1to2);
addRegexToken('ss', match1to2, match2);
addParseToken(['s', 'ss'], SECOND);
// MOMENTS
var getSetSecond = makeGetSet('Seconds', false);
// FORMATTING
addFormatToken('S', 0, 0, function () {
return ~~(this.millisecond() / 100);
});
addFormatToken(0, ['SS', 2], 0, function () {
return ~~(this.millisecond() / 10);
});
addFormatToken(0, ['SSS', 3], 0, 'millisecond');
addFormatToken(0, ['SSSS', 4], 0, function () {
return this.millisecond() * 10;
});
addFormatToken(0, ['SSSSS', 5], 0, function () {
return this.millisecond() * 100;
});
addFormatToken(0, ['SSSSSS', 6], 0, function () {
return this.millisecond() * 1000;
});
addFormatToken(0, ['SSSSSSS', 7], 0, function () {
return this.millisecond() * 10000;
});
addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
return this.millisecond() * 100000;
});
addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
return this.millisecond() * 1000000;
});
// ALIASES
addUnitAlias('millisecond', 'ms');
// PRIORITY
addUnitPriority('millisecond', 16);
// PARSING
addRegexToken('S', match1to3, match1);
addRegexToken('SS', match1to3, match2);
addRegexToken('SSS', match1to3, match3);
var token;
for (token = 'SSSS'; token.length <= 9; token += 'S') {
addRegexToken(token, matchUnsigned);
}
function parseMs(input, array) {
array[MILLISECOND] = toInt(('0.' + input) * 1000);
}
for (token = 'S'; token.length <= 9; token += 'S') {
addParseToken(token, parseMs);
}
// MOMENTS
var getSetMillisecond = makeGetSet('Milliseconds', false);
// FORMATTING
addFormatToken('z', 0, 0, 'zoneAbbr');
addFormatToken('zz', 0, 0, 'zoneName');
// MOMENTS
function getZoneAbbr () {
return this._isUTC ? 'UTC' : '';
}
function getZoneName () {
return this._isUTC ? 'Coordinated Universal Time' : '';
}
var proto = Moment.prototype;
proto.add = add;
proto.calendar = calendar$1;
proto.clone = clone;
proto.diff = diff;
proto.endOf = endOf;
proto.format = format;
proto.from = from;
proto.fromNow = fromNow;
proto.to = to;
proto.toNow = toNow;
proto.get = stringGet;
proto.invalidAt = invalidAt;
proto.isAfter = isAfter;
proto.isBefore = isBefore;
proto.isBetween = isBetween;
proto.isSame = isSame;
proto.isSameOrAfter = isSameOrAfter;
proto.isSameOrBefore = isSameOrBefore;
proto.isValid = isValid$2;
proto.lang = lang;
proto.locale = locale;
proto.localeData = localeData;
proto.max = prototypeMax;
proto.min = prototypeMin;
proto.parsingFlags = parsingFlags;
proto.set = stringSet;
proto.startOf = startOf;
proto.subtract = subtract;
proto.toArray = toArray;
proto.toObject = toObject;
proto.toDate = toDate;
proto.toISOString = toISOString;
proto.inspect = inspect;
proto.toJSON = toJSON;
proto.toString = toString;
proto.unix = unix;
proto.valueOf = valueOf;
proto.creationData = creationData;
// Year
proto.year = getSetYear;
proto.isLeapYear = getIsLeapYear;
// Week Year
proto.weekYear = getSetWeekYear;
proto.isoWeekYear = getSetISOWeekYear;
// Quarter
proto.quarter = proto.quarters = getSetQuarter;
// Month
proto.month = getSetMonth;
proto.daysInMonth = getDaysInMonth;
// Week
proto.week = proto.weeks = getSetWeek;
proto.isoWeek = proto.isoWeeks = getSetISOWeek;
proto.weeksInYear = getWeeksInYear;
proto.isoWeeksInYear = getISOWeeksInYear;
// Day
proto.date = getSetDayOfMonth;
proto.day = proto.days = getSetDayOfWeek;
proto.weekday = getSetLocaleDayOfWeek;
proto.isoWeekday = getSetISODayOfWeek;
proto.dayOfYear = getSetDayOfYear;
// Hour
proto.hour = proto.hours = getSetHour;
// Minute
proto.minute = proto.minutes = getSetMinute;
// Second
proto.second = proto.seconds = getSetSecond;
// Millisecond
proto.millisecond = proto.milliseconds = getSetMillisecond;
// Offset
proto.utcOffset = getSetOffset;
proto.utc = setOffsetToUTC;
proto.local = setOffsetToLocal;
proto.parseZone = setOffsetToParsedOffset;
proto.hasAlignedHourOffset = hasAlignedHourOffset;
proto.isDST = isDaylightSavingTime;
proto.isLocal = isLocal;
proto.isUtcOffset = isUtcOffset;
proto.isUtc = isUtc;
proto.isUTC = isUtc;
// Timezone
proto.zoneAbbr = getZoneAbbr;
proto.zoneName = getZoneName;
// Deprecations
proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
function createUnix (input) {
return createLocal(input * 1000);
}
function createInZone () {
return createLocal.apply(null, arguments).parseZone();
}
function preParsePostFormat (string) {
return string;
}
var proto$1 = Locale.prototype;
proto$1.calendar = calendar;
proto$1.longDateFormat = longDateFormat;
proto$1.invalidDate = invalidDate;
proto$1.ordinal = ordinal;
proto$1.preparse = preParsePostFormat;
proto$1.postformat = preParsePostFormat;
proto$1.relativeTime = relativeTime;
proto$1.pastFuture = pastFuture;
proto$1.set = set;
// Month
proto$1.months = localeMonths;
proto$1.monthsShort = localeMonthsShort;
proto$1.monthsParse = localeMonthsParse;
proto$1.monthsRegex = monthsRegex;
proto$1.monthsShortRegex = monthsShortRegex;
// Week
proto$1.week = localeWeek;
proto$1.firstDayOfYear = localeFirstDayOfYear;
proto$1.firstDayOfWeek = localeFirstDayOfWeek;
// Day of Week
proto$1.weekdays = localeWeekdays;
proto$1.weekdaysMin = localeWeekdaysMin;
proto$1.weekdaysShort = localeWeekdaysShort;
proto$1.weekdaysParse = localeWeekdaysParse;
proto$1.weekdaysRegex = weekdaysRegex;
proto$1.weekdaysShortRegex = weekdaysShortRegex;
proto$1.weekdaysMinRegex = weekdaysMinRegex;
// Hours
proto$1.isPM = localeIsPM;
proto$1.meridiem = localeMeridiem;
function get$1 (format, index, field, setter) {
var locale = getLocale();
var utc = createUTC().set(setter, index);
return locale[field](utc, format);
}
function listMonthsImpl (format, index, field) {
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
if (index != null) {
return get$1(format, index, field, 'month');
}
var i;
var out = [];
for (i = 0; i < 12; i++) {
out[i] = get$1(format, i, field, 'month');
}
return out;
}
// ()
// (5)
// (fmt, 5)
// (fmt)
// (true)
// (true, 5)
// (true, fmt, 5)
// (true, fmt)
function listWeekdaysImpl (localeSorted, format, index, field) {
if (typeof localeSorted === 'boolean') {
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
} else {
format = localeSorted;
index = format;
localeSorted = false;
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
}
var locale = getLocale(),
shift = localeSorted ? locale._week.dow : 0;
if (index != null) {
return get$1(format, (index + shift) % 7, field, 'day');
}
var i;
var out = [];
for (i = 0; i < 7; i++) {
out[i] = get$1(format, (i + shift) % 7, field, 'day');
}
return out;
}
function listMonths (format, index) {
return listMonthsImpl(format, index, 'months');
}
function listMonthsShort (format, index) {
return listMonthsImpl(format, index, 'monthsShort');
}
function listWeekdays (localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
}
function listWeekdaysShort (localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
}
function listWeekdaysMin (localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
}
getSetGlobalLocale('en', {
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal : function (number) {
var b = number % 10,
output = (toInt(number % 100 / 10) === 1) ? 'th' :
(b === 1) ? 'st' :
(b === 2) ? 'nd' :
(b === 3) ? 'rd' : 'th';
return number + output;
}
});
// Side effect imports
hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
var mathAbs = Math.abs;
function abs () {
var data = this._data;
this._milliseconds = mathAbs(this._milliseconds);
this._days = mathAbs(this._days);
this._months = mathAbs(this._months);
data.milliseconds = mathAbs(data.milliseconds);
data.seconds = mathAbs(data.seconds);
data.minutes = mathAbs(data.minutes);
data.hours = mathAbs(data.hours);
data.months = mathAbs(data.months);
data.years = mathAbs(data.years);
return this;
}
function addSubtract$1 (duration, input, value, direction) {
var other = createDuration(input, value);
duration._milliseconds += direction * other._milliseconds;
duration._days += direction * other._days;
duration._months += direction * other._months;
return duration._bubble();
}
// supports only 2.0-style add(1, 's') or add(duration)
function add$1 (input, value) {
return addSubtract$1(this, input, value, 1);
}
// supports only 2.0-style subtract(1, 's') or subtract(duration)
function subtract$1 (input, value) {
return addSubtract$1(this, input, value, -1);
}
function absCeil (number) {
if (number < 0) {
return Math.floor(number);
} else {
return Math.ceil(number);
}
}
function bubble () {
var milliseconds = this._milliseconds;
var days = this._days;
var months = this._months;
var data = this._data;
var seconds, minutes, hours, years, monthsFromDays;
// if we have a mix of positive and negative values, bubble down first
// check: https://github.com/moment/moment/issues/2166
if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
(milliseconds <= 0 && days <= 0 && months <= 0))) {
milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
days = 0;
months = 0;
}
// The following code bubbles up values, see the tests for
// examples of what that means.
data.milliseconds = milliseconds % 1000;
seconds = absFloor(milliseconds / 1000);
data.seconds = seconds % 60;
minutes = absFloor(seconds / 60);
data.minutes = minutes % 60;
hours = absFloor(minutes / 60);
data.hours = hours % 24;
days += absFloor(hours / 24);
// convert days to months
monthsFromDays = absFloor(daysToMonths(days));
months += monthsFromDays;
days -= absCeil(monthsToDays(monthsFromDays));
// 12 months -> 1 year
years = absFloor(months / 12);
months %= 12;
data.days = days;
data.months = months;
data.years = years;
return this;
}
function daysToMonths (days) {
// 400 years have 146097 days (taking into account leap year rules)
// 400 years have 12 months === 4800
return days * 4800 / 146097;
}
function monthsToDays (months) {
// the reverse of daysToMonths
return months * 146097 / 4800;
}
function as (units) {
if (!this.isValid()) {
return NaN;
}
var days;
var months;
var milliseconds = this._milliseconds;
units = normalizeUnits(units);
if (units === 'month' || units === 'year') {
days = this._days + milliseconds / 864e5;
months = this._months + daysToMonths(days);
return units === 'month' ? months : months / 12;
} else {
// handle milliseconds separately because of floating point math errors (issue #1867)
days = this._days + Math.round(monthsToDays(this._months));
switch (units) {
case 'week' : return days / 7 + milliseconds / 6048e5;
case 'day' : return days + milliseconds / 864e5;
case 'hour' : return days * 24 + milliseconds / 36e5;
case 'minute' : return days * 1440 + milliseconds / 6e4;
case 'second' : return days * 86400 + milliseconds / 1000;
// Math.floor prevents floating point math errors here
case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
default: throw new Error('Unknown unit ' + units);
}
}
}
// TODO: Use this.as('ms')?
function valueOf$1 () {
if (!this.isValid()) {
return NaN;
}
return (
this._milliseconds +
this._days * 864e5 +
(this._months % 12) * 2592e6 +
toInt(this._months / 12) * 31536e6
);
}
function makeAs (alias) {
return function () {
return this.as(alias);
};
}
var asMilliseconds = makeAs('ms');
var asSeconds = makeAs('s');
var asMinutes = makeAs('m');
var asHours = makeAs('h');
var asDays = makeAs('d');
var asWeeks = makeAs('w');
var asMonths = makeAs('M');
var asYears = makeAs('y');
function get$2 (units) {
units = normalizeUnits(units);
return this.isValid() ? this[units + 's']() : NaN;
}
function makeGetter(name) {
return function () {
return this.isValid() ? this._data[name] : NaN;
};
}
var milliseconds = makeGetter('milliseconds');
var seconds = makeGetter('seconds');
var minutes = makeGetter('minutes');
var hours = makeGetter('hours');
var days = makeGetter('days');
var months = makeGetter('months');
var years = makeGetter('years');
function weeks () {
return absFloor(this.days() / 7);
}
var round = Math.round;
var thresholds = {
ss: 44, // a few seconds to seconds
s : 45, // seconds to minute
m : 45, // minutes to hour
h : 22, // hours to day
d : 26, // days to month
M : 11 // months to year
};
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
var duration = createDuration(posNegDuration).abs();
var seconds = round(duration.as('s'));
var minutes = round(duration.as('m'));
var hours = round(duration.as('h'));
var days = round(duration.as('d'));
var months = round(duration.as('M'));
var years = round(duration.as('y'));
var a = seconds <= thresholds.ss && ['s', seconds] ||
seconds < thresholds.s && ['ss', seconds] ||
minutes <= 1 && ['m'] ||
minutes < thresholds.m && ['mm', minutes] ||
hours <= 1 && ['h'] ||
hours < thresholds.h && ['hh', hours] ||
days <= 1 && ['d'] ||
days < thresholds.d && ['dd', days] ||
months <= 1 && ['M'] ||
months < thresholds.M && ['MM', months] ||
years <= 1 && ['y'] || ['yy', years];
a[2] = withoutSuffix;
a[3] = +posNegDuration > 0;
a[4] = locale;
return substituteTimeAgo.apply(null, a);
}
// This function allows you to set the rounding function for relative time strings
function getSetRelativeTimeRounding (roundingFunction) {
if (roundingFunction === undefined) {
return round;
}
if (typeof(roundingFunction) === 'function') {
round = roundingFunction;
return true;
}
return false;
}
// This function allows you to set a threshold for relative time strings
function getSetRelativeTimeThreshold (threshold, limit) {
if (thresholds[threshold] === undefined) {
return false;
}
if (limit === undefined) {
return thresholds[threshold];
}
thresholds[threshold] = limit;
if (threshold === 's') {
thresholds.ss = limit - 1;
}
return true;
}
function humanize (withSuffix) {
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var locale = this.localeData();
var output = relativeTime$1(this, !withSuffix, locale);
if (withSuffix) {
output = locale.pastFuture(+this, output);
}
return locale.postformat(output);
}
var abs$1 = Math.abs;
function toISOString$1() {
// for ISO strings we do not use the normal bubbling rules:
// * milliseconds bubble up until they become hours
// * days do not bubble at all
// * months bubble up until they become years
// This is because there is no context-free conversion between hours and days
// (think of clock changes)
// and also not between days and months (28-31 days per month)
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var seconds = abs$1(this._milliseconds) / 1000;
var days = abs$1(this._days);
var months = abs$1(this._months);
var minutes, hours, years;
// 3600 seconds -> 60 minutes -> 1 hour
minutes = absFloor(seconds / 60);
hours = absFloor(minutes / 60);
seconds %= 60;
minutes %= 60;
// 12 months -> 1 year
years = absFloor(months / 12);
months %= 12;
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
var Y = years;
var M = months;
var D = days;
var h = hours;
var m = minutes;
var s = seconds;
var total = this.asSeconds();
if (!total) {
// this is the same as C#'s (Noda) and python (isodate)...
// but not other JS (goog.date)
return 'P0D';
}
return (total < 0 ? '-' : '') +
'P' +
(Y ? Y + 'Y' : '') +
(M ? M + 'M' : '') +
(D ? D + 'D' : '') +
((h || m || s) ? 'T' : '') +
(h ? h + 'H' : '') +
(m ? m + 'M' : '') +
(s ? s + 'S' : '');
}
var proto$2 = Duration.prototype;
proto$2.isValid = isValid$1;
proto$2.abs = abs;
proto$2.add = add$1;
proto$2.subtract = subtract$1;
proto$2.as = as;
proto$2.asMilliseconds = asMilliseconds;
proto$2.asSeconds = asSeconds;
proto$2.asMinutes = asMinutes;
proto$2.asHours = asHours;
proto$2.asDays = asDays;
proto$2.asWeeks = asWeeks;
proto$2.asMonths = asMonths;
proto$2.asYears = asYears;
proto$2.valueOf = valueOf$1;
proto$2._bubble = bubble;
proto$2.get = get$2;
proto$2.milliseconds = milliseconds;
proto$2.seconds = seconds;
proto$2.minutes = minutes;
proto$2.hours = hours;
proto$2.days = days;
proto$2.weeks = weeks;
proto$2.months = months;
proto$2.years = years;
proto$2.humanize = humanize;
proto$2.toISOString = toISOString$1;
proto$2.toString = toISOString$1;
proto$2.toJSON = toISOString$1;
proto$2.locale = locale;
proto$2.localeData = localeData;
// Deprecations
proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
proto$2.lang = lang;
// Side effect imports
// FORMATTING
addFormatToken('X', 0, 0, 'unix');
addFormatToken('x', 0, 0, 'valueOf');
// PARSING
addRegexToken('x', matchSigned);
addRegexToken('X', matchTimestamp);
addParseToken('X', function (input, array, config) {
config._d = new Date(parseFloat(input, 10) * 1000);
});
addParseToken('x', function (input, array, config) {
config._d = new Date(toInt(input));
});
// Side effect imports
hooks.version = '2.18.1';
setHookCallback(createLocal);
hooks.fn = proto;
hooks.min = min;
hooks.max = max;
hooks.now = now;
hooks.utc = createUTC;
hooks.unix = createUnix;
hooks.months = listMonths;
hooks.isDate = isDate;
hooks.locale = getSetGlobalLocale;
hooks.invalid = createInvalid;
hooks.duration = createDuration;
hooks.isMoment = isMoment;
hooks.weekdays = listWeekdays;
hooks.parseZone = createInZone;
hooks.localeData = getLocale;
hooks.isDuration = isDuration;
hooks.monthsShort = listMonthsShort;
hooks.weekdaysMin = listWeekdaysMin;
hooks.defineLocale = defineLocale;
hooks.updateLocale = updateLocale;
hooks.locales = listLocales;
hooks.weekdaysShort = listWeekdaysShort;
hooks.normalizeUnits = normalizeUnits;
hooks.relativeTimeRounding = getSetRelativeTimeRounding;
hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
hooks.calendarFormat = getCalendarFormat;
hooks.prototype = proto;
return hooks;
})));
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(247)(module)))
/***/ },
/* 15 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.warning = warning;
exports.format = format;
exports.isEmptyValue = isEmptyValue;
exports.isEmptyObject = isEmptyObject;
exports.asyncMap = asyncMap;
exports.complementError = complementError;
exports.deepMerge = deepMerge;
var formatRegExp = /%[sdj%]/g;
var warning2 = function warning2() {};
if (true) {
warning2 = function warning2(type, message) {
if (typeof console !== 'undefined' && console.warn) {
console.warn(type, message);
}
};
}
function warning(type, errors) {
// only warn native warning, default type is string, confuses many people...
if (errors.every(function (e) {
return typeof e === 'string';
})) {
warning2(type, errors);
}
}
function format() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var i = 1;
var f = args[0];
var len = args.length;
if (typeof f === 'function') {
return f.apply(null, args.slice(1));
}
if (typeof f === 'string') {
var str = String(f).replace(formatRegExp, function (x) {
if (x === '%%') {
return '%';
}
if (i >= len) {
return x;
}
switch (x) {
case '%s':
return String(args[i++]);
case '%d':
return Number(args[i++]);
case '%j':
try {
return JSON.stringify(args[i++]);
} catch (_) {
return '[Circular]';
}
break;
default:
return x;
}
});
for (var arg = args[i]; i < len; arg = args[++i]) {
str += ' ' + arg;
}
return str;
}
return f;
}
function isNativeStringType(type) {
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'pattern';
}
function isEmptyValue(value, type) {
if (value === undefined || value === null) {
return true;
}
if (type === 'array' && Array.isArray(value) && !value.length) {
return true;
}
if (isNativeStringType(type) && typeof value === 'string' && !value) {
return true;
}
return false;
}
function isEmptyObject(obj) {
return Object.keys(obj).length === 0;
}
function asyncParallelArray(arr, func, callback) {
var results = [];
var total = 0;
var arrLength = arr.length;
function count(errors) {
results.push.apply(results, errors);
total++;
if (total === arrLength) {
callback(results);
}
}
arr.forEach(function (a) {
func(a, count);
});
}
function asyncSerialArray(arr, func, callback) {
var index = 0;
var arrLength = arr.length;
function next(errors) {
if (errors && errors.length) {
callback(errors);
return;
}
var original = index;
index = index + 1;
if (original < arrLength) {
func(arr[original], next);
} else {
callback([]);
}
}
next([]);
}
function flattenObjArr(objArr) {
var ret = [];
Object.keys(objArr).forEach(function (k) {
ret.push.apply(ret, objArr[k]);
});
return ret;
}
function asyncMap(objArr, option, func, callback) {
if (option.first) {
var flattenArr = flattenObjArr(objArr);
return asyncSerialArray(flattenArr, func, callback);
}
var firstFields = option.firstFields || [];
if (firstFields === true) {
firstFields = Object.keys(objArr);
}
var objArrKeys = Object.keys(objArr);
var objArrLength = objArrKeys.length;
var total = 0;
var results = [];
var next = function next(errors) {
results.push.apply(results, errors);
total++;
if (total === objArrLength) {
callback(results);
}
};
objArrKeys.forEach(function (key) {
var arr = objArr[key];
if (firstFields.indexOf(key) !== -1) {
asyncSerialArray(arr, func, next);
} else {
asyncParallelArray(arr, func, next);
}
});
}
function complementError(rule) {
return function (oe) {
if (oe && oe.message) {
oe.field = oe.field || rule.fullField;
return oe;
}
return {
message: oe,
field: oe.field || rule.fullField
};
};
}
function deepMerge(target, source) {
if (source) {
for (var s in source) {
if (source.hasOwnProperty(s)) {
var value = source[s];
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && _typeof(target[s]) === 'object') {
target[s] = _extends({}, target[s], value);
} else {
target[s] = value;
}
}
}
}
return target;
}
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
'use strict';
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var validateFormat = function validateFormat(format) {};
if (true) {
validateFormat = function validateFormat(format) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
};
}
function invariant(condition, format, a, b, c, d, e, f) {
validateFormat(format);
if (!condition) {
var error;
if (format === undefined) {
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
module.exports = invariant;
/***/ },
/* 17 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
// export this package's api
module.exports = __webpack_require__(528);
/***/ },
/* 18 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = {
required: __webpack_require__(132),
whitespace: __webpack_require__(256),
type: __webpack_require__(255),
range: __webpack_require__(254),
"enum": __webpack_require__(252),
pattern: __webpack_require__(253)
};
module.exports = exports['default'];
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftModifier
* @typechecks
*
*/
'use strict';
var CharacterMetadata = __webpack_require__(25);
var ContentStateInlineStyle = __webpack_require__(430);
var Immutable = __webpack_require__(11);
var applyEntityToContentState = __webpack_require__(446);
var getCharacterRemovalRange = __webpack_require__(467);
var getContentStateFragment = __webpack_require__(77);
var insertFragmentIntoContentState = __webpack_require__(472);
var insertTextIntoContentState = __webpack_require__(473);
var invariant = __webpack_require__(16);
var modifyBlockForContentState = __webpack_require__(484);
var removeEntitiesAtEdges = __webpack_require__(191);
var removeRangeFromContentState = __webpack_require__(485);
var splitBlockInContentState = __webpack_require__(487);
var OrderedSet = Immutable.OrderedSet;
/**
* `DraftModifier` provides a set of convenience methods that apply
* modifications to a `ContentState` object based on a target `SelectionState`.
*
* Any change to a `ContentState` should be decomposable into a series of
* transaction functions that apply the required changes and return output
* `ContentState` objects.
*
* These functions encapsulate some of the most common transaction sequences.
*/
var DraftModifier = {
replaceText: function replaceText(contentState, rangeToReplace, text, inlineStyle, entityKey) {
var withoutEntities = removeEntitiesAtEdges(contentState, rangeToReplace);
var withoutText = removeRangeFromContentState(withoutEntities, rangeToReplace);
var character = CharacterMetadata.create({
style: inlineStyle || OrderedSet(),
entity: entityKey || null
});
return insertTextIntoContentState(withoutText, withoutText.getSelectionAfter(), text, character);
},
insertText: function insertText(contentState, targetRange, text, inlineStyle, entityKey) {
!targetRange.isCollapsed() ? true ? invariant(false, 'Target range must be collapsed for `insertText`.') : invariant(false) : void 0;
return DraftModifier.replaceText(contentState, targetRange, text, inlineStyle, entityKey);
},
moveText: function moveText(contentState, removalRange, targetRange) {
var movedFragment = getContentStateFragment(contentState, removalRange);
var afterRemoval = DraftModifier.removeRange(contentState, removalRange, 'backward');
return DraftModifier.replaceWithFragment(afterRemoval, targetRange, movedFragment);
},
replaceWithFragment: function replaceWithFragment(contentState, targetRange, fragment) {
var withoutEntities = removeEntitiesAtEdges(contentState, targetRange);
var withoutText = removeRangeFromContentState(withoutEntities, targetRange);
return insertFragmentIntoContentState(withoutText, withoutText.getSelectionAfter(), fragment);
},
removeRange: function removeRange(contentState, rangeToRemove, removalDirection) {
// Check whether the selection state overlaps with a single entity.
// If so, try to remove the appropriate substring of the entity text.
if (rangeToRemove.getAnchorKey() === rangeToRemove.getFocusKey()) {
var key = rangeToRemove.getAnchorKey();
var startOffset = rangeToRemove.getStartOffset();
var endOffset = rangeToRemove.getEndOffset();
var block = contentState.getBlockForKey(key);
var startEntity = block.getEntityAt(startOffset);
var endEntity = block.getEntityAt(endOffset - 1);
if (startEntity && startEntity === endEntity) {
var adjustedRemovalRange = getCharacterRemovalRange(contentState.getEntityMap(), block, rangeToRemove, removalDirection);
return removeRangeFromContentState(contentState, adjustedRemovalRange);
}
}
var withoutEntities = removeEntitiesAtEdges(contentState, rangeToRemove);
return removeRangeFromContentState(withoutEntities, rangeToRemove);
},
splitBlock: function splitBlock(contentState, selectionState) {
var withoutEntities = removeEntitiesAtEdges(contentState, selectionState);
var withoutText = removeRangeFromContentState(withoutEntities, selectionState);
return splitBlockInContentState(withoutText, withoutText.getSelectionAfter());
},
applyInlineStyle: function applyInlineStyle(contentState, selectionState, inlineStyle) {
return ContentStateInlineStyle.add(contentState, selectionState, inlineStyle);
},
removeInlineStyle: function removeInlineStyle(contentState, selectionState, inlineStyle) {
return ContentStateInlineStyle.remove(contentState, selectionState, inlineStyle);
},
setBlockType: function setBlockType(contentState, selectionState, blockType) {
return modifyBlockForContentState(contentState, selectionState, function (block) {
return block.merge({ type: blockType, depth: 0 });
});
},
setBlockData: function setBlockData(contentState, selectionState, blockData) {
return modifyBlockForContentState(contentState, selectionState, function (block) {
return block.merge({ data: blockData });
});
},
mergeBlockData: function mergeBlockData(contentState, selectionState, blockData) {
return modifyBlockForContentState(contentState, selectionState, function (block) {
return block.merge({ data: block.getData().merge(blockData) });
});
},
applyEntity: function applyEntity(contentState, selectionState, entityKey) {
var withoutEntities = removeEntitiesAtEdges(contentState, selectionState);
return applyEntityToContentState(withoutEntities, selectionState, entityKey);
}
};
module.exports = DraftModifier;
/***/ },
/* 20 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _warning = __webpack_require__(51);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var warned = {};
exports["default"] = function (valid, message) {
if (!valid && !warned[message]) {
(0, _warning2["default"])(false, message);
warned[message] = true;
}
};
module.exports = exports['default'];
/***/ },
/* 21 */
/***/ function(module, exports) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
var nullthrows = function nullthrows(x) {
if (x != null) {
return x;
}
throw new Error("Got unexpected null or undefined");
};
module.exports = nullthrows;
/***/ },
/* 22 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var assign = __webpack_require__(8);
module.exports = function omit(obj, fields) {
var copy = assign({}, obj);
for (var i = 0; i < fields.length; i++) {
var key = fields[i];
delete copy[key];
}
return copy;
};
/***/ },
/* 23 */
/***/ function(module, exports) {
var core = module.exports = {version: '2.4.0'};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {
var store = __webpack_require__(101)('wks')
, uid = __webpack_require__(71)
, Symbol = __webpack_require__(29).Symbol
, USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function(name){
return store[name] || (store[name] =
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
};
$exports.store = store;
/***/ },
/* 25 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule CharacterMetadata
* @typechecks
*
*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _require = __webpack_require__(11);
var Map = _require.Map;
var OrderedSet = _require.OrderedSet;
var Record = _require.Record;
// Immutable.map is typed such that the value for every key in the map
// must be the same type
var EMPTY_SET = OrderedSet();
var defaultRecord = {
style: EMPTY_SET,
entity: null
};
var CharacterMetadataRecord = Record(defaultRecord);
var CharacterMetadata = function (_CharacterMetadataRec) {
_inherits(CharacterMetadata, _CharacterMetadataRec);
function CharacterMetadata() {
_classCallCheck(this, CharacterMetadata);
return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
}
CharacterMetadata.prototype.getStyle = function getStyle() {
return this.get('style');
};
CharacterMetadata.prototype.getEntity = function getEntity() {
return this.get('entity');
};
CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
return this.getStyle().has(style);
};
CharacterMetadata.applyStyle = function applyStyle(record, style) {
var withStyle = record.set('style', record.getStyle().add(style));
return CharacterMetadata.create(withStyle);
};
CharacterMetadata.removeStyle = function removeStyle(record, style) {
var withoutStyle = record.set('style', record.getStyle().remove(style));
return CharacterMetadata.create(withoutStyle);
};
CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
return CharacterMetadata.create(withEntity);
};
/**
* Use this function instead of the `CharacterMetadata` constructor.
* Since most content generally uses only a very small number of
* style/entity permutations, we can reuse these objects as often as
* possible.
*/
CharacterMetadata.create = function create(config) {
if (!config) {
return EMPTY;
}
var defaultConfig = { style: EMPTY_SET, entity: null };
// Fill in unspecified properties, if necessary.
var configMap = Map(defaultConfig).merge(config);
var existing = pool.get(configMap);
if (existing) {
return existing;
}
var newCharacter = new CharacterMetadata(configMap);
pool = pool.set(configMap, newCharacter);
return newCharacter;
};
return CharacterMetadata;
}(CharacterMetadataRecord);
var EMPTY = new CharacterMetadata();
var pool = Map([[Map(defaultRecord), EMPTY]]);
CharacterMetadata.EMPTY = EMPTY;
module.exports = CharacterMetadata;
/***/ },
/* 26 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _iterator = __webpack_require__(371);
var _iterator2 = _interopRequireDefault(_iterator);
var _symbol = __webpack_require__(370);
var _symbol2 = _interopRequireDefault(_symbol);
var _typeof = typeof _symbol2["default"] === "function" && typeof _iterator2["default"] === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2["default"] === "function" && obj.constructor === _symbol2["default"] && obj !== _symbol2["default"].prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = typeof _symbol2["default"] === "function" && _typeof(_iterator2["default"]) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
} : function (obj) {
return obj && typeof _symbol2["default"] === "function" && obj.constructor === _symbol2["default"] && obj !== _symbol2["default"].prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
};
/***/ },
/* 27 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule generateRandomKey
* @typechecks
*
*/
'use strict';
var seenKeys = {};
var MULTIPLIER = Math.pow(2, 24);
function generateRandomKey() {
var key = void 0;
while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
key = Math.floor(Math.random() * MULTIPLIER).toString(32);
}
seenKeys[key] = true;
return key;
}
module.exports = generateRandomKey;
/***/ },
/* 28 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
'use strict';
var UserAgentData = __webpack_require__(498);
var VersionRange = __webpack_require__(499);
var mapObject = __webpack_require__(512);
var memoizeStringOnly = __webpack_require__(513);
/**
* Checks to see whether `name` and `version` satisfy `query`.
*
* @param {string} name Name of the browser, device, engine or platform
* @param {?string} version Version of the browser, engine or platform
* @param {string} query Query of form "Name [range expression]"
* @param {?function} normalizer Optional pre-processor for range expression
* @return {boolean}
*/
function compare(name, version, query, normalizer) {
// check for exact match with no version
if (name === query) {
return true;
}
// check for non-matching names
if (!query.startsWith(name)) {
return false;
}
// full comparison with version
var range = query.slice(name.length);
if (version) {
range = normalizer ? normalizer(range) : range;
return VersionRange.contains(range, version);
}
return false;
}
/**
* Normalizes `version` by stripping any "NT" prefix, but only on the Windows
* platform.
*
* Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class.
*
* @param {string} version
* @return {string}
*/
function normalizePlatformVersion(version) {
if (UserAgentData.platformName === 'Windows') {
return version.replace(/^\s*NT/, '');
}
return version;
}
/**
* Provides client-side access to the authoritative PHP-generated User Agent
* information supplied by the server.
*/
var UserAgent = {
/**
* Check if the User Agent browser matches `query`.
*
* `query` should be a string like "Chrome" or "Chrome > 33".
*
* Valid browser names include:
*
* - ACCESS NetFront
* - AOL
* - Amazon Silk
* - Android
* - BlackBerry
* - BlackBerry PlayBook
* - Chrome
* - Chrome for iOS
* - Chrome frame
* - Facebook PHP SDK
* - Facebook for iOS
* - Firefox
* - IE
* - IE Mobile
* - Mobile Safari
* - Motorola Internet Browser
* - Nokia
* - Openwave Mobile Browser
* - Opera
* - Opera Mini
* - Opera Mobile
* - Safari
* - UIWebView
* - Unknown
* - webOS
* - etc...
*
* An authoritative list can be found in the PHP `BrowserDetector` class and
* related classes in the same file (see calls to `new UserAgentBrowser` here:
* https://fburl.com/50728104).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name [range expression]"
* @return {boolean}
*/
isBrowser: function isBrowser(query) {
return compare(UserAgentData.browserName, UserAgentData.browserFullVersion, query);
},
/**
* Check if the User Agent browser uses a 32 or 64 bit architecture.
*
* @note Function results are memoized
*
* @param {string} query Query of the form "32" or "64".
* @return {boolean}
*/
isBrowserArchitecture: function isBrowserArchitecture(query) {
return compare(UserAgentData.browserArchitecture, null, query);
},
/**
* Check if the User Agent device matches `query`.
*
* `query` should be a string like "iPhone" or "iPad".
*
* Valid device names include:
*
* - Kindle
* - Kindle Fire
* - Unknown
* - iPad
* - iPhone
* - iPod
* - etc...
*
* An authoritative list can be found in the PHP `DeviceDetector` class and
* related classes in the same file (see calls to `new UserAgentDevice` here:
* https://fburl.com/50728332).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name"
* @return {boolean}
*/
isDevice: function isDevice(query) {
return compare(UserAgentData.deviceName, null, query);
},
/**
* Check if the User Agent rendering engine matches `query`.
*
* `query` should be a string like "WebKit" or "WebKit >= 537".
*
* Valid engine names include:
*
* - Gecko
* - Presto
* - Trident
* - WebKit
* - etc...
*
* An authoritative list can be found in the PHP `RenderingEngineDetector`
* class related classes in the same file (see calls to `new
* UserAgentRenderingEngine` here: https://fburl.com/50728617).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name [range expression]"
* @return {boolean}
*/
isEngine: function isEngine(query) {
return compare(UserAgentData.engineName, UserAgentData.engineVersion, query);
},
/**
* Check if the User Agent platform matches `query`.
*
* `query` should be a string like "Windows" or "iOS 5 - 6".
*
* Valid platform names include:
*
* - Android
* - BlackBerry OS
* - Java ME
* - Linux
* - Mac OS X
* - Mac OS X Calendar
* - Mac OS X Internet Account
* - Symbian
* - SymbianOS
* - Windows
* - Windows Mobile
* - Windows Phone
* - iOS
* - iOS Facebook Integration Account
* - iOS Facebook Social Sharing UI
* - webOS
* - Chrome OS
* - etc...
*
* An authoritative list can be found in the PHP `PlatformDetector` class and
* related classes in the same file (see calls to `new UserAgentPlatform`
* here: https://fburl.com/50729226).
*
* @note Function results are memoized
*
* @param {string} query Query of the form "Name [range expression]"
* @return {boolean}
*/
isPlatform: function isPlatform(query) {
return compare(UserAgentData.platformName, UserAgentData.platformFullVersion, query, normalizePlatformVersion);
},
/**
* Check if the User Agent platform is a 32 or 64 bit architecture.
*
* @note Function results are memoized
*
* @param {string} query Query of the form "32" or "64".
* @return {boolean}
*/
isPlatformArchitecture: function isPlatformArchitecture(query) {
return compare(UserAgentData.platformArchitecture, null, query);
}
};
module.exports = mapObject(UserAgent, memoizeStringOnly);
/***/ },
/* 29 */
/***/ function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
/***/ },
/* 30 */
/***/ function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(35)
, IE8_DOM_DEFINE = __webpack_require__(163)
, toPrimitive = __webpack_require__(104)
, dP = Object.defineProperty;
exports.f = __webpack_require__(36) ? Object.defineProperty : function defineProperty(O, P, Attributes){
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if(IE8_DOM_DEFINE)try {
return dP(O, P, Attributes);
} catch(e){ /* empty */ }
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
if('value' in Attributes)O[P] = Attributes.value;
return O;
};
/***/ },
/* 31 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
exports.getTodayTime = getTodayTime;
exports.getTitleString = getTitleString;
exports.getTodayTimeStr = getTodayTimeStr;
exports.getMonthName = getMonthName;
exports.syncTime = syncTime;
exports.getTimeConfig = getTimeConfig;
exports.isTimeValidByConfig = isTimeValidByConfig;
exports.isTimeValid = isTimeValid;
exports.isAllowedDate = isAllowedDate;
var _moment = __webpack_require__(14);
var _moment2 = _interopRequireDefault(_moment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var defaultDisabledTime = {
disabledHours: function disabledHours() {
return [];
},
disabledMinutes: function disabledMinutes() {
return [];
},
disabledSeconds: function disabledSeconds() {
return [];
}
};
function getTodayTime(value) {
var today = (0, _moment2["default"])();
today.locale(value.locale()).utcOffset(value.utcOffset());
return today;
}
function getTitleString(value) {
return value.year() + '-' + (value.month() + 1) + '-' + value.date();
}
function getTodayTimeStr(value) {
var today = getTodayTime(value);
return getTitleString(today);
}
function getMonthName(month) {
var locale = month.locale();
var localeData = month.localeData();
return localeData[locale === 'zh-cn' ? 'months' : 'monthsShort'](month);
}
function syncTime(from, to) {
to.hour(from.hour());
to.minute(from.minute());
to.second(from.second());
}
function getTimeConfig(value, disabledTime) {
var disabledTimeConfig = disabledTime ? disabledTime(value) : {};
disabledTimeConfig = (0, _extends3["default"])({}, defaultDisabledTime, disabledTimeConfig);
return disabledTimeConfig;
}
function isTimeValidByConfig(value, disabledTimeConfig) {
var invalidTime = false;
if (value) {
var hour = value.hour();
var minutes = value.minute();
var seconds = value.second();
var disabledHours = disabledTimeConfig.disabledHours();
if (disabledHours.indexOf(hour) === -1) {
var disabledMinutes = disabledTimeConfig.disabledMinutes(hour);
if (disabledMinutes.indexOf(minutes) === -1) {
var disabledSeconds = disabledTimeConfig.disabledSeconds(hour, minutes);
invalidTime = disabledSeconds.indexOf(seconds) !== -1;
} else {
invalidTime = true;
}
} else {
invalidTime = true;
}
}
return !invalidTime;
}
function isTimeValid(value, disabledTime) {
var disabledTimeConfig = getTimeConfig(value, disabledTime);
return isTimeValidByConfig(value, disabledTimeConfig);
}
function isAllowedDate(value, disabledDate, disabledTime) {
if (disabledDate) {
if (disabledDate(value)) {
return false;
}
}
if (disabledTime) {
if (!isTimeValid(value, disabledTime)) {
return false;
}
}
return true;
}
/***/ },
/* 32 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = addEventListenerWrap;
var _addDomEventListener = __webpack_require__(131);
var _addDomEventListener2 = _interopRequireDefault(_addDomEventListener);
var _reactDom = __webpack_require__(9);
var _reactDom2 = _interopRequireDefault(_reactDom);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function addEventListenerWrap(target, eventType, cb) {
/* eslint camelcase: 2 */
var callback = _reactDom2["default"].unstable_batchedUpdates ? function run(e) {
_reactDom2["default"].unstable_batchedUpdates(cb, e);
} : cb;
return (0, _addDomEventListener2["default"])(target, eventType, callback);
}
module.exports = exports['default'];
/***/ },
/* 33 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var fetchKeys = __webpack_require__(519);
module.exports = function shallowEqual(objA, objB, compare, compareContext) {
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
if (ret !== void 0) {
return !!ret;
}
if (objA === objB) {
return true;
}
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
return false;
}
var keysA = fetchKeys(objA);
var keysB = fetchKeys(objB);
var len = keysA.length;
if (len !== keysB.length) {
return false;
}
compareContext = compareContext || null;
// Test for A's keys different from B.
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
for (var i = 0; i < len; i++) {
var key = keysA[i];
if (!bHasOwnProperty(key)) {
return false;
}
var valueA = objA[key];
var valueB = objB[key];
var _ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
if (_ret === false || _ret === void 0 && valueA !== valueB) {
return false;
}
}
return true;
};
/***/ },
/* 34 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _from = __webpack_require__(363);
var _from2 = _interopRequireDefault(_from);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
} else {
return (0, _from2["default"])(arr);
}
};
/***/ },
/* 35 */
/***/ function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(57);
module.exports = function(it){
if(!isObject(it))throw TypeError(it + ' is not an object!');
return it;
};
/***/ },
/* 36 */
/***/ function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(56)(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ },
/* 37 */
/***/ function(module, exports, __webpack_require__) {
var global = __webpack_require__(29)
, core = __webpack_require__(23)
, ctx = __webpack_require__(93)
, hide = __webpack_require__(46)
, PROTOTYPE = 'prototype';
var $export = function(type, name, source){
var IS_FORCED = type & $export.F
, IS_GLOBAL = type & $export.G
, IS_STATIC = type & $export.S
, IS_PROTO = type & $export.P
, IS_BIND = type & $export.B
, IS_WRAP = type & $export.W
, exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
, expProto = exports[PROTOTYPE]
, target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
, key, own, out;
if(IS_GLOBAL)source = name;
for(key in source){
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if(own && key in exports)continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function(C){
var F = function(a, b, c){
if(this instanceof C){
switch(arguments.length){
case 0: return new C;
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if(IS_PROTO){
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ },
/* 38 */
/***/ function(module, exports) {
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function(it, key){
return hasOwnProperty.call(it, key);
};
/***/ },
/* 39 */
/***/ function(module, exports, __webpack_require__) {
// to indexed object, toObject with fallback for non-array-like ES3 strings
var IObject = __webpack_require__(164)
, defined = __webpack_require__(94);
module.exports = function(it){
return IObject(defined(it));
};
/***/ },
/* 40 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ContentBlock
*
*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Immutable = __webpack_require__(11);
var findRangesImmutable = __webpack_require__(76);
var List = Immutable.List;
var Map = Immutable.Map;
var OrderedSet = Immutable.OrderedSet;
var Record = Immutable.Record;
var EMPTY_SET = OrderedSet();
var defaultRecord = {
key: '',
type: 'unstyled',
text: '',
characterList: List(),
depth: 0,
data: Map()
};
var ContentBlockRecord = Record(defaultRecord);
var ContentBlock = function (_ContentBlockRecord) {
_inherits(ContentBlock, _ContentBlockRecord);
function ContentBlock() {
_classCallCheck(this, ContentBlock);
return _possibleConstructorReturn(this, _ContentBlockRecord.apply(this, arguments));
}
ContentBlock.prototype.getKey = function getKey() {
return this.get('key');
};
ContentBlock.prototype.getType = function getType() {
return this.get('type');
};
ContentBlock.prototype.getText = function getText() {
return this.get('text');
};
ContentBlock.prototype.getCharacterList = function getCharacterList() {
return this.get('characterList');
};
ContentBlock.prototype.getLength = function getLength() {
return this.getText().length;
};
ContentBlock.prototype.getDepth = function getDepth() {
return this.get('depth');
};
ContentBlock.prototype.getData = function getData() {
return this.get('data');
};
ContentBlock.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
var character = this.getCharacterList().get(offset);
return character ? character.getStyle() : EMPTY_SET;
};
ContentBlock.prototype.getEntityAt = function getEntityAt(offset) {
var character = this.getCharacterList().get(offset);
return character ? character.getEntity() : null;
};
/**
* Execute a callback for every contiguous range of styles within the block.
*/
ContentBlock.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
};
/**
* Execute a callback for every contiguous range of entities within the block.
*/
ContentBlock.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
};
return ContentBlock;
}(ContentBlockRecord);
function haveEqualStyle(charA, charB) {
return charA.getStyle() === charB.getStyle();
}
function haveEqualEntity(charA, charB) {
return charA.getEntity() === charB.getEntity();
}
module.exports = ContentBlock;
/***/ },
/* 41 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
/**
* Unicode-enabled replacesments for basic String functions.
*
* All the functions in this module assume that the input string is a valid
* UTF-16 encoding of a Unicode sequence. If it's not the case, the behavior
* will be undefined.
*
* WARNING: Since this module is typechecks-enforced, you may find new bugs
* when replacing normal String functions with ones provided here.
*/
'use strict';
var invariant = __webpack_require__(16);
// These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a
// surrogate code unit.
var SURROGATE_HIGH_START = 0xD800;
var SURROGATE_HIGH_END = 0xDBFF;
var SURROGATE_LOW_START = 0xDC00;
var SURROGATE_LOW_END = 0xDFFF;
var SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/;
/**
* @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF]
* @return {boolean} Whether code-unit is in a surrogate (hi/low) range
*/
function isCodeUnitInSurrogateRange(codeUnit) {
return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END;
}
/**
* Returns whether the two characters starting at `index` form a surrogate pair.
* For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and
* (s, 1) returns false.
*
* @param {string} str
* @param {number} index
* @return {boolean}
*/
function isSurrogatePair(str, index) {
!(0 <= index && index < str.length) ? true ? invariant(false, 'isSurrogatePair: Invalid index %s for string length %s.', index, str.length) : invariant(false) : void 0;
if (index + 1 === str.length) {
return false;
}
var first = str.charCodeAt(index);
var second = str.charCodeAt(index + 1);
return SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END && SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END;
}
/**
* @param {string} str Non-empty string
* @return {boolean} True if the input includes any surrogate code units
*/
function hasSurrogateUnit(str) {
return SURROGATE_UNITS_REGEX.test(str);
}
/**
* Return the length of the original Unicode character at given position in the
* String by looking into the UTF-16 code unit; that is equal to 1 for any
* non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and
* returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact
* representing non-BMP characters ([U+10000..U+10FFFF]).
*
* Examples:
* - '\u0020' => 1
* - '\u3020' => 1
* - '\uD835' => 2
* - '\uD835\uDDEF' => 2
* - '\uDDEF' => 2
*
* @param {string} str Non-empty string
* @param {number} pos Position in the string to look for one code unit
* @return {number} Number 1 or 2
*/
function getUTF16Length(str, pos) {
return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos));
}
/**
* Fully Unicode-enabled replacement for String#length
*
* @param {string} str Valid Unicode string
* @return {number} The number of Unicode characters in the string
*/
function strlen(str) {
// Call the native functions if there's no surrogate char
if (!hasSurrogateUnit(str)) {
return str.length;
}
var len = 0;
for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
len++;
}
return len;
}
/**
* Fully Unicode-enabled replacement for String#substr()
*
* @param {string} str Valid Unicode string
* @param {number} start Location in Unicode sequence to begin extracting
* @param {?number} length The number of Unicode characters to extract
* (default: to the end of the string)
* @return {string} Extracted sub-string
*/
function substr(str, start, length) {
start = start || 0;
length = length === undefined ? Infinity : length || 0;
// Call the native functions if there's no surrogate char
if (!hasSurrogateUnit(str)) {
return str.substr(start, length);
}
// Obvious cases
var size = str.length;
if (size <= 0 || start > size || length <= 0) {
return '';
}
// Find the actual starting position
var posA = 0;
if (start > 0) {
for (; start > 0 && posA < size; start--) {
posA += getUTF16Length(str, posA);
}
if (posA >= size) {
return '';
}
} else if (start < 0) {
for (posA = size; start < 0 && 0 < posA; start++) {
posA -= getUTF16Length(str, posA - 1);
}
if (posA < 0) {
posA = 0;
}
}
// Find the actual ending position
var posB = size;
if (length < size) {
for (posB = posA; length > 0 && posB < size; length--) {
posB += getUTF16Length(str, posB);
}
}
return str.substring(posA, posB);
}
/**
* Fully Unicode-enabled replacement for String#substring()
*
* @param {string} str Valid Unicode string
* @param {number} start Location in Unicode sequence to begin extracting
* @param {?number} end Location in Unicode sequence to end extracting
* (default: end of the string)
* @return {string} Extracted sub-string
*/
function substring(str, start, end) {
start = start || 0;
end = end === undefined ? Infinity : end || 0;
if (start < 0) {
start = 0;
}
if (end < 0) {
end = 0;
}
var length = Math.abs(end - start);
start = start < end ? start : end;
return substr(str, start, length);
}
/**
* Get a list of Unicode code-points from a String
*
* @param {string} str Valid Unicode string
* @return {array<number>} A list of code-points in [0..0x10FFFF]
*/
function getCodePoints(str) {
var codePoints = [];
for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
codePoints.push(str.codePointAt(pos));
}
return codePoints;
}
var UnicodeUtils = {
getCodePoints: getCodePoints,
getUTF16Length: getUTF16Length,
hasSurrogateUnit: hasSurrogateUnit,
isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange,
isSurrogatePair: isSurrogatePair,
strlen: strlen,
substring: substring,
substr: substr
};
module.exports = UnicodeUtils;
/***/ },
/* 42 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
module.exports = __webpack_require__(659);
/***/ },
/* 43 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactComponentWithPureRenderMixin
*/
var shallowEqual = __webpack_require__(33);
function shallowCompare(instance, nextProps, nextState) {
return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
}
/**
* If your React component's render function is "pure", e.g. it will render the
* same result given the same props and state, provide this mixin for a
* considerable performance boost.
*
* Most React components have pure render functions.
*
* Example:
*
* var ReactComponentWithPureRenderMixin =
* require('ReactComponentWithPureRenderMixin');
* React.createClass({
* mixins: [ReactComponentWithPureRenderMixin],
*
* render: function() {
* return <div className={this.props.className}>foo</div>;
* }
* });
*
* Note: This only checks shallow equality for props and state. If these contain
* complex data structures this mixin may have false-negatives for deeper
* differences. Only mixin to components which have simple props and state, or
* use `forceUpdate()` when you know deep data structures have changed.
*
* See https://facebook.github.io/react/docs/pure-render-mixin.html
*/
var ReactComponentWithPureRenderMixin = {
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}
};
module.exports = ReactComponentWithPureRenderMixin;
/***/ },
/* 44 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _button = __webpack_require__(285);
var _button2 = _interopRequireDefault(_button);
var _buttonGroup = __webpack_require__(284);
var _buttonGroup2 = _interopRequireDefault(_buttonGroup);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
_button2["default"].Group = _buttonGroup2["default"];
exports["default"] = _button2["default"];
module.exports = exports['default'];
/***/ },
/* 45 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Checkbox = __webpack_require__(139);
var _Checkbox2 = _interopRequireDefault(_Checkbox);
var _Group = __webpack_require__(291);
var _Group2 = _interopRequireDefault(_Group);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
_Checkbox2["default"].Group = _Group2["default"];
exports["default"] = _Checkbox2["default"];
module.exports = exports['default'];
/***/ },
/* 46 */
/***/ function(module, exports, __webpack_require__) {
var dP = __webpack_require__(30)
, createDesc = __webpack_require__(59);
module.exports = __webpack_require__(36) ? function(object, key, value){
return dP.f(object, key, createDesc(1, value));
} : function(object, key, value){
object[key] = value;
return object;
};
/***/ },
/* 47 */
/***/ function(module, exports) {
module.exports = {};
/***/ },
/* 48 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Draft
*/
'use strict';
var AtomicBlockUtils = __webpack_require__(428);
var BlockMapBuilder = __webpack_require__(61);
var CharacterMetadata = __webpack_require__(25);
var CompositeDraftDecorator = __webpack_require__(429);
var ContentBlock = __webpack_require__(40);
var ContentState = __webpack_require__(74);
var DefaultDraftBlockRenderMap = __webpack_require__(109);
var DefaultDraftInlineStyle = __webpack_require__(174);
var DraftEditor = __webpack_require__(431);
var DraftEditorBlock = __webpack_require__(175);
var DraftEntity = __webpack_require__(75);
var DraftModifier = __webpack_require__(19);
var DraftEntityInstance = __webpack_require__(176);
var EditorState = __webpack_require__(10);
var KeyBindingUtil = __webpack_require__(110);
var RichTextEditorUtil = __webpack_require__(442);
var SelectionState = __webpack_require__(49);
var convertFromDraftStateToRaw = __webpack_require__(447);
var convertFromHTMLToContentBlocks = __webpack_require__(179);
var convertFromRawToDraftState = __webpack_require__(448);
var generateRandomKey = __webpack_require__(27);
var getDefaultKeyBinding = __webpack_require__(180);
var getVisibleSelectionRect = __webpack_require__(471);
var DraftPublic = {
Editor: DraftEditor,
EditorBlock: DraftEditorBlock,
EditorState: EditorState,
CompositeDecorator: CompositeDraftDecorator,
Entity: DraftEntity,
EntityInstance: DraftEntityInstance,
BlockMapBuilder: BlockMapBuilder,
CharacterMetadata: CharacterMetadata,
ContentBlock: ContentBlock,
ContentState: ContentState,
SelectionState: SelectionState,
AtomicBlockUtils: AtomicBlockUtils,
KeyBindingUtil: KeyBindingUtil,
Modifier: DraftModifier,
RichUtils: RichTextEditorUtil,
DefaultDraftBlockRenderMap: DefaultDraftBlockRenderMap,
DefaultDraftInlineStyle: DefaultDraftInlineStyle,
convertFromHTML: convertFromHTMLToContentBlocks,
convertFromRaw: convertFromRawToDraftState,
convertToRaw: convertFromDraftStateToRaw,
genKey: generateRandomKey,
getDefaultKeyBinding: getDefaultKeyBinding,
getVisibleSelectionRect: getVisibleSelectionRect
};
module.exports = DraftPublic;
/***/ },
/* 49 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule SelectionState
* @typechecks
*
*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Immutable = __webpack_require__(11);
var Record = Immutable.Record;
var defaultRecord = {
anchorKey: '',
anchorOffset: 0,
focusKey: '',
focusOffset: 0,
isBackward: false,
hasFocus: false
};
var SelectionStateRecord = Record(defaultRecord);
var SelectionState = function (_SelectionStateRecord) {
_inherits(SelectionState, _SelectionStateRecord);
function SelectionState() {
_classCallCheck(this, SelectionState);
return _possibleConstructorReturn(this, _SelectionStateRecord.apply(this, arguments));
}
SelectionState.prototype.serialize = function serialize() {
return 'Anchor: ' + this.getAnchorKey() + ':' + this.getAnchorOffset() + ', ' + 'Focus: ' + this.getFocusKey() + ':' + this.getFocusOffset() + ', ' + 'Is Backward: ' + String(this.getIsBackward()) + ', ' + 'Has Focus: ' + String(this.getHasFocus());
};
SelectionState.prototype.getAnchorKey = function getAnchorKey() {
return this.get('anchorKey');
};
SelectionState.prototype.getAnchorOffset = function getAnchorOffset() {
return this.get('anchorOffset');
};
SelectionState.prototype.getFocusKey = function getFocusKey() {
return this.get('focusKey');
};
SelectionState.prototype.getFocusOffset = function getFocusOffset() {
return this.get('focusOffset');
};
SelectionState.prototype.getIsBackward = function getIsBackward() {
return this.get('isBackward');
};
SelectionState.prototype.getHasFocus = function getHasFocus() {
return this.get('hasFocus');
};
/**
* Return whether the specified range overlaps with an edge of the
* SelectionState.
*/
SelectionState.prototype.hasEdgeWithin = function hasEdgeWithin(blockKey, start, end) {
var anchorKey = this.getAnchorKey();
var focusKey = this.getFocusKey();
if (anchorKey === focusKey && anchorKey === blockKey) {
var selectionStart = this.getStartOffset();
var selectionEnd = this.getEndOffset();
return start <= selectionEnd && selectionStart <= end;
}
if (blockKey !== anchorKey && blockKey !== focusKey) {
return false;
}
var offsetToCheck = blockKey === anchorKey ? this.getAnchorOffset() : this.getFocusOffset();
return start <= offsetToCheck && end >= offsetToCheck;
};
SelectionState.prototype.isCollapsed = function isCollapsed() {
return this.getAnchorKey() === this.getFocusKey() && this.getAnchorOffset() === this.getFocusOffset();
};
SelectionState.prototype.getStartKey = function getStartKey() {
return this.getIsBackward() ? this.getFocusKey() : this.getAnchorKey();
};
SelectionState.prototype.getStartOffset = function getStartOffset() {
return this.getIsBackward() ? this.getFocusOffset() : this.getAnchorOffset();
};
SelectionState.prototype.getEndKey = function getEndKey() {
return this.getIsBackward() ? this.getAnchorKey() : this.getFocusKey();
};
SelectionState.prototype.getEndOffset = function getEndOffset() {
return this.getIsBackward() ? this.getAnchorOffset() : this.getFocusOffset();
};
SelectionState.createEmpty = function createEmpty(key) {
return new SelectionState({
anchorKey: key,
anchorOffset: 0,
focusKey: key,
focusOffset: 0,
isBackward: false,
hasFocus: false
});
};
return SelectionState;
}(SelectionStateRecord);
module.exports = SelectionState;
/***/ },
/* 50 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
(function (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Immutable = factory());
}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;
function createClass(ctor, superClass) {
if (superClass) {
ctor.prototype = Object.create(superClass.prototype);
}
ctor.prototype.constructor = ctor;
}
function Iterable(value) {
return isIterable(value) ? value : Seq(value);
}
createClass(KeyedIterable, Iterable);
function KeyedIterable(value) {
return isKeyed(value) ? value : KeyedSeq(value);
}
createClass(IndexedIterable, Iterable);
function IndexedIterable(value) {
return isIndexed(value) ? value : IndexedSeq(value);
}
createClass(SetIterable, Iterable);
function SetIterable(value) {
return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
}
function isIterable(maybeIterable) {
return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
}
function isKeyed(maybeKeyed) {
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
}
function isIndexed(maybeIndexed) {
return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
}
function isAssociative(maybeAssociative) {
return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
}
function isOrdered(maybeOrdered) {
return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
}
Iterable.isIterable = isIterable;
Iterable.isKeyed = isKeyed;
Iterable.isIndexed = isIndexed;
Iterable.isAssociative = isAssociative;
Iterable.isOrdered = isOrdered;
Iterable.Keyed = KeyedIterable;
Iterable.Indexed = IndexedIterable;
Iterable.Set = SetIterable;
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
// Used for setting prototype methods that IE8 chokes on.
var DELETE = 'delete';
// Constants describing the size of trie nodes.
var SHIFT = 5; // Resulted in best performance after ______?
var SIZE = 1 << SHIFT;
var MASK = SIZE - 1;
// A consistent shared value representing "not set" which equals nothing other
// than itself, and nothing that could be provided externally.
var NOT_SET = {};
// Boolean references, Rough equivalent of `bool &`.
var CHANGE_LENGTH = { value: false };
var DID_ALTER = { value: false };
function MakeRef(ref) {
ref.value = false;
return ref;
}
function SetRef(ref) {
ref && (ref.value = true);
}
// A function which returns a value representing an "owner" for transient writes
// to tries. The return value will only ever equal itself, and will not equal
// the return of any subsequent call of this function.
function OwnerID() {}
// http://jsperf.com/copy-array-inline
function arrCopy(arr, offset) {
offset = offset || 0;
var len = Math.max(0, arr.length - offset);
var newArr = new Array(len);
for (var ii = 0; ii < len; ii++) {
newArr[ii] = arr[ii + offset];
}
return newArr;
}
function ensureSize(iter) {
if (iter.size === undefined) {
iter.size = iter.__iterate(returnTrue);
}
return iter.size;
}
function wrapIndex(iter, index) {
// This implements "is array index" which the ECMAString spec defines as:
//
// A String property name P is an array index if and only if
// ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
// to 2^32−1.
//
// http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
if (typeof index !== 'number') {
var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
if ('' + uint32Index !== index || uint32Index === 4294967295) {
return NaN;
}
index = uint32Index;
}
return index < 0 ? ensureSize(iter) + index : index;
}
function returnTrue() {
return true;
}
function wholeSlice(begin, end, size) {
return (begin === 0 || (size !== undefined && begin <= -size)) &&
(end === undefined || (size !== undefined && end >= size));
}
function resolveBegin(begin, size) {
return resolveIndex(begin, size, 0);
}
function resolveEnd(end, size) {
return resolveIndex(end, size, size);
}
function resolveIndex(index, size, defaultIndex) {
return index === undefined ?
defaultIndex :
index < 0 ?
Math.max(0, size + index) :
size === undefined ?
index :
Math.min(size, index);
}
/* global Symbol */
var ITERATE_KEYS = 0;
var ITERATE_VALUES = 1;
var ITERATE_ENTRIES = 2;
var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator';
var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
function Iterator(next) {
this.next = next;
}
Iterator.prototype.toString = function() {
return '[Iterator]';
};
Iterator.KEYS = ITERATE_KEYS;
Iterator.VALUES = ITERATE_VALUES;
Iterator.ENTRIES = ITERATE_ENTRIES;
Iterator.prototype.inspect =
Iterator.prototype.toSource = function () { return this.toString(); }
Iterator.prototype[ITERATOR_SYMBOL] = function () {
return this;
};
function iteratorValue(type, k, v, iteratorResult) {
var value = type === 0 ? k : type === 1 ? v : [k, v];
iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
value: value, done: false
});
return iteratorResult;
}
function iteratorDone() {
return { value: undefined, done: true };
}
function hasIterator(maybeIterable) {
return !!getIteratorFn(maybeIterable);
}
function isIterator(maybeIterator) {
return maybeIterator && typeof maybeIterator.next === 'function';
}
function getIterator(iterable) {
var iteratorFn = getIteratorFn(iterable);
return iteratorFn && iteratorFn.call(iterable);
}
function getIteratorFn(iterable) {
var iteratorFn = iterable && (
(REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
iterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
function isArrayLike(value) {
return value && typeof value.length === 'number';
}
createClass(Seq, Iterable);
function Seq(value) {
return value === null || value === undefined ? emptySequence() :
isIterable(value) ? value.toSeq() : seqFromValue(value);
}
Seq.of = function(/*...values*/) {
return Seq(arguments);
};
Seq.prototype.toSeq = function() {
return this;
};
Seq.prototype.toString = function() {
return this.__toString('Seq {', '}');
};
Seq.prototype.cacheResult = function() {
if (!this._cache && this.__iterateUncached) {
this._cache = this.entrySeq().toArray();
this.size = this._cache.length;
}
return this;
};
// abstract __iterateUncached(fn, reverse)
Seq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, true);
};
// abstract __iteratorUncached(type, reverse)
Seq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, true);
};
createClass(KeyedSeq, Seq);
function KeyedSeq(value) {
return value === null || value === undefined ?
emptySequence().toKeyedSeq() :
isIterable(value) ?
(isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
keyedSeqFromValue(value);
}
KeyedSeq.prototype.toKeyedSeq = function() {
return this;
};
createClass(IndexedSeq, Seq);
function IndexedSeq(value) {
return value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
}
IndexedSeq.of = function(/*...values*/) {
return IndexedSeq(arguments);
};
IndexedSeq.prototype.toIndexedSeq = function() {
return this;
};
IndexedSeq.prototype.toString = function() {
return this.__toString('Seq [', ']');
};
IndexedSeq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, false);
};
IndexedSeq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, false);
};
createClass(SetSeq, Seq);
function SetSeq(value) {
return (
value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value
).toSetSeq();
}
SetSeq.of = function(/*...values*/) {
return SetSeq(arguments);
};
SetSeq.prototype.toSetSeq = function() {
return this;
};
Seq.isSeq = isSeq;
Seq.Keyed = KeyedSeq;
Seq.Set = SetSeq;
Seq.Indexed = IndexedSeq;
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
Seq.prototype[IS_SEQ_SENTINEL] = true;
createClass(ArraySeq, IndexedSeq);
function ArraySeq(array) {
this._array = array;
this.size = array.length;
}
ArraySeq.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
};
ArraySeq.prototype.__iterate = function(fn, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
return ii + 1;
}
}
return ii;
};
ArraySeq.prototype.__iterator = function(type, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
var ii = 0;
return new Iterator(function()
{return ii > maxIndex ?
iteratorDone() :
iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
);
};
createClass(ObjectSeq, KeyedSeq);
function ObjectSeq(object) {
var keys = Object.keys(object);
this._object = object;
this._keys = keys;
this.size = keys.length;
}
ObjectSeq.prototype.get = function(key, notSetValue) {
if (notSetValue !== undefined && !this.has(key)) {
return notSetValue;
}
return this._object[key];
};
ObjectSeq.prototype.has = function(key) {
return this._object.hasOwnProperty(key);
};
ObjectSeq.prototype.__iterate = function(fn, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var key = keys[reverse ? maxIndex - ii : ii];
if (fn(object[key], key, this) === false) {
return ii + 1;
}
}
return ii;
};
ObjectSeq.prototype.__iterator = function(type, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
var ii = 0;
return new Iterator(function() {
var key = keys[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, key, object[key]);
});
};
ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
createClass(IterableSeq, IndexedSeq);
function IterableSeq(iterable) {
this._iterable = iterable;
this.size = iterable.length || iterable.size;
}
IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
var iterations = 0;
if (isIterator(iterator)) {
var step;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
}
return iterations;
};
IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
if (!isIterator(iterator)) {
return new Iterator(iteratorDone);
}
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step : iteratorValue(type, iterations++, step.value);
});
};
createClass(IteratorSeq, IndexedSeq);
function IteratorSeq(iterator) {
this._iterator = iterator;
this._iteratorCache = [];
}
IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
while (iterations < cache.length) {
if (fn(cache[iterations], iterations++, this) === false) {
return iterations;
}
}
var step;
while (!(step = iterator.next()).done) {
var val = step.value;
cache[iterations] = val;
if (fn(val, iterations++, this) === false) {
break;
}
}
return iterations;
};
IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
return new Iterator(function() {
if (iterations >= cache.length) {
var step = iterator.next();
if (step.done) {
return step;
}
cache[iterations] = step.value;
}
return iteratorValue(type, iterations, cache[iterations++]);
});
};
// # pragma Helper functions
function isSeq(maybeSeq) {
return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
}
var EMPTY_SEQ;
function emptySequence() {
return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
}
function keyedSeqFromValue(value) {
var seq =
Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
typeof value === 'object' ? new ObjectSeq(value) :
undefined;
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of [k, v] entries, '+
'or keyed object: ' + value
);
}
return seq;
}
function indexedSeqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value);
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values: ' + value
);
}
return seq;
}
function seqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value) ||
(typeof value === 'object' && new ObjectSeq(value));
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values, or keyed object: ' + value
);
}
return seq;
}
function maybeIndexedSeqFromValue(value) {
return (
isArrayLike(value) ? new ArraySeq(value) :
isIterator(value) ? new IteratorSeq(value) :
hasIterator(value) ? new IterableSeq(value) :
undefined
);
}
function seqIterate(seq, fn, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var entry = cache[reverse ? maxIndex - ii : ii];
if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
return ii + 1;
}
}
return ii;
}
return seq.__iterateUncached(fn, reverse);
}
function seqIterator(seq, type, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
var ii = 0;
return new Iterator(function() {
var entry = cache[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
});
}
return seq.__iteratorUncached(type, reverse);
}
function fromJS(json, converter) {
return converter ?
fromJSWith(converter, json, '', {'': json}) :
fromJSDefault(json);
}
function fromJSWith(converter, json, key, parentJSON) {
if (Array.isArray(json)) {
return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
if (isPlainObj(json)) {
return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
return json;
}
function fromJSDefault(json) {
if (Array.isArray(json)) {
return IndexedSeq(json).map(fromJSDefault).toList();
}
if (isPlainObj(json)) {
return KeyedSeq(json).map(fromJSDefault).toMap();
}
return json;
}
function isPlainObj(value) {
return value && (value.constructor === Object || value.constructor === undefined);
}
/**
* An extension of the "same-value" algorithm as [described for use by ES6 Map
* and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
*
* NaN is considered the same as NaN, however -0 and 0 are considered the same
* value, which is different from the algorithm described by
* [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
*
* This is extended further to allow Objects to describe the values they
* represent, by way of `valueOf` or `equals` (and `hashCode`).
*
* Note: because of this extension, the key equality of Immutable.Map and the
* value equality of Immutable.Set will differ from ES6 Map and Set.
*
* ### Defining custom values
*
* The easiest way to describe the value an object represents is by implementing
* `valueOf`. For example, `Date` represents a value by returning a unix
* timestamp for `valueOf`:
*
* var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
* var date2 = new Date(1234567890000);
* date1.valueOf(); // 1234567890000
* assert( date1 !== date2 );
* assert( Immutable.is( date1, date2 ) );
*
* Note: overriding `valueOf` may have other implications if you use this object
* where JavaScript expects a primitive, such as implicit string coercion.
*
* For more complex types, especially collections, implementing `valueOf` may
* not be performant. An alternative is to implement `equals` and `hashCode`.
*
* `equals` takes another object, presumably of similar type, and returns true
* if the it is equal. Equality is symmetrical, so the same result should be
* returned if this and the argument are flipped.
*
* assert( a.equals(b) === b.equals(a) );
*
* `hashCode` returns a 32bit integer number representing the object which will
* be used to determine how to store the value object in a Map or Set. You must
* provide both or neither methods, one must not exist without the other.
*
* Also, an important relationship between these methods must be upheld: if two
* values are equal, they *must* return the same hashCode. If the values are not
* equal, they might have the same hashCode; this is called a hash collision,
* and while undesirable for performance reasons, it is acceptable.
*
* if (a.equals(b)) {
* assert( a.hashCode() === b.hashCode() );
* }
*
* All Immutable collections implement `equals` and `hashCode`.
*
*/
function is(valueA, valueB) {
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
if (typeof valueA.valueOf === 'function' &&
typeof valueB.valueOf === 'function') {
valueA = valueA.valueOf();
valueB = valueB.valueOf();
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
}
if (typeof valueA.equals === 'function' &&
typeof valueB.equals === 'function' &&
valueA.equals(valueB)) {
return true;
}
return false;
}
function deepEqual(a, b) {
if (a === b) {
return true;
}
if (
!isIterable(b) ||
a.size !== undefined && b.size !== undefined && a.size !== b.size ||
a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
isKeyed(a) !== isKeyed(b) ||
isIndexed(a) !== isIndexed(b) ||
isOrdered(a) !== isOrdered(b)
) {
return false;
}
if (a.size === 0 && b.size === 0) {
return true;
}
var notAssociative = !isAssociative(a);
if (isOrdered(a)) {
var entries = a.entries();
return b.every(function(v, k) {
var entry = entries.next().value;
return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
}) && entries.next().done;
}
var flipped = false;
if (a.size === undefined) {
if (b.size === undefined) {
if (typeof a.cacheResult === 'function') {
a.cacheResult();
}
} else {
flipped = true;
var _ = a;
a = b;
b = _;
}
}
var allEqual = true;
var bSize = b.__iterate(function(v, k) {
if (notAssociative ? !a.has(v) :
flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
allEqual = false;
return false;
}
});
return allEqual && a.size === bSize;
}
createClass(Repeat, IndexedSeq);
function Repeat(value, times) {
if (!(this instanceof Repeat)) {
return new Repeat(value, times);
}
this._value = value;
this.size = times === undefined ? Infinity : Math.max(0, times);
if (this.size === 0) {
if (EMPTY_REPEAT) {
return EMPTY_REPEAT;
}
EMPTY_REPEAT = this;
}
}
Repeat.prototype.toString = function() {
if (this.size === 0) {
return 'Repeat []';
}
return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
};
Repeat.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._value : notSetValue;
};
Repeat.prototype.includes = function(searchValue) {
return is(this._value, searchValue);
};
Repeat.prototype.slice = function(begin, end) {
var size = this.size;
return wholeSlice(begin, end, size) ? this :
new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
};
Repeat.prototype.reverse = function() {
return this;
};
Repeat.prototype.indexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return 0;
}
return -1;
};
Repeat.prototype.lastIndexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return this.size;
}
return -1;
};
Repeat.prototype.__iterate = function(fn, reverse) {
for (var ii = 0; ii < this.size; ii++) {
if (fn(this._value, ii, this) === false) {
return ii + 1;
}
}
return ii;
};
Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
var ii = 0;
return new Iterator(function()
{return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
);
};
Repeat.prototype.equals = function(other) {
return other instanceof Repeat ?
is(this._value, other._value) :
deepEqual(other);
};
var EMPTY_REPEAT;
function invariant(condition, error) {
if (!condition) throw new Error(error);
}
createClass(Range, IndexedSeq);
function Range(start, end, step) {
if (!(this instanceof Range)) {
return new Range(start, end, step);
}
invariant(step !== 0, 'Cannot step a Range by 0');
start = start || 0;
if (end === undefined) {
end = Infinity;
}
step = step === undefined ? 1 : Math.abs(step);
if (end < start) {
step = -step;
}
this._start = start;
this._end = end;
this._step = step;
this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
if (this.size === 0) {
if (EMPTY_RANGE) {
return EMPTY_RANGE;
}
EMPTY_RANGE = this;
}
}
Range.prototype.toString = function() {
if (this.size === 0) {
return 'Range []';
}
return 'Range [ ' +
this._start + '...' + this._end +
(this._step !== 1 ? ' by ' + this._step : '') +
' ]';
};
Range.prototype.get = function(index, notSetValue) {
return this.has(index) ?
this._start + wrapIndex(this, index) * this._step :
notSetValue;
};
Range.prototype.includes = function(searchValue) {
var possibleIndex = (searchValue - this._start) / this._step;
return possibleIndex >= 0 &&
possibleIndex < this.size &&
possibleIndex === Math.floor(possibleIndex);
};
Range.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
begin = resolveBegin(begin, this.size);
end = resolveEnd(end, this.size);
if (end <= begin) {
return new Range(0, 0);
}
return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
};
Range.prototype.indexOf = function(searchValue) {
var offsetValue = searchValue - this._start;
if (offsetValue % this._step === 0) {
var index = offsetValue / this._step;
if (index >= 0 && index < this.size) {
return index
}
}
return -1;
};
Range.prototype.lastIndexOf = function(searchValue) {
return this.indexOf(searchValue);
};
Range.prototype.__iterate = function(fn, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(value, ii, this) === false) {
return ii + 1;
}
value += reverse ? -step : step;
}
return ii;
};
Range.prototype.__iterator = function(type, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
var ii = 0;
return new Iterator(function() {
var v = value;
value += reverse ? -step : step;
return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
});
};
Range.prototype.equals = function(other) {
return other instanceof Range ?
this._start === other._start &&
this._end === other._end &&
this._step === other._step :
deepEqual(this, other);
};
var EMPTY_RANGE;
createClass(Collection, Iterable);
function Collection() {
throw TypeError('Abstract');
}
createClass(KeyedCollection, Collection);function KeyedCollection() {}
createClass(IndexedCollection, Collection);function IndexedCollection() {}
createClass(SetCollection, Collection);function SetCollection() {}
Collection.Keyed = KeyedCollection;
Collection.Indexed = IndexedCollection;
Collection.Set = SetCollection;
var imul =
typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
Math.imul :
function imul(a, b) {
a = a | 0; // int
b = b | 0; // int
var c = a & 0xffff;
var d = b & 0xffff;
// Shift by 0 fixes the sign on the high part.
return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
};
// v8 has an optimization for storing 31-bit signed numbers.
// Values which have either 00 or 11 as the high order bits qualify.
// This function drops the highest order bit in a signed number, maintaining
// the sign bit.
function smi(i32) {
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
}
function hash(o) {
if (o === false || o === null || o === undefined) {
return 0;
}
if (typeof o.valueOf === 'function') {
o = o.valueOf();
if (o === false || o === null || o === undefined) {
return 0;
}
}
if (o === true) {
return 1;
}
var type = typeof o;
if (type === 'number') {
if (o !== o || o === Infinity) {
return 0;
}
var h = o | 0;
if (h !== o) {
h ^= o * 0xFFFFFFFF;
}
while (o > 0xFFFFFFFF) {
o /= 0xFFFFFFFF;
h ^= o;
}
return smi(h);
}
if (type === 'string') {
return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
}
if (typeof o.hashCode === 'function') {
return o.hashCode();
}
if (type === 'object') {
return hashJSObj(o);
}
if (typeof o.toString === 'function') {
return hashString(o.toString());
}
throw new Error('Value type ' + type + ' cannot be hashed.');
}
function cachedHashString(string) {
var hash = stringHashCache[string];
if (hash === undefined) {
hash = hashString(string);
if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
STRING_HASH_CACHE_SIZE = 0;
stringHashCache = {};
}
STRING_HASH_CACHE_SIZE++;
stringHashCache[string] = hash;
}
return hash;
}
// http://jsperf.com/hashing-strings
function hashString(string) {
// This is the hash from JVM
// The hash code for a string is computed as
// s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
// where s[i] is the ith character of the string and n is the length of
// the string. We "mod" the result to make it between 0 (inclusive) and 2^31
// (exclusive) by dropping high bits.
var hash = 0;
for (var ii = 0; ii < string.length; ii++) {
hash = 31 * hash + string.charCodeAt(ii) | 0;
}
return smi(hash);
}
function hashJSObj(obj) {
var hash;
if (usingWeakMap) {
hash = weakMap.get(obj);
if (hash !== undefined) {
return hash;
}
}
hash = obj[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
if (!canDefineProperty) {
hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
hash = getIENodeHash(obj);
if (hash !== undefined) {
return hash;
}
}
hash = ++objHashUID;
if (objHashUID & 0x40000000) {
objHashUID = 0;
}
if (usingWeakMap) {
weakMap.set(obj, hash);
} else if (isExtensible !== undefined && isExtensible(obj) === false) {
throw new Error('Non-extensible objects are not allowed as keys.');
} else if (canDefineProperty) {
Object.defineProperty(obj, UID_HASH_KEY, {
'enumerable': false,
'configurable': false,
'writable': false,
'value': hash
});
} else if (obj.propertyIsEnumerable !== undefined &&
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
// Since we can't define a non-enumerable property on the object
// we'll hijack one of the less-used non-enumerable properties to
// save our hash on it. Since this is a function it will not show up in
// `JSON.stringify` which is what we want.
obj.propertyIsEnumerable = function() {
return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
};
obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
} else if (obj.nodeType !== undefined) {
// At this point we couldn't get the IE `uniqueID` to use as a hash
// and we couldn't use a non-enumerable property to exploit the
// dontEnum bug so we simply add the `UID_HASH_KEY` on the node
// itself.
obj[UID_HASH_KEY] = hash;
} else {
throw new Error('Unable to set a non-enumerable property on object.');
}
return hash;
}
// Get references to ES5 object methods.
var isExtensible = Object.isExtensible;
// True if Object.defineProperty works as expected. IE8 fails this test.
var canDefineProperty = (function() {
try {
Object.defineProperty({}, '@', {});
return true;
} catch (e) {
return false;
}
}());
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
// and avoid memory leaks from the IE cloneNode bug.
function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
}
// If possible, use a WeakMap.
var usingWeakMap = typeof WeakMap === 'function';
var weakMap;
if (usingWeakMap) {
weakMap = new WeakMap();
}
var objHashUID = 0;
var UID_HASH_KEY = '__immutablehash__';
if (typeof Symbol === 'function') {
UID_HASH_KEY = Symbol(UID_HASH_KEY);
}
var STRING_HASH_CACHE_MIN_STRLEN = 16;
var STRING_HASH_CACHE_MAX_SIZE = 255;
var STRING_HASH_CACHE_SIZE = 0;
var stringHashCache = {};
function assertNotInfinite(size) {
invariant(
size !== Infinity,
'Cannot perform this action with an infinite size.'
);
}
createClass(Map, KeyedCollection);
// @pragma Construction
function Map(value) {
return value === null || value === undefined ? emptyMap() :
isMap(value) && !isOrdered(value) ? value :
emptyMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
Map.of = function() {var keyValues = SLICE$0.call(arguments, 0);
return emptyMap().withMutations(function(map ) {
for (var i = 0; i < keyValues.length; i += 2) {
if (i + 1 >= keyValues.length) {
throw new Error('Missing value for key: ' + keyValues[i]);
}
map.set(keyValues[i], keyValues[i + 1]);
}
});
};
Map.prototype.toString = function() {
return this.__toString('Map {', '}');
};
// @pragma Access
Map.prototype.get = function(k, notSetValue) {
return this._root ?
this._root.get(0, undefined, k, notSetValue) :
notSetValue;
};
// @pragma Modification
Map.prototype.set = function(k, v) {
return updateMap(this, k, v);
};
Map.prototype.setIn = function(keyPath, v) {
return this.updateIn(keyPath, NOT_SET, function() {return v});
};
Map.prototype.remove = function(k) {
return updateMap(this, k, NOT_SET);
};
Map.prototype.deleteIn = function(keyPath) {
return this.updateIn(keyPath, function() {return NOT_SET});
};
Map.prototype.update = function(k, notSetValue, updater) {
return arguments.length === 1 ?
k(this) :
this.updateIn([k], notSetValue, updater);
};
Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
if (!updater) {
updater = notSetValue;
notSetValue = undefined;
}
var updatedValue = updateInDeepMap(
this,
forceIterator(keyPath),
notSetValue,
updater
);
return updatedValue === NOT_SET ? undefined : updatedValue;
};
Map.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._root = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyMap();
};
// @pragma Composition
Map.prototype.merge = function(/*...iters*/) {
return mergeIntoMapWith(this, undefined, arguments);
};
Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, merger, iters);
};
Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.merge === 'function' ?
m.merge.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoMapWith(this, deepMerger, arguments);
};
Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
};
Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.mergeDeep === 'function' ?
m.mergeDeep.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.sort = function(comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator));
};
Map.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator, mapper));
};
// @pragma Mutability
Map.prototype.withMutations = function(fn) {
var mutable = this.asMutable();
fn(mutable);
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
};
Map.prototype.asMutable = function() {
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
};
Map.prototype.asImmutable = function() {
return this.__ensureOwner();
};
Map.prototype.wasAltered = function() {
return this.__altered;
};
Map.prototype.__iterator = function(type, reverse) {
return new MapIterator(this, type, reverse);
};
Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
this._root && this._root.iterate(function(entry ) {
iterations++;
return fn(entry[1], entry[0], this$0);
}, reverse);
return iterations;
};
Map.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeMap(this.size, this._root, ownerID, this.__hash);
};
function isMap(maybeMap) {
return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
}
Map.isMap = isMap;
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
var MapPrototype = Map.prototype;
MapPrototype[IS_MAP_SENTINEL] = true;
MapPrototype[DELETE] = MapPrototype.remove;
MapPrototype.removeIn = MapPrototype.deleteIn;
// #pragma Trie Nodes
function ArrayMapNode(ownerID, entries) {
this.ownerID = ownerID;
this.entries = entries;
}
ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && entries.length === 1) {
return; // undefined
}
if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
return createNodes(ownerID, entries, key, value);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new ArrayMapNode(ownerID, newEntries);
};
function BitmapIndexedNode(ownerID, bitmap, nodes) {
this.ownerID = ownerID;
this.bitmap = bitmap;
this.nodes = nodes;
}
BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
var bitmap = this.bitmap;
return (bitmap & bit) === 0 ? notSetValue :
this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
};
BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var bit = 1 << keyHashFrag;
var bitmap = this.bitmap;
var exists = (bitmap & bit) !== 0;
if (!exists && value === NOT_SET) {
return this;
}
var idx = popCount(bitmap & (bit - 1));
var nodes = this.nodes;
var node = exists ? nodes[idx] : undefined;
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
}
if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
return nodes[idx ^ 1];
}
if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
return newNode;
}
var isEditable = ownerID && ownerID === this.ownerID;
var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
var newNodes = exists ? newNode ?
setIn(nodes, idx, newNode, isEditable) :
spliceOut(nodes, idx, isEditable) :
spliceIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.bitmap = newBitmap;
this.nodes = newNodes;
return this;
}
return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
};
function HashArrayMapNode(ownerID, count, nodes) {
this.ownerID = ownerID;
this.count = count;
this.nodes = nodes;
}
HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var node = this.nodes[idx];
return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
};
HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var removed = value === NOT_SET;
var nodes = this.nodes;
var node = nodes[idx];
if (removed && !node) {
return this;
}
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
var newCount = this.count;
if (!node) {
newCount++;
} else if (!newNode) {
newCount--;
if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
return packNodes(ownerID, nodes, newCount, idx);
}
}
var isEditable = ownerID && ownerID === this.ownerID;
var newNodes = setIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.count = newCount;
this.nodes = newNodes;
return this;
}
return new HashArrayMapNode(ownerID, newCount, newNodes);
};
function HashCollisionNode(ownerID, keyHash, entries) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entries = entries;
}
HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var removed = value === NOT_SET;
if (keyHash !== this.keyHash) {
if (removed) {
return this;
}
SetRef(didAlter);
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
}
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && len === 2) {
return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new HashCollisionNode(ownerID, this.keyHash, newEntries);
};
function ValueNode(ownerID, keyHash, entry) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entry = entry;
}
ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
};
ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var keyMatch = is(key, this.entry[0]);
if (keyMatch ? value === this.entry[1] : removed) {
return this;
}
SetRef(didAlter);
if (removed) {
SetRef(didChangeSize);
return; // undefined
}
if (keyMatch) {
if (ownerID && ownerID === this.ownerID) {
this.entry[1] = value;
return this;
}
return new ValueNode(ownerID, this.keyHash, [key, value]);
}
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
};
// #pragma Iterators
ArrayMapNode.prototype.iterate =
HashCollisionNode.prototype.iterate = function (fn, reverse) {
var entries = this.entries;
for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
return false;
}
}
}
BitmapIndexedNode.prototype.iterate =
HashArrayMapNode.prototype.iterate = function (fn, reverse) {
var nodes = this.nodes;
for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
var node = nodes[reverse ? maxIndex - ii : ii];
if (node && node.iterate(fn, reverse) === false) {
return false;
}
}
}
ValueNode.prototype.iterate = function (fn, reverse) {
return fn(this.entry);
}
createClass(MapIterator, Iterator);
function MapIterator(map, type, reverse) {
this._type = type;
this._reverse = reverse;
this._stack = map._root && mapIteratorFrame(map._root);
}
MapIterator.prototype.next = function() {
var type = this._type;
var stack = this._stack;
while (stack) {
var node = stack.node;
var index = stack.index++;
var maxIndex;
if (node.entry) {
if (index === 0) {
return mapIteratorValue(type, node.entry);
}
} else if (node.entries) {
maxIndex = node.entries.length - 1;
if (index <= maxIndex) {
return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
}
} else {
maxIndex = node.nodes.length - 1;
if (index <= maxIndex) {
var subNode = node.nodes[this._reverse ? maxIndex - index : index];
if (subNode) {
if (subNode.entry) {
return mapIteratorValue(type, subNode.entry);
}
stack = this._stack = mapIteratorFrame(subNode, stack);
}
continue;
}
}
stack = this._stack = this._stack.__prev;
}
return iteratorDone();
};
function mapIteratorValue(type, entry) {
return iteratorValue(type, entry[0], entry[1]);
}
function mapIteratorFrame(node, prev) {
return {
node: node,
index: 0,
__prev: prev
};
}
function makeMap(size, root, ownerID, hash) {
var map = Object.create(MapPrototype);
map.size = size;
map._root = root;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_MAP;
function emptyMap() {
return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
}
function updateMap(map, k, v) {
var newRoot;
var newSize;
if (!map._root) {
if (v === NOT_SET) {
return map;
}
newSize = 1;
newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
} else {
var didChangeSize = MakeRef(CHANGE_LENGTH);
var didAlter = MakeRef(DID_ALTER);
newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
if (!didAlter.value) {
return map;
}
newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
}
if (map.__ownerID) {
map.size = newSize;
map._root = newRoot;
map.__hash = undefined;
map.__altered = true;
return map;
}
return newRoot ? makeMap(newSize, newRoot) : emptyMap();
}
function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (!node) {
if (value === NOT_SET) {
return node;
}
SetRef(didAlter);
SetRef(didChangeSize);
return new ValueNode(ownerID, keyHash, [key, value]);
}
return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
}
function isLeafNode(node) {
return node.constructor === ValueNode || node.constructor === HashCollisionNode;
}
function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
if (node.keyHash === keyHash) {
return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
}
var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var newNode;
var nodes = idx1 === idx2 ?
[mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
}
function createNodes(ownerID, entries, key, value) {
if (!ownerID) {
ownerID = new OwnerID();
}
var node = new ValueNode(ownerID, hash(key), [key, value]);
for (var ii = 0; ii < entries.length; ii++) {
var entry = entries[ii];
node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
}
return node;
}
function packNodes(ownerID, nodes, count, excluding) {
var bitmap = 0;
var packedII = 0;
var packedNodes = new Array(count);
for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
var node = nodes[ii];
if (node !== undefined && ii !== excluding) {
bitmap |= bit;
packedNodes[packedII++] = node;
}
}
return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
}
function expandNodes(ownerID, nodes, bitmap, including, node) {
var count = 0;
var expandedNodes = new Array(SIZE);
for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
}
expandedNodes[including] = node;
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
}
function mergeIntoMapWith(map, merger, iterables) {
var iters = [];
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = KeyedIterable(value);
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
return mergeIntoCollectionWith(map, merger, iters);
}
function deepMerger(existing, value, key) {
return existing && existing.mergeDeep && isIterable(value) ?
existing.mergeDeep(value) :
is(existing, value) ? existing : value;
}
function deepMergerWith(merger) {
return function(existing, value, key) {
if (existing && existing.mergeDeepWith && isIterable(value)) {
return existing.mergeDeepWith(merger, value);
}
var nextValue = merger(existing, value, key);
return is(existing, nextValue) ? existing : nextValue;
};
}
function mergeIntoCollectionWith(collection, merger, iters) {
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return collection;
}
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
return collection.constructor(iters[0]);
}
return collection.withMutations(function(collection ) {
var mergeIntoMap = merger ?
function(value, key) {
collection.update(key, NOT_SET, function(existing )
{return existing === NOT_SET ? value : merger(existing, value, key)}
);
} :
function(value, key) {
collection.set(key, value);
}
for (var ii = 0; ii < iters.length; ii++) {
iters[ii].forEach(mergeIntoMap);
}
});
}
function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
var isNotSet = existing === NOT_SET;
var step = keyPathIter.next();
if (step.done) {
var existingValue = isNotSet ? notSetValue : existing;
var newValue = updater(existingValue);
return newValue === existingValue ? existing : newValue;
}
invariant(
isNotSet || (existing && existing.set),
'invalid keyPath'
);
var key = step.value;
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
var nextUpdated = updateInDeepMap(
nextExisting,
keyPathIter,
notSetValue,
updater
);
return nextUpdated === nextExisting ? existing :
nextUpdated === NOT_SET ? existing.remove(key) :
(isNotSet ? emptyMap() : existing).set(key, nextUpdated);
}
function popCount(x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x7f;
}
function setIn(array, idx, val, canEdit) {
var newArray = canEdit ? array : arrCopy(array);
newArray[idx] = val;
return newArray;
}
function spliceIn(array, idx, val, canEdit) {
var newLen = array.length + 1;
if (canEdit && idx + 1 === newLen) {
array[idx] = val;
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
newArray[ii] = val;
after = -1;
} else {
newArray[ii] = array[ii + after];
}
}
return newArray;
}
function spliceOut(array, idx, canEdit) {
var newLen = array.length - 1;
if (canEdit && idx === newLen) {
array.pop();
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
after = 1;
}
newArray[ii] = array[ii + after];
}
return newArray;
}
var MAX_ARRAY_MAP_SIZE = SIZE / 4;
var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
createClass(List, IndexedCollection);
// @pragma Construction
function List(value) {
var empty = emptyList();
if (value === null || value === undefined) {
return empty;
}
if (isList(value)) {
return value;
}
var iter = IndexedIterable(value);
var size = iter.size;
if (size === 0) {
return empty;
}
assertNotInfinite(size);
if (size > 0 && size < SIZE) {
return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
}
return empty.withMutations(function(list ) {
list.setSize(size);
iter.forEach(function(v, i) {return list.set(i, v)});
});
}
List.of = function(/*...values*/) {
return this(arguments);
};
List.prototype.toString = function() {
return this.__toString('List [', ']');
};
// @pragma Access
List.prototype.get = function(index, notSetValue) {
index = wrapIndex(this, index);
if (index >= 0 && index < this.size) {
index += this._origin;
var node = listNodeFor(this, index);
return node && node.array[index & MASK];
}
return notSetValue;
};
// @pragma Modification
List.prototype.set = function(index, value) {
return updateList(this, index, value);
};
List.prototype.remove = function(index) {
return !this.has(index) ? this :
index === 0 ? this.shift() :
index === this.size - 1 ? this.pop() :
this.splice(index, 1);
};
List.prototype.insert = function(index, value) {
return this.splice(index, 0, value);
};
List.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = this._origin = this._capacity = 0;
this._level = SHIFT;
this._root = this._tail = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyList();
};
List.prototype.push = function(/*...values*/) {
var values = arguments;
var oldSize = this.size;
return this.withMutations(function(list ) {
setListBounds(list, 0, oldSize + values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(oldSize + ii, values[ii]);
}
});
};
List.prototype.pop = function() {
return setListBounds(this, 0, -1);
};
List.prototype.unshift = function(/*...values*/) {
var values = arguments;
return this.withMutations(function(list ) {
setListBounds(list, -values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(ii, values[ii]);
}
});
};
List.prototype.shift = function() {
return setListBounds(this, 1);
};
// @pragma Composition
List.prototype.merge = function(/*...iters*/) {
return mergeIntoListWith(this, undefined, arguments);
};
List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, merger, iters);
};
List.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoListWith(this, deepMerger, arguments);
};
List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, deepMergerWith(merger), iters);
};
List.prototype.setSize = function(size) {
return setListBounds(this, 0, size);
};
// @pragma Iteration
List.prototype.slice = function(begin, end) {
var size = this.size;
if (wholeSlice(begin, end, size)) {
return this;
}
return setListBounds(
this,
resolveBegin(begin, size),
resolveEnd(end, size)
);
};
List.prototype.__iterator = function(type, reverse) {
var index = 0;
var values = iterateList(this, reverse);
return new Iterator(function() {
var value = values();
return value === DONE ?
iteratorDone() :
iteratorValue(type, index++, value);
});
};
List.prototype.__iterate = function(fn, reverse) {
var index = 0;
var values = iterateList(this, reverse);
var value;
while ((value = values()) !== DONE) {
if (fn(value, index++, this) === false) {
break;
}
}
return index;
};
List.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
return this;
}
return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
};
function isList(maybeList) {
return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
}
List.isList = isList;
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
var ListPrototype = List.prototype;
ListPrototype[IS_LIST_SENTINEL] = true;
ListPrototype[DELETE] = ListPrototype.remove;
ListPrototype.setIn = MapPrototype.setIn;
ListPrototype.deleteIn =
ListPrototype.removeIn = MapPrototype.removeIn;
ListPrototype.update = MapPrototype.update;
ListPrototype.updateIn = MapPrototype.updateIn;
ListPrototype.mergeIn = MapPrototype.mergeIn;
ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
ListPrototype.withMutations = MapPrototype.withMutations;
ListPrototype.asMutable = MapPrototype.asMutable;
ListPrototype.asImmutable = MapPrototype.asImmutable;
ListPrototype.wasAltered = MapPrototype.wasAltered;
function VNode(array, ownerID) {
this.array = array;
this.ownerID = ownerID;
}
// TODO: seems like these methods are very similar
VNode.prototype.removeBefore = function(ownerID, level, index) {
if (index === level ? 1 << level : 0 || this.array.length === 0) {
return this;
}
var originIndex = (index >>> level) & MASK;
if (originIndex >= this.array.length) {
return new VNode([], ownerID);
}
var removingFirst = originIndex === 0;
var newChild;
if (level > 0) {
var oldChild = this.array[originIndex];
newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
if (newChild === oldChild && removingFirst) {
return this;
}
}
if (removingFirst && !newChild) {
return this;
}
var editable = editableVNode(this, ownerID);
if (!removingFirst) {
for (var ii = 0; ii < originIndex; ii++) {
editable.array[ii] = undefined;
}
}
if (newChild) {
editable.array[originIndex] = newChild;
}
return editable;
};
VNode.prototype.removeAfter = function(ownerID, level, index) {
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
return this;
}
var sizeIndex = ((index - 1) >>> level) & MASK;
if (sizeIndex >= this.array.length) {
return this;
}
var newChild;
if (level > 0) {
var oldChild = this.array[sizeIndex];
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
if (newChild === oldChild && sizeIndex === this.array.length - 1) {
return this;
}
}
var editable = editableVNode(this, ownerID);
editable.array.splice(sizeIndex + 1);
if (newChild) {
editable.array[sizeIndex] = newChild;
}
return editable;
};
var DONE = {};
function iterateList(list, reverse) {
var left = list._origin;
var right = list._capacity;
var tailPos = getTailOffset(right);
var tail = list._tail;
return iterateNodeOrLeaf(list._root, list._level, 0);
function iterateNodeOrLeaf(node, level, offset) {
return level === 0 ?
iterateLeaf(node, offset) :
iterateNode(node, level, offset);
}
function iterateLeaf(node, offset) {
var array = offset === tailPos ? tail && tail.array : node && node.array;
var from = offset > left ? 0 : left - offset;
var to = right - offset;
if (to > SIZE) {
to = SIZE;
}
return function() {
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
return array && array[idx];
};
}
function iterateNode(node, level, offset) {
var values;
var array = node && node.array;
var from = offset > left ? 0 : (left - offset) >> level;
var to = ((right - offset) >> level) + 1;
if (to > SIZE) {
to = SIZE;
}
return function() {
do {
if (values) {
var value = values();
if (value !== DONE) {
return value;
}
values = null;
}
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
values = iterateNodeOrLeaf(
array && array[idx], level - SHIFT, offset + (idx << level)
);
} while (true);
};
}
}
function makeList(origin, capacity, level, root, tail, ownerID, hash) {
var list = Object.create(ListPrototype);
list.size = capacity - origin;
list._origin = origin;
list._capacity = capacity;
list._level = level;
list._root = root;
list._tail = tail;
list.__ownerID = ownerID;
list.__hash = hash;
list.__altered = false;
return list;
}
var EMPTY_LIST;
function emptyList() {
return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
}
function updateList(list, index, value) {
index = wrapIndex(list, index);
if (index !== index) {
return list;
}
if (index >= list.size || index < 0) {
return list.withMutations(function(list ) {
index < 0 ?
setListBounds(list, index).set(0, value) :
setListBounds(list, 0, index + 1).set(index, value)
});
}
index += list._origin;
var newTail = list._tail;
var newRoot = list._root;
var didAlter = MakeRef(DID_ALTER);
if (index >= getTailOffset(list._capacity)) {
newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
} else {
newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
}
if (!didAlter.value) {
return list;
}
if (list.__ownerID) {
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
}
function updateVNode(node, ownerID, level, index, value, didAlter) {
var idx = (index >>> level) & MASK;
var nodeHas = node && idx < node.array.length;
if (!nodeHas && value === undefined) {
return node;
}
var newNode;
if (level > 0) {
var lowerNode = node && node.array[idx];
var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
if (newLowerNode === lowerNode) {
return node;
}
newNode = editableVNode(node, ownerID);
newNode.array[idx] = newLowerNode;
return newNode;
}
if (nodeHas && node.array[idx] === value) {
return node;
}
SetRef(didAlter);
newNode = editableVNode(node, ownerID);
if (value === undefined && idx === newNode.array.length - 1) {
newNode.array.pop();
} else {
newNode.array[idx] = value;
}
return newNode;
}
function editableVNode(node, ownerID) {
if (ownerID && node && ownerID === node.ownerID) {
return node;
}
return new VNode(node ? node.array.slice() : [], ownerID);
}
function listNodeFor(list, rawIndex) {
if (rawIndex >= getTailOffset(list._capacity)) {
return list._tail;
}
if (rawIndex < 1 << (list._level + SHIFT)) {
var node = list._root;
var level = list._level;
while (node && level > 0) {
node = node.array[(rawIndex >>> level) & MASK];
level -= SHIFT;
}
return node;
}
}
function setListBounds(list, begin, end) {
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
var owner = list.__ownerID || new OwnerID();
var oldOrigin = list._origin;
var oldCapacity = list._capacity;
var newOrigin = oldOrigin + begin;
var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
return list;
}
// If it's going to end after it starts, it's empty.
if (newOrigin >= newCapacity) {
return list.clear();
}
var newLevel = list._level;
var newRoot = list._root;
// New origin might need creating a higher root.
var offsetShift = 0;
while (newOrigin + offsetShift < 0) {
newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
newLevel += SHIFT;
offsetShift += 1 << newLevel;
}
if (offsetShift) {
newOrigin += offsetShift;
oldOrigin += offsetShift;
newCapacity += offsetShift;
oldCapacity += offsetShift;
}
var oldTailOffset = getTailOffset(oldCapacity);
var newTailOffset = getTailOffset(newCapacity);
// New size might need creating a higher root.
while (newTailOffset >= 1 << (newLevel + SHIFT)) {
newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
newLevel += SHIFT;
}
// Locate or create the new tail.
var oldTail = list._tail;
var newTail = newTailOffset < oldTailOffset ?
listNodeFor(list, newCapacity - 1) :
newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
// Merge Tail into tree.
if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
newRoot = editableVNode(newRoot, owner);
var node = newRoot;
for (var level = newLevel; level > SHIFT; level -= SHIFT) {
var idx = (oldTailOffset >>> level) & MASK;
node = node.array[idx] = editableVNode(node.array[idx], owner);
}
node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
}
// If the size has been reduced, there's a chance the tail needs to be trimmed.
if (newCapacity < oldCapacity) {
newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
}
// If the new origin is within the tail, then we do not need a root.
if (newOrigin >= newTailOffset) {
newOrigin -= newTailOffset;
newCapacity -= newTailOffset;
newLevel = SHIFT;
newRoot = null;
newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
// Otherwise, if the root has been trimmed, garbage collect.
} else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
offsetShift = 0;
// Identify the new top root node of the subtree of the old root.
while (newRoot) {
var beginIndex = (newOrigin >>> newLevel) & MASK;
if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
break;
}
if (beginIndex) {
offsetShift += (1 << newLevel) * beginIndex;
}
newLevel -= SHIFT;
newRoot = newRoot.array[beginIndex];
}
// Trim the new sides of the new root.
if (newRoot && newOrigin > oldOrigin) {
newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
}
if (newRoot && newTailOffset < oldTailOffset) {
newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
}
if (offsetShift) {
newOrigin -= offsetShift;
newCapacity -= offsetShift;
}
}
if (list.__ownerID) {
list.size = newCapacity - newOrigin;
list._origin = newOrigin;
list._capacity = newCapacity;
list._level = newLevel;
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
}
function mergeIntoListWith(list, merger, iterables) {
var iters = [];
var maxSize = 0;
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = IndexedIterable(value);
if (iter.size > maxSize) {
maxSize = iter.size;
}
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
if (maxSize > list.size) {
list = list.setSize(maxSize);
}
return mergeIntoCollectionWith(list, merger, iters);
}
function getTailOffset(size) {
return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
}
createClass(OrderedMap, Map);
// @pragma Construction
function OrderedMap(value) {
return value === null || value === undefined ? emptyOrderedMap() :
isOrderedMap(value) ? value :
emptyOrderedMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
OrderedMap.of = function(/*...values*/) {
return this(arguments);
};
OrderedMap.prototype.toString = function() {
return this.__toString('OrderedMap {', '}');
};
// @pragma Access
OrderedMap.prototype.get = function(k, notSetValue) {
var index = this._map.get(k);
return index !== undefined ? this._list.get(index)[1] : notSetValue;
};
// @pragma Modification
OrderedMap.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._map.clear();
this._list.clear();
return this;
}
return emptyOrderedMap();
};
OrderedMap.prototype.set = function(k, v) {
return updateOrderedMap(this, k, v);
};
OrderedMap.prototype.remove = function(k) {
return updateOrderedMap(this, k, NOT_SET);
};
OrderedMap.prototype.wasAltered = function() {
return this._map.wasAltered() || this._list.wasAltered();
};
OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._list.__iterate(
function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
reverse
);
};
OrderedMap.prototype.__iterator = function(type, reverse) {
return this._list.fromEntrySeq().__iterator(type, reverse);
};
OrderedMap.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
var newList = this._list.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
this._list = newList;
return this;
}
return makeOrderedMap(newMap, newList, ownerID, this.__hash);
};
function isOrderedMap(maybeOrderedMap) {
return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
}
OrderedMap.isOrderedMap = isOrderedMap;
OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
function makeOrderedMap(map, list, ownerID, hash) {
var omap = Object.create(OrderedMap.prototype);
omap.size = map ? map.size : 0;
omap._map = map;
omap._list = list;
omap.__ownerID = ownerID;
omap.__hash = hash;
return omap;
}
var EMPTY_ORDERED_MAP;
function emptyOrderedMap() {
return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
}
function updateOrderedMap(omap, k, v) {
var map = omap._map;
var list = omap._list;
var i = map.get(k);
var has = i !== undefined;
var newMap;
var newList;
if (v === NOT_SET) { // removed
if (!has) {
return omap;
}
if (list.size >= SIZE && list.size >= map.size * 2) {
newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
if (omap.__ownerID) {
newMap.__ownerID = newList.__ownerID = omap.__ownerID;
}
} else {
newMap = map.remove(k);
newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
}
} else {
if (has) {
if (v === list.get(i)[1]) {
return omap;
}
newMap = map;
newList = list.set(i, [k, v]);
} else {
newMap = map.set(k, list.size);
newList = list.set(list.size, [k, v]);
}
}
if (omap.__ownerID) {
omap.size = newMap.size;
omap._map = newMap;
omap._list = newList;
omap.__hash = undefined;
return omap;
}
return makeOrderedMap(newMap, newList);
}
createClass(ToKeyedSequence, KeyedSeq);
function ToKeyedSequence(indexed, useKeys) {
this._iter = indexed;
this._useKeys = useKeys;
this.size = indexed.size;
}
ToKeyedSequence.prototype.get = function(key, notSetValue) {
return this._iter.get(key, notSetValue);
};
ToKeyedSequence.prototype.has = function(key) {
return this._iter.has(key);
};
ToKeyedSequence.prototype.valueSeq = function() {
return this._iter.valueSeq();
};
ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
var reversedSequence = reverseFactory(this, true);
if (!this._useKeys) {
reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
}
return reversedSequence;
};
ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
var mappedSequence = mapFactory(this, mapper, context);
if (!this._useKeys) {
mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
}
return mappedSequence;
};
ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var ii;
return this._iter.__iterate(
this._useKeys ?
function(v, k) {return fn(v, k, this$0)} :
((ii = reverse ? resolveSize(this) : 0),
function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
reverse
);
};
ToKeyedSequence.prototype.__iterator = function(type, reverse) {
if (this._useKeys) {
return this._iter.__iterator(type, reverse);
}
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var ii = reverse ? resolveSize(this) : 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, reverse ? --ii : ii++, step.value, step);
});
};
ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
createClass(ToIndexedSequence, IndexedSeq);
function ToIndexedSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToIndexedSequence.prototype.includes = function(value) {
return this._iter.includes(value);
};
ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
};
ToIndexedSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, iterations++, step.value, step)
});
};
createClass(ToSetSequence, SetSeq);
function ToSetSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToSetSequence.prototype.has = function(key) {
return this._iter.includes(key);
};
ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
};
ToSetSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, step.value, step.value, step);
});
};
createClass(FromEntriesSequence, KeyedSeq);
function FromEntriesSequence(entries) {
this._iter = entries;
this.size = entries.size;
}
FromEntriesSequence.prototype.entrySeq = function() {
return this._iter.toSeq();
};
FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(entry ) {
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return fn(
indexedIterable ? entry.get(1) : entry[1],
indexedIterable ? entry.get(0) : entry[0],
this$0
);
}
}, reverse);
};
FromEntriesSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return iteratorValue(
type,
indexedIterable ? entry.get(0) : entry[0],
indexedIterable ? entry.get(1) : entry[1],
step
);
}
}
});
};
ToIndexedSequence.prototype.cacheResult =
ToKeyedSequence.prototype.cacheResult =
ToSetSequence.prototype.cacheResult =
FromEntriesSequence.prototype.cacheResult =
cacheResultThrough;
function flipFactory(iterable) {
var flipSequence = makeSequence(iterable);
flipSequence._iter = iterable;
flipSequence.size = iterable.size;
flipSequence.flip = function() {return iterable};
flipSequence.reverse = function () {
var reversedSequence = iterable.reverse.apply(this); // super.reverse()
reversedSequence.flip = function() {return iterable.reverse()};
return reversedSequence;
};
flipSequence.has = function(key ) {return iterable.includes(key)};
flipSequence.includes = function(key ) {return iterable.has(key)};
flipSequence.cacheResult = cacheResultThrough;
flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
}
flipSequence.__iteratorUncached = function(type, reverse) {
if (type === ITERATE_ENTRIES) {
var iterator = iterable.__iterator(type, reverse);
return new Iterator(function() {
var step = iterator.next();
if (!step.done) {
var k = step.value[0];
step.value[0] = step.value[1];
step.value[1] = k;
}
return step;
});
}
return iterable.__iterator(
type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
reverse
);
}
return flipSequence;
}
function mapFactory(iterable, mapper, context) {
var mappedSequence = makeSequence(iterable);
mappedSequence.size = iterable.size;
mappedSequence.has = function(key ) {return iterable.has(key)};
mappedSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v === NOT_SET ?
notSetValue :
mapper.call(context, v, key, iterable);
};
mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(
function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
reverse
);
}
mappedSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
return new Iterator(function() {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
return iteratorValue(
type,
key,
mapper.call(context, entry[1], key, iterable),
step
);
});
}
return mappedSequence;
}
function reverseFactory(iterable, useKeys) {
var reversedSequence = makeSequence(iterable);
reversedSequence._iter = iterable;
reversedSequence.size = iterable.size;
reversedSequence.reverse = function() {return iterable};
if (iterable.flip) {
reversedSequence.flip = function () {
var flipSequence = flipFactory(iterable);
flipSequence.reverse = function() {return iterable.flip()};
return flipSequence;
};
}
reversedSequence.get = function(key, notSetValue)
{return iterable.get(useKeys ? key : -1 - key, notSetValue)};
reversedSequence.has = function(key )
{return iterable.has(useKeys ? key : -1 - key)};
reversedSequence.includes = function(value ) {return iterable.includes(value)};
reversedSequence.cacheResult = cacheResultThrough;
reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
};
reversedSequence.__iterator =
function(type, reverse) {return iterable.__iterator(type, !reverse)};
return reversedSequence;
}
function filterFactory(iterable, predicate, context, useKeys) {
var filterSequence = makeSequence(iterable);
if (useKeys) {
filterSequence.has = function(key ) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
};
filterSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
v : notSetValue;
};
}
filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
}, reverse);
return iterations;
};
filterSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterations = 0;
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
var value = entry[1];
if (predicate.call(context, value, key, iterable)) {
return iteratorValue(type, useKeys ? key : iterations++, value, step);
}
}
});
}
return filterSequence;
}
function countByFactory(iterable, grouper, context) {
var groups = Map().asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
0,
function(a ) {return a + 1}
);
});
return groups.asImmutable();
}
function groupByFactory(iterable, grouper, context) {
var isKeyedIter = isKeyed(iterable);
var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
);
});
var coerce = iterableClass(iterable);
return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
}
function sliceFactory(iterable, begin, end, useKeys) {
var originalSize = iterable.size;
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
if (end === Infinity) {
end = originalSize;
} else {
end = end | 0;
}
}
if (wholeSlice(begin, end, originalSize)) {
return iterable;
}
var resolvedBegin = resolveBegin(begin, originalSize);
var resolvedEnd = resolveEnd(end, originalSize);
// begin or end will be NaN if they were provided as negative numbers and
// this iterable's size is unknown. In that case, cache first so there is
// a known size and these do not resolve to NaN.
if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
}
// Note: resolvedEnd is undefined when the original sequence's length is
// unknown and this slice did not supply an end and should contain all
// elements after resolvedBegin.
// In that case, resolvedSize will be NaN and sliceSize will remain undefined.
var resolvedSize = resolvedEnd - resolvedBegin;
var sliceSize;
if (resolvedSize === resolvedSize) {
sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
}
var sliceSeq = makeSequence(iterable);
// If iterable.size is undefined, the size of the realized sliceSeq is
// unknown at this point unless the number of items to slice is 0
sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
sliceSeq.get = function (index, notSetValue) {
index = wrapIndex(this, index);
return index >= 0 && index < sliceSize ?
iterable.get(index + resolvedBegin, notSetValue) :
notSetValue;
}
}
sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (sliceSize === 0) {
return 0;
}
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var skipped = 0;
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k) {
if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
iterations !== sliceSize;
}
});
return iterations;
};
sliceSeq.__iteratorUncached = function(type, reverse) {
if (sliceSize !== 0 && reverse) {
return this.cacheResult().__iterator(type, reverse);
}
// Don't bother instantiating parent iterator if taking 0.
var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
var skipped = 0;
var iterations = 0;
return new Iterator(function() {
while (skipped++ < resolvedBegin) {
iterator.next();
}
if (++iterations > sliceSize) {
return iteratorDone();
}
var step = iterator.next();
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations - 1, undefined, step);
} else {
return iteratorValue(type, iterations - 1, step.value[1], step);
}
});
}
return sliceSeq;
}
function takeWhileFactory(iterable, predicate, context) {
var takeSequence = makeSequence(iterable);
takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterations = 0;
iterable.__iterate(function(v, k, c)
{return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
);
return iterations;
};
takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterating = true;
return new Iterator(function() {
if (!iterating) {
return iteratorDone();
}
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var k = entry[0];
var v = entry[1];
if (!predicate.call(context, v, k, this$0)) {
iterating = false;
return iteratorDone();
}
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return takeSequence;
}
function skipWhileFactory(iterable, predicate, context, useKeys) {
var skipSequence = makeSequence(iterable);
skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
});
return iterations;
};
skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var skipping = true;
var iterations = 0;
return new Iterator(function() {
var step, k, v;
do {
step = iterator.next();
if (step.done) {
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations++, undefined, step);
} else {
return iteratorValue(type, iterations++, step.value[1], step);
}
}
var entry = step.value;
k = entry[0];
v = entry[1];
skipping && (skipping = predicate.call(context, v, k, this$0));
} while (skipping);
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return skipSequence;
}
function concatFactory(iterable, values) {
var isKeyedIterable = isKeyed(iterable);
var iters = [iterable].concat(values).map(function(v ) {
if (!isIterable(v)) {
v = isKeyedIterable ?
keyedSeqFromValue(v) :
indexedSeqFromValue(Array.isArray(v) ? v : [v]);
} else if (isKeyedIterable) {
v = KeyedIterable(v);
}
return v;
}).filter(function(v ) {return v.size !== 0});
if (iters.length === 0) {
return iterable;
}
if (iters.length === 1) {
var singleton = iters[0];
if (singleton === iterable ||
isKeyedIterable && isKeyed(singleton) ||
isIndexed(iterable) && isIndexed(singleton)) {
return singleton;
}
}
var concatSeq = new ArraySeq(iters);
if (isKeyedIterable) {
concatSeq = concatSeq.toKeyedSeq();
} else if (!isIndexed(iterable)) {
concatSeq = concatSeq.toSetSeq();
}
concatSeq = concatSeq.flatten(true);
concatSeq.size = iters.reduce(
function(sum, seq) {
if (sum !== undefined) {
var size = seq.size;
if (size !== undefined) {
return sum + size;
}
}
},
0
);
return concatSeq;
}
function flattenFactory(iterable, depth, useKeys) {
var flatSequence = makeSequence(iterable);
flatSequence.__iterateUncached = function(fn, reverse) {
var iterations = 0;
var stopped = false;
function flatDeep(iter, currentDepth) {var this$0 = this;
iter.__iterate(function(v, k) {
if ((!depth || currentDepth < depth) && isIterable(v)) {
flatDeep(v, currentDepth + 1);
} else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
stopped = true;
}
return !stopped;
}, reverse);
}
flatDeep(iterable, 0);
return iterations;
}
flatSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(type, reverse);
var stack = [];
var iterations = 0;
return new Iterator(function() {
while (iterator) {
var step = iterator.next();
if (step.done !== false) {
iterator = stack.pop();
continue;
}
var v = step.value;
if (type === ITERATE_ENTRIES) {
v = v[1];
}
if ((!depth || stack.length < depth) && isIterable(v)) {
stack.push(iterator);
iterator = v.__iterator(type, reverse);
} else {
return useKeys ? step : iteratorValue(type, iterations++, v, step);
}
}
return iteratorDone();
});
}
return flatSequence;
}
function flatMapFactory(iterable, mapper, context) {
var coerce = iterableClass(iterable);
return iterable.toSeq().map(
function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
).flatten(true);
}
function interposeFactory(iterable, separator) {
var interposedSequence = makeSequence(iterable);
interposedSequence.size = iterable.size && iterable.size * 2 -1;
interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k)
{return (!iterations || fn(separator, iterations++, this$0) !== false) &&
fn(v, iterations++, this$0) !== false},
reverse
);
return iterations;
};
interposedSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
var step;
return new Iterator(function() {
if (!step || iterations % 2) {
step = iterator.next();
if (step.done) {
return step;
}
}
return iterations % 2 ?
iteratorValue(type, iterations++, separator) :
iteratorValue(type, iterations++, step.value, step);
});
};
return interposedSequence;
}
function sortFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
var isKeyedIterable = isKeyed(iterable);
var index = 0;
var entries = iterable.toSeq().map(
function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
).toArray();
entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
isKeyedIterable ?
function(v, i) { entries[i].length = 2; } :
function(v, i) { entries[i] = v[1]; }
);
return isKeyedIterable ? KeyedSeq(entries) :
isIndexed(iterable) ? IndexedSeq(entries) :
SetSeq(entries);
}
function maxFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
if (mapper) {
var entry = iterable.toSeq()
.map(function(v, k) {return [v, mapper(v, k, iterable)]})
.reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
return entry && entry[0];
} else {
return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
}
}
function maxCompare(comparator, a, b) {
var comp = comparator(b, a);
// b is considered the new max if the comparator declares them equal, but
// they are not equal and b is in fact a nullish value.
return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
}
function zipWithFactory(keyIter, zipper, iters) {
var zipSequence = makeSequence(keyIter);
zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
// Note: this a generic base implementation of __iterate in terms of
// __iterator which may be more generically useful in the future.
zipSequence.__iterate = function(fn, reverse) {
/* generic:
var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
iterations++;
if (fn(step.value[1], step.value[0], this) === false) {
break;
}
}
return iterations;
*/
// indexed:
var iterator = this.__iterator(ITERATE_VALUES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
return iterations;
};
zipSequence.__iteratorUncached = function(type, reverse) {
var iterators = iters.map(function(i )
{return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
);
var iterations = 0;
var isDone = false;
return new Iterator(function() {
var steps;
if (!isDone) {
steps = iterators.map(function(i ) {return i.next()});
isDone = steps.some(function(s ) {return s.done});
}
if (isDone) {
return iteratorDone();
}
return iteratorValue(
type,
iterations++,
zipper.apply(null, steps.map(function(s ) {return s.value}))
);
});
};
return zipSequence
}
// #pragma Helper Functions
function reify(iter, seq) {
return isSeq(iter) ? seq : iter.constructor(seq);
}
function validateEntry(entry) {
if (entry !== Object(entry)) {
throw new TypeError('Expected [K, V] tuple: ' + entry);
}
}
function resolveSize(iter) {
assertNotInfinite(iter.size);
return ensureSize(iter);
}
function iterableClass(iterable) {
return isKeyed(iterable) ? KeyedIterable :
isIndexed(iterable) ? IndexedIterable :
SetIterable;
}
function makeSequence(iterable) {
return Object.create(
(
isKeyed(iterable) ? KeyedSeq :
isIndexed(iterable) ? IndexedSeq :
SetSeq
).prototype
);
}
function cacheResultThrough() {
if (this._iter.cacheResult) {
this._iter.cacheResult();
this.size = this._iter.size;
return this;
} else {
return Seq.prototype.cacheResult.call(this);
}
}
function defaultComparator(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
function forceIterator(keyPath) {
var iter = getIterator(keyPath);
if (!iter) {
// Array might not be iterable in this environment, so we need a fallback
// to our wrapped type.
if (!isArrayLike(keyPath)) {
throw new TypeError('Expected iterable or array-like: ' + keyPath);
}
iter = getIterator(Iterable(keyPath));
}
return iter;
}
createClass(Record, KeyedCollection);
function Record(defaultValues, name) {
var hasInitialized;
var RecordType = function Record(values) {
if (values instanceof RecordType) {
return values;
}
if (!(this instanceof RecordType)) {
return new RecordType(values);
}
if (!hasInitialized) {
hasInitialized = true;
var keys = Object.keys(defaultValues);
setProps(RecordTypePrototype, keys);
RecordTypePrototype.size = keys.length;
RecordTypePrototype._name = name;
RecordTypePrototype._keys = keys;
RecordTypePrototype._defaultValues = defaultValues;
}
this._map = Map(values);
};
var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
RecordTypePrototype.constructor = RecordType;
return RecordType;
}
Record.prototype.toString = function() {
return this.__toString(recordName(this) + ' {', '}');
};
// @pragma Access
Record.prototype.has = function(k) {
return this._defaultValues.hasOwnProperty(k);
};
Record.prototype.get = function(k, notSetValue) {
if (!this.has(k)) {
return notSetValue;
}
var defaultVal = this._defaultValues[k];
return this._map ? this._map.get(k, defaultVal) : defaultVal;
};
// @pragma Modification
Record.prototype.clear = function() {
if (this.__ownerID) {
this._map && this._map.clear();
return this;
}
var RecordType = this.constructor;
return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
};
Record.prototype.set = function(k, v) {
if (!this.has(k)) {
throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
}
if (this._map && !this._map.has(k)) {
var defaultVal = this._defaultValues[k];
if (v === defaultVal) {
return this;
}
}
var newMap = this._map && this._map.set(k, v);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.remove = function(k) {
if (!this.has(k)) {
return this;
}
var newMap = this._map && this._map.remove(k);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
};
Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
};
Record.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map && this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return makeRecord(this, newMap, ownerID);
};
var RecordPrototype = Record.prototype;
RecordPrototype[DELETE] = RecordPrototype.remove;
RecordPrototype.deleteIn =
RecordPrototype.removeIn = MapPrototype.removeIn;
RecordPrototype.merge = MapPrototype.merge;
RecordPrototype.mergeWith = MapPrototype.mergeWith;
RecordPrototype.mergeIn = MapPrototype.mergeIn;
RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
RecordPrototype.setIn = MapPrototype.setIn;
RecordPrototype.update = MapPrototype.update;
RecordPrototype.updateIn = MapPrototype.updateIn;
RecordPrototype.withMutations = MapPrototype.withMutations;
RecordPrototype.asMutable = MapPrototype.asMutable;
RecordPrototype.asImmutable = MapPrototype.asImmutable;
function makeRecord(likeRecord, map, ownerID) {
var record = Object.create(Object.getPrototypeOf(likeRecord));
record._map = map;
record.__ownerID = ownerID;
return record;
}
function recordName(record) {
return record._name || record.constructor.name || 'Record';
}
function setProps(prototype, names) {
try {
names.forEach(setProp.bind(undefined, prototype));
} catch (error) {
// Object.defineProperty failed. Probably IE8.
}
}
function setProp(prototype, name) {
Object.defineProperty(prototype, name, {
get: function() {
return this.get(name);
},
set: function(value) {
invariant(this.__ownerID, 'Cannot set on an immutable record.');
this.set(name, value);
}
});
}
createClass(Set, SetCollection);
// @pragma Construction
function Set(value) {
return value === null || value === undefined ? emptySet() :
isSet(value) && !isOrdered(value) ? value :
emptySet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
Set.of = function(/*...values*/) {
return this(arguments);
};
Set.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
Set.prototype.toString = function() {
return this.__toString('Set {', '}');
};
// @pragma Access
Set.prototype.has = function(value) {
return this._map.has(value);
};
// @pragma Modification
Set.prototype.add = function(value) {
return updateSet(this, this._map.set(value, true));
};
Set.prototype.remove = function(value) {
return updateSet(this, this._map.remove(value));
};
Set.prototype.clear = function() {
return updateSet(this, this._map.clear());
};
// @pragma Composition
Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return this;
}
if (this.size === 0 && !this.__ownerID && iters.length === 1) {
return this.constructor(iters[0]);
}
return this.withMutations(function(set ) {
for (var ii = 0; ii < iters.length; ii++) {
SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
}
});
};
Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (!iters.every(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (iters.some(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.merge = function() {
return this.union.apply(this, arguments);
};
Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return this.union.apply(this, iters);
};
Set.prototype.sort = function(comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator));
};
Set.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator, mapper));
};
Set.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
};
Set.prototype.__iterator = function(type, reverse) {
return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
};
Set.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return this.__make(newMap, ownerID);
};
function isSet(maybeSet) {
return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
}
Set.isSet = isSet;
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
var SetPrototype = Set.prototype;
SetPrototype[IS_SET_SENTINEL] = true;
SetPrototype[DELETE] = SetPrototype.remove;
SetPrototype.mergeDeep = SetPrototype.merge;
SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
SetPrototype.withMutations = MapPrototype.withMutations;
SetPrototype.asMutable = MapPrototype.asMutable;
SetPrototype.asImmutable = MapPrototype.asImmutable;
SetPrototype.__empty = emptySet;
SetPrototype.__make = makeSet;
function updateSet(set, newMap) {
if (set.__ownerID) {
set.size = newMap.size;
set._map = newMap;
return set;
}
return newMap === set._map ? set :
newMap.size === 0 ? set.__empty() :
set.__make(newMap);
}
function makeSet(map, ownerID) {
var set = Object.create(SetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_SET;
function emptySet() {
return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
}
createClass(OrderedSet, Set);
// @pragma Construction
function OrderedSet(value) {
return value === null || value === undefined ? emptyOrderedSet() :
isOrderedSet(value) ? value :
emptyOrderedSet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
OrderedSet.of = function(/*...values*/) {
return this(arguments);
};
OrderedSet.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
OrderedSet.prototype.toString = function() {
return this.__toString('OrderedSet {', '}');
};
function isOrderedSet(maybeOrderedSet) {
return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
}
OrderedSet.isOrderedSet = isOrderedSet;
var OrderedSetPrototype = OrderedSet.prototype;
OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
OrderedSetPrototype.__empty = emptyOrderedSet;
OrderedSetPrototype.__make = makeOrderedSet;
function makeOrderedSet(map, ownerID) {
var set = Object.create(OrderedSetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_ORDERED_SET;
function emptyOrderedSet() {
return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
}
createClass(Stack, IndexedCollection);
// @pragma Construction
function Stack(value) {
return value === null || value === undefined ? emptyStack() :
isStack(value) ? value :
emptyStack().unshiftAll(value);
}
Stack.of = function(/*...values*/) {
return this(arguments);
};
Stack.prototype.toString = function() {
return this.__toString('Stack [', ']');
};
// @pragma Access
Stack.prototype.get = function(index, notSetValue) {
var head = this._head;
index = wrapIndex(this, index);
while (head && index--) {
head = head.next;
}
return head ? head.value : notSetValue;
};
Stack.prototype.peek = function() {
return this._head && this._head.value;
};
// @pragma Modification
Stack.prototype.push = function(/*...values*/) {
if (arguments.length === 0) {
return this;
}
var newSize = this.size + arguments.length;
var head = this._head;
for (var ii = arguments.length - 1; ii >= 0; ii--) {
head = {
value: arguments[ii],
next: head
};
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pushAll = function(iter) {
iter = IndexedIterable(iter);
if (iter.size === 0) {
return this;
}
assertNotInfinite(iter.size);
var newSize = this.size;
var head = this._head;
iter.reverse().forEach(function(value ) {
newSize++;
head = {
value: value,
next: head
};
});
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pop = function() {
return this.slice(1);
};
Stack.prototype.unshift = function(/*...values*/) {
return this.push.apply(this, arguments);
};
Stack.prototype.unshiftAll = function(iter) {
return this.pushAll(iter);
};
Stack.prototype.shift = function() {
return this.pop.apply(this, arguments);
};
Stack.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._head = undefined;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyStack();
};
Stack.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
var resolvedBegin = resolveBegin(begin, this.size);
var resolvedEnd = resolveEnd(end, this.size);
if (resolvedEnd !== this.size) {
// super.slice(begin, end);
return IndexedCollection.prototype.slice.call(this, begin, end);
}
var newSize = this.size - resolvedBegin;
var head = this._head;
while (resolvedBegin--) {
head = head.next;
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
// @pragma Mutability
Stack.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeStack(this.size, this._head, ownerID, this.__hash);
};
// @pragma Iteration
Stack.prototype.__iterate = function(fn, reverse) {
if (reverse) {
return this.reverse().__iterate(fn);
}
var iterations = 0;
var node = this._head;
while (node) {
if (fn(node.value, iterations++, this) === false) {
break;
}
node = node.next;
}
return iterations;
};
Stack.prototype.__iterator = function(type, reverse) {
if (reverse) {
return this.reverse().__iterator(type);
}
var iterations = 0;
var node = this._head;
return new Iterator(function() {
if (node) {
var value = node.value;
node = node.next;
return iteratorValue(type, iterations++, value);
}
return iteratorDone();
});
};
function isStack(maybeStack) {
return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
}
Stack.isStack = isStack;
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
var StackPrototype = Stack.prototype;
StackPrototype[IS_STACK_SENTINEL] = true;
StackPrototype.withMutations = MapPrototype.withMutations;
StackPrototype.asMutable = MapPrototype.asMutable;
StackPrototype.asImmutable = MapPrototype.asImmutable;
StackPrototype.wasAltered = MapPrototype.wasAltered;
function makeStack(size, head, ownerID, hash) {
var map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}
/**
* Contributes additional methods to a constructor
*/
function mixin(ctor, methods) {
var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
Object.keys(methods).forEach(keyCopier);
Object.getOwnPropertySymbols &&
Object.getOwnPropertySymbols(methods).forEach(keyCopier);
return ctor;
}
Iterable.Iterator = Iterator;
mixin(Iterable, {
// ### Conversion to other types
toArray: function() {
assertNotInfinite(this.size);
var array = new Array(this.size || 0);
this.valueSeq().__iterate(function(v, i) { array[i] = v; });
return array;
},
toIndexedSeq: function() {
return new ToIndexedSequence(this);
},
toJS: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
).__toJS();
},
toJSON: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
).__toJS();
},
toKeyedSeq: function() {
return new ToKeyedSequence(this, true);
},
toMap: function() {
// Use Late Binding here to solve the circular dependency.
return Map(this.toKeyedSeq());
},
toObject: function() {
assertNotInfinite(this.size);
var object = {};
this.__iterate(function(v, k) { object[k] = v; });
return object;
},
toOrderedMap: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedMap(this.toKeyedSeq());
},
toOrderedSet: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
},
toSet: function() {
// Use Late Binding here to solve the circular dependency.
return Set(isKeyed(this) ? this.valueSeq() : this);
},
toSetSeq: function() {
return new ToSetSequence(this);
},
toSeq: function() {
return isIndexed(this) ? this.toIndexedSeq() :
isKeyed(this) ? this.toKeyedSeq() :
this.toSetSeq();
},
toStack: function() {
// Use Late Binding here to solve the circular dependency.
return Stack(isKeyed(this) ? this.valueSeq() : this);
},
toList: function() {
// Use Late Binding here to solve the circular dependency.
return List(isKeyed(this) ? this.valueSeq() : this);
},
// ### Common JavaScript methods and properties
toString: function() {
return '[Iterable]';
},
__toString: function(head, tail) {
if (this.size === 0) {
return head + tail;
}
return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
},
// ### ES6 Collection methods (ES6 Array and Map)
concat: function() {var values = SLICE$0.call(arguments, 0);
return reify(this, concatFactory(this, values));
},
includes: function(searchValue) {
return this.some(function(value ) {return is(value, searchValue)});
},
entries: function() {
return this.__iterator(ITERATE_ENTRIES);
},
every: function(predicate, context) {
assertNotInfinite(this.size);
var returnValue = true;
this.__iterate(function(v, k, c) {
if (!predicate.call(context, v, k, c)) {
returnValue = false;
return false;
}
});
return returnValue;
},
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, true));
},
find: function(predicate, context, notSetValue) {
var entry = this.findEntry(predicate, context);
return entry ? entry[1] : notSetValue;
},
forEach: function(sideEffect, context) {
assertNotInfinite(this.size);
return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
},
join: function(separator) {
assertNotInfinite(this.size);
separator = separator !== undefined ? '' + separator : ',';
var joined = '';
var isFirst = true;
this.__iterate(function(v ) {
isFirst ? (isFirst = false) : (joined += separator);
joined += v !== null && v !== undefined ? v.toString() : '';
});
return joined;
},
keys: function() {
return this.__iterator(ITERATE_KEYS);
},
map: function(mapper, context) {
return reify(this, mapFactory(this, mapper, context));
},
reduce: function(reducer, initialReduction, context) {
assertNotInfinite(this.size);
var reduction;
var useFirst;
if (arguments.length < 2) {
useFirst = true;
} else {
reduction = initialReduction;
}
this.__iterate(function(v, k, c) {
if (useFirst) {
useFirst = false;
reduction = v;
} else {
reduction = reducer.call(context, reduction, v, k, c);
}
});
return reduction;
},
reduceRight: function(reducer, initialReduction, context) {
var reversed = this.toKeyedSeq().reverse();
return reversed.reduce.apply(reversed, arguments);
},
reverse: function() {
return reify(this, reverseFactory(this, true));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, true));
},
some: function(predicate, context) {
return !this.every(not(predicate), context);
},
sort: function(comparator) {
return reify(this, sortFactory(this, comparator));
},
values: function() {
return this.__iterator(ITERATE_VALUES);
},
// ### More sequential methods
butLast: function() {
return this.slice(0, -1);
},
isEmpty: function() {
return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
},
count: function(predicate, context) {
return ensureSize(
predicate ? this.toSeq().filter(predicate, context) : this
);
},
countBy: function(grouper, context) {
return countByFactory(this, grouper, context);
},
equals: function(other) {
return deepEqual(this, other);
},
entrySeq: function() {
var iterable = this;
if (iterable._cache) {
// We cache as an entries array, so we can just return the cache!
return new ArraySeq(iterable._cache);
}
var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
return entriesSequence;
},
filterNot: function(predicate, context) {
return this.filter(not(predicate), context);
},
findEntry: function(predicate, context, notSetValue) {
var found = notSetValue;
this.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
found = [k, v];
return false;
}
});
return found;
},
findKey: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},
findLast: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
},
findLastEntry: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().findEntry(predicate, context, notSetValue);
},
findLastKey: function(predicate, context) {
return this.toKeyedSeq().reverse().findKey(predicate, context);
},
first: function() {
return this.find(returnTrue);
},
flatMap: function(mapper, context) {
return reify(this, flatMapFactory(this, mapper, context));
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, true));
},
fromEntrySeq: function() {
return new FromEntriesSequence(this);
},
get: function(searchKey, notSetValue) {
return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
},
getIn: function(searchKeyPath, notSetValue) {
var nested = this;
// Note: in an ES6 environment, we would prefer:
// for (var key of searchKeyPath) {
var iter = forceIterator(searchKeyPath);
var step;
while (!(step = iter.next()).done) {
var key = step.value;
nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
if (nested === NOT_SET) {
return notSetValue;
}
}
return nested;
},
groupBy: function(grouper, context) {
return groupByFactory(this, grouper, context);
},
has: function(searchKey) {
return this.get(searchKey, NOT_SET) !== NOT_SET;
},
hasIn: function(searchKeyPath) {
return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
},
isSubset: function(iter) {
iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
return this.every(function(value ) {return iter.includes(value)});
},
isSuperset: function(iter) {
iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
return iter.isSubset(this);
},
keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},
keySeq: function() {
return this.toSeq().map(keyMapper).toIndexedSeq();
},
last: function() {
return this.toSeq().reverse().first();
},
lastKeyOf: function(searchValue) {
return this.toKeyedSeq().reverse().keyOf(searchValue);
},
max: function(comparator) {
return maxFactory(this, comparator);
},
maxBy: function(mapper, comparator) {
return maxFactory(this, comparator, mapper);
},
min: function(comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
},
minBy: function(mapper, comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
},
rest: function() {
return this.slice(1);
},
skip: function(amount) {
return this.slice(Math.max(0, amount));
},
skipLast: function(amount) {
return reify(this, this.toSeq().reverse().skip(amount).reverse());
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, true));
},
skipUntil: function(predicate, context) {
return this.skipWhile(not(predicate), context);
},
sortBy: function(mapper, comparator) {
return reify(this, sortFactory(this, comparator, mapper));
},
take: function(amount) {
return this.slice(0, Math.max(0, amount));
},
takeLast: function(amount) {
return reify(this, this.toSeq().reverse().take(amount).reverse());
},
takeWhile: function(predicate, context) {
return reify(this, takeWhileFactory(this, predicate, context));
},
takeUntil: function(predicate, context) {
return this.takeWhile(not(predicate), context);
},
valueSeq: function() {
return this.toIndexedSeq();
},
// ### Hashable Object
hashCode: function() {
return this.__hash || (this.__hash = hashIterable(this));
}
// ### Internal
// abstract __iterate(fn, reverse)
// abstract __iterator(type, reverse)
});
// var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
// var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
// var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
// var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
var IterablePrototype = Iterable.prototype;
IterablePrototype[IS_ITERABLE_SENTINEL] = true;
IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
IterablePrototype.__toJS = IterablePrototype.toArray;
IterablePrototype.__toStringMapper = quoteString;
IterablePrototype.inspect =
IterablePrototype.toSource = function() { return this.toString(); };
IterablePrototype.chain = IterablePrototype.flatMap;
IterablePrototype.contains = IterablePrototype.includes;
mixin(KeyedIterable, {
// ### More sequential methods
flip: function() {
return reify(this, flipFactory(this));
},
mapEntries: function(mapper, context) {var this$0 = this;
var iterations = 0;
return reify(this,
this.toSeq().map(
function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
).fromEntrySeq()
);
},
mapKeys: function(mapper, context) {var this$0 = this;
return reify(this,
this.toSeq().flip().map(
function(k, v) {return mapper.call(context, k, v, this$0)}
).flip()
);
}
});
var KeyedIterablePrototype = KeyedIterable.prototype;
KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
mixin(IndexedIterable, {
// ### Conversion to other types
toKeyedSeq: function() {
return new ToKeyedSequence(this, false);
},
// ### ES6 Collection methods (ES6 Array and Map)
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, false));
},
findIndex: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry ? entry[0] : -1;
},
indexOf: function(searchValue) {
var key = this.keyOf(searchValue);
return key === undefined ? -1 : key;
},
lastIndexOf: function(searchValue) {
var key = this.lastKeyOf(searchValue);
return key === undefined ? -1 : key;
},
reverse: function() {
return reify(this, reverseFactory(this, false));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, false));
},
splice: function(index, removeNum /*, ...values*/) {
var numArgs = arguments.length;
removeNum = Math.max(removeNum | 0, 0);
if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
return this;
}
// If index is negative, it should resolve relative to the size of the
// collection. However size may be expensive to compute if not cached, so
// only call count() if the number is in fact negative.
index = resolveBegin(index, index < 0 ? this.count() : this.size);
var spliced = this.slice(0, index);
return reify(
this,
numArgs === 1 ?
spliced :
spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
);
},
// ### More collection methods
findLastIndex: function(predicate, context) {
var entry = this.findLastEntry(predicate, context);
return entry ? entry[0] : -1;
},
first: function() {
return this.get(0);
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, false));
},
get: function(index, notSetValue) {
index = wrapIndex(this, index);
return (index < 0 || (this.size === Infinity ||
(this.size !== undefined && index > this.size))) ?
notSetValue :
this.find(function(_, key) {return key === index}, undefined, notSetValue);
},
has: function(index) {
index = wrapIndex(this, index);
return index >= 0 && (this.size !== undefined ?
this.size === Infinity || index < this.size :
this.indexOf(index) !== -1
);
},
interpose: function(separator) {
return reify(this, interposeFactory(this, separator));
},
interleave: function(/*...iterables*/) {
var iterables = [this].concat(arrCopy(arguments));
var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
var interleaved = zipped.flatten(true);
if (zipped.size) {
interleaved.size = zipped.size * iterables.length;
}
return reify(this, interleaved);
},
keySeq: function() {
return Range(0, this.size);
},
last: function() {
return this.get(-1);
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, false));
},
zip: function(/*, ...iterables */) {
var iterables = [this].concat(arrCopy(arguments));
return reify(this, zipWithFactory(this, defaultZipper, iterables));
},
zipWith: function(zipper/*, ...iterables */) {
var iterables = arrCopy(arguments);
iterables[0] = this;
return reify(this, zipWithFactory(this, zipper, iterables));
}
});
IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
mixin(SetIterable, {
// ### ES6 Collection methods (ES6 Array and Map)
get: function(value, notSetValue) {
return this.has(value) ? value : notSetValue;
},
includes: function(value) {
return this.has(value);
},
// ### More sequential methods
keySeq: function() {
return this.valueSeq();
}
});
SetIterable.prototype.has = IterablePrototype.includes;
SetIterable.prototype.contains = SetIterable.prototype.includes;
// Mixin subclasses
mixin(KeyedSeq, KeyedIterable.prototype);
mixin(IndexedSeq, IndexedIterable.prototype);
mixin(SetSeq, SetIterable.prototype);
mixin(KeyedCollection, KeyedIterable.prototype);
mixin(IndexedCollection, IndexedIterable.prototype);
mixin(SetCollection, SetIterable.prototype);
// #pragma Helper functions
function keyMapper(v, k) {
return k;
}
function entryMapper(v, k) {
return [k, v];
}
function not(predicate) {
return function() {
return !predicate.apply(this, arguments);
}
}
function neg(predicate) {
return function() {
return -predicate.apply(this, arguments);
}
}
function quoteString(value) {
return typeof value === 'string' ? JSON.stringify(value) : String(value);
}
function defaultZipper() {
return arrCopy(arguments);
}
function defaultNegComparator(a, b) {
return a < b ? 1 : a > b ? -1 : 0;
}
function hashIterable(iterable) {
if (iterable.size === Infinity) {
return 0;
}
var ordered = isOrdered(iterable);
var keyed = isKeyed(iterable);
var h = ordered ? 1 : 0;
var size = iterable.__iterate(
keyed ?
ordered ?
function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
ordered ?
function(v ) { h = 31 * h + hash(v) | 0; } :
function(v ) { h = h + hash(v) | 0; }
);
return murmurHashOfSize(size, h);
}
function murmurHashOfSize(size, h) {
h = imul(h, 0xCC9E2D51);
h = imul(h << 15 | h >>> -15, 0x1B873593);
h = imul(h << 13 | h >>> -13, 5);
h = (h + 0xE6546B64 | 0) ^ size;
h = imul(h ^ h >>> 16, 0x85EBCA6B);
h = imul(h ^ h >>> 13, 0xC2B2AE35);
h = smi(h ^ h >>> 16);
return h;
}
function hashMerge(a, b) {
return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
}
var Immutable = {
Iterable: Iterable,
Seq: Seq,
Collection: Collection,
Map: Map,
OrderedMap: OrderedMap,
List: List,
Stack: Stack,
Set: Set,
OrderedSet: OrderedSet,
Record: Record,
Range: Range,
Repeat: Repeat,
is: is,
fromJS: fromJS
};
return Immutable;
}));
/***/ },
/* 51 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var warning = function() {};
if (true) {
warning = function(condition, format, args) {
var len = arguments.length;
args = new Array(len > 2 ? len - 2 : 0);
for (var key = 2; key < len; key++) {
args[key - 2] = arguments[key];
}
if (format === undefined) {
throw new Error(
'`warning(condition, format, ...args)` requires a warning ' +
'message argument'
);
}
if (format.length < 10 || (/^[s\W]*$/).test(format)) {
throw new Error(
'The warning format should be able to uniquely identify this ' +
'warning. Please, use a more descriptive format than: ' + format
);
}
if (!condition) {
var argIndex = 0;
var message = 'Warning: ' +
format.replace(/%s/g, function() {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch(x) {}
}
};
}
module.exports = warning;
/***/ },
/* 52 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = function (componentName, defaultLocale) {
return function (Component) {
var ComponentWithStatics = Component;
return _a = function (_Component) {
(0, _inherits3["default"])(_a, _Component);
function _a() {
(0, _classCallCheck3["default"])(this, _a);
return (0, _possibleConstructorReturn3["default"])(this, _Component.apply(this, arguments));
}
_a.prototype.getLocale = function getLocale() {
var antLocale = this.context.antLocale;
var localeFromContext = antLocale && antLocale[componentName];
var localeFromProps = this.props.locale || {};
return (0, _extends3["default"])({}, defaultLocale, localeFromContext || {}, localeFromProps);
};
return _a;
}(Component), _a.propTypes = ComponentWithStatics.propTypes, _a.defaultProps = ComponentWithStatics.defaultProps, _a.contextTypes = (0, _extends3["default"])({}, ComponentWithStatics.context || {}, { antLocale: _react.PropTypes.object }), _a;
var _a;
};
};
module.exports = exports['default'];
/***/ },
/* 53 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _rcSelect = __webpack_require__(230);
var _rcSelect2 = _interopRequireDefault(_rcSelect);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _warning = __webpack_require__(20);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var __rest = undefined && undefined.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}return t;
};
// => It is needless to export the declaration of below two inner components.
// export { Option, OptGroup };
var Select = function (_React$Component) {
(0, _inherits3["default"])(Select, _React$Component);
function Select() {
(0, _classCallCheck3["default"])(this, Select);
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
}
Select.prototype.getLocale = function getLocale() {
var antLocale = this.context.antLocale;
if (antLocale && antLocale.Select) {
return antLocale.Select;
}
return {
notFoundContent: 'æ— åŒ¹é…ç»“æžœ'
};
};
Select.prototype.render = function render() {
var _classNames;
var _a = this.props,
prefixCls = _a.prefixCls,
_a$className = _a.className,
className = _a$className === undefined ? '' : _a$className,
size = _a.size,
mode = _a.mode,
multiple = _a.multiple,
tags = _a.tags,
combobox = _a.combobox,
restProps = __rest(_a, ["prefixCls", "className", "size", "mode", "multiple", "tags", "combobox"]);
(0, _warning2["default"])(!multiple && !tags && !combobox, '`Select[multiple|tags|combobox]` is deprecated, please use `Select[mode]` instead.');
var cls = (0, _classnames2["default"])((_classNames = {}, (0, _defineProperty3["default"])(_classNames, prefixCls + '-lg', size === 'large'), (0, _defineProperty3["default"])(_classNames, prefixCls + '-sm', size === 'small'), _classNames), className);
var locale = this.getLocale();
var _props = this.props,
_props$notFoundConten = _props.notFoundContent,
notFoundContent = _props$notFoundConten === undefined ? locale.notFoundContent : _props$notFoundConten,
optionLabelProp = _props.optionLabelProp;
var isCombobox = mode === 'combobox' || combobox;
if (isCombobox) {
notFoundContent = null;
// children 带 dom ç»“æž„æ—¶ï¼Œæ— æ³•å¡«å…¥è¾“å…¥æ¡†
optionLabelProp = optionLabelProp || 'value';
}
var modeConfig = {
multiple: mode === 'multiple' || multiple,
tags: mode === 'tags' || tags,
combobox: isCombobox
};
return _react2["default"].createElement(_rcSelect2["default"], (0, _extends3["default"])({}, restProps, modeConfig, { prefixCls: prefixCls, className: cls, optionLabelProp: optionLabelProp || 'children', notFoundContent: notFoundContent }));
};
return Select;
}(_react2["default"].Component);
exports["default"] = Select;
Select.Option = _rcSelect.Option;
Select.OptGroup = _rcSelect.OptGroup;
Select.defaultProps = {
prefixCls: 'ant-select',
showSearch: false,
transitionName: 'slide-up',
choiceTransitionName: 'zoom'
};
Select.propTypes = {
prefixCls: _react.PropTypes.string,
className: _react.PropTypes.string,
size: _react.PropTypes.oneOf(['default', 'large', 'small']),
combobox: _react.PropTypes.bool,
notFoundContent: _react.PropTypes.any,
showSearch: _react.PropTypes.bool,
optionLabelProp: _react.PropTypes.string,
transitionName: _react.PropTypes.string,
choiceTransitionName: _react.PropTypes.string
};
Select.contextTypes = {
antLocale: _react2["default"].PropTypes.object
};
module.exports = exports['default'];
/***/ },
/* 54 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _rcTooltip = __webpack_require__(649);
var _rcTooltip2 = _interopRequireDefault(_rcTooltip);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _placements = __webpack_require__(348);
var _placements2 = _interopRequireDefault(_placements);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var splitObject = function splitObject(obj, keys) {
var picked = {};
var omited = (0, _extends3["default"])({}, obj);
keys.forEach(function (key) {
if (obj && key in obj) {
picked[key] = obj[key];
delete omited[key];
}
});
return { picked: picked, omited: omited };
};
var Tooltip = function (_React$Component) {
(0, _inherits3["default"])(Tooltip, _React$Component);
function Tooltip(props) {
(0, _classCallCheck3["default"])(this, Tooltip);
var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.call(this, props));
_this.onVisibleChange = function (visible) {
var onVisibleChange = _this.props.onVisibleChange;
if (!('visible' in _this.props)) {
_this.setState({ visible: _this.isNoTitle() ? false : visible });
}
if (onVisibleChange && !_this.isNoTitle()) {
onVisibleChange(visible);
}
};
// 动态设置动画点
_this.onPopupAlign = function (domNode, align) {
var placements = _this.getPlacements();
// 当前返回的位置
var placement = Object.keys(placements).filter(function (key) {
return placements[key].points[0] === align.points[0] && placements[key].points[1] === align.points[1];
})[0];
if (!placement) {
return;
}
// æ ¹æ®å½“å‰åæ ‡è®¾ç½®åŠ¨ç”»ç‚¹
var rect = domNode.getBoundingClientRect();
var transformOrigin = {
top: '50%',
left: '50%'
};
if (placement.indexOf('top') >= 0 || placement.indexOf('Bottom') >= 0) {
transformOrigin.top = rect.height - align.offset[1] + 'px';
} else if (placement.indexOf('Top') >= 0 || placement.indexOf('bottom') >= 0) {
transformOrigin.top = -align.offset[1] + 'px';
}
if (placement.indexOf('left') >= 0 || placement.indexOf('Right') >= 0) {
transformOrigin.left = rect.width - align.offset[0] + 'px';
} else if (placement.indexOf('right') >= 0 || placement.indexOf('Left') >= 0) {
transformOrigin.left = -align.offset[0] + 'px';
}
domNode.style.transformOrigin = transformOrigin.left + ' ' + transformOrigin.top;
};
_this.state = {
visible: !!props.visible
};
return _this;
}
Tooltip.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if ('visible' in nextProps) {
this.setState({ visible: nextProps.visible });
}
};
Tooltip.prototype.getPopupDomNode = function getPopupDomNode() {
return this.refs.tooltip.getPopupDomNode();
};
Tooltip.prototype.getPlacements = function getPlacements() {
var _props = this.props,
builtinPlacements = _props.builtinPlacements,
arrowPointAtCenter = _props.arrowPointAtCenter;
return builtinPlacements || (0, _placements2["default"])({
arrowPointAtCenter: arrowPointAtCenter,
verticalArrowShift: 8
});
};
Tooltip.prototype.isHoverTrigger = function isHoverTrigger() {
var trigger = this.props.trigger;
if (!trigger || trigger === 'hover') {
return true;
}
if (Array.isArray(trigger)) {
return trigger.indexOf('hover') >= 0;
}
return false;
};
// Fix Tooltip won't hide at disabled button
// mouse events don't trigger at disabled button in Chrome
// https://github.com/react-component/tooltip/issues/18
Tooltip.prototype.getDisabledCompatibleChildren = function getDisabledCompatibleChildren(element) {
if ((element.type.__ANT_BUTTON || element.type === 'button') && element.props.disabled && this.isHoverTrigger()) {
// Pick some layout related style properties up to span
// Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254
var _splitObject = splitObject(element.props.style, ['position', 'left', 'right', 'top', 'bottom', 'float', 'display', 'zIndex']),
picked = _splitObject.picked,
omited = _splitObject.omited;
var spanStyle = (0, _extends3["default"])({ display: 'inline-block' }, picked, { cursor: 'not-allowed' });
var buttonStyle = (0, _extends3["default"])({}, omited, { pointerEvents: 'none' });
var child = (0, _react.cloneElement)(element, {
style: buttonStyle,
className: null
});
return _react2["default"].createElement(
'span',
{ style: spanStyle, className: element.props.className },
child
);
}
return element;
};
Tooltip.prototype.isNoTitle = function isNoTitle() {
var _props2 = this.props,
title = _props2.title,
overlay = _props2.overlay;
return !title && !overlay; // overlay for old version compatibility
};
Tooltip.prototype.render = function render() {
var props = this.props,
state = this.state;
var prefixCls = props.prefixCls,
title = props.title,
overlay = props.overlay,
openClassName = props.openClassName,
getPopupContainer = props.getPopupContainer,
getTooltipContainer = props.getTooltipContainer;
var children = props.children;
var visible = state.visible;
// Hide tooltip when there is no title
if (!('visible' in props) && this.isNoTitle()) {
visible = false;
}
var child = this.getDisabledCompatibleChildren(_react2["default"].isValidElement(children) ? children : _react2["default"].createElement(
'span',
null,
children
));
var childProps = child.props;
var childCls = (0, _classnames2["default"])(childProps.className, (0, _defineProperty3["default"])({}, openClassName || prefixCls + '-open', true));
return _react2["default"].createElement(
_rcTooltip2["default"],
(0, _extends3["default"])({}, this.props, { getTooltipContainer: getPopupContainer || getTooltipContainer, ref: 'tooltip', builtinPlacements: this.getPlacements(), overlay: overlay || title, visible: visible, onVisibleChange: this.onVisibleChange, onPopupAlign: this.onPopupAlign }),
visible ? (0, _react.cloneElement)(child, { className: childCls }) : child
);
};
return Tooltip;
}(_react2["default"].Component);
exports["default"] = Tooltip;
Tooltip.defaultProps = {
prefixCls: 'ant-tooltip',
placement: 'top',
transitionName: 'zoom-big-fast',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
arrowPointAtCenter: false
};
module.exports = exports['default'];
/***/ },
/* 55 */
/***/ function(module, exports) {
"use strict";
exports.__esModule = true;
exports["default"] = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
/***/ },
/* 56 */
/***/ function(module, exports) {
module.exports = function(exec){
try {
return !!exec();
} catch(e){
return true;
}
};
/***/ },
/* 57 */
/***/ function(module, exports) {
module.exports = function(it){
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ },
/* 58 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
var $keys = __webpack_require__(168)
, enumBugKeys = __webpack_require__(95);
module.exports = Object.keys || function keys(O){
return $keys(O, enumBugKeys);
};
/***/ },
/* 59 */
/***/ function(module, exports) {
module.exports = function(bitmap, value){
return {
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
};
};
/***/ },
/* 60 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _propertyUtils = __webpack_require__(423);
var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
var getComputedStyleX = void 0;
function force(x, y) {
return x + y;
}
function css(el, name, v) {
var value = v;
if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
for (var i in name) {
if (name.hasOwnProperty(i)) {
css(el, i, name[i]);
}
}
return undefined;
}
if (typeof value !== 'undefined') {
if (typeof value === 'number') {
value = value + 'px';
}
el.style[name] = value;
return undefined;
}
return getComputedStyleX(el, name);
}
function getClientPosition(elem) {
var box = void 0;
var x = void 0;
var y = void 0;
var doc = elem.ownerDocument;
var body = doc.body;
var docElem = doc && doc.documentElement;
// æ ¹æ® GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect æ–¹æ³•ï¼Œä¸ç”¨å†è€ƒè™‘ä¼ ç»Ÿçš„å®žçŽ°æ–¹å¼
box = elem.getBoundingClientRect();
// 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
// ä½†æµ‹è¯•å‘çŽ°ï¼Œè¿™æ ·åè€Œä¼šå¯¼è‡´å½“ html å’Œ body 有边距/è¾¹æ¡†æ ·å¼æ—¶ï¼ŒèŽ·å–çš„å€¼ä¸æ­£ç¡®
// 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
x = box.left;
y = box.top;
// In IE, most of the time, 2 extra pixels are added to the top and left
// due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
// IE6 standards mode, this border can be overridden by setting the
// document element's border to zero -- thus, we cannot rely on the
// offset always being 2 pixels.
// In quirks mode, the offset can be determined by querying the body's
// clientLeft/clientTop, but in standards mode, it is found by querying
// the document element's clientLeft/clientTop. Since we already called
// getClientBoundingRect we have already forced a reflow, so it is not
// too expensive just to query them all.
// ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
// çª—å£è¾¹æ¡†æ ‡å‡†æ˜¯è®¾ documentElement ,quirks 时设置 body
// 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
// 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
// æ ‡å‡† ie 下 docElem.clientTop 就是 border-top
// ie7 html 即窗口边框改变不了。永远为 2
// ä½†æ ‡å‡† firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
x -= docElem.clientLeft || body.clientLeft || 0;
y -= docElem.clientTop || body.clientTop || 0;
return {
left: x,
top: y
};
}
function getScroll(w, top) {
var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
var method = 'scroll' + (top ? 'Top' : 'Left');
if (typeof ret !== 'number') {
var d = w.document;
// ie6,7,8 standard mode
ret = d.documentElement[method];
if (typeof ret !== 'number') {
// quirks mode
ret = d.body[method];
}
}
return ret;
}
function getScrollLeft(w) {
return getScroll(w);
}
function getScrollTop(w) {
return getScroll(w, true);
}
function getOffset(el) {
var pos = getClientPosition(el);
var doc = el.ownerDocument;
var w = doc.defaultView || doc.parentWindow;
pos.left += getScrollLeft(w);
pos.top += getScrollTop(w);
return pos;
}
function _getComputedStyle(elem, name, cs) {
var computedStyle = cs;
var val = '';
var d = elem.ownerDocument;
computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null);
// https://github.com/kissyteam/kissy/issues/61
if (computedStyle) {
val = computedStyle.getPropertyValue(name) || computedStyle[name];
}
return val;
}
var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');
var RE_POS = /^(top|right|bottom|left)$/;
var CURRENT_STYLE = 'currentStyle';
var RUNTIME_STYLE = 'runtimeStyle';
var LEFT = 'left';
var PX = 'px';
function _getComputedStyleIE(elem, name) {
// currentStyle maybe null
// http://msdn.microsoft.com/en-us/library/ms535231.aspx
var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];
// 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
// 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
// 在 ie 下不对,需要直接用 offset 方式
// borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
// From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
// exclude left right for relativity
if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
// Remember the original values
var style = elem.style;
var left = style[LEFT];
var rsLeft = elem[RUNTIME_STYLE][LEFT];
// prevent flashing of content
elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];
// Put in the new values to get a computed value out
style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
ret = style.pixelLeft + PX;
// Revert the changed values
style[LEFT] = left;
elem[RUNTIME_STYLE][LEFT] = rsLeft;
}
return ret === '' ? 'auto' : ret;
}
if (typeof window !== 'undefined') {
getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
}
function getOffsetDirection(dir, option) {
if (dir === 'left') {
return option.useCssRight ? 'right' : dir;
}
return option.useCssBottom ? 'bottom' : dir;
}
function oppositeOffsetDirection(dir) {
if (dir === 'left') {
return 'right';
} else if (dir === 'right') {
return 'left';
} else if (dir === 'top') {
return 'bottom';
} else if (dir === 'bottom') {
return 'top';
}
}
// 设置 elem 相对 elem.ownerDocument çš„åæ ‡
function setLeftTop(elem, offset, option) {
// set position first, in-case top/left are set even on static elem
if (css(elem, 'position') === 'static') {
elem.style.position = 'relative';
}
var presetH = -999;
var presetV = -999;
var horizontalProperty = getOffsetDirection('left', option);
var verticalProperty = getOffsetDirection('top', option);
var oppositeHorizontalProperty = oppositeOffsetDirection(horizontalProperty);
var oppositeVerticalProperty = oppositeOffsetDirection(verticalProperty);
if (horizontalProperty !== 'left') {
presetH = 999;
}
if (verticalProperty !== 'top') {
presetV = 999;
}
var originalTransition = '';
var originalOffset = getOffset(elem);
if ('left' in offset || 'top' in offset) {
originalTransition = (0, _propertyUtils.getTransitionProperty)(elem) || '';
(0, _propertyUtils.setTransitionProperty)(elem, 'none');
}
if ('left' in offset) {
elem.style[oppositeHorizontalProperty] = '';
elem.style[horizontalProperty] = presetH + 'px';
}
if ('top' in offset) {
elem.style[oppositeVerticalProperty] = '';
elem.style[verticalProperty] = presetV + 'px';
}
var old = getOffset(elem);
var originalStyle = {};
for (var key in offset) {
if (offset.hasOwnProperty(key)) {
var dir = getOffsetDirection(key, option);
var preset = key === 'left' ? presetH : presetV;
var off = originalOffset[key] - old[key];
if (dir === key) {
originalStyle[dir] = preset + off;
} else {
originalStyle[dir] = preset - off;
}
}
}
css(elem, originalStyle);
// force relayout
force(elem.offsetTop, elem.offsetLeft);
if ('left' in offset || 'top' in offset) {
(0, _propertyUtils.setTransitionProperty)(elem, originalTransition);
}
var ret = {};
for (var _key in offset) {
if (offset.hasOwnProperty(_key)) {
var _dir = getOffsetDirection(_key, option);
var _off = offset[_key] - originalOffset[_key];
if (_key === _dir) {
ret[_dir] = originalStyle[_dir] + _off;
} else {
ret[_dir] = originalStyle[_dir] - _off;
}
}
}
css(elem, ret);
}
function setTransform(elem, offset) {
var originalOffset = getOffset(elem);
var originalXY = (0, _propertyUtils.getTransformXY)(elem);
var resultXY = { x: originalXY.x, y: originalXY.y };
if ('left' in offset) {
resultXY.x = originalXY.x + offset.left - originalOffset.left;
}
if ('top' in offset) {
resultXY.y = originalXY.y + offset.top - originalOffset.top;
}
(0, _propertyUtils.setTransformXY)(elem, resultXY);
}
function setOffset(elem, offset, option) {
if (option.useCssRight || option.useCssBottom) {
setLeftTop(elem, offset, option);
} else if (option.useCssTransform && (0, _propertyUtils.getTransformName)() in document.body.style) {
setTransform(elem, offset, option);
} else {
setLeftTop(elem, offset, option);
}
}
function each(arr, fn) {
for (var i = 0; i < arr.length; i++) {
fn(arr[i]);
}
}
function isBorderBoxFn(elem) {
return getComputedStyleX(elem, 'boxSizing') === 'border-box';
}
var BOX_MODELS = ['margin', 'border', 'padding'];
var CONTENT_INDEX = -1;
var PADDING_INDEX = 2;
var BORDER_INDEX = 1;
var MARGIN_INDEX = 0;
function swap(elem, options, callback) {
var old = {};
var style = elem.style;
var name = void 0;
// Remember the old values, and insert the new ones
for (name in options) {
if (options.hasOwnProperty(name)) {
old[name] = style[name];
style[name] = options[name];
}
}
callback.call(elem);
// Revert the old values
for (name in options) {
if (options.hasOwnProperty(name)) {
style[name] = old[name];
}
}
}
function getPBMWidth(elem, props, which) {
var value = 0;
var prop = void 0;
var j = void 0;
var i = void 0;
for (j = 0; j < props.length; j++) {
prop = props[j];
if (prop) {
for (i = 0; i < which.length; i++) {
var cssProp = void 0;
if (prop === 'border') {
cssProp = '' + prop + which[i] + 'Width';
} else {
cssProp = prop + which[i];
}
value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
}
}
}
return value;
}
/**
* A crude way of determining if an object is a window
* @member util
*/
function isWindow(obj) {
// must use == for ie8
/* eslint eqeqeq:0 */
return obj !== null && obj !== undefined && obj == obj.window;
}
var domUtils = {};
each(['Width', 'Height'], function (name) {
domUtils['doc' + name] = function (refWin) {
var d = refWin.document;
return Math.max(
// firefox chrome documentElement.scrollHeight< body.scrollHeight
// ie standard mode : documentElement.scrollHeight> body.scrollHeight
d.documentElement['scroll' + name],
// quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
d.body['scroll' + name], domUtils['viewport' + name](d));
};
domUtils['viewport' + name] = function (win) {
// pc browser includes scrollbar in window.innerWidth
var prop = 'client' + name;
var doc = win.document;
var body = doc.body;
var documentElement = doc.documentElement;
var documentElementProp = documentElement[prop];
// æ ‡å‡†æ¨¡å¼å– documentElement
// backcompat 取 body
return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
};
});
/*
å¾—åˆ°å…ƒç´ çš„å¤§å°ä¿¡æ¯
@param elem
@param name
@param {String} [extra] 'padding' : (css width) + padding
'border' : (css width) + padding + border
'margin' : (css width) + padding + border + margin
*/
function getWH(elem, name, ex) {
var extra = ex;
if (isWindow(elem)) {
return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
} else if (elem.nodeType === 9) {
return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
}
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;
var computedStyle = getComputedStyleX(elem);
var isBorderBox = isBorderBoxFn(elem, computedStyle);
var cssBoxValue = 0;
if (borderBoxValue === null || borderBoxValue === undefined || borderBoxValue <= 0) {
borderBoxValue = undefined;
// Fall back to computed then un computed css if necessary
cssBoxValue = getComputedStyleX(elem, name);
if (cssBoxValue === null || cssBoxValue === undefined || Number(cssBoxValue) < 0) {
cssBoxValue = elem.style[name] || 0;
}
// Normalize '', auto, and prepare for extra
cssBoxValue = parseFloat(cssBoxValue) || 0;
}
if (extra === undefined) {
extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
}
var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
var val = borderBoxValue || cssBoxValue;
if (extra === CONTENT_INDEX) {
if (borderBoxValueOrIsBorderBox) {
return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle);
}
return cssBoxValue;
} else if (borderBoxValueOrIsBorderBox) {
if (extra === BORDER_INDEX) {
return val;
}
return val + (extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle));
}
return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle);
}
var cssShow = {
position: 'absolute',
visibility: 'hidden',
display: 'block'
};
// fix #119 : https://github.com/kissyteam/kissy/issues/119
function getWHIgnoreDisplay() {
for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) {
args[_key2] = arguments[_key2];
}
var val = void 0;
var elem = args[0];
// in case elem is window
// elem.offsetWidth === undefined
if (elem.offsetWidth !== 0) {
val = getWH.apply(undefined, args);
} else {
swap(elem, cssShow, function () {
val = getWH.apply(undefined, args);
});
}
return val;
}
each(['width', 'height'], function (name) {
var first = name.charAt(0).toUpperCase() + name.slice(1);
domUtils['outer' + first] = function (el, includeMargin) {
return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
};
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
domUtils[name] = function (elem, v) {
var val = v;
if (val !== undefined) {
if (elem) {
var computedStyle = getComputedStyleX(elem);
var isBorderBox = isBorderBoxFn(elem);
if (isBorderBox) {
val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);
}
return css(elem, name, val);
}
return undefined;
}
return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
};
});
function mix(to, from) {
for (var i in from) {
if (from.hasOwnProperty(i)) {
to[i] = from[i];
}
}
return to;
}
var utils = {
getWindow: function getWindow(node) {
if (node && node.document && node.setTimeout) {
return node;
}
var doc = node.ownerDocument || node;
return doc.defaultView || doc.parentWindow;
},
offset: function offset(el, value, option) {
if (typeof value !== 'undefined') {
setOffset(el, value, option || {});
} else {
return getOffset(el);
}
},
isWindow: isWindow,
each: each,
css: css,
clone: function clone(obj) {
var i = void 0;
var ret = {};
for (i in obj) {
if (obj.hasOwnProperty(i)) {
ret[i] = obj[i];
}
}
var overflow = obj.overflow;
if (overflow) {
for (i in obj) {
if (obj.hasOwnProperty(i)) {
ret.overflow[i] = obj.overflow[i];
}
}
}
return ret;
},
mix: mix,
getWindowScrollLeft: function getWindowScrollLeft(w) {
return getScrollLeft(w);
},
getWindowScrollTop: function getWindowScrollTop(w) {
return getScrollTop(w);
},
merge: function merge() {
var ret = {};
for (var _len2 = arguments.length, args = Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {
args[_key3] = arguments[_key3];
}
for (var i = 0; i < args.length; i++) {
utils.mix(ret, args[i]);
}
return ret;
},
viewportWidth: 0,
viewportHeight: 0
};
mix(utils, domUtils);
exports["default"] = utils;
module.exports = exports['default'];
/***/ },
/* 61 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule BlockMapBuilder
*
*/
'use strict';
var Immutable = __webpack_require__(11);
var OrderedMap = Immutable.OrderedMap;
var BlockMapBuilder = {
createFromArray: function createFromArray(blocks) {
return OrderedMap(blocks.map(function (block) {
return [block.getKey(), block];
}));
}
};
module.exports = BlockMapBuilder;
/***/ },
/* 62 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftOffsetKey
*
*/
'use strict';
var KEY_DELIMITER = '-';
var DraftOffsetKey = {
encode: function encode(blockKey, decoratorKey, leafKey) {
return blockKey + KEY_DELIMITER + decoratorKey + KEY_DELIMITER + leafKey;
},
decode: function decode(offsetKey) {
var _offsetKey$split = offsetKey.split(KEY_DELIMITER);
var blockKey = _offsetKey$split[0];
var decoratorKey = _offsetKey$split[1];
var leafKey = _offsetKey$split[2];
return {
blockKey: blockKey,
decoratorKey: parseInt(decoratorKey, 10),
leafKey: parseInt(leafKey, 10)
};
}
};
module.exports = DraftOffsetKey;
/***/ },
/* 63 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule removeTextWithStrategy
*
*/
'use strict';
var DraftModifier = __webpack_require__(19);
/**
* For a collapsed selection state, remove text based on the specified strategy.
* If the selection state is not collapsed, remove the entire selected range.
*/
function removeTextWithStrategy(editorState, strategy, direction) {
var selection = editorState.getSelection();
var content = editorState.getCurrentContent();
var target = selection;
if (selection.isCollapsed()) {
if (direction === 'forward') {
if (editorState.isSelectionAtEndOfContent()) {
return content;
}
} else if (editorState.isSelectionAtStartOfContent()) {
return content;
}
target = strategy(editorState);
if (target === selection) {
return content;
}
}
return DraftModifier.removeRange(content, target, direction);
}
module.exports = removeTextWithStrategy;
/***/ },
/* 64 */
/***/ function(module, exports) {
'use strict';
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
/**
* This function is used to mark string literals representing CSS class names
* so that they can be transformed statically. This allows for modularization
* and minification of CSS class names.
*
* In static_upstream, this function is actually implemented, but it should
* eventually be replaced with something more descriptive, and the transform
* that is used in the main stack should be ported for use elsewhere.
*
* @param string|object className to modularize, or an object of key/values.
* In the object case, the values are conditions that
* determine if the className keys should be included.
* @param [string ...] Variable list of classNames in the string case.
* @return string Renderable space-separated CSS className.
*/
function cx(classNames) {
if (typeof classNames == 'object') {
return Object.keys(classNames).filter(function (className) {
return classNames[className];
}).map(replace).join(' ');
}
return Array.prototype.map.call(arguments, replace).join(' ');
}
function replace(str) {
return str.replace(/\//g, '-');
}
module.exports = cx;
/***/ },
/* 65 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @ignore
* some key-codes definition and utils from closure-library
* @author [email protected]
*/
var KeyCode = {
/**
* MAC_ENTER
*/
MAC_ENTER: 3,
/**
* BACKSPACE
*/
BACKSPACE: 8,
/**
* TAB
*/
TAB: 9,
/**
* NUMLOCK on FF/Safari Mac
*/
NUM_CENTER: 12, // NUMLOCK on FF/Safari Mac
/**
* ENTER
*/
ENTER: 13,
/**
* SHIFT
*/
SHIFT: 16,
/**
* CTRL
*/
CTRL: 17,
/**
* ALT
*/
ALT: 18,
/**
* PAUSE
*/
PAUSE: 19,
/**
* CAPS_LOCK
*/
CAPS_LOCK: 20,
/**
* ESC
*/
ESC: 27,
/**
* SPACE
*/
SPACE: 32,
/**
* PAGE_UP
*/
PAGE_UP: 33, // also NUM_NORTH_EAST
/**
* PAGE_DOWN
*/
PAGE_DOWN: 34, // also NUM_SOUTH_EAST
/**
* END
*/
END: 35, // also NUM_SOUTH_WEST
/**
* HOME
*/
HOME: 36, // also NUM_NORTH_WEST
/**
* LEFT
*/
LEFT: 37, // also NUM_WEST
/**
* UP
*/
UP: 38, // also NUM_NORTH
/**
* RIGHT
*/
RIGHT: 39, // also NUM_EAST
/**
* DOWN
*/
DOWN: 40, // also NUM_SOUTH
/**
* PRINT_SCREEN
*/
PRINT_SCREEN: 44,
/**
* INSERT
*/
INSERT: 45, // also NUM_INSERT
/**
* DELETE
*/
DELETE: 46, // also NUM_DELETE
/**
* ZERO
*/
ZERO: 48,
/**
* ONE
*/
ONE: 49,
/**
* TWO
*/
TWO: 50,
/**
* THREE
*/
THREE: 51,
/**
* FOUR
*/
FOUR: 52,
/**
* FIVE
*/
FIVE: 53,
/**
* SIX
*/
SIX: 54,
/**
* SEVEN
*/
SEVEN: 55,
/**
* EIGHT
*/
EIGHT: 56,
/**
* NINE
*/
NINE: 57,
/**
* QUESTION_MARK
*/
QUESTION_MARK: 63, // needs localization
/**
* A
*/
A: 65,
/**
* B
*/
B: 66,
/**
* C
*/
C: 67,
/**
* D
*/
D: 68,
/**
* E
*/
E: 69,
/**
* F
*/
F: 70,
/**
* G
*/
G: 71,
/**
* H
*/
H: 72,
/**
* I
*/
I: 73,
/**
* J
*/
J: 74,
/**
* K
*/
K: 75,
/**
* L
*/
L: 76,
/**
* M
*/
M: 77,
/**
* N
*/
N: 78,
/**
* O
*/
O: 79,
/**
* P
*/
P: 80,
/**
* Q
*/
Q: 81,
/**
* R
*/
R: 82,
/**
* S
*/
S: 83,
/**
* T
*/
T: 84,
/**
* U
*/
U: 85,
/**
* V
*/
V: 86,
/**
* W
*/
W: 87,
/**
* X
*/
X: 88,
/**
* Y
*/
Y: 89,
/**
* Z
*/
Z: 90,
/**
* META
*/
META: 91, // WIN_KEY_LEFT
/**
* WIN_KEY_RIGHT
*/
WIN_KEY_RIGHT: 92,
/**
* CONTEXT_MENU
*/
CONTEXT_MENU: 93,
/**
* NUM_ZERO
*/
NUM_ZERO: 96,
/**
* NUM_ONE
*/
NUM_ONE: 97,
/**
* NUM_TWO
*/
NUM_TWO: 98,
/**
* NUM_THREE
*/
NUM_THREE: 99,
/**
* NUM_FOUR
*/
NUM_FOUR: 100,
/**
* NUM_FIVE
*/
NUM_FIVE: 101,
/**
* NUM_SIX
*/
NUM_SIX: 102,
/**
* NUM_SEVEN
*/
NUM_SEVEN: 103,
/**
* NUM_EIGHT
*/
NUM_EIGHT: 104,
/**
* NUM_NINE
*/
NUM_NINE: 105,
/**
* NUM_MULTIPLY
*/
NUM_MULTIPLY: 106,
/**
* NUM_PLUS
*/
NUM_PLUS: 107,
/**
* NUM_MINUS
*/
NUM_MINUS: 109,
/**
* NUM_PERIOD
*/
NUM_PERIOD: 110,
/**
* NUM_DIVISION
*/
NUM_DIVISION: 111,
/**
* F1
*/
F1: 112,
/**
* F2
*/
F2: 113,
/**
* F3
*/
F3: 114,
/**
* F4
*/
F4: 115,
/**
* F5
*/
F5: 116,
/**
* F6
*/
F6: 117,
/**
* F7
*/
F7: 118,
/**
* F8
*/
F8: 119,
/**
* F9
*/
F9: 120,
/**
* F10
*/
F10: 121,
/**
* F11
*/
F11: 122,
/**
* F12
*/
F12: 123,
/**
* NUMLOCK
*/
NUMLOCK: 144,
/**
* SEMICOLON
*/
SEMICOLON: 186, // needs localization
/**
* DASH
*/
DASH: 189, // needs localization
/**
* EQUALS
*/
EQUALS: 187, // needs localization
/**
* COMMA
*/
COMMA: 188, // needs localization
/**
* PERIOD
*/
PERIOD: 190, // needs localization
/**
* SLASH
*/
SLASH: 191, // needs localization
/**
* APOSTROPHE
*/
APOSTROPHE: 192, // needs localization
/**
* SINGLE_QUOTE
*/
SINGLE_QUOTE: 222, // needs localization
/**
* OPEN_SQUARE_BRACKET
*/
OPEN_SQUARE_BRACKET: 219, // needs localization
/**
* BACKSLASH
*/
BACKSLASH: 220, // needs localization
/**
* CLOSE_SQUARE_BRACKET
*/
CLOSE_SQUARE_BRACKET: 221, // needs localization
/**
* WIN_KEY
*/
WIN_KEY: 224,
/**
* MAC_FF_META
*/
MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91
/**
* WIN_IME
*/
WIN_IME: 229
};
/*
whether text and modified key is entered at the same time.
*/
KeyCode.isTextModifyingKeyEvent = function isTextModifyingKeyEvent(e) {
var keyCode = e.keyCode;
if (e.altKey && !e.ctrlKey || e.metaKey ||
// Function keys don't generate text
keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) {
return false;
}
// The following keys are quite harmless, even in combination with
// CTRL, ALT or SHIFT.
switch (keyCode) {
case KeyCode.ALT:
case KeyCode.CAPS_LOCK:
case KeyCode.CONTEXT_MENU:
case KeyCode.CTRL:
case KeyCode.DOWN:
case KeyCode.END:
case KeyCode.ESC:
case KeyCode.HOME:
case KeyCode.INSERT:
case KeyCode.LEFT:
case KeyCode.MAC_FF_META:
case KeyCode.META:
case KeyCode.NUMLOCK:
case KeyCode.NUM_CENTER:
case KeyCode.PAGE_DOWN:
case KeyCode.PAGE_UP:
case KeyCode.PAUSE:
case KeyCode.PRINT_SCREEN:
case KeyCode.RIGHT:
case KeyCode.SHIFT:
case KeyCode.UP:
case KeyCode.WIN_KEY:
case KeyCode.WIN_KEY_RIGHT:
return false;
default:
return true;
}
};
/*
whether character is entered.
*/
KeyCode.isCharacterKey = function isCharacterKey(keyCode) {
if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
return true;
}
if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
return true;
}
if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
return true;
}
// Safari sends zero key code for non-latin characters.
if (window.navigation.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) {
return true;
}
switch (keyCode) {
case KeyCode.SPACE:
case KeyCode.QUESTION_MARK:
case KeyCode.NUM_PLUS:
case KeyCode.NUM_MINUS:
case KeyCode.NUM_PERIOD:
case KeyCode.NUM_DIVISION:
case KeyCode.SEMICOLON:
case KeyCode.DASH:
case KeyCode.EQUALS:
case KeyCode.COMMA:
case KeyCode.PERIOD:
case KeyCode.SLASH:
case KeyCode.APOSTROPHE:
case KeyCode.SINGLE_QUOTE:
case KeyCode.OPEN_SQUARE_BRACKET:
case KeyCode.BACKSLASH:
case KeyCode.CLOSE_SQUARE_BRACKET:
return true;
default:
return false;
}
};
exports["default"] = KeyCode;
module.exports = exports['default'];
/***/ },
/* 66 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getComponentLocale = getComponentLocale;
exports.getLocaleCode = getLocaleCode;
var _objectAssign = __webpack_require__(8);
var _objectAssign2 = _interopRequireDefault(_objectAssign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function getComponentLocale(props, context, componentName, getDefaultLocale) {
var locale = context && context.antLocale && context.antLocale[componentName] ? context.antLocale[componentName] : getDefaultLocale();
var result = (0, _objectAssign2["default"])({}, locale, props.locale);
result.lang = (0, _objectAssign2["default"])({}, locale.lang, props.locale.lang);
return result;
}
function getLocaleCode(context) {
var localeCode = context.antLocale && context.antLocale.locale;
// Had use LocaleProvide but didn't set locale
if (context.antLocale && context.antLocale.exist && !localeCode) {
return 'zh-cn';
}
return localeCode;
}
/***/ },
/* 67 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = getRequestAnimationFrame;
exports.cancelRequestAnimationFrame = cancelRequestAnimationFrame;
var availablePrefixs = ['moz', 'ms', 'webkit'];
function requestAnimationFramePolyfill() {
var lastTime = 0;
return function (callback) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
function getRequestAnimationFrame() {
if (typeof window === 'undefined') {
return function () {};
}
if (window.requestAnimationFrame) {
return window.requestAnimationFrame;
}
var prefix = availablePrefixs.filter(function (key) {
return key + 'RequestAnimationFrame' in window;
})[0];
return prefix ? window[prefix + 'RequestAnimationFrame'] : requestAnimationFramePolyfill();
}
function cancelRequestAnimationFrame(id) {
if (typeof window === 'undefined') {
return null;
}
if (window.cancelAnimationFrame) {
return window.cancelAnimationFrame(id);
}
var prefix = availablePrefixs.filter(function (key) {
return key + 'CancelAnimationFrame' in window || key + 'CancelRequestAnimationFrame' in window;
})[0];
return prefix ? (window[prefix + 'CancelAnimationFrame'] || window[prefix + 'CancelRequestAnimationFrame']).call(this, id) : clearTimeout(id);
}
/***/ },
/* 68 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Input = __webpack_require__(146);
var _Input2 = _interopRequireDefault(_Input);
var _Group = __webpack_require__(307);
var _Group2 = _interopRequireDefault(_Group);
var _Search = __webpack_require__(308);
var _Search2 = _interopRequireDefault(_Search);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
_Input2["default"].Group = _Group2["default"];
_Input2["default"].Search = _Search2["default"];
exports["default"] = _Input2["default"];
module.exports = exports['default'];
/***/ },
/* 69 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Group = exports.Button = undefined;
var _radio = __webpack_require__(90);
var _radio2 = _interopRequireDefault(_radio);
var _group = __webpack_require__(325);
var _group2 = _interopRequireDefault(_group);
var _radioButton = __webpack_require__(326);
var _radioButton2 = _interopRequireDefault(_radioButton);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
_radio2["default"].Button = _radioButton2["default"];
_radio2["default"].Group = _group2["default"];
exports.Button = _radioButton2["default"];
exports.Group = _group2["default"];
exports["default"] = _radio2["default"];
/***/ },
/* 70 */
/***/ function(module, exports) {
exports.f = {}.propertyIsEnumerable;
/***/ },
/* 71 */
/***/ function(module, exports) {
var id = 0
, px = Math.random();
module.exports = function(key){
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
/***/ },
/* 72 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $at = __webpack_require__(402)(true);
// 21.1.3.27 String.prototype[@@iterator]()
__webpack_require__(165)(String, 'String', function(iterated){
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
}, function(){
var O = this._t
, index = this._i
, point;
if(index >= O.length)return {value: undefined, done: true};
point = $at(O, index);
this._i += point.length;
return {value: point, done: false};
});
/***/ },
/* 73 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
module.exports = __webpack_require__(426);
/***/ },
/* 74 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ContentState
* @typechecks
*
*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var BlockMapBuilder = __webpack_require__(61);
var CharacterMetadata = __webpack_require__(25);
var ContentBlock = __webpack_require__(40);
var DraftEntity = __webpack_require__(75);
var Immutable = __webpack_require__(11);
var SelectionState = __webpack_require__(49);
var generateRandomKey = __webpack_require__(27);
var sanitizeDraftText = __webpack_require__(114);
var List = Immutable.List;
var Record = Immutable.Record;
var Repeat = Immutable.Repeat;
var defaultRecord = {
entityMap: null,
blockMap: null,
selectionBefore: null,
selectionAfter: null
};
var ContentStateRecord = Record(defaultRecord);
var ContentState = function (_ContentStateRecord) {
_inherits(ContentState, _ContentStateRecord);
function ContentState() {
_classCallCheck(this, ContentState);
return _possibleConstructorReturn(this, _ContentStateRecord.apply(this, arguments));
}
ContentState.prototype.getEntityMap = function getEntityMap() {
// TODO: update this when we fully remove DraftEntity
return DraftEntity;
};
ContentState.prototype.getBlockMap = function getBlockMap() {
return this.get('blockMap');
};
ContentState.prototype.getSelectionBefore = function getSelectionBefore() {
return this.get('selectionBefore');
};
ContentState.prototype.getSelectionAfter = function getSelectionAfter() {
return this.get('selectionAfter');
};
ContentState.prototype.getBlockForKey = function getBlockForKey(key) {
var block = this.getBlockMap().get(key);
return block;
};
ContentState.prototype.getKeyBefore = function getKeyBefore(key) {
return this.getBlockMap().reverse().keySeq().skipUntil(function (v) {
return v === key;
}).skip(1).first();
};
ContentState.prototype.getKeyAfter = function getKeyAfter(key) {
return this.getBlockMap().keySeq().skipUntil(function (v) {
return v === key;
}).skip(1).first();
};
ContentState.prototype.getBlockAfter = function getBlockAfter(key) {
return this.getBlockMap().skipUntil(function (_, k) {
return k === key;
}).skip(1).first();
};
ContentState.prototype.getBlockBefore = function getBlockBefore(key) {
return this.getBlockMap().reverse().skipUntil(function (_, k) {
return k === key;
}).skip(1).first();
};
ContentState.prototype.getBlocksAsArray = function getBlocksAsArray() {
return this.getBlockMap().toArray();
};
ContentState.prototype.getFirstBlock = function getFirstBlock() {
return this.getBlockMap().first();
};
ContentState.prototype.getLastBlock = function getLastBlock() {
return this.getBlockMap().last();
};
ContentState.prototype.getPlainText = function getPlainText(delimiter) {
return this.getBlockMap().map(function (block) {
return block ? block.getText() : '';
}).join(delimiter || '\n');
};
ContentState.prototype.getLastCreatedEntityKey = function getLastCreatedEntityKey() {
// TODO: update this when we fully remove DraftEntity
return DraftEntity.__getLastCreatedEntityKey();
};
ContentState.prototype.hasText = function hasText() {
var blockMap = this.getBlockMap();
return blockMap.size > 1 || blockMap.first().getLength() > 0;
};
ContentState.prototype.createEntity = function createEntity(type, mutability, data) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__create(type, mutability, data);
return this;
};
ContentState.prototype.mergeEntityData = function mergeEntityData(key, toMerge) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__mergeData(key, toMerge);
return this;
};
ContentState.prototype.replaceEntityData = function replaceEntityData(key, newData) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__replaceData(key, newData);
return this;
};
ContentState.prototype.addEntity = function addEntity(instance) {
// TODO: update this when we fully remove DraftEntity
DraftEntity.__add(instance);
return this;
};
ContentState.prototype.getEntity = function getEntity(key) {
// TODO: update this when we fully remove DraftEntity
return DraftEntity.__get(key);
};
ContentState.createFromBlockArray = function createFromBlockArray(
// TODO: update flow type when we completely deprecate the old entity API
blocks, entityMap) {
// TODO: remove this when we completely deprecate the old entity API
var theBlocks = Array.isArray(blocks) ? blocks : blocks.contentBlocks;
var blockMap = BlockMapBuilder.createFromArray(theBlocks);
var selectionState = blockMap.isEmpty() ? new SelectionState() : SelectionState.createEmpty(blockMap.first().getKey());
return new ContentState({
blockMap: blockMap,
entityMap: entityMap || DraftEntity,
selectionBefore: selectionState,
selectionAfter: selectionState
});
};
ContentState.createFromText = function createFromText(text) {
var delimiter = arguments.length <= 1 || arguments[1] === undefined ? /\r\n?|\n/g : arguments[1];
var strings = text.split(delimiter);
var blocks = strings.map(function (block) {
block = sanitizeDraftText(block);
return new ContentBlock({
key: generateRandomKey(),
text: block,
type: 'unstyled',
characterList: List(Repeat(CharacterMetadata.EMPTY, block.length))
});
});
return ContentState.createFromBlockArray(blocks);
};
return ContentState;
}(ContentStateRecord);
module.exports = ContentState;
/***/ },
/* 75 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _assign = __webpack_require__(8);
var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftEntity
* @typechecks
*
*/
var DraftEntityInstance = __webpack_require__(176);
var Immutable = __webpack_require__(11);
var invariant = __webpack_require__(16);
var Map = Immutable.Map;
var instances = Map();
var instanceKey = 0;
/**
* Temporary utility for generating the warnings
*/
function logWarning(oldMethodCall, newMethodCall) {
console.warn('WARNING: ' + oldMethodCall + ' will be deprecated soon!\nPlease use "' + newMethodCall + '" instead.');
}
/**
* A "document entity" is an object containing metadata associated with a
* piece of text in a ContentBlock.
*
* For example, a `link` entity might include a `uri` property. When a
* ContentBlock is rendered in the browser, text that refers to that link
* entity may be rendered as an anchor, with the `uri` as the href value.
*
* In a ContentBlock, every position in the text may correspond to zero
* or one entities. This correspondence is tracked using a key string,
* generated via DraftEntity.create() and used to obtain entity metadata
* via DraftEntity.get().
*/
var DraftEntity = {
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.getLastCreatedEntityKey' instead.
* ---
* Get the random key string from whatever entity was last created.
* We need this to support the new API, as part of transitioning to put Entity
* storage in contentState.
*/
getLastCreatedEntityKey: function getLastCreatedEntityKey() {
logWarning('DraftEntity.getLastCreatedEntityKey', 'contentState.getLastCreatedEntityKey');
return DraftEntity.__getLastCreatedEntityKey();
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.createEntity' instead.
* ---
* Create a DraftEntityInstance and store it for later retrieval.
*
* A random key string will be generated and returned. This key may
* be used to track the entity's usage in a ContentBlock, and for
* retrieving data about the entity at render time.
*/
create: function create(type, mutability, data) {
logWarning('DraftEntity.create', 'contentState.createEntity');
return DraftEntity.__create(type, mutability, data);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.addEntity' instead.
* ---
* Add an existing DraftEntityInstance to the DraftEntity map. This is
* useful when restoring instances from the server.
*/
add: function add(instance) {
logWarning('DraftEntity.add', 'contentState.addEntity');
return DraftEntity.__add(instance);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.getEntity' instead.
* ---
* Retrieve the entity corresponding to the supplied key string.
*/
get: function get(key) {
logWarning('DraftEntity.get', 'contentState.getEntity');
return DraftEntity.__get(key);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.mergeEntityData' instead.
* ---
* Entity instances are immutable. If you need to update the data for an
* instance, this method will merge your data updates and return a new
* instance.
*/
mergeData: function mergeData(key, toMerge) {
logWarning('DraftEntity.mergeData', 'contentState.mergeEntityData');
return DraftEntity.__mergeData(key, toMerge);
},
/**
* WARNING: This method will be deprecated soon!
* Please use 'contentState.replaceEntityData' instead.
* ---
* Completely replace the data for a given instance.
*/
replaceData: function replaceData(key, newData) {
logWarning('DraftEntity.replaceData', 'contentState.replaceEntityData');
return DraftEntity.__replaceData(key, newData);
},
// ***********************************WARNING******************************
// --- the above public API will be deprecated in the next version of Draft!
// The methods below this line are private - don't call them directly.
/**
* Get the random key string from whatever entity was last created.
* We need this to support the new API, as part of transitioning to put Entity
* storage in contentState.
*/
__getLastCreatedEntityKey: function __getLastCreatedEntityKey() {
return '' + instanceKey;
},
/**
* Create a DraftEntityInstance and store it for later retrieval.
*
* A random key string will be generated and returned. This key may
* be used to track the entity's usage in a ContentBlock, and for
* retrieving data about the entity at render time.
*/
__create: function __create(type, mutability, data) {
return DraftEntity.__add(new DraftEntityInstance({ type: type, mutability: mutability, data: data || {} }));
},
/**
* Add an existing DraftEntityInstance to the DraftEntity map. This is
* useful when restoring instances from the server.
*/
__add: function __add(instance) {
var key = '' + ++instanceKey;
instances = instances.set(key, instance);
return key;
},
/**
* Retrieve the entity corresponding to the supplied key string.
*/
__get: function __get(key) {
var instance = instances.get(key);
!!!instance ? true ? invariant(false, 'Unknown DraftEntity key.') : invariant(false) : void 0;
return instance;
},
/**
* Entity instances are immutable. If you need to update the data for an
* instance, this method will merge your data updates and return a new
* instance.
*/
__mergeData: function __mergeData(key, toMerge) {
var instance = DraftEntity.__get(key);
var newData = _extends({}, instance.getData(), toMerge);
var newInstance = instance.set('data', newData);
instances = instances.set(key, newInstance);
return newInstance;
},
/**
* Completely replace the data for a given instance.
*/
__replaceData: function __replaceData(key, newData) {
var instance = DraftEntity.__get(key);
var newInstance = instance.set('data', newData);
instances = instances.set(key, newInstance);
return newInstance;
}
};
module.exports = DraftEntity;
/***/ },
/* 76 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule findRangesImmutable
*
*/
'use strict';
/**
* Search through an array to find contiguous stretches of elements that
* match a specified filter function.
*
* When ranges are found, execute a specified `found` function to supply
* the values to the caller.
*/
function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
if (!haystack.size) {
return;
}
var cursor = 0;
haystack.reduce(function (value, nextValue, nextIndex) {
/* $FlowFixMe(>=0.28.0): `value` could be undefined! */
if (!areEqualFn(value, nextValue)) {
/* $FlowFixMe(>=0.28.0): `value` could be undefined! */
if (filterFn(value)) {
foundFn(cursor, nextIndex);
}
cursor = nextIndex;
}
return nextValue;
});
filterFn(haystack.last()) && foundFn(cursor, haystack.count());
}
module.exports = findRangesImmutable;
/***/ },
/* 77 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getContentStateFragment
* @typechecks
*
*/
'use strict';
var generateRandomKey = __webpack_require__(27);
var removeEntitiesAtEdges = __webpack_require__(191);
function getContentStateFragment(contentState, selectionState) {
var startKey = selectionState.getStartKey();
var startOffset = selectionState.getStartOffset();
var endKey = selectionState.getEndKey();
var endOffset = selectionState.getEndOffset();
// Edge entities should be stripped to ensure that we don't preserve
// invalid partial entities when the fragment is reused. We do, however,
// preserve entities that are entirely within the selection range.
var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
var blockMap = contentWithoutEdgeEntities.getBlockMap();
var blockKeys = blockMap.keySeq();
var startIndex = blockKeys.indexOf(startKey);
var endIndex = blockKeys.indexOf(endKey) + 1;
var slice = blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
var newKey = generateRandomKey();
var text = block.getText();
var chars = block.getCharacterList();
if (startKey === endKey) {
return block.merge({
key: newKey,
text: text.slice(startOffset, endOffset),
characterList: chars.slice(startOffset, endOffset)
});
}
if (blockKey === startKey) {
return block.merge({
key: newKey,
text: text.slice(startOffset),
characterList: chars.slice(startOffset)
});
}
if (blockKey === endKey) {
return block.merge({
key: newKey,
text: text.slice(0, endOffset),
characterList: chars.slice(0, endOffset)
});
}
return block.set('key', newKey);
});
return slice.toOrderedMap();
}
module.exports = getContentStateFragment;
/***/ },
/* 78 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule isEventHandled
* @typechecks
*
*/
'use strict';
/**
* Utility method for determining whether or not the value returned
* from a handler indicates that it was handled.
*/
function isEventHandled(value) {
return value === 'handled' || value === true;
}
module.exports = isEventHandled;
/***/ },
/* 79 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = __webpack_require__(1);
var _en_US = __webpack_require__(211);
var _en_US2 = _interopRequireDefault(_en_US);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function noop() {}
exports["default"] = {
propTypes: {
className: _react.PropTypes.string,
locale: _react.PropTypes.object,
style: _react.PropTypes.object,
visible: _react.PropTypes.bool,
onSelect: _react.PropTypes.func,
prefixCls: _react.PropTypes.string,
onChange: _react.PropTypes.func,
onOk: _react.PropTypes.func
},
getDefaultProps: function getDefaultProps() {
return {
locale: _en_US2["default"],
style: {},
visible: true,
prefixCls: 'rc-calendar',
className: '',
onSelect: noop,
onChange: noop,
onClear: noop,
renderFooter: function renderFooter() {
return null;
},
renderSidebar: function renderSidebar() {
return null;
}
};
},
shouldComponentUpdate: function shouldComponentUpdate(nextProps) {
return this.props.visible || nextProps.visible;
},
getFormat: function getFormat() {
var format = this.props.format;
var _props = this.props,
locale = _props.locale,
timePicker = _props.timePicker;
if (!format) {
if (timePicker) {
format = locale.dateTimeFormat;
} else {
format = locale.dateFormat;
}
}
return format;
},
focus: function focus() {
if (this.refs.root) {
this.refs.root.focus();
}
}
};
module.exports = exports['default'];
/***/ },
/* 80 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Divider = exports.ItemGroup = exports.MenuItemGroup = exports.MenuItem = exports.Item = exports.SubMenu = undefined;
var _Menu = __webpack_require__(583);
var _Menu2 = _interopRequireDefault(_Menu);
var _SubMenu = __webpack_require__(586);
var _SubMenu2 = _interopRequireDefault(_SubMenu);
var _MenuItem = __webpack_require__(584);
var _MenuItem2 = _interopRequireDefault(_MenuItem);
var _MenuItemGroup = __webpack_require__(585);
var _MenuItemGroup2 = _interopRequireDefault(_MenuItemGroup);
var _Divider = __webpack_require__(582);
var _Divider2 = _interopRequireDefault(_Divider);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports.SubMenu = _SubMenu2["default"];
exports.Item = _MenuItem2["default"];
exports.MenuItem = _MenuItem2["default"];
exports.MenuItemGroup = _MenuItemGroup2["default"];
exports.ItemGroup = _MenuItemGroup2["default"];
exports.Divider = _Divider2["default"];
exports["default"] = _Menu2["default"];
/***/ },
/* 81 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.noop = noop;
exports.getKeyFromChildrenIndex = getKeyFromChildrenIndex;
exports.loopMenuItem = loopMenuItem;
exports.loopMenuItemRecusively = loopMenuItemRecusively;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function noop() {}
function getKeyFromChildrenIndex(child, menuEventKey, index) {
var prefix = menuEventKey || '';
return child.key || prefix + 'item_' + index;
}
function loopMenuItem(children, cb) {
var index = -1;
_react2["default"].Children.forEach(children, function (c) {
index++;
if (c && c.type && c.type.isMenuItemGroup) {
_react2["default"].Children.forEach(c.props.children, function (c2) {
index++;
cb(c2, index);
});
} else {
cb(c, index);
}
});
}
function loopMenuItemRecusively(children, keys, ret) {
if (!children || ret.find) {
return;
}
_react2["default"].Children.forEach(children, function (c) {
if (ret.find) {
return;
}
if (c) {
var construt = c.type;
if (!construt || !(construt.isSubMenu || construt.isMenuItem || construt.isMenuItemGroup)) {
return;
}
if (keys.indexOf(c.key) !== -1) {
ret.find = true;
} else if (c.props.children) {
loopMenuItemRecusively(c.props.children, keys, ret);
}
}
});
}
/***/ },
/* 82 */
/***/ function(module, exports) {
'use strict';
/**
* @ignore
* some key-codes definition and utils from closure-library
* @author [email protected]
*/
var KeyCode = {
/**
* MAC_ENTER
*/
MAC_ENTER: 3,
/**
* BACKSPACE
*/
BACKSPACE: 8,
/**
* TAB
*/
TAB: 9,
/**
* NUMLOCK on FF/Safari Mac
*/
NUM_CENTER: 12, // NUMLOCK on FF/Safari Mac
/**
* ENTER
*/
ENTER: 13,
/**
* SHIFT
*/
SHIFT: 16,
/**
* CTRL
*/
CTRL: 17,
/**
* ALT
*/
ALT: 18,
/**
* PAUSE
*/
PAUSE: 19,
/**
* CAPS_LOCK
*/
CAPS_LOCK: 20,
/**
* ESC
*/
ESC: 27,
/**
* SPACE
*/
SPACE: 32,
/**
* PAGE_UP
*/
PAGE_UP: 33, // also NUM_NORTH_EAST
/**
* PAGE_DOWN
*/
PAGE_DOWN: 34, // also NUM_SOUTH_EAST
/**
* END
*/
END: 35, // also NUM_SOUTH_WEST
/**
* HOME
*/
HOME: 36, // also NUM_NORTH_WEST
/**
* LEFT
*/
LEFT: 37, // also NUM_WEST
/**
* UP
*/
UP: 38, // also NUM_NORTH
/**
* RIGHT
*/
RIGHT: 39, // also NUM_EAST
/**
* DOWN
*/
DOWN: 40, // also NUM_SOUTH
/**
* PRINT_SCREEN
*/
PRINT_SCREEN: 44,
/**
* INSERT
*/
INSERT: 45, // also NUM_INSERT
/**
* DELETE
*/
DELETE: 46, // also NUM_DELETE
/**
* ZERO
*/
ZERO: 48,
/**
* ONE
*/
ONE: 49,
/**
* TWO
*/
TWO: 50,
/**
* THREE
*/
THREE: 51,
/**
* FOUR
*/
FOUR: 52,
/**
* FIVE
*/
FIVE: 53,
/**
* SIX
*/
SIX: 54,
/**
* SEVEN
*/
SEVEN: 55,
/**
* EIGHT
*/
EIGHT: 56,
/**
* NINE
*/
NINE: 57,
/**
* QUESTION_MARK
*/
QUESTION_MARK: 63, // needs localization
/**
* A
*/
A: 65,
/**
* B
*/
B: 66,
/**
* C
*/
C: 67,
/**
* D
*/
D: 68,
/**
* E
*/
E: 69,
/**
* F
*/
F: 70,
/**
* G
*/
G: 71,
/**
* H
*/
H: 72,
/**
* I
*/
I: 73,
/**
* J
*/
J: 74,
/**
* K
*/
K: 75,
/**
* L
*/
L: 76,
/**
* M
*/
M: 77,
/**
* N
*/
N: 78,
/**
* O
*/
O: 79,
/**
* P
*/
P: 80,
/**
* Q
*/
Q: 81,
/**
* R
*/
R: 82,
/**
* S
*/
S: 83,
/**
* T
*/
T: 84,
/**
* U
*/
U: 85,
/**
* V
*/
V: 86,
/**
* W
*/
W: 87,
/**
* X
*/
X: 88,
/**
* Y
*/
Y: 89,
/**
* Z
*/
Z: 90,
/**
* META
*/
META: 91, // WIN_KEY_LEFT
/**
* WIN_KEY_RIGHT
*/
WIN_KEY_RIGHT: 92,
/**
* CONTEXT_MENU
*/
CONTEXT_MENU: 93,
/**
* NUM_ZERO
*/
NUM_ZERO: 96,
/**
* NUM_ONE
*/
NUM_ONE: 97,
/**
* NUM_TWO
*/
NUM_TWO: 98,
/**
* NUM_THREE
*/
NUM_THREE: 99,
/**
* NUM_FOUR
*/
NUM_FOUR: 100,
/**
* NUM_FIVE
*/
NUM_FIVE: 101,
/**
* NUM_SIX
*/
NUM_SIX: 102,
/**
* NUM_SEVEN
*/
NUM_SEVEN: 103,
/**
* NUM_EIGHT
*/
NUM_EIGHT: 104,
/**
* NUM_NINE
*/
NUM_NINE: 105,
/**
* NUM_MULTIPLY
*/
NUM_MULTIPLY: 106,
/**
* NUM_PLUS
*/
NUM_PLUS: 107,
/**
* NUM_MINUS
*/
NUM_MINUS: 109,
/**
* NUM_PERIOD
*/
NUM_PERIOD: 110,
/**
* NUM_DIVISION
*/
NUM_DIVISION: 111,
/**
* F1
*/
F1: 112,
/**
* F2
*/
F2: 113,
/**
* F3
*/
F3: 114,
/**
* F4
*/
F4: 115,
/**
* F5
*/
F5: 116,
/**
* F6
*/
F6: 117,
/**
* F7
*/
F7: 118,
/**
* F8
*/
F8: 119,
/**
* F9
*/
F9: 120,
/**
* F10
*/
F10: 121,
/**
* F11
*/
F11: 122,
/**
* F12
*/
F12: 123,
/**
* NUMLOCK
*/
NUMLOCK: 144,
/**
* SEMICOLON
*/
SEMICOLON: 186, // needs localization
/**
* DASH
*/
DASH: 189, // needs localization
/**
* EQUALS
*/
EQUALS: 187, // needs localization
/**
* COMMA
*/
COMMA: 188, // needs localization
/**
* PERIOD
*/
PERIOD: 190, // needs localization
/**
* SLASH
*/
SLASH: 191, // needs localization
/**
* APOSTROPHE
*/
APOSTROPHE: 192, // needs localization
/**
* SINGLE_QUOTE
*/
SINGLE_QUOTE: 222, // needs localization
/**
* OPEN_SQUARE_BRACKET
*/
OPEN_SQUARE_BRACKET: 219, // needs localization
/**
* BACKSLASH
*/
BACKSLASH: 220, // needs localization
/**
* CLOSE_SQUARE_BRACKET
*/
CLOSE_SQUARE_BRACKET: 221, // needs localization
/**
* WIN_KEY
*/
WIN_KEY: 224,
/**
* MAC_FF_META
*/
MAC_FF_META: 224, // Firefox (Gecko) fires this for the meta key instead of 91
/**
* WIN_IME
*/
WIN_IME: 229
};
/*
whether text and modified key is entered at the same time.
*/
KeyCode.isTextModifyingKeyEvent = function isTextModifyingKeyEvent(e) {
var keyCode = e.keyCode;
if (e.altKey && !e.ctrlKey || e.metaKey ||
// Function keys don't generate text
keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12) {
return false;
}
// The following keys are quite harmless, even in combination with
// CTRL, ALT or SHIFT.
switch (keyCode) {
case KeyCode.ALT:
case KeyCode.CAPS_LOCK:
case KeyCode.CONTEXT_MENU:
case KeyCode.CTRL:
case KeyCode.DOWN:
case KeyCode.END:
case KeyCode.ESC:
case KeyCode.HOME:
case KeyCode.INSERT:
case KeyCode.LEFT:
case KeyCode.MAC_FF_META:
case KeyCode.META:
case KeyCode.NUMLOCK:
case KeyCode.NUM_CENTER:
case KeyCode.PAGE_DOWN:
case KeyCode.PAGE_UP:
case KeyCode.PAUSE:
case KeyCode.PRINT_SCREEN:
case KeyCode.RIGHT:
case KeyCode.SHIFT:
case KeyCode.UP:
case KeyCode.WIN_KEY:
case KeyCode.WIN_KEY_RIGHT:
return false;
default:
return true;
}
};
/*
whether character is entered.
*/
KeyCode.isCharacterKey = function isCharacterKey(keyCode) {
if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
return true;
}
if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
return true;
}
if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
return true;
}
// Safari sends zero key code for non-latin characters.
if (window.navigation.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) {
return true;
}
switch (keyCode) {
case KeyCode.SPACE:
case KeyCode.QUESTION_MARK:
case KeyCode.NUM_PLUS:
case KeyCode.NUM_MINUS:
case KeyCode.NUM_PERIOD:
case KeyCode.NUM_DIVISION:
case KeyCode.SEMICOLON:
case KeyCode.DASH:
case KeyCode.EQUALS:
case KeyCode.COMMA:
case KeyCode.PERIOD:
case KeyCode.SLASH:
case KeyCode.APOSTROPHE:
case KeyCode.SINGLE_QUOTE:
case KeyCode.OPEN_SQUARE_BRACKET:
case KeyCode.BACKSLASH:
case KeyCode.CLOSE_SQUARE_BRACKET:
return true;
default:
return false;
}
};
module.exports = KeyCode;
/***/ },
/* 83 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UNSELECTABLE_ATTRIBUTE = exports.UNSELECTABLE_STYLE = undefined;
exports.getValuePropValue = getValuePropValue;
exports.getPropValue = getPropValue;
exports.isCombobox = isCombobox;
exports.isMultipleOrTags = isMultipleOrTags;
exports.isMultipleOrTagsOrCombobox = isMultipleOrTagsOrCombobox;
exports.isSingleMode = isSingleMode;
exports.toArray = toArray;
exports.preventDefaultEvent = preventDefaultEvent;
exports.findIndexInValueByKey = findIndexInValueByKey;
exports.findIndexInValueByLabel = findIndexInValueByLabel;
exports.getSelectKeys = getSelectKeys;
exports.findFirstMenuItem = findFirstMenuItem;
exports.includesSeparators = includesSeparators;
exports.splitBySeparators = splitBySeparators;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function getValuePropValue(child) {
var props = child.props;
if ('value' in props) {
return props.value;
}
if (child.key) {
return child.key;
}
if (child.type && child.type.isSelectOptGroup && props.label) {
return props.label;
}
throw new Error('no key or value or label(only for OptGroup) for ' + child);
}
function getPropValue(child, prop) {
if (prop === 'value') {
return getValuePropValue(child);
}
return child.props[prop];
}
function isCombobox(props) {
return props.combobox;
}
function isMultipleOrTags(props) {
return props.multiple || props.tags;
}
function isMultipleOrTagsOrCombobox(props) {
return isMultipleOrTags(props) || isCombobox(props);
}
function isSingleMode(props) {
return !isMultipleOrTagsOrCombobox(props);
}
function toArray(value) {
var ret = value;
if (value === undefined) {
ret = [];
} else if (!Array.isArray(value)) {
ret = [value];
}
return ret;
}
function preventDefaultEvent(e) {
e.preventDefault();
}
function findIndexInValueByKey(value, key) {
var index = -1;
for (var i = 0; i < value.length; i++) {
if (value[i].key === key) {
index = i;
break;
}
}
return index;
}
function findIndexInValueByLabel(value, label) {
var index = -1;
for (var i = 0; i < value.length; i++) {
if (toArray(value[i].label).join('') === label) {
index = i;
break;
}
}
return index;
}
function getSelectKeys(menuItems, value) {
if (value === null || value === undefined) {
return [];
}
var selectedKeys = [];
_react2["default"].Children.forEach(menuItems, function (item) {
if (item.type.isMenuItemGroup) {
selectedKeys = selectedKeys.concat(getSelectKeys(item.props.children, value));
} else {
var itemValue = getValuePropValue(item);
var itemKey = item.key;
if (findIndexInValueByKey(value, itemValue) !== -1 && itemKey) {
selectedKeys.push(itemKey);
}
}
});
return selectedKeys;
}
var UNSELECTABLE_STYLE = exports.UNSELECTABLE_STYLE = {
userSelect: 'none',
WebkitUserSelect: 'none'
};
var UNSELECTABLE_ATTRIBUTE = exports.UNSELECTABLE_ATTRIBUTE = {
unselectable: 'unselectable'
};
function findFirstMenuItem(children) {
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.type.isMenuItemGroup) {
var found = findFirstMenuItem(child.props.children);
if (found) {
return found;
}
} else if (!child.props.disabled) {
return child;
}
}
return null;
}
function includesSeparators(string, separators) {
for (var i = 0; i < separators.length; ++i) {
if (string.lastIndexOf(separators[i]) > 0) {
return true;
}
}
return false;
}
function splitBySeparators(string, separators) {
var reg = new RegExp('[' + separators.join() + ']');
var array = string.split(reg);
if (array[0] === '') {
array.shift();
}
if (array[array.length - 1] === '') {
array.pop();
}
return array;
}
/***/ },
/* 84 */
/***/ function(module, exports) {
function arrayTreeFilter(data, filterFn, options) {
options = options || {};
options.childrenKeyName = options.childrenKeyName || 'children';
var children = data || [];
var result = [];
var level = 0;
var foundItem;
do {
var foundItem = children.filter(function(item) {
return filterFn(item, level);
})[0];
if (!foundItem) {
break;
}
result.push(foundItem);
children = foundItem[options.childrenKeyName] || [];
level += 1;
} while(children.length > 0);
return result;
}
module.exports = arrayTreeFilter;
/***/ },
/* 85 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _rule = __webpack_require__(18);
var _rule2 = _interopRequireDefault(_rule);
var _util = __webpack_require__(15);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function type(rule, value, callback, source, options) {
var ruleType = rule.type;
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if ((0, _util.isEmptyValue)(value, ruleType) && !rule.required) {
return callback();
}
_rule2["default"].required(rule, value, source, errors, options, ruleType);
if (!(0, _util.isEmptyValue)(value, ruleType)) {
_rule2["default"].type(rule, value, source, errors, options);
}
}
callback(errors);
}
exports["default"] = type;
module.exports = exports['default'];
/***/ },
/* 86 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = getScroll;
function getScroll(target, top) {
if (typeof window === 'undefined') {
return 0;
}
var prop = top ? 'pageYOffset' : 'pageXOffset';
var method = top ? 'scrollTop' : 'scrollLeft';
var isWindow = target === window;
var ret = isWindow ? target[prop] : target[method];
// ie6,7,8 standard mode
if (isWindow && typeof ret !== 'number') {
ret = window.document.documentElement[method];
}
return ret;
}
module.exports = exports['default'];
/***/ },
/* 87 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _cssAnimation = __webpack_require__(108);
var _cssAnimation2 = _interopRequireDefault(_cssAnimation);
var _getRequestAnimationFrame = __webpack_require__(67);
var _getRequestAnimationFrame2 = _interopRequireDefault(_getRequestAnimationFrame);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var reqAnimFrame = (0, _getRequestAnimationFrame2["default"])();
function animate(node, show, done) {
var height = void 0;
var requestAnimationFrameId = void 0;
return (0, _cssAnimation2["default"])(node, 'ant-motion-collapse', {
start: function start() {
if (!show) {
node.style.height = node.offsetHeight + 'px';
node.style.opacity = 1;
} else {
height = node.offsetHeight;
node.style.height = 0;
node.style.opacity = 0;
}
},
active: function active() {
if (requestAnimationFrameId) {
(0, _getRequestAnimationFrame.cancelRequestAnimationFrame)(requestAnimationFrameId);
}
requestAnimationFrameId = reqAnimFrame(function () {
node.style.height = (show ? height : 0) + 'px';
node.style.opacity = show ? 1 : 0;
});
},
end: function end() {
if (requestAnimationFrameId) {
(0, _getRequestAnimationFrame.cancelRequestAnimationFrame)(requestAnimationFrameId);
}
node.style.height = '';
node.style.opacity = '';
done();
}
});
}
var animation = {
enter: function enter(node, done) {
return animate(node, true, done);
},
leave: function leave(node, done) {
return animate(node, false, done);
},
appear: function appear(node, done) {
return animate(node, true, done);
}
};
exports["default"] = animation;
module.exports = exports['default'];
/***/ },
/* 88 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _dropdown = __webpack_require__(143);
var _dropdown2 = _interopRequireDefault(_dropdown);
var _dropdownButton = __webpack_require__(299);
var _dropdownButton2 = _interopRequireDefault(_dropdownButton);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
_dropdown2["default"].Button = _dropdownButton2["default"];
exports["default"] = _dropdown2["default"];
module.exports = exports['default'];
/***/ },
/* 89 */,
/* 90 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _rcRadio = __webpack_require__(603);
var _rcRadio2 = _interopRequireDefault(_rcRadio);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _shallowequal = __webpack_require__(33);
var _shallowequal2 = _interopRequireDefault(_shallowequal);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var __rest = undefined && undefined.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}return t;
};
var Radio = function (_React$Component) {
(0, _inherits3["default"])(Radio, _React$Component);
function Radio() {
(0, _classCallCheck3["default"])(this, Radio);
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
}
Radio.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState, nextContext) {
return !(0, _shallowequal2["default"])(this.props, nextProps) || !(0, _shallowequal2["default"])(this.state, nextState) || !(0, _shallowequal2["default"])(this.context.radioGroup, nextContext.radioGroup);
};
Radio.prototype.render = function render() {
var _classNames;
var _a = this.props,
prefixCls = _a.prefixCls,
className = _a.className,
children = _a.children,
style = _a.style,
restProps = __rest(_a, ["prefixCls", "className", "children", "style"]);
var radioProps = (0, _extends3["default"])({}, restProps);
if (this.context.radioGroup) {
radioProps.onChange = this.context.radioGroup.onChange;
radioProps.checked = this.props.value === this.context.radioGroup.value;
radioProps.disabled = this.props.disabled || this.context.radioGroup.disabled;
}
var wrapperClassString = (0, _classnames2["default"])((_classNames = {}, (0, _defineProperty3["default"])(_classNames, prefixCls + '-wrapper', true), (0, _defineProperty3["default"])(_classNames, prefixCls + '-wrapper-checked', radioProps.checked), (0, _defineProperty3["default"])(_classNames, prefixCls + '-wrapper-disabled', radioProps.disabled), _classNames), className);
return _react2["default"].createElement(
'label',
{ className: wrapperClassString, style: style, onMouseEnter: this.props.onMouseEnter, onMouseLeave: this.props.onMouseLeave },
_react2["default"].createElement(_rcRadio2["default"], (0, _extends3["default"])({}, radioProps, { prefixCls: prefixCls })),
children !== undefined ? _react2["default"].createElement(
'span',
null,
children
) : null
);
};
return Radio;
}(_react2["default"].Component);
exports["default"] = Radio;
Radio.defaultProps = {
prefixCls: 'ant-radio'
};
Radio.contextTypes = {
radioGroup: _react.PropTypes.any
};
module.exports = exports['default'];
/***/ },
/* 91 */
/***/ function(module, exports, __webpack_require__) {
/**
* Module dependencies.
*/
try {
var index = __webpack_require__(160);
} catch (err) {
var index = __webpack_require__(160);
}
/**
* Whitespace regexp.
*/
var re = /\s+/;
/**
* toString reference.
*/
var toString = Object.prototype.toString;
/**
* Wrap `el` in a `ClassList`.
*
* @param {Element} el
* @return {ClassList}
* @api public
*/
module.exports = function(el){
return new ClassList(el);
};
/**
* Initialize a new ClassList for `el`.
*
* @param {Element} el
* @api private
*/
function ClassList(el) {
if (!el || !el.nodeType) {
throw new Error('A DOM element reference is required');
}
this.el = el;
this.list = el.classList;
}
/**
* Add class `name` if not already present.
*
* @param {String} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.add = function(name){
// classList
if (this.list) {
this.list.add(name);
return this;
}
// fallback
var arr = this.array();
var i = index(arr, name);
if (!~i) arr.push(name);
this.el.className = arr.join(' ');
return this;
};
/**
* Remove class `name` when present, or
* pass a regular expression to remove
* any which match.
*
* @param {String|RegExp} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.remove = function(name){
if ('[object RegExp]' == toString.call(name)) {
return this.removeMatching(name);
}
// classList
if (this.list) {
this.list.remove(name);
return this;
}
// fallback
var arr = this.array();
var i = index(arr, name);
if (~i) arr.splice(i, 1);
this.el.className = arr.join(' ');
return this;
};
/**
* Remove all classes matching `re`.
*
* @param {RegExp} re
* @return {ClassList}
* @api private
*/
ClassList.prototype.removeMatching = function(re){
var arr = this.array();
for (var i = 0; i < arr.length; i++) {
if (re.test(arr[i])) {
this.remove(arr[i]);
}
}
return this;
};
/**
* Toggle class `name`, can force state via `force`.
*
* For browsers that support classList, but do not support `force` yet,
* the mistake will be detected and corrected.
*
* @param {String} name
* @param {Boolean} force
* @return {ClassList}
* @api public
*/
ClassList.prototype.toggle = function(name, force){
// classList
if (this.list) {
if ("undefined" !== typeof force) {
if (force !== this.list.toggle(name, force)) {
this.list.toggle(name); // toggle again to correct
}
} else {
this.list.toggle(name);
}
return this;
}
// fallback
if ("undefined" !== typeof force) {
if (!force) {
this.remove(name);
} else {
this.add(name);
}
} else {
if (this.has(name)) {
this.remove(name);
} else {
this.add(name);
}
}
return this;
};
/**
* Return an array of classes.
*
* @return {Array}
* @api public
*/
ClassList.prototype.array = function(){
var className = this.el.getAttribute('class') || '';
var str = className.replace(/^\s+|\s+$/g, '');
var arr = str.split(re);
if ('' === arr[0]) arr.shift();
return arr;
};
/**
* Check if class `name` is present.
*
* @param {String} name
* @return {ClassList}
* @api public
*/
ClassList.prototype.has =
ClassList.prototype.contains = function(name){
return this.list
? this.list.contains(name)
: !! ~index(this.array(), name);
};
/***/ },
/* 92 */
/***/ function(module, exports) {
var toString = {}.toString;
module.exports = function(it){
return toString.call(it).slice(8, -1);
};
/***/ },
/* 93 */
/***/ function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(383);
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
}
return function(/* ...args */){
return fn.apply(that, arguments);
};
};
/***/ },
/* 94 */
/***/ function(module, exports) {
// 7.2.1 RequireObjectCoercible(argument)
module.exports = function(it){
if(it == undefined)throw TypeError("Can't call method on " + it);
return it;
};
/***/ },
/* 95 */
/***/ function(module, exports) {
// IE 8- don't enum bug keys
module.exports = (
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
).split(',');
/***/ },
/* 96 */
/***/ function(module, exports) {
module.exports = true;
/***/ },
/* 97 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var anObject = __webpack_require__(35)
, dPs = __webpack_require__(398)
, enumBugKeys = __webpack_require__(95)
, IE_PROTO = __webpack_require__(100)('IE_PROTO')
, Empty = function(){ /* empty */ }
, PROTOTYPE = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function(){
// Thrash, waste and sodomy: IE GC bug
var iframe = __webpack_require__(162)('iframe')
, i = enumBugKeys.length
, lt = '<'
, gt = '>'
, iframeDocument;
iframe.style.display = 'none';
__webpack_require__(388).appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
return createDict();
};
module.exports = Object.create || function create(O, Properties){
var result;
if(O !== null){
Empty[PROTOTYPE] = anObject(O);
result = new Empty;
Empty[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : dPs(result, Properties);
};
/***/ },
/* 98 */
/***/ function(module, exports) {
exports.f = Object.getOwnPropertySymbols;
/***/ },
/* 99 */
/***/ function(module, exports, __webpack_require__) {
var def = __webpack_require__(30).f
, has = __webpack_require__(38)
, TAG = __webpack_require__(24)('toStringTag');
module.exports = function(it, tag, stat){
if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
};
/***/ },
/* 100 */
/***/ function(module, exports, __webpack_require__) {
var shared = __webpack_require__(101)('keys')
, uid = __webpack_require__(71);
module.exports = function(key){
return shared[key] || (shared[key] = uid(key));
};
/***/ },
/* 101 */
/***/ function(module, exports, __webpack_require__) {
var global = __webpack_require__(29)
, SHARED = '__core-js_shared__'
, store = global[SHARED] || (global[SHARED] = {});
module.exports = function(key){
return store[key] || (store[key] = {});
};
/***/ },
/* 102 */
/***/ function(module, exports) {
// 7.1.4 ToInteger
var ceil = Math.ceil
, floor = Math.floor;
module.exports = function(it){
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
/***/ },
/* 103 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.13 ToObject(argument)
var defined = __webpack_require__(94);
module.exports = function(it){
return Object(defined(it));
};
/***/ },
/* 104 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(57);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function(it, S){
if(!isObject(it))return it;
var fn, val;
if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ },
/* 105 */
/***/ function(module, exports, __webpack_require__) {
var global = __webpack_require__(29)
, core = __webpack_require__(23)
, LIBRARY = __webpack_require__(96)
, wksExt = __webpack_require__(106)
, defineProperty = __webpack_require__(30).f;
module.exports = function(name){
var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
};
/***/ },
/* 106 */
/***/ function(module, exports, __webpack_require__) {
exports.f = __webpack_require__(24);
/***/ },
/* 107 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(407);
var global = __webpack_require__(29)
, hide = __webpack_require__(46)
, Iterators = __webpack_require__(47)
, TO_STRING_TAG = __webpack_require__(24)('toStringTag');
for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
var NAME = collections[i]
, Collection = global[NAME]
, proto = Collection && Collection.prototype;
if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
Iterators[NAME] = Iterators.Array;
}
/***/ },
/* 108 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _Event = __webpack_require__(416);
var _Event2 = _interopRequireDefault(_Event);
var _componentClasses = __webpack_require__(91);
var _componentClasses2 = _interopRequireDefault(_componentClasses);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var isCssAnimationSupported = _Event2["default"].endEvents.length !== 0;
var capitalPrefixes = ['Webkit', 'Moz', 'O',
// ms is special .... !
'ms'];
var prefixes = ['-webkit-', '-moz-', '-o-', 'ms-', ''];
function getStyleProperty(node, name) {
// old ff need null, https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
var style = window.getComputedStyle(node, null);
var ret = '';
for (var i = 0; i < prefixes.length; i++) {
ret = style.getPropertyValue(prefixes[i] + name);
if (ret) {
break;
}
}
return ret;
}
function fixBrowserByTimeout(node) {
if (isCssAnimationSupported) {
var transitionDelay = parseFloat(getStyleProperty(node, 'transition-delay')) || 0;
var transitionDuration = parseFloat(getStyleProperty(node, 'transition-duration')) || 0;
var animationDelay = parseFloat(getStyleProperty(node, 'animation-delay')) || 0;
var animationDuration = parseFloat(getStyleProperty(node, 'animation-duration')) || 0;
var time = Math.max(transitionDuration + transitionDelay, animationDuration + animationDelay);
// sometimes, browser bug
node.rcEndAnimTimeout = setTimeout(function () {
node.rcEndAnimTimeout = null;
if (node.rcEndListener) {
node.rcEndListener();
}
}, time * 1000 + 200);
}
}
function clearBrowserBugTimeout(node) {
if (node.rcEndAnimTimeout) {
clearTimeout(node.rcEndAnimTimeout);
node.rcEndAnimTimeout = null;
}
}
var cssAnimation = function cssAnimation(node, transitionName, endCallback) {
var nameIsObj = (typeof transitionName === 'undefined' ? 'undefined' : _typeof(transitionName)) === 'object';
var className = nameIsObj ? transitionName.name : transitionName;
var activeClassName = nameIsObj ? transitionName.active : transitionName + '-active';
var end = endCallback;
var start = void 0;
var active = void 0;
var nodeClasses = (0, _componentClasses2["default"])(node);
if (endCallback && Object.prototype.toString.call(endCallback) === '[object Object]') {
end = endCallback.end;
start = endCallback.start;
active = endCallback.active;
}
if (node.rcEndListener) {
node.rcEndListener();
}
node.rcEndListener = function (e) {
if (e && e.target !== node) {
return;
}
if (node.rcAnimTimeout) {
clearTimeout(node.rcAnimTimeout);
node.rcAnimTimeout = null;
}
clearBrowserBugTimeout(node);
nodeClasses.remove(className);
nodeClasses.remove(activeClassName);
_Event2["default"].removeEndEventListener(node, node.rcEndListener);
node.rcEndListener = null;
// Usually this optional end is used for informing an owner of
// a leave animation and telling it to remove the child.
if (end) {
end();
}
};
_Event2["default"].addEndEventListener(node, node.rcEndListener);
if (start) {
start();
}
nodeClasses.add(className);
node.rcAnimTimeout = setTimeout(function () {
node.rcAnimTimeout = null;
nodeClasses.add(activeClassName);
if (active) {
setTimeout(active, 0);
}
fixBrowserByTimeout(node);
// 30ms for firefox
}, 30);
return {
stop: function stop() {
if (node.rcEndListener) {
node.rcEndListener();
}
}
};
};
cssAnimation.style = function (node, style, callback) {
if (node.rcEndListener) {
node.rcEndListener();
}
node.rcEndListener = function (e) {
if (e && e.target !== node) {
return;
}
if (node.rcAnimTimeout) {
clearTimeout(node.rcAnimTimeout);
node.rcAnimTimeout = null;
}
clearBrowserBugTimeout(node);
_Event2["default"].removeEndEventListener(node, node.rcEndListener);
node.rcEndListener = null;
// Usually this optional callback is used for informing an owner of
// a leave animation and telling it to remove the child.
if (callback) {
callback();
}
};
_Event2["default"].addEndEventListener(node, node.rcEndListener);
node.rcAnimTimeout = setTimeout(function () {
for (var s in style) {
if (style.hasOwnProperty(s)) {
node.style[s] = style[s];
}
}
node.rcAnimTimeout = null;
fixBrowserByTimeout(node);
}, 0);
};
cssAnimation.setTransition = function (node, p, value) {
var property = p;
var v = value;
if (value === undefined) {
v = property;
property = '';
}
property = property || '';
capitalPrefixes.forEach(function (prefix) {
node.style[prefix + 'Transition' + property] = v;
});
};
cssAnimation.isCssAnimationSupported = isCssAnimationSupported;
exports["default"] = cssAnimation;
module.exports = exports['default'];
/***/ },
/* 109 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DefaultDraftBlockRenderMap
*
*/
'use strict';
var _require = __webpack_require__(11);
var Map = _require.Map;
var React = __webpack_require__(1);
var cx = __webpack_require__(64);
var UL_WRAP = React.createElement('ul', { className: cx('public/DraftStyleDefault/ul') });
var OL_WRAP = React.createElement('ol', { className: cx('public/DraftStyleDefault/ol') });
var PRE_WRAP = React.createElement('pre', { className: cx('public/DraftStyleDefault/pre') });
var DefaultDraftBlockRenderMap = Map({
'header-one': {
element: 'h1'
},
'header-two': {
element: 'h2'
},
'header-three': {
element: 'h3'
},
'header-four': {
element: 'h4'
},
'header-five': {
element: 'h5'
},
'header-six': {
element: 'h6'
},
'unordered-list-item': {
element: 'li',
wrapper: UL_WRAP
},
'ordered-list-item': {
element: 'li',
wrapper: OL_WRAP
},
'blockquote': {
element: 'blockquote'
},
'atomic': {
element: 'figure'
},
'code-block': {
element: 'pre',
wrapper: PRE_WRAP
},
'unstyled': {
element: 'div',
aliasedElements: ['p']
}
});
module.exports = DefaultDraftBlockRenderMap;
/***/ },
/* 110 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule KeyBindingUtil
* @typechecks
*
*/
'use strict';
var UserAgent = __webpack_require__(28);
var isOSX = UserAgent.isPlatform('Mac OS X');
var KeyBindingUtil = {
/**
* Check whether the ctrlKey modifier is *not* being used in conjunction with
* the altKey modifier. If they are combined, the result is an `altGraph`
* key modifier, which should not be handled by this set of key bindings.
*/
isCtrlKeyCommand: function isCtrlKeyCommand(e) {
return !!e.ctrlKey && !e.altKey;
},
isOptionKeyCommand: function isOptionKeyCommand(e) {
return isOSX && e.altKey;
},
hasCommandModifier: function hasCommandModifier(e) {
return isOSX ? !!e.metaKey && !e.altKey : KeyBindingUtil.isCtrlKeyCommand(e);
}
};
module.exports = KeyBindingUtil;
/***/ },
/* 111 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule findAncestorOffsetKey
* @typechecks
*
*/
'use strict';
var getSelectionOffsetKeyForNode = __webpack_require__(185);
/**
* Get the key from the node's nearest offset-aware ancestor.
*/
function findAncestorOffsetKey(node) {
var searchNode = node;
while (searchNode && searchNode !== document.documentElement) {
var key = getSelectionOffsetKeyForNode(searchNode);
if (key != null) {
return key;
}
searchNode = searchNode.parentNode;
}
return null;
}
module.exports = findAncestorOffsetKey;
/***/ },
/* 112 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getEntityKeyForSelection
* @typechecks
*
*/
'use strict';
/**
* Return the entity key that should be used when inserting text for the
* specified target selection, only if the entity is `MUTABLE`. `IMMUTABLE`
* and `SEGMENTED` entities should not be used for insertion behavior.
*/
function getEntityKeyForSelection(contentState, targetSelection) {
var entityKey;
if (targetSelection.isCollapsed()) {
var key = targetSelection.getAnchorKey();
var offset = targetSelection.getAnchorOffset();
if (offset > 0) {
entityKey = contentState.getBlockForKey(key).getEntityAt(offset - 1);
return filterKey(contentState.getEntityMap(), entityKey);
}
return null;
}
var startKey = targetSelection.getStartKey();
var startOffset = targetSelection.getStartOffset();
var startBlock = contentState.getBlockForKey(startKey);
entityKey = startOffset === startBlock.getLength() ? null : startBlock.getEntityAt(startOffset);
return filterKey(contentState.getEntityMap(), entityKey);
}
/**
* Determine whether an entity key corresponds to a `MUTABLE` entity. If so,
* return it. If not, return null.
*/
function filterKey(entityMap, entityKey) {
if (entityKey) {
var entity = entityMap.__get(entityKey);
return entity.getMutability() === 'MUTABLE' ? entityKey : null;
}
return null;
}
module.exports = getEntityKeyForSelection;
/***/ },
/* 113 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule moveSelectionBackward
*
*/
'use strict';
/**
* Given a collapsed selection, move the focus `maxDistance` backward within
* the selected block. If the selection will go beyond the start of the block,
* move focus to the end of the previous block, but no further.
*
* This function is not Unicode-aware, so surrogate pairs will be treated
* as having length 2.
*/
function moveSelectionBackward(editorState, maxDistance) {
var selection = editorState.getSelection();
var content = editorState.getCurrentContent();
var key = selection.getStartKey();
var offset = selection.getStartOffset();
var focusKey = key;
var focusOffset = 0;
if (maxDistance > offset) {
var keyBefore = content.getKeyBefore(key);
if (keyBefore == null) {
focusKey = key;
} else {
focusKey = keyBefore;
var blockBefore = content.getBlockForKey(keyBefore);
focusOffset = blockBefore.getText().length;
}
} else {
focusOffset = offset - maxDistance;
}
return selection.merge({
focusKey: focusKey,
focusOffset: focusOffset,
isBackward: true
});
}
module.exports = moveSelectionBackward;
/***/ },
/* 114 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule sanitizeDraftText
*
*/
'use strict';
var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
function sanitizeDraftText(input) {
return input.replace(REGEX_BLOCK_DELIMITER, '');
}
module.exports = sanitizeDraftText;
/***/ },
/* 115 */
/***/ function(module, exports) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
module.exports = {
BACKSPACE: 8,
TAB: 9,
RETURN: 13,
ALT: 18,
ESC: 27,
SPACE: 32,
PAGE_UP: 33,
PAGE_DOWN: 34,
END: 35,
HOME: 36,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
COMMA: 188,
PERIOD: 190,
A: 65,
Z: 90,
ZERO: 48,
NUMPAD_0: 96,
NUMPAD_9: 105
};
/***/ },
/* 116 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
var getStyleProperty = __webpack_require__(505);
/**
* @param {DOMNode} element [description]
* @param {string} name Overflow style property name.
* @return {boolean} True if the supplied ndoe is scrollable.
*/
function _isNodeScrollable(element, name) {
var overflow = Style.get(element, name);
return overflow === 'auto' || overflow === 'scroll';
}
/**
* Utilities for querying and mutating style properties.
*/
var Style = {
/**
* Gets the style property for the supplied node. This will return either the
* computed style, if available, or the declared style.
*
* @param {DOMNode} node
* @param {string} name Style property name.
* @return {?string} Style property value.
*/
get: getStyleProperty,
/**
* Determines the nearest ancestor of a node that is scrollable.
*
* NOTE: This can be expensive if used repeatedly or on a node nested deeply.
*
* @param {?DOMNode} node Node from which to start searching.
* @return {?DOMWindow|DOMElement} Scroll parent of the supplied node.
*/
getScrollParent: function getScrollParent(node) {
if (!node) {
return null;
}
var ownerDocument = node.ownerDocument;
while (node && node !== ownerDocument.body) {
if (_isNodeScrollable(node, 'overflow') || _isNodeScrollable(node, 'overflowY') || _isNodeScrollable(node, 'overflowX')) {
return node;
}
node = node.parentNode;
}
return ownerDocument.defaultView || ownerDocument.parentWindow;
}
};
module.exports = Style;
/***/ },
/* 117 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*
*/
/**
* Constants to represent text directionality
*
* Also defines a *global* direciton, to be used in bidi algorithms as a
* default fallback direciton, when no better direction is found or provided.
*
* NOTE: Use `setGlobalDir()`, or update `initGlobalDir()`, to set the initial
* global direction value based on the application.
*
* Part of the implementation of Unicode Bidirectional Algorithm (UBA)
* Unicode Standard Annex #9 (UAX9)
* http://www.unicode.org/reports/tr9/
*/
'use strict';
var invariant = __webpack_require__(16);
var NEUTRAL = 'NEUTRAL'; // No strong direction
var LTR = 'LTR'; // Left-to-Right direction
var RTL = 'RTL'; // Right-to-Left direction
var globalDir = null;
// == Helpers ==
/**
* Check if a directionality value is a Strong one
*/
function isStrong(dir) {
return dir === LTR || dir === RTL;
}
/**
* Get string value to be used for `dir` HTML attribute or `direction` CSS
* property.
*/
function getHTMLDir(dir) {
!isStrong(dir) ? true ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
return dir === LTR ? 'ltr' : 'rtl';
}
/**
* Get string value to be used for `dir` HTML attribute or `direction` CSS
* property, but returns null if `dir` has same value as `otherDir`.
* `null`.
*/
function getHTMLDirIfDifferent(dir, otherDir) {
!isStrong(dir) ? true ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
!isStrong(otherDir) ? true ? invariant(false, '`otherDir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0;
return dir === otherDir ? null : getHTMLDir(dir);
}
// == Global Direction ==
/**
* Set the global direction.
*/
function setGlobalDir(dir) {
globalDir = dir;
}
/**
* Initialize the global direction
*/
function initGlobalDir() {
setGlobalDir(LTR);
}
/**
* Get the global direction
*/
function getGlobalDir() {
if (!globalDir) {
this.initGlobalDir();
}
!globalDir ? true ? invariant(false, 'Global direction not set.') : invariant(false) : void 0;
return globalDir;
}
var UnicodeBidiDirection = {
// Values
NEUTRAL: NEUTRAL,
LTR: LTR,
RTL: RTL,
// Helpers
isStrong: isStrong,
getHTMLDir: getHTMLDir,
getHTMLDirIfDifferent: getHTMLDirIfDifferent,
// Global Direction
setGlobalDir: setGlobalDir,
initGlobalDir: initGlobalDir,
getGlobalDir: getGlobalDir
};
module.exports = UnicodeBidiDirection;
/***/ },
/* 118 */
/***/ function(module, exports) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
function makeEmptyFunction(arg) {
return function () {
return arg;
};
}
/**
* This function accepts and discards inputs; it has no side effects. This is
* primarily useful idiomatically for overridable function endpoints which
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
*/
var emptyFunction = function emptyFunction() {};
emptyFunction.thatReturns = makeEmptyFunction;
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
emptyFunction.thatReturnsThis = function () {
return this;
};
emptyFunction.thatReturnsArgument = function (arg) {
return arg;
};
module.exports = emptyFunction;
/***/ },
/* 119 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
'use strict';
var getDocumentScrollElement = __webpack_require__(502);
var getUnboundedScrollPosition = __webpack_require__(506);
/**
* Gets the scroll position of the supplied element or window.
*
* The return values are bounded. This means that if the scroll position is
* negative or exceeds the element boundaries (which is possible using inertial
* scrolling), you will get zero or the maximum scroll position, respectively.
*
* If you need the unbound scroll position, use `getUnboundedScrollPosition`.
*
* @param {DOMWindow|DOMElement} scrollable
* @return {object} Map with `x` and `y` keys.
*/
function getScrollPosition(scrollable) {
var documentScrollElement = getDocumentScrollElement(scrollable.ownerDocument || scrollable.document);
if (scrollable.Window && scrollable instanceof scrollable.Window) {
scrollable = documentScrollElement;
}
var scrollPosition = getUnboundedScrollPosition(scrollable);
var viewport = scrollable === documentScrollElement ? scrollable.ownerDocument.documentElement : scrollable;
var xMax = scrollable.scrollWidth - viewport.clientWidth;
var yMax = scrollable.scrollHeight - viewport.clientHeight;
scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax));
scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax));
return scrollPosition;
}
module.exports = getScrollPosition;
/***/ },
/* 120 */
/***/ function(module, exports) {
/* WEBPACK VAR INJECTION */(function(global) {/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/** `Object#toString` result references. */
var symbolTag = '[object Symbol]';
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Gets the timestamp of the number of milliseconds that have elapsed since
* the Unix epoch (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Date
* @returns {number} Returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = function() {
return root.Date.now();
};
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
result = wait - timeSinceLastCall;
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
}
/**
* Converts `value` to a number.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {number} Returns the number.
* @example
*
* _.toNumber(3.2);
* // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
*
* _.toNumber(Infinity);
* // => Infinity
*
* _.toNumber('3.2');
* // => 3.2
*/
function toNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? (other + '') : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, '');
var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value);
}
module.exports = debounce;
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ },
/* 121 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _DateTHead = __webpack_require__(536);
var _DateTHead2 = _interopRequireDefault(_DateTHead);
var _DateTBody = __webpack_require__(535);
var _DateTBody2 = _interopRequireDefault(_DateTBody);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var DateTable = function (_React$Component) {
(0, _inherits3["default"])(DateTable, _React$Component);
function DateTable() {
(0, _classCallCheck3["default"])(this, DateTable);
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
}
DateTable.prototype.render = function render() {
var props = this.props;
var prefixCls = props.prefixCls;
return _react2["default"].createElement(
'table',
{ className: prefixCls + '-table', cellSpacing: '0', role: 'grid' },
_react2["default"].createElement(_DateTHead2["default"], props),
_react2["default"].createElement(_DateTBody2["default"], props)
);
};
return DateTable;
}(_react2["default"].Component);
exports["default"] = DateTable;
module.exports = exports['default'];
/***/ },
/* 122 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _moment = __webpack_require__(14);
var _moment2 = _interopRequireDefault(_moment);
var _index = __webpack_require__(31);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function noop() {}
function getNow() {
return (0, _moment2["default"])();
}
function getNowByCurrentStateValue(value) {
var ret = void 0;
if (value) {
ret = (0, _index.getTodayTime)(value);
} else {
ret = getNow();
}
return ret;
}
var CalendarMixin = {
propTypes: {
value: _react.PropTypes.object,
defaultValue: _react.PropTypes.object,
onKeyDown: _react.PropTypes.func
},
getDefaultProps: function getDefaultProps() {
return {
onKeyDown: noop
};
},
getInitialState: function getInitialState() {
var props = this.props;
var value = props.value || props.defaultValue || getNow();
return {
value: value,
selectedValue: props.selectedValue || props.defaultSelectedValue
};
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var value = nextProps.value;
var selectedValue = nextProps.selectedValue;
if ('value' in nextProps) {
value = value || nextProps.defaultValue || getNowByCurrentStateValue(this.state.value);
this.setState({
value: value
});
}
if ('selectedValue' in nextProps) {
this.setState({
selectedValue: selectedValue
});
}
},
onSelect: function onSelect(value, cause) {
if (value) {
this.setValue(value);
}
this.setSelectedValue(value, cause);
},
renderRoot: function renderRoot(newProps) {
var _className;
var props = this.props;
var prefixCls = props.prefixCls;
var className = (_className = {}, (0, _defineProperty3["default"])(_className, prefixCls, 1), (0, _defineProperty3["default"])(_className, prefixCls + '-hidden', !props.visible), (0, _defineProperty3["default"])(_className, props.className, !!props.className), (0, _defineProperty3["default"])(_className, newProps.className, !!newProps.className), _className);
return _react2["default"].createElement(
'div',
{
ref: 'root',
className: '' + (0, _classnames2["default"])(className),
style: this.props.style,
tabIndex: '0',
onKeyDown: this.onKeyDown
},
newProps.children
);
},
setSelectedValue: function setSelectedValue(selectedValue, cause) {
// if (this.isAllowedDate(selectedValue)) {
if (!('selectedValue' in this.props)) {
this.setState({
selectedValue: selectedValue
});
}
this.props.onSelect(selectedValue, cause);
// }
},
setValue: function setValue(value) {
var originalValue = this.state.value;
if (!('value' in this.props)) {
this.setState({
value: value
});
}
if (originalValue && value && !originalValue.isSame(value) || !originalValue && value || originalValue && !value) {
this.props.onChange(value);
}
},
isAllowedDate: function isAllowedDate(value) {
var disabledDate = this.props.disabledDate;
var disabledTime = this.props.disabledTime;
return (0, _index.isAllowedDate)(value, disabledDate, disabledTime);
}
};
exports["default"] = CalendarMixin;
module.exports = exports['default'];
/***/ },
/* 123 */
82,
/* 124 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exportContent;
var _draftJs = __webpack_require__(48);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function encodeContent(text) {
return text.split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;').split('\xA0').join('&nbsp;').split('\n').join('<br > \n');
}
var MentionGenerator = function () {
function MentionGenerator(contentState, options) {
_classCallCheck(this, MentionGenerator);
this.contentState = contentState;
this.options = options;
}
MentionGenerator.prototype.generate = function generate() {
var contentRaw = (0, _draftJs.convertToRaw)(this.contentState);
return this.processContent(contentRaw);
};
MentionGenerator.prototype.processContent = function processContent(contentRaw) {
var blocks = contentRaw.blocks;
var encode = this.options.encode;
return blocks.map(function (block) {
return encode ? encodeContent(block.text) : block.text;
}).join(encode ? '<br />\n' : '\n');
};
return MentionGenerator;
}();
function exportContent(editorState) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var content = editorState.getCurrentContent();
return new MentionGenerator(content, options).generate();
}
module.exports = exports['default'];
/***/ },
/* 125 */
/***/ function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = getSearchWord;
function getWord(text, position) {
var str = String(text);
/* eslint no-bitwise:0 */
var pos = Number(position) >>> 0;
// Search for the word's beginning and end.
var left = str.slice(0, pos + 1).search(/\S+$/);
var right = str.slice(pos).search(/\s/);
if (right < 0) {
return {
word: str.slice(left),
begin: left,
end: str.length
};
}
// Return the word, using the located bounds to extract it from the string.
return {
word: str.slice(left, right + pos),
begin: left,
end: right + pos
};
}
function getSearchWord(editorState, selection) {
var anchorKey = selection.getAnchorKey();
var anchorOffset = selection.getAnchorOffset() - 1;
var currentContent = editorState.getCurrentContent();
var currentBlock = currentContent.getBlockForKey(anchorKey);
var blockText = currentBlock.getText();
return getWord(blockText, anchorOffset);
}
module.exports = exports['default'];
/***/ },
/* 126 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _toConsumableArray2 = __webpack_require__(34);
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
exports.isEventFromHandle = isEventFromHandle;
exports.isValueOutOfRange = isValueOutOfRange;
exports.isNotTouchEvent = isNotTouchEvent;
exports.getClosestPoint = getClosestPoint;
exports.getPrecision = getPrecision;
exports.getMousePosition = getMousePosition;
exports.getTouchPosition = getTouchPosition;
exports.getHandleCenterPosition = getHandleCenterPosition;
exports.ensureValueInRange = ensureValueInRange;
exports.ensureValuePrecision = ensureValuePrecision;
exports.pauseEvent = pauseEvent;
var _reactDom = __webpack_require__(9);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function isEventFromHandle(e, handles) {
return Object.keys(handles).some(function (key) {
return e.target === (0, _reactDom.findDOMNode)(handles[key]);
});
}
function isValueOutOfRange(value, _ref) {
var min = _ref.min,
max = _ref.max;
return value < min || value > max;
}
function isNotTouchEvent(e) {
return e.touches.length > 1 || e.type.toLowerCase() === 'touchend' && e.touches.length > 0;
}
function getClosestPoint(val, _ref2) {
var marks = _ref2.marks,
step = _ref2.step,
min = _ref2.min;
var points = Object.keys(marks).map(parseFloat);
if (step !== null) {
var closestStep = Math.round((val - min) / step) * step + min;
points.push(closestStep);
}
var diffs = points.map(function (point) {
return Math.abs(val - point);
});
return points[diffs.indexOf(Math.min.apply(Math, (0, _toConsumableArray3["default"])(diffs)))];
}
function getPrecision(step) {
var stepString = step.toString();
var precision = 0;
if (stepString.indexOf('.') >= 0) {
precision = stepString.length - stepString.indexOf('.') - 1;
}
return precision;
}
function getMousePosition(vertical, e) {
return vertical ? e.clientY : e.pageX;
}
function getTouchPosition(vertical, e) {
return vertical ? e.touches[0].clientY : e.touches[0].pageX;
}
function getHandleCenterPosition(vertical, handle) {
var coords = handle.getBoundingClientRect();
return vertical ? coords.top + coords.height * 0.5 : coords.left + coords.width * 0.5;
}
function ensureValueInRange(val, _ref3) {
var max = _ref3.max,
min = _ref3.min;
if (val <= min) {
return min;
}
if (val >= max) {
return max;
}
return val;
}
function ensureValuePrecision(val, props) {
var step = props.step;
var closestPoint = getClosestPoint(val, props);
return step === null ? closestPoint : parseFloat(closestPoint.toFixed(getPrecision(step)));
}
function pauseEvent(e) {
e.stopPropagation();
e.preventDefault();
}
/***/ },
/* 127 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var Table = __webpack_require__(629);
var Column = __webpack_require__(625);
var ColumnGroup = __webpack_require__(626);
Table.Column = Column;
Table.ColumnGroup = ColumnGroup;
module.exports = Table;
/***/ },
/* 128 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
exports.toArray = toArray;
exports.getActiveIndex = getActiveIndex;
exports.getActiveKey = getActiveKey;
exports.setTransform = setTransform;
exports.isTransformSupported = isTransformSupported;
exports.setTransition = setTransition;
exports.getTransformPropValue = getTransformPropValue;
exports.isVertical = isVertical;
exports.getTransformByIndex = getTransformByIndex;
exports.getMarginStyle = getMarginStyle;
exports.getStyle = getStyle;
exports.setPxStyle = setPxStyle;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function toArray(children) {
// allow [c,[a,b]]
var c = [];
_react2["default"].Children.forEach(children, function (child) {
if (child) {
c.push(child);
}
});
return c;
}
function getActiveIndex(children, activeKey) {
var c = toArray(children);
for (var i = 0; i < c.length; i++) {
if (c[i].key === activeKey) {
return i;
}
}
return -1;
}
function getActiveKey(children, index) {
var c = toArray(children);
return c[index].key;
}
function setTransform(style, v) {
style.transform = v;
style.webkitTransform = v;
style.mozTransform = v;
}
function isTransformSupported(style) {
return 'transform' in style || 'webkitTransform' in style || 'MozTransform' in style;
}
function setTransition(style, v) {
style.transition = v;
style.webkitTransition = v;
style.MozTransition = v;
}
function getTransformPropValue(v) {
return {
transform: v,
WebkitTransform: v,
MozTransform: v
};
}
function isVertical(tabBarPosition) {
return tabBarPosition === 'left' || tabBarPosition === 'right';
}
function getTransformByIndex(index, tabBarPosition) {
var translate = isVertical(tabBarPosition) ? 'translateY' : 'translateX';
return translate + '(' + -index * 100 + '%) translateZ(0)';
}
function getMarginStyle(index, tabBarPosition) {
var marginDirection = isVertical(tabBarPosition) ? 'marginTop' : 'marginLeft';
return (0, _defineProperty3["default"])({}, marginDirection, -index * 100 + '%');
}
function getStyle(el, property) {
return +getComputedStyle(el).getPropertyValue(property).replace('px', '');
}
function setPxStyle(el, property, value) {
el.style[property] = value + 'px';
}
/***/ },
/* 129 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = toArray;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function toArray(children) {
var ret = [];
_react2["default"].Children.forEach(children, function (c) {
ret.push(c);
});
return ret;
}
module.exports = exports['default'];
/***/ },
/* 130 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(9);
var _reactDom2 = _interopRequireDefault(_reactDom);
var _trackHelper = __webpack_require__(246);
var _objectAssign = __webpack_require__(8);
var _objectAssign2 = _interopRequireDefault(_objectAssign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var helpers = {
initialize: function initialize(props) {
var slickList = _reactDom2["default"].findDOMNode(this.list);
var slideCount = _react2["default"].Children.count(props.children);
var listWidth = this.getWidth(slickList);
var trackWidth = this.getWidth(_reactDom2["default"].findDOMNode(this.track));
var slideWidth;
if (!props.vertical) {
var centerPaddingAdj = props.centerMode && parseInt(props.centerPadding) * 2;
slideWidth = (this.getWidth(_reactDom2["default"].findDOMNode(this)) - centerPaddingAdj) / props.slidesToShow;
} else {
slideWidth = this.getWidth(_reactDom2["default"].findDOMNode(this));
}
var slideHeight = this.getHeight(slickList.querySelector('[data-index="0"]'));
var listHeight = slideHeight * props.slidesToShow;
var currentSlide = props.rtl ? slideCount - 1 - props.initialSlide : props.initialSlide;
this.setState({
slideCount: slideCount,
slideWidth: slideWidth,
listWidth: listWidth,
trackWidth: trackWidth,
currentSlide: currentSlide,
slideHeight: slideHeight,
listHeight: listHeight
}, function () {
var targetLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2["default"])({
slideIndex: this.state.currentSlide,
trackRef: this.track
}, props, this.state));
// getCSS function needs previously set state
var trackStyle = (0, _trackHelper.getTrackCSS)((0, _objectAssign2["default"])({ left: targetLeft }, props, this.state));
this.setState({ trackStyle: trackStyle });
this.autoPlay(); // once we're set up, trigger the initial autoplay.
});
},
update: function update(props) {
var slickList = _reactDom2["default"].findDOMNode(this.list);
// This method has mostly same code as initialize method.
// Refactor it
var slideCount = _react2["default"].Children.count(props.children);
var listWidth = this.getWidth(slickList);
var trackWidth = this.getWidth(_reactDom2["default"].findDOMNode(this.track));
var slideWidth;
if (!props.vertical) {
var centerPaddingAdj = props.centerMode && parseInt(props.centerPadding) * 2;
slideWidth = (this.getWidth(_reactDom2["default"].findDOMNode(this)) - centerPaddingAdj) / props.slidesToShow;
} else {
slideWidth = this.getWidth(_reactDom2["default"].findDOMNode(this));
}
var slideHeight = this.getHeight(slickList.querySelector('[data-index="0"]'));
var listHeight = slideHeight * props.slidesToShow;
// pause slider if autoplay is set to false
if (props.autoplay) {
this.pause();
} else {
this.autoPlay();
}
this.setState({
slideCount: slideCount,
slideWidth: slideWidth,
listWidth: listWidth,
trackWidth: trackWidth,
slideHeight: slideHeight,
listHeight: listHeight
}, function () {
var targetLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2["default"])({
slideIndex: this.state.currentSlide,
trackRef: this.track
}, props, this.state));
// getCSS function needs previously set state
var trackStyle = (0, _trackHelper.getTrackCSS)((0, _objectAssign2["default"])({ left: targetLeft }, props, this.state));
this.setState({ trackStyle: trackStyle });
});
},
getWidth: function getWidth(elem) {
return elem.getBoundingClientRect().width || elem.offsetWidth || 0;
},
getHeight: function getHeight(elem) {
return elem.getBoundingClientRect().height || elem.offsetHeight || 0;
},
adaptHeight: function adaptHeight() {
if (this.props.adaptiveHeight) {
var selector = '[data-index="' + this.state.currentSlide + '"]';
if (this.list) {
var slickList = _reactDom2["default"].findDOMNode(this.list);
slickList.style.height = slickList.querySelector(selector).offsetHeight + 'px';
}
}
},
canGoNext: function canGoNext(opts) {
var canGo = true;
if (!opts.infinite) {
if (opts.centerMode) {
// check if current slide is last slide
if (opts.currentSlide >= opts.slideCount - 1) {
canGo = false;
}
} else {
// check if all slides are shown in slider
if (opts.slideCount <= opts.slidesToShow || opts.currentSlide >= opts.slideCount - opts.slidesToShow) {
canGo = false;
}
}
}
return canGo;
},
slideHandler: function slideHandler(index) {
var _this = this;
// Functionality of animateSlide and postSlide is merged into this function
// console.log('slideHandler', index);
var targetSlide, currentSlide;
var targetLeft, currentLeft;
var callback;
if (this.props.waitForAnimate && this.state.animating) {
return;
}
if (this.props.fade) {
currentSlide = this.state.currentSlide;
// Don't change slide if it's not infite and current slide is the first or last slide.
if (this.props.infinite === false && (index < 0 || index >= this.state.slideCount)) {
return;
}
// Shifting targetSlide back into the range
if (index < 0) {
targetSlide = index + this.state.slideCount;
} else if (index >= this.state.slideCount) {
targetSlide = index - this.state.slideCount;
} else {
targetSlide = index;
}
if (this.props.lazyLoad && this.state.lazyLoadedList.indexOf(targetSlide) < 0) {
this.setState({
lazyLoadedList: this.state.lazyLoadedList.concat(targetSlide)
});
}
callback = function callback() {
_this.setState({
animating: false
});
if (_this.props.afterChange) {
_this.props.afterChange(targetSlide);
}
delete _this.animationEndCallback;
};
this.setState({
animating: true,
currentSlide: targetSlide
}, function () {
this.animationEndCallback = setTimeout(callback, this.props.speed);
});
if (this.props.beforeChange) {
this.props.beforeChange(this.state.currentSlide, targetSlide);
}
this.autoPlay();
return;
}
targetSlide = index;
if (targetSlide < 0) {
if (this.props.infinite === false) {
currentSlide = 0;
} else if (this.state.slideCount % this.props.slidesToScroll !== 0) {
currentSlide = this.state.slideCount - this.state.slideCount % this.props.slidesToScroll;
} else {
currentSlide = this.state.slideCount + targetSlide;
}
} else if (targetSlide >= this.state.slideCount) {
if (this.props.infinite === false) {
currentSlide = this.state.slideCount - this.props.slidesToShow;
} else if (this.state.slideCount % this.props.slidesToScroll !== 0) {
currentSlide = 0;
} else {
currentSlide = targetSlide - this.state.slideCount;
}
} else {
currentSlide = targetSlide;
}
targetLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2["default"])({
slideIndex: targetSlide,
trackRef: this.track
}, this.props, this.state));
currentLeft = (0, _trackHelper.getTrackLeft)((0, _objectAssign2["default"])({
slideIndex: currentSlide,
trackRef: this.track
}, this.props, this.state));
if (this.props.infinite === false) {
targetLeft = currentLeft;
}
if (this.props.beforeChange) {
this.props.beforeChange(this.state.currentSlide, currentSlide);
}
if (this.props.lazyLoad) {
var loaded = true;
var slidesToLoad = [];
for (var i = targetSlide; i < targetSlide + this.props.slidesToShow; i++) {
loaded = loaded && this.state.lazyLoadedList.indexOf(i) >= 0;
if (!loaded) {
slidesToLoad.push(i);
}
}
if (!loaded) {
this.setState({
lazyLoadedList: this.state.lazyLoadedList.concat(slidesToLoad)
});
}
}
// Slide Transition happens here.
// animated transition happens to target Slide and
// non - animated transition happens to current Slide
// If CSS transitions are false, directly go the current slide.
if (this.props.useCSS === false) {
this.setState({
currentSlide: currentSlide,
trackStyle: (0, _trackHelper.getTrackCSS)((0, _objectAssign2["default"])({ left: currentLeft }, this.props, this.state))
}, function () {
if (this.props.afterChange) {
this.props.afterChange(currentSlide);
}
});
} else {
var nextStateChanges = {
animating: false,
currentSlide: currentSlide,
trackStyle: (0, _trackHelper.getTrackCSS)((0, _objectAssign2["default"])({ left: currentLeft }, this.props, this.state)),
swipeLeft: null
};
callback = function callback() {
_this.setState(nextStateChanges);
if (_this.props.afterChange) {
_this.props.afterChange(currentSlide);
}
delete _this.animationEndCallback;
};
this.setState({
animating: true,
currentSlide: currentSlide,
trackStyle: (0, _trackHelper.getTrackAnimateCSS)((0, _objectAssign2["default"])({ left: targetLeft }, this.props, this.state))
}, function () {
this.animationEndCallback = setTimeout(callback, this.props.speed);
});
}
this.autoPlay();
},
swipeDirection: function swipeDirection(touchObject) {
var xDist, yDist, r, swipeAngle;
xDist = touchObject.startX - touchObject.curX;
yDist = touchObject.startY - touchObject.curY;
r = Math.atan2(yDist, xDist);
swipeAngle = Math.round(r * 180 / Math.PI);
if (swipeAngle < 0) {
swipeAngle = 360 - Math.abs(swipeAngle);
}
if (swipeAngle <= 45 && swipeAngle >= 0 || swipeAngle <= 360 && swipeAngle >= 315) {
return this.props.rtl === false ? 'left' : 'right';
}
if (swipeAngle >= 135 && swipeAngle <= 225) {
return this.props.rtl === false ? 'right' : 'left';
}
if (this.props.verticalSwiping === true) {
if (swipeAngle >= 35 && swipeAngle <= 135) {
return 'down';
} else {
return 'up';
}
}
return 'vertical';
},
play: function play() {
var nextIndex;
if (!this.state.mounted) {
return false;
}
if (this.props.rtl) {
nextIndex = this.state.currentSlide - this.props.slidesToScroll;
} else {
if (this.canGoNext(_extends({}, this.props, this.state))) {
nextIndex = this.state.currentSlide + this.props.slidesToScroll;
} else {
return false;
}
}
this.slideHandler(nextIndex);
},
autoPlay: function autoPlay() {
if (this.state.autoPlayTimer) {
clearTimeout(this.state.autoPlayTimer);
}
if (this.props.autoplay) {
this.setState({
autoPlayTimer: setTimeout(this.play, this.props.autoplaySpeed)
});
}
},
pause: function pause() {
if (this.state.autoPlayTimer) {
clearTimeout(this.state.autoPlayTimer);
this.setState({
autoPlayTimer: null
});
}
}
};
exports["default"] = helpers;
/***/ },
/* 131 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = addEventListener;
var _EventObject = __webpack_require__(249);
var _EventObject2 = _interopRequireDefault(_EventObject);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function addEventListener(target, eventType, callback) {
function wrapCallback(e) {
var ne = new _EventObject2["default"](e);
callback.call(target, ne);
}
if (target.addEventListener) {
target.addEventListener(eventType, wrapCallback, false);
return {
remove: function remove() {
target.removeEventListener(eventType, wrapCallback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent('on' + eventType, wrapCallback);
return {
remove: function remove() {
target.detachEvent('on' + eventType, wrapCallback);
}
};
}
}
module.exports = exports['default'];
/***/ },
/* 132 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _util = __webpack_require__(15);
var util = _interopRequireWildcard(_util);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
/**
* Rule for validating required fields.
*
* @param rule The validation rule.
* @param value The value of the field on the source object.
* @param source The source object being validated.
* @param errors An array of errors that this rule may add
* validation errors to.
* @param options The validation options.
* @param options.messages The validation messages.
*/
function required(rule, value, source, errors, options, type) {
if (rule.required && (!source.hasOwnProperty(rule.field) || util.isEmptyValue(value, type || rule.type))) {
errors.push(util.format(options.messages.required, rule.fullField));
}
}
exports["default"] = required;
module.exports = exports['default'];
/***/ },
/* 133 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _typeof2 = __webpack_require__(26);
var _typeof3 = _interopRequireDefault(_typeof2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(9);
var _reactDom2 = _interopRequireDefault(_reactDom);
var _addEventListener = __webpack_require__(32);
var _addEventListener2 = _interopRequireDefault(_addEventListener);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _shallowequal = __webpack_require__(33);
var _shallowequal2 = _interopRequireDefault(_shallowequal);
var _omit = __webpack_require__(22);
var _omit2 = _interopRequireDefault(_omit);
var _getScroll = __webpack_require__(86);
var _getScroll2 = _interopRequireDefault(_getScroll);
var _throttleByAnimationFrame = __webpack_require__(273);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var __decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if ((typeof Reflect === "undefined" ? "undefined" : (0, _typeof3["default"])(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
}return c > 3 && r && Object.defineProperty(target, key, r), r;
};
function getTargetRect(target) {
return target !== window ? target.getBoundingClientRect() : { top: 0, left: 0, bottom: 0 };
}
function getOffset(element, target) {
var elemRect = element.getBoundingClientRect();
var targetRect = getTargetRect(target);
var scrollTop = (0, _getScroll2["default"])(target, true);
var scrollLeft = (0, _getScroll2["default"])(target, false);
var docElem = window.document.body;
var clientTop = docElem.clientTop || 0;
var clientLeft = docElem.clientLeft || 0;
return {
top: elemRect.top - targetRect.top + scrollTop - clientTop,
left: elemRect.left - targetRect.left + scrollLeft - clientLeft,
width: elemRect.width,
height: elemRect.height
};
}
function noop() {}
function getDefaultTarget() {
return typeof window !== 'undefined' ? window : null;
}
;
var Affix = function (_React$Component) {
(0, _inherits3["default"])(Affix, _React$Component);
function Affix(props) {
(0, _classCallCheck3["default"])(this, Affix);
var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.call(this, props));
_this.state = {
affixStyle: null,
placeholderStyle: null
};
return _this;
}
Affix.prototype.setAffixStyle = function setAffixStyle(e, affixStyle) {
var _this2 = this;
var _props = this.props,
_props$onChange = _props.onChange,
onChange = _props$onChange === undefined ? noop : _props$onChange,
_props$target = _props.target,
target = _props$target === undefined ? getDefaultTarget : _props$target;
var originalAffixStyle = this.state.affixStyle;
var isWindow = target() === window;
if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) {
return;
}
if ((0, _shallowequal2["default"])(affixStyle, originalAffixStyle)) {
return;
}
this.setState({ affixStyle: affixStyle }, function () {
var affixed = !!_this2.state.affixStyle;
if (affixStyle && !originalAffixStyle || !affixStyle && originalAffixStyle) {
onChange(affixed);
}
});
};
Affix.prototype.setPlaceholderStyle = function setPlaceholderStyle(placeholderStyle) {
var originalPlaceholderStyle = this.state.placeholderStyle;
if ((0, _shallowequal2["default"])(placeholderStyle, originalPlaceholderStyle)) {
return;
}
this.setState({ placeholderStyle: placeholderStyle });
};
Affix.prototype.updatePosition = function updatePosition(e) {
var _props2 = this.props,
offsetTop = _props2.offsetTop,
offsetBottom = _props2.offsetBottom,
offset = _props2.offset,
_props2$target = _props2.target,
target = _props2$target === undefined ? getDefaultTarget : _props2$target;
var targetNode = target();
// Backwards support
offsetTop = offsetTop || offset;
var scrollTop = (0, _getScroll2["default"])(targetNode, true);
var affixNode = _reactDom2["default"].findDOMNode(this);
var elemOffset = getOffset(affixNode, targetNode);
var elemSize = {
width: this.refs.fixedNode.offsetWidth,
height: this.refs.fixedNode.offsetHeight
};
var offsetMode = {
top: false,
bottom: false
};
// Default to `offsetTop=0`.
if (typeof offsetTop !== 'number' && typeof offsetBottom !== 'number') {
offsetMode.top = true;
offsetTop = 0;
} else {
offsetMode.top = typeof offsetTop === 'number';
offsetMode.bottom = typeof offsetBottom === 'number';
}
var targetRect = getTargetRect(targetNode);
var targetInnerHeight = targetNode.innerHeight || targetNode.clientHeight;
if (scrollTop > elemOffset.top - offsetTop && offsetMode.top) {
// Fixed Top
var width = elemOffset.width;
this.setAffixStyle(e, {
position: 'fixed',
top: targetRect.top + offsetTop,
left: targetRect.left + elemOffset.left,
width: width
});
this.setPlaceholderStyle({
width: width,
height: affixNode.offsetHeight
});
} else if (scrollTop < elemOffset.top + elemSize.height + offsetBottom - targetInnerHeight && offsetMode.bottom) {
// Fixed Bottom
var targetBottomOffet = targetNode === window ? 0 : window.innerHeight - targetRect.bottom;
var _width = elemOffset.width;
this.setAffixStyle(e, {
position: 'fixed',
bottom: targetBottomOffet + offsetBottom,
left: targetRect.left + elemOffset.left,
width: _width
});
this.setPlaceholderStyle({
width: _width,
height: affixNode.offsetHeight
});
} else {
var affixStyle = this.state.affixStyle;
if (e.type === 'resize' && affixStyle && affixStyle.position === 'fixed' && affixNode.offsetWidth) {
this.setAffixStyle(e, (0, _extends3["default"])({}, affixStyle, { width: affixNode.offsetWidth }));
} else {
this.setAffixStyle(e, null);
}
this.setPlaceholderStyle(null);
}
};
Affix.prototype.componentDidMount = function componentDidMount() {
var _this3 = this;
var target = this.props.target || getDefaultTarget;
// Wait for parent component ref has its value
this.timeout = setTimeout(function () {
_this3.setTargetEventListeners(target);
});
};
Affix.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (this.props.target !== nextProps.target) {
this.clearScrollEventListeners();
this.setTargetEventListeners(nextProps.target);
// Mock Event object.
this.updatePosition({});
}
};
Affix.prototype.componentWillUnmount = function componentWillUnmount() {
this.clearScrollEventListeners();
clearTimeout(this.timeout);
this.updatePosition.cancel();
};
Affix.prototype.setTargetEventListeners = function setTargetEventListeners(getTarget) {
var target = getTarget();
if (!target) {
return;
}
this.clearScrollEventListeners();
this.scrollEvent = (0, _addEventListener2["default"])(target, 'scroll', this.updatePosition);
this.resizeEvent = (0, _addEventListener2["default"])(target, 'resize', this.updatePosition);
};
Affix.prototype.clearScrollEventListeners = function clearScrollEventListeners() {
var _this4 = this;
['scrollEvent', 'resizeEvent'].forEach(function (name) {
if (_this4[name]) {
_this4[name].remove();
}
});
};
Affix.prototype.render = function render() {
var className = (0, _classnames2["default"])((0, _defineProperty3["default"])({}, this.props.prefixCls || 'ant-affix', this.state.affixStyle));
var props = (0, _omit2["default"])(this.props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target', 'onChange']);
var placeholderStyle = (0, _extends3["default"])({}, this.state.placeholderStyle, this.props.style);
return _react2["default"].createElement(
"div",
(0, _extends3["default"])({}, props, { style: placeholderStyle }),
_react2["default"].createElement(
"div",
{ className: className, ref: "fixedNode", style: this.state.affixStyle },
this.props.children
)
);
};
return Affix;
}(_react2["default"].Component);
exports["default"] = Affix;
Affix.propTypes = {
offsetTop: _react2["default"].PropTypes.number,
offsetBottom: _react2["default"].PropTypes.number,
target: _react2["default"].PropTypes.func
};
__decorate([(0, _throttleByAnimationFrame.throttleByAnimationFrameDecorator)()], Affix.prototype, "updatePosition", null);
module.exports = exports['default'];
/***/ },
/* 134 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.scrollTo = exports.easeInOutCubic = exports.reqAnimFrame = undefined;
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
exports.getDefaultTarget = getDefaultTarget;
exports.getOffsetTop = getOffsetTop;
var _getScroll = __webpack_require__(86);
var _getScroll2 = _interopRequireDefault(_getScroll);
var _getRequestAnimationFrame = __webpack_require__(67);
var _getRequestAnimationFrame2 = _interopRequireDefault(_getRequestAnimationFrame);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var reqAnimFrame = exports.reqAnimFrame = (0, _getRequestAnimationFrame2["default"])();
var easeInOutCubic = exports.easeInOutCubic = function easeInOutCubic(t, b, c, d) {
var cc = c - b;
t /= d / 2;
if (t < 1) {
return cc / 2 * t * t * t + b;
}
return cc / 2 * ((t -= 2) * t * t + 2) + b;
};
function getDefaultTarget() {
return typeof window !== 'undefined' ? window : null;
}
function getOffsetTop(element) {
if (!element) {
return 0;
}
if (!element.getClientRects().length) {
return 0;
}
var rect = element.getBoundingClientRect();
if (rect.width || rect.height) {
var doc = element.ownerDocument;
var docElem = doc.documentElement;
return rect.top - docElem.clientTop;
}
return rect.top;
}
function _scrollTo(href) {
var offsetTop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getDefaultTarget;
var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
var scrollTop = (0, _getScroll2["default"])(target(), true);
var targetElement = document.getElementById(href.substring(1));
if (!targetElement) {
return;
}
var eleOffsetTop = getOffsetTop(targetElement);
var targetScrollTop = scrollTop + eleOffsetTop - offsetTop;
var startTime = Date.now();
var frameFunc = function frameFunc() {
var timestamp = Date.now();
var time = timestamp - startTime;
window.scrollTo(window.pageXOffset, easeInOutCubic(time, scrollTop, targetScrollTop, 450));
if (time < 450) {
reqAnimFrame(frameFunc);
} else {
callback();
}
};
reqAnimFrame(frameFunc);
history.pushState(null, '', href);
}
exports.scrollTo = _scrollTo;
var AnchorHelper = function () {
function AnchorHelper() {
(0, _classCallCheck3["default"])(this, AnchorHelper);
this.links = [];
this.currentAnchor = null;
this._activeAnchor = '';
}
AnchorHelper.prototype.addLink = function addLink(link) {
if (this.links.indexOf(link) === -1) {
this.links.push(link);
}
};
AnchorHelper.prototype.getCurrentActiveAnchor = function getCurrentActiveAnchor() {
return this.currentAnchor;
};
AnchorHelper.prototype.setActiveAnchor = function setActiveAnchor(component) {
this.currentAnchor = component;
};
AnchorHelper.prototype.getCurrentAnchor = function getCurrentAnchor() {
var offsetTop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var bounds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
var activeAnchor = '';
if (typeof document === 'undefined') {
return activeAnchor;
}
var linksPositions = this.links.map(function (section) {
var target = document.getElementById(section.substring(1));
if (target && getOffsetTop(target) < offsetTop + bounds) {
var top = getOffsetTop(target);
if (top <= offsetTop + bounds) {
return {
section: section,
top: top,
bottom: top + target.clientHeight
};
}
}
return null;
}).filter(function (section) {
return section !== null;
});
if (linksPositions.length) {
var maxSection = linksPositions.reduce(function (prev, curr) {
return curr.top > prev.top ? curr : prev;
});
return maxSection.section;
}
return '';
};
AnchorHelper.prototype.scrollTo = function scrollTo(href, offsetTop) {
var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getDefaultTarget;
var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
_scrollTo(href, offsetTop, target, callback);
};
return AnchorHelper;
}();
exports["default"] = AnchorHelper;
/***/ },
/* 135 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var __rest = undefined && undefined.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}return t;
};
var BreadcrumbItem = function (_React$Component) {
(0, _inherits3["default"])(BreadcrumbItem, _React$Component);
function BreadcrumbItem() {
(0, _classCallCheck3["default"])(this, BreadcrumbItem);
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
}
BreadcrumbItem.prototype.render = function render() {
var _a = this.props,
prefixCls = _a.prefixCls,
separator = _a.separator,
children = _a.children,
restProps = __rest(_a, ["prefixCls", "separator", "children"]);
var link = void 0;
if ('href' in this.props) {
link = _react2["default"].createElement(
'a',
(0, _extends3["default"])({ className: prefixCls + '-link' }, restProps),
children
);
} else {
link = _react2["default"].createElement(
'span',
(0, _extends3["default"])({ className: prefixCls + '-link' }, restProps),
children
);
}
if (children) {
return _react2["default"].createElement(
'span',
null,
link,
_react2["default"].createElement(
'span',
{ className: prefixCls + '-separator' },
separator
)
);
}
return null;
};
return BreadcrumbItem;
}(_react2["default"].Component);
exports["default"] = BreadcrumbItem;
BreadcrumbItem.__ANT_BREADCRUMB_ITEM = true;
BreadcrumbItem.defaultProps = {
prefixCls: 'ant-breadcrumb',
separator: '/'
};
BreadcrumbItem.propTypes = {
prefixCls: _react.PropTypes.string,
separator: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.element]),
href: _react.PropTypes.string
};
module.exports = exports['default'];
/***/ },
/* 136 */,
/* 137 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var PREFIX_CLS = exports.PREFIX_CLS = 'ant-fullcalendar';
/***/ },
/* 138 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _zh_CN = __webpack_require__(142);
var _zh_CN2 = _interopRequireDefault(_zh_CN);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = _zh_CN2["default"];
module.exports = exports['default'];
/***/ },
/* 139 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _rcCheckbox = __webpack_require__(217);
var _rcCheckbox2 = _interopRequireDefault(_rcCheckbox);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _PureRenderMixin = __webpack_require__(43);
var _PureRenderMixin2 = _interopRequireDefault(_PureRenderMixin);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var __rest = undefined && undefined.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}return t;
};
var Checkbox = function (_React$Component) {
(0, _inherits3["default"])(Checkbox, _React$Component);
function Checkbox() {
(0, _classCallCheck3["default"])(this, Checkbox);
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
}
Checkbox.prototype.shouldComponentUpdate = function shouldComponentUpdate() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _PureRenderMixin2["default"].shouldComponentUpdate.apply(this, args);
};
Checkbox.prototype.render = function render() {
var _a = this.props,
prefixCls = _a.prefixCls,
style = _a.style,
children = _a.children,
className = _a.className,
indeterminate = _a.indeterminate,
onMouseEnter = _a.onMouseEnter,
onMouseLeave = _a.onMouseLeave,
restProps = __rest(_a, ["prefixCls", "style", "children", "className", "indeterminate", "onMouseEnter", "onMouseLeave"]);
var classString = (0, _classnames2["default"])(className, (0, _defineProperty3["default"])({}, prefixCls + '-wrapper', true));
var checkboxClass = (0, _classnames2["default"])((0, _defineProperty3["default"])({}, prefixCls + '-indeterminate', indeterminate));
return _react2["default"].createElement(
'label',
{ className: classString, style: style, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave },
_react2["default"].createElement(_rcCheckbox2["default"], (0, _extends3["default"])({}, restProps, { prefixCls: prefixCls, className: checkboxClass, children: null })),
children !== undefined ? _react2["default"].createElement(
'span',
null,
children
) : null
);
};
return Checkbox;
}(_react2["default"].Component);
exports["default"] = Checkbox;
Checkbox.defaultProps = {
prefixCls: 'ant-checkbox',
indeterminate: false
};
module.exports = exports['default'];
/***/ },
/* 140 */,
/* 141 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _grid = __webpack_require__(145);
exports["default"] = _grid.Col;
module.exports = exports['default'];
/***/ },
/* 142 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _zh_CN = __webpack_require__(212);
var _zh_CN2 = _interopRequireDefault(_zh_CN);
var _zh_CN3 = __webpack_require__(156);
var _zh_CN4 = _interopRequireDefault(_zh_CN3);
var _objectAssign = __webpack_require__(8);
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _moment = __webpack_require__(14);
var _moment2 = _interopRequireDefault(_moment);
__webpack_require__(523);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// å¤‡æ³¨ï¼šä»¥ä¸‹ä»£ç æ— æ³•å®Œå…¨æŒ‰æœ€åˆè®¾è®¡è¿è¡Œï¼Œä½†ä¸ºäº†ä¿è¯å…¼å®¹æ€§ï¼Œéœ€è¦ä¿ç•™ï¼Œç›´è‡³ antd 默认语言改为英文
// 1. å¦‚æžœç”¨æˆ·ä¸ç»™æ—¶é—´ç±»ç»„ä»¶ä¼ å…¥ value defaultValue,则运行符合预期
// 2. å¦‚æžœç”¨æˆ·ä¼ å…¥ value defaultValueï¼Œå› ä¸ºè¿™æ®µä»£ç æ²¡æœ‰åœ¨ç”¨æˆ·ä»£ç ä¹‹å‰è¿è¡Œï¼Œæ‰€ä»¥ç”¨æˆ·è°ƒç”¨ moment 时,默认语言依然为英文
// To set the default locale of moment to zh-cn globally.
_moment2["default"].locale('zh-cn');
// Merge into a locale object
var locale = {
lang: (0, _objectAssign2["default"])({
placeholder: '请选择日期',
rangePlaceholder: ['开始日期', '结束日期']
}, _zh_CN2["default"]),
timePickerLocale: (0, _objectAssign2["default"])({}, _zh_CN4["default"])
};
// should add whitespace between char in Button
locale.lang.ok = '确 定';
// All settings at:
// https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json
exports["default"] = locale;
module.exports = exports['default'];
/***/ },
/* 143 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _rcDropdown = __webpack_require__(555);
var _rcDropdown2 = _interopRequireDefault(_rcDropdown);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var Dropdown = function (_React$Component) {
(0, _inherits3["default"])(Dropdown, _React$Component);
function Dropdown() {
(0, _classCallCheck3["default"])(this, Dropdown);
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
}
Dropdown.prototype.getTransitionName = function getTransitionName() {
var _props$placement = this.props.placement,
placement = _props$placement === undefined ? '' : _props$placement;
if (placement.indexOf('top') >= 0) {
return 'slide-down';
}
return 'slide-up';
};
Dropdown.prototype.render = function render() {
var _props = this.props,
children = _props.children,
prefixCls = _props.prefixCls;
var dropdownTrigger = (0, _react.cloneElement)(children, {
className: (0, _classnames2["default"])(children.props.className, prefixCls + '-trigger')
});
return _react2["default"].createElement(
_rcDropdown2["default"],
(0, _extends3["default"])({ transitionName: this.getTransitionName() }, this.props),
dropdownTrigger
);
};
return Dropdown;
}(_react2["default"].Component);
exports["default"] = Dropdown;
Dropdown.defaultProps = {
prefixCls: 'ant-dropdown',
mouseEnterDelay: 0.15,
mouseLeaveDelay: 0.1,
placement: 'bottomLeft'
};
module.exports = exports['default'];
/***/ },
/* 144 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var FIELD_META_PROP = exports.FIELD_META_PROP = 'data-__meta';
/***/ },
/* 145 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Col = exports.Row = undefined;
var _row = __webpack_require__(304);
var _row2 = _interopRequireDefault(_row);
var _col = __webpack_require__(303);
var _col2 = _interopRequireDefault(_col);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports.Row = _row2["default"];
exports.Col = _col2["default"];
/***/ },
/* 146 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _calculateNodeHeight = __webpack_require__(309);
var _calculateNodeHeight2 = _interopRequireDefault(_calculateNodeHeight);
var _objectAssign = __webpack_require__(8);
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _omit = __webpack_require__(22);
var _omit2 = _interopRequireDefault(_omit);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function fixControlledValue(value) {
if (typeof value === 'undefined' || value === null) {
return '';
}
return value;
}
function onNextFrame(cb) {
if (window.requestAnimationFrame) {
return window.requestAnimationFrame(cb);
}
return window.setTimeout(cb, 1);
}
function clearNextFrameAction(nextFrameId) {
if (window.cancelAnimationFrame) {
window.cancelAnimationFrame(nextFrameId);
} else {
window.clearTimeout(nextFrameId);
}
}
;
var Input = function (_Component) {
(0, _inherits3["default"])(Input, _Component);
function Input() {
(0, _classCallCheck3["default"])(this, Input);
var _this = (0, _possibleConstructorReturn3["default"])(this, _Component.apply(this, arguments));
_this.state = {
textareaStyles: null,
isFocus: false
};
_this.handleKeyDown = function (e) {
var _this$props = _this.props,
onPressEnter = _this$props.onPressEnter,
onKeyDown = _this$props.onKeyDown;
if (e.keyCode === 13 && onPressEnter) {
onPressEnter(e);
}
if (onKeyDown) {
onKeyDown(e);
}
};
_this.handleTextareaChange = function (e) {
if (!('value' in _this.props)) {
_this.resizeTextarea();
}
var onChange = _this.props.onChange;
if (onChange) {
onChange(e);
}
};
_this.resizeTextarea = function () {
var _this$props2 = _this.props,
type = _this$props2.type,
autosize = _this$props2.autosize;
if (type !== 'textarea' || !autosize || !_this.refs.input) {
return;
}
var minRows = autosize ? autosize.minRows : null;
var maxRows = autosize ? autosize.maxRows : null;
var textareaStyles = (0, _calculateNodeHeight2["default"])(_this.refs.input, false, minRows, maxRows);
_this.setState({ textareaStyles: textareaStyles });
};
return _this;
}
Input.prototype.componentDidMount = function componentDidMount() {
this.resizeTextarea();
};
Input.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
// Re-render with the new content then recalculate the height as required.
if (this.props.value !== nextProps.value) {
if (this.nextFrameActionId) {
clearNextFrameAction(this.nextFrameActionId);
}
this.nextFrameActionId = onNextFrame(this.resizeTextarea);
}
};
Input.prototype.focus = function focus() {
this.refs.input.focus();
};
Input.prototype.renderLabeledInput = function renderLabeledInput(children) {
var _classNames;
var props = this.props;
// Not wrap when there is not addons
if (props.type === 'textarea' || !props.addonBefore && !props.addonAfter) {
return children;
}
var wrapperClassName = props.prefixCls + '-group';
var addonClassName = wrapperClassName + '-addon';
var addonBefore = props.addonBefore ? _react2["default"].createElement(
'span',
{ className: addonClassName },
props.addonBefore
) : null;
var addonAfter = props.addonAfter ? _react2["default"].createElement(
'span',
{ className: addonClassName },
props.addonAfter
) : null;
var className = (0, _classnames2["default"])((_classNames = {}, (0, _defineProperty3["default"])(_classNames, props.prefixCls + '-wrapper', true), (0, _defineProperty3["default"])(_classNames, wrapperClassName, addonBefore || addonAfter), _classNames));
return _react2["default"].createElement(
'span',
{ className: className },
addonBefore,
children,
addonAfter
);
};
Input.prototype.renderLabeledIcon = function renderLabeledIcon(children) {
var props = this.props;
if (props.type === 'textarea' || !('prefix' in props || 'suffix' in props)) {
return children;
}
var prefix = props.prefix ? _react2["default"].createElement(
'span',
{ className: props.prefixCls + '-prefix' },
props.prefix
) : null;
var suffix = props.suffix ? _react2["default"].createElement(
'span',
{ className: props.prefixCls + '-suffix' },
props.suffix
) : null;
return _react2["default"].createElement(
'span',
{ className: props.prefixCls + '-affix-wrapper', style: props.style },
prefix,
(0, _react.cloneElement)(children, { style: null }),
suffix
);
};
Input.prototype.renderInput = function renderInput() {
var _classNames2;
var props = (0, _objectAssign2["default"])({}, this.props);
// Fix https://fb.me/react-unknown-prop
var otherProps = (0, _omit2["default"])(this.props, ['prefixCls', 'onPressEnter', 'autosize', 'addonBefore', 'addonAfter', 'prefix', 'suffix']);
var prefixCls = props.prefixCls;
if (!props.type) {
return props.children;
}
var inputClassName = (0, _classnames2["default"])(prefixCls, (_classNames2 = {}, (0, _defineProperty3["default"])(_classNames2, prefixCls + '-sm', props.size === 'small'), (0, _defineProperty3["default"])(_classNames2, prefixCls + '-lg', props.size === 'large'), _classNames2), props.className);
if ('value' in props) {
otherProps.value = fixControlledValue(props.value);
// Input elements must be either controlled or uncontrolled,
// specify either the value prop, or the defaultValue prop, but not both.
delete otherProps.defaultValue;
}
switch (props.type) {
case 'textarea':
return _react2["default"].createElement('textarea', (0, _extends3["default"])({}, otherProps, { style: (0, _objectAssign2["default"])({}, props.style, this.state.textareaStyles), className: inputClassName, onKeyDown: this.handleKeyDown, onChange: this.handleTextareaChange, ref: 'input' }));
default:
return this.renderLabeledIcon(_react2["default"].createElement('input', (0, _extends3["default"])({}, otherProps, { className: inputClassName, onKeyDown: this.handleKeyDown, ref: 'input' })));
}
};
Input.prototype.render = function render() {
return this.renderLabeledInput(this.renderInput());
};
return Input;
}(_react.Component);
exports["default"] = Input;
Input.defaultProps = {
disabled: false,
prefixCls: 'ant-input',
type: 'text',
autosize: false
};
Input.propTypes = {
type: _react.PropTypes.string,
id: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]),
size: _react.PropTypes.oneOf(['small', 'default', 'large']),
disabled: _react.PropTypes.bool,
value: _react.PropTypes.any,
defaultValue: _react.PropTypes.any,
className: _react.PropTypes.string,
addonBefore: _react.PropTypes.node,
addonAfter: _react.PropTypes.node,
prefixCls: _react.PropTypes.string,
autosize: _react.PropTypes.oneOfType([_react.PropTypes.bool, _react.PropTypes.object]),
onPressEnter: _react.PropTypes.func,
onKeyDown: _react.PropTypes.func,
onFocus: _react.PropTypes.func,
onBlur: _react.PropTypes.func,
prefix: _react.PropTypes.node,
suffix: _react.PropTypes.node
};
module.exports = exports['default'];
/***/ },
/* 147 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _rcMenu = __webpack_require__(80);
var _rcMenu2 = _interopRequireDefault(_rcMenu);
var _openAnimation = __webpack_require__(87);
var _openAnimation2 = _interopRequireDefault(_openAnimation);
var _warning = __webpack_require__(20);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var Menu = function (_React$Component) {
(0, _inherits3["default"])(Menu, _React$Component);
function Menu(props) {
(0, _classCallCheck3["default"])(this, Menu);
var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.call(this, props));
_this.handleClick = function (e) {
_this.setOpenKeys([]);
var onClick = _this.props.onClick;
if (onClick) {
onClick(e);
}
};
_this.handleOpenChange = function (openKeys) {
_this.setOpenKeys(openKeys);
var onOpenChange = _this.props.onOpenChange;
if (onOpenChange) {
onOpenChange(openKeys);
}
};
(0, _warning2["default"])(!('onOpen' in props || 'onClose' in props), '`onOpen` and `onClose` are removed, please use `onOpenChange` instead, ' + 'see: http://u.ant.design/menu-on-open-change.');
var openKeys = void 0;
if ('defaultOpenKeys' in props) {
openKeys = props.defaultOpenKeys;
} else if ('openKeys' in props) {
openKeys = props.openKeys;
}
_this.state = {
openKeys: openKeys || []
};
return _this;
}
Menu.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (this.props.mode === 'inline' && nextProps.mode !== 'inline') {
this.switchModeFromInline = true;
}
if ('openKeys' in nextProps) {
this.setState({ openKeys: nextProps.openKeys });
}
};
Menu.prototype.setOpenKeys = function setOpenKeys(openKeys) {
if (!('openKeys' in this.props)) {
this.setState({ openKeys: openKeys });
}
};
Menu.prototype.render = function render() {
var openAnimation = this.props.openAnimation || this.props.openTransitionName;
if (this.props.openAnimation === undefined && this.props.openTransitionName === undefined) {
switch (this.props.mode) {
case 'horizontal':
openAnimation = 'slide-up';
break;
case 'vertical':
// When mode switch from inline
// submenu should hide without animation
if (this.switchModeFromInline) {
openAnimation = '';
this.switchModeFromInline = false;
} else {
openAnimation = 'zoom-big';
}
break;
case 'inline':
openAnimation = _openAnimation2["default"];
break;
default:
}
}
var props = {};
var className = this.props.className + ' ' + this.props.prefixCls + '-' + this.props.theme;
if (this.props.mode !== 'inline') {
// There is this.state.openKeys for
// closing vertical popup submenu after click it
props = {
openKeys: this.state.openKeys,
onClick: this.handleClick,
onOpenChange: this.handleOpenChange,
openTransitionName: openAnimation,
className: className
};
} else {
props = {
openAnimation: openAnimation,
className: className
};
}
return _react2["default"].createElement(_rcMenu2["default"], (0, _extends3["default"])({}, this.props, props));
};
return Menu;
}(_react2["default"].Component);
exports["default"] = Menu;
Menu.Divider = _rcMenu.Divider;
Menu.Item = _rcMenu.Item;
Menu.SubMenu = _rcMenu.SubMenu;
Menu.ItemGroup = _rcMenu.ItemGroup;
Menu.defaultProps = {
prefixCls: 'ant-menu',
className: '',
theme: 'light'
};
module.exports = exports['default'];
/***/ },
/* 148 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _rcDialog = __webpack_require__(552);
var _rcDialog2 = _interopRequireDefault(_rcDialog);
var _addEventListener = __webpack_require__(32);
var _addEventListener2 = _interopRequireDefault(_addEventListener);
var _button = __webpack_require__(44);
var _button2 = _interopRequireDefault(_button);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var mousePosition = void 0;
var mousePositionEventBinded = void 0;
var Modal = function (_React$Component) {
(0, _inherits3["default"])(Modal, _React$Component);
function Modal() {
(0, _classCallCheck3["default"])(this, Modal);
var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
_this.handleCancel = function (e) {
var onCancel = _this.props.onCancel;
if (onCancel) {
onCancel(e);
}
};
_this.handleOk = function (e) {
var onOk = _this.props.onOk;
if (onOk) {
onOk(e);
}
};
return _this;
}
Modal.prototype.componentDidMount = function componentDidMount() {
if (mousePositionEventBinded) {
return;
}
// åªæœ‰ç‚¹å‡»äº‹ä»¶æ”¯æŒä»Žé¼ æ ‡ä½ç½®åŠ¨ç”»å±•å¼€
(0, _addEventListener2["default"])(document.documentElement, 'click', function (e) {
mousePosition = {
x: e.pageX,
y: e.pageY
};
// 100ms 内发生过点击事件,则从点击位置动画展示
// 否则直接 zoom 展示
// è¿™æ ·å¯ä»¥å…¼å®¹éžç‚¹å‡»æ–¹å¼å±•å¼€
setTimeout(function () {
return mousePosition = null;
}, 100);
});
mousePositionEventBinded = true;
};
Modal.prototype.render = function render() {
var _props = this.props,
okText = _props.okText,
cancelText = _props.cancelText,
confirmLoading = _props.confirmLoading,
footer = _props.footer,
visible = _props.visible;
if (this.context.antLocale && this.context.antLocale.Modal) {
okText = okText || this.context.antLocale.Modal.okText;
cancelText = cancelText || this.context.antLocale.Modal.cancelText;
}
var defaultFooter = [_react2["default"].createElement(
_button2["default"],
{ key: 'cancel', size: 'large', onClick: this.handleCancel },
cancelText || '取消'
), _react2["default"].createElement(
_button2["default"],
{ key: 'confirm', type: 'primary', size: 'large', loading: confirmLoading, onClick: this.handleOk },
okText || '确定'
)];
return _react2["default"].createElement(_rcDialog2["default"], (0, _extends3["default"])({ onClose: this.handleCancel, footer: footer === undefined ? defaultFooter : footer }, this.props, { visible: visible, mousePosition: mousePosition }));
};
return Modal;
}(_react2["default"].Component);
exports["default"] = Modal;
Modal.defaultProps = {
prefixCls: 'ant-modal',
width: 520,
transitionName: 'zoom',
maskTransitionName: 'fade',
confirmLoading: false,
visible: false
};
Modal.propTypes = {
prefixCls: _react.PropTypes.string,
onOk: _react.PropTypes.func,
onCancel: _react.PropTypes.func,
okText: _react.PropTypes.node,
cancelText: _react.PropTypes.node,
width: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string]),
confirmLoading: _react.PropTypes.bool,
visible: _react.PropTypes.bool,
align: _react.PropTypes.object,
footer: _react.PropTypes.node,
title: _react.PropTypes.node,
closable: _react.PropTypes.bool
};
Modal.contextTypes = {
antLocale: _react2["default"].PropTypes.object
};
module.exports = exports['default'];
/***/ },
/* 149 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.changeConfirmLocale = changeConfirmLocale;
exports.getConfirmLocale = getConfirmLocale;
var _objectAssign = __webpack_require__(8);
var _objectAssign2 = _interopRequireDefault(_objectAssign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var defaultLocale = {
okText: '确定',
cancelText: '取消',
justOkText: '知道了'
};
var runtimeLocale = (0, _objectAssign2["default"])({}, defaultLocale);
function changeConfirmLocale(newLocale) {
if (newLocale) {
runtimeLocale = (0, _objectAssign2["default"])({}, runtimeLocale, newLocale);
} else {
runtimeLocale = (0, _objectAssign2["default"])({}, defaultLocale);
}
}
function getConfirmLocale() {
return runtimeLocale;
}
/***/ },
/* 150 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PaginationProps = undefined;
var _Pagination = __webpack_require__(321);
Object.defineProperty(exports, 'PaginationProps', {
enumerable: true,
get: function get() {
return _Pagination.PaginationProps;
}
});
var _Pagination2 = _interopRequireDefault(_Pagination);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = _Pagination2["default"];
/***/ },
/* 151 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _progress = __webpack_require__(324);
var _progress2 = _interopRequireDefault(_progress);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = _progress2["default"];
module.exports = exports['default'];
/***/ },
/* 152 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _grid = __webpack_require__(145);
exports["default"] = _grid.Row;
module.exports = exports['default'];
/***/ },
/* 153 */,
/* 154 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(9);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _rcAnimate = __webpack_require__(17);
var _rcAnimate2 = _interopRequireDefault(_rcAnimate);
var _isCssAnimationSupported = __webpack_require__(271);
var _isCssAnimationSupported2 = _interopRequireDefault(_isCssAnimationSupported);
var _omit = __webpack_require__(22);
var _omit2 = _interopRequireDefault(_omit);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var __rest = undefined && undefined.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}return t;
};
var Spin = function (_React$Component) {
(0, _inherits3["default"])(Spin, _React$Component);
function Spin(props) {
(0, _classCallCheck3["default"])(this, Spin);
var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.call(this, props));
var spinning = props.spinning;
_this.state = {
spinning: spinning
};
return _this;
}
Spin.prototype.isNestedPattern = function isNestedPattern() {
return !!(this.props && this.props.children);
};
Spin.prototype.componentDidMount = function componentDidMount() {
if (!(0, _isCssAnimationSupported2["default"])()) {
// Show text in IE8/9
(0, _reactDom.findDOMNode)(this).className += ' ' + this.props.prefixCls + '-show-text';
}
};
Spin.prototype.componentWillUnmount = function componentWillUnmount() {
if (this.debounceTimeout) {
clearTimeout(this.debounceTimeout);
}
if (this.delayTimeout) {
clearTimeout(this.delayTimeout);
}
};
Spin.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var _this2 = this;
var currentSpinning = this.props.spinning;
var spinning = nextProps.spinning;
var delay = this.props.delay;
if (this.debounceTimeout) {
clearTimeout(this.debounceTimeout);
}
if (currentSpinning && !spinning) {
this.debounceTimeout = setTimeout(function () {
return _this2.setState({ spinning: spinning });
}, 300);
if (this.delayTimeout) {
clearTimeout(this.delayTimeout);
}
} else {
if (spinning && delay && !isNaN(Number(delay))) {
this.delayTimeout = setTimeout(function () {
return _this2.setState({ spinning: spinning });
}, delay);
} else {
this.setState({ spinning: spinning });
}
}
};
Spin.prototype.render = function render() {
var _classNames;
var _a = this.props,
className = _a.className,
size = _a.size,
prefixCls = _a.prefixCls,
tip = _a.tip,
wrapperClassName = _a.wrapperClassName,
restProps = __rest(_a, ["className", "size", "prefixCls", "tip", "wrapperClassName"]);var spinning = this.state.spinning;
var spinClassName = (0, _classnames2["default"])(prefixCls, (_classNames = {}, (0, _defineProperty3["default"])(_classNames, prefixCls + '-sm', size === 'small'), (0, _defineProperty3["default"])(_classNames, prefixCls + '-lg', size === 'large'), (0, _defineProperty3["default"])(_classNames, prefixCls + '-spinning', spinning), (0, _defineProperty3["default"])(_classNames, prefixCls + '-show-text', !!tip), _classNames), className);
// fix https://fb.me/react-unknown-prop
var divProps = (0, _omit2["default"])(restProps, ['spinning', 'delay']);
var spinElement = _react2["default"].createElement(
'div',
(0, _extends3["default"])({}, divProps, { className: spinClassName }),
_react2["default"].createElement(
'span',
{ className: prefixCls + '-dot' },
_react2["default"].createElement('i', null),
_react2["default"].createElement('i', null),
_react2["default"].createElement('i', null),
_react2["default"].createElement('i', null)
),
tip ? _react2["default"].createElement(
'div',
{ className: prefixCls + '-text' },
tip
) : null
);
if (this.isNestedPattern()) {
var _classNames2;
var animateClassName = prefixCls + '-nested-loading';
if (wrapperClassName) {
animateClassName += ' ' + wrapperClassName;
}
var containerClassName = (0, _classnames2["default"])((_classNames2 = {}, (0, _defineProperty3["default"])(_classNames2, prefixCls + '-container', true), (0, _defineProperty3["default"])(_classNames2, prefixCls + '-blur', spinning), _classNames2));
return _react2["default"].createElement(
_rcAnimate2["default"],
(0, _extends3["default"])({}, divProps, { component: 'div', className: animateClassName, style: null, transitionName: 'fade' }),
spinning && _react2["default"].createElement(
'div',
{ key: 'loading' },
spinElement
),
_react2["default"].createElement(
'div',
{ className: containerClassName, key: 'container' },
this.props.children
)
);
}
return spinElement;
};
return Spin;
}(_react2["default"].Component);
exports["default"] = Spin;
Spin.defaultProps = {
prefixCls: 'ant-spin',
spinning: true,
size: 'default',
wrapperClassName: ''
};
Spin.propTypes = {
prefixCls: _react.PropTypes.string,
className: _react.PropTypes.string,
spinning: _react.PropTypes.bool,
size: _react.PropTypes.oneOf(['small', 'default', 'large']),
wrapperClassName: _react.PropTypes.string
};
module.exports = exports['default'];
/***/ },
/* 155 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _rcTable = __webpack_require__(127);
var _rcTable2 = _interopRequireDefault(_rcTable);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var ColumnGroup = function (_RcTable$ColumnGroup) {
(0, _inherits3["default"])(ColumnGroup, _RcTable$ColumnGroup);
function ColumnGroup() {
(0, _classCallCheck3["default"])(this, ColumnGroup);
return (0, _possibleConstructorReturn3["default"])(this, _RcTable$ColumnGroup.apply(this, arguments));
}
return ColumnGroup;
}(_rcTable2["default"].ColumnGroup);
exports["default"] = ColumnGroup;
module.exports = exports['default'];
/***/ },
/* 156 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var locale = {
placeholder: '请选择时间'
};
exports["default"] = locale;
module.exports = exports['default'];
/***/ },
/* 157 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var __rest = undefined && undefined.__rest || function (s, e) {
var t = {};
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
}return t;
};
var TimelineItem = function (_React$Component) {
(0, _inherits3["default"])(TimelineItem, _React$Component);
function TimelineItem() {
(0, _classCallCheck3["default"])(this, TimelineItem);
return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
}
TimelineItem.prototype.render = function render() {
var _classNames, _classNames2;
var _a = this.props,
prefixCls = _a.prefixCls,
className = _a.className,
_a$color = _a.color,
color = _a$color === undefined ? '' : _a$color,
last = _a.last,
children = _a.children,
pending = _a.pending,
dot = _a.dot,
restProps = __rest(_a, ["prefixCls", "className", "color", "last", "children", "pending", "dot"]);
var itemClassName = (0, _classnames2["default"])((_classNames = {}, (0, _defineProperty3["default"])(_classNames, prefixCls + '-item', true), (0, _defineProperty3["default"])(_classNames, prefixCls + '-item-last', last), (0, _defineProperty3["default"])(_classNames, prefixCls + '-item-pending', pending), _classNames), className);
var dotClassName = (0, _classnames2["default"])((_classNames2 = {}, (0, _defineProperty3["default"])(_classNames2, prefixCls + '-item-head', true), (0, _defineProperty3["default"])(_classNames2, prefixCls + '-item-head-custom', dot), (0, _defineProperty3["default"])(_classNames2, prefixCls + '-item-head-' + color, true), _classNames2));
return _react2["default"].createElement(
'li',
(0, _extends3["default"])({}, restProps, { className: itemClassName }),
_react2["default"].createElement('div', { className: prefixCls + '-item-tail' }),
_react2["default"].createElement(
'div',
{ className: dotClassName, style: { borderColor: /blue|red|green/.test(color) ? null : color } },
dot
),
_react2["default"].createElement(
'div',
{ className: prefixCls + '-item-content' },
children
)
);
};
return TimelineItem;
}(_react2["default"].Component);
exports["default"] = TimelineItem;
TimelineItem.defaultProps = {
prefixCls: 'ant-timeline',
color: 'blue',
last: false,
pending: false
};
module.exports = exports['default'];
/***/ },
/* 158 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = undefined;
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _icon = __webpack_require__(12);
var _icon2 = _interopRequireDefault(_icon);
var _input = __webpack_require__(68);
var _input2 = _interopRequireDefault(_input);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var Search = function (_React$Component) {
(0, _inherits3["default"])(Search, _React$Component);
function Search() {
(0, _classCallCheck3["default"])(this, Search);
var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
_this.handleChange = function (e) {
var onChange = _this.props.onChange;
if (onChange) {
onChange(e);
}
};
_this.handleClear = function (e) {
e.preventDefault();
var handleClear = _this.props.handleClear;
if (handleClear) {
handleClear(e);
}
};
return _this;
}
Search.prototype.render = function render() {
var _props = this.props,
placeholder = _props.placeholder,
value = _props.value,
prefixCls = _props.prefixCls;
var icon = value && value.length > 0 ? _react2["default"].createElement(
'a',
{ href: '#', className: prefixCls + '-action', onClick: this.handleClear },
_react2["default"].createElement(_icon2["default"], { type: 'cross-circle' })
) : _react2["default"].createElement(
'span',
{ className: prefixCls + '-action' },
_react2["default"].createElement(_icon2["default"], { type: 'search' })
);
return _react2["default"].createElement(
'div',
null,
_react2["default"].createElement(_input2["default"], { placeholder: placeholder, className: prefixCls, value: value, ref: 'input', onChange: this.handleChange }),
icon
);
};
return Search;
}(_react2["default"].Component);
exports["default"] = Search;
Search.defaultProps = {
placeholder: ''
};
module.exports = exports['default'];
/***/ },
/* 159 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.UploadProps = undefined;
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = __webpack_require__(3);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(4);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(6);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(5);
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _rcUpload = __webpack_require__(664);
var _rcUpload2 = _interopRequireDefault(_rcUpload);
var _classnames = __webpack_require__(2);
var _classnames2 = _interopRequireDefault(_classnames);
var _objectAssign = __webpack_require__(8);
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _UploadList = __webpack_require__(358);
var _UploadList2 = _interopRequireDefault(_UploadList);
var _interface = __webpack_require__(360);
var _utils = __webpack_require__(361);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var defaultLocale = {
uploading: 'æ–‡ä»¶ä¸Šä¼ ä¸­',
removeFile: 'åˆ é™¤æ–‡ä»¶',
uploadError: 'ä¸Šä¼ é”™è¯¯',
previewFile: '预览文件'
};
exports.UploadProps = _interface.UploadProps;
var Upload = function (_React$Component) {
(0, _inherits3["default"])(Upload, _React$Component);
function Upload(props) {
(0, _classCallCheck3["default"])(this, Upload);
var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.call(this, props));
_this.onStart = function (file) {
var targetItem = void 0;
var nextFileList = _this.state.fileList.concat();
if (file.length > 0) {
targetItem = file.map(function (f) {
var fileObject = (0, _utils.fileToObject)(f);
fileObject.status = 'uploading';
return fileObject;
});
nextFileList = nextFileList.concat(targetItem);
} else {
targetItem = (0, _utils.fileToObject)(file);
targetItem.status = 'uploading';
nextFileList.push(targetItem);
}
_this.onChange({
file: targetItem,
fileList: nextFileList
});
// fix ie progress
if (!window.FormData) {
_this.autoUpdateProgress(0, targetItem);
}
};
_this.onSuccess = function (response, file) {
_this.clearProgressTimer();
try {
if (typeof response === 'string') {
response = JSON.parse(response);
}
} catch (e) {}
var fileList = _this.state.fileList;
var targetItem = (0, _utils.getFileItem)(file, fileList);
// removed
if (!targetItem) {
return;
}
targetItem.status = 'done';
targetItem.response = response;
_this.onChange({
file: (0, _extends3["default"])({}, targetItem),
fileList: fileList
});
};
_this.onProgress = function (e, file) {
var fileList = _this.state.fileList;
var targetItem = (0, _utils.getFileItem)(file, fileList);
// removed
if (!targetItem) {
return;
}
targetItem.percent = e.percent;
_this.onChange({
event: e,
file: (0, _extends3["default"])({}, targetItem),
fileList: _this.state.fileList
});
};
_this.onError = function (error, response, file) {
_this.clearProgressTimer();
var fileList = _this.state.fileList;
var targetItem = (0, _utils.getFileItem)(file, fileList);
// removed
if (!targetItem) {
return;
}
targetItem.error = error;
targetItem.response = response;
targetItem.status = 'error';
_this.onChange({
file: (0, _extends3["default"])({}, targetItem),
fileList: fileList
});
};
_this.handleManualRemove = function (file) {
_this.refs.upload.abort(file);
file.status = 'removed'; // eslint-disable-line
_this.handleRemove(file);
};
_this.onChange = function (info) {
if (!('fileList' in _this.props)) {
_this.setState({ fileList: info.fileList });
}
var onChange = _this.props.onChange;
if (onChange) {
onChange(info);
}
};
_this.onFileDrop = function (e) {
_this.setState({
dragState: e.type
});
};
_this.state = {
fileList: _this.props.fileList || _this.props.defaultFileList || [],
dragState: 'drop'
};
return _this;
}
Upload.prototype.componentWillUnmount = function componentWillUnmount() {
this.clearProgressTimer();
};
Upload.prototype.getLocale = function getLocale() {
var locale = {};
if (this.context.antLocale && this.context.antLocale.Upload) {
locale = this.context.antLocale.Upload;
}
return (0, _objectAssign2["default"])({}, defaultLocale, locale, this.props.locale);
};
Upload.prototype.autoUpdateProgress = function autoUpdateProgress(_, file) {
var _this2 = this;
var getPercent = (0, _utils.genPercentAdd)();
var curPercent = 0;
this.clearProgressTimer();
this.progressTimer = setInterval(function () {
curPercent = getPercent(curPercent);
_this2.onProgress({
percent: curPercent
}, file);
}, 200);
};
Upload.prototype.handleRemove = function handleRemove(file) {
var onRemove = this.props.onRemove;
// Prevent removing file
var onRemoveReturnValue = onRemove && onRemove(file);
if (onRemoveReturnValue === false) {
return;
}
var removedFileList = (0, _utils.removeFileItem)(file, this.state.fileList);
if (removedFileList) {
this.onChange({
file: file,
fileList: removedFileList
});
}
};
Upload.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if ('fileList' in nextProps) {
this.setState({
fileList: nextProps.fileList || []
});
}
};
Upload.prototype.clearProgressTimer = function clearProgressTimer() {
clearInterval(this.progressTimer);
};
Upload.prototype.render = function render() {
var _classNames2;
var _props = this.props,
_props$prefixCls = _props.prefixCls,
prefixCls = _props$prefixCls === undefined ? '' : _props$prefixCls,
showUploadList = _props.showUploadList,
listType = _props.listType,
onPreview = _props.onPreview,
type = _props.type,
disabled = _props.disabled,
children = _props.children,
className = _props.className;
var rcUploadProps = (0, _objectAssign2["default"])({}, {
onStart: this.onStart,
onError: this.onError,
onProgress: this.onProgress,
onSuccess: this.onSuccess
}, this.props);
delete rcUploadProps.className;
var showRemoveIcon = showUploadList.showRemoveIcon,
showPreviewIcon = showUploadList.showPreviewIcon;
var uploadList = showUploadList ? _react2["default"].createElement(_UploadList2["default"], { listType: listType, items: this.state.fileList, onPreview: onPreview, onRemove: this.handleManualRemove, showRemoveIcon: showRemoveIcon, showPreviewIcon: showPreviewIcon, locale: this.getLocale() }) : null;
if (type === 'drag') {
var _classNames;
var dragCls = (0, _classnames2["default"])(prefixCls, (_classNames = {}, (0, _defineProperty3["default"])(_classNames, prefixCls + '-drag', true), (0, _defineProperty3["default"])(_classNames, prefixCls + '-drag-uploading', this.state.fileList.some(function (file) {
return file.status === 'uploading';
})), (0, _defineProperty3["default"])(_classNames, prefixCls + '-drag-hover', this.state.dragState === 'dragover'), (0, _defineProperty3["default"])(_classNames, prefixCls + '-disabled', disabled), _classNames));
return _react2["default"].createElement(
'span',
{ className: className },
_react2["default"].createElement(
'div',
{ className: dragCls, onDrop: this.onFileDrop, onDragOver: this.onFileDrop, onDragLeave: this.onFileDrop },
_react2["default"].createElement(
_rcUpload2["default"],
(0, _extends3["default"])({}, rcUploadProps, { ref: 'upload', className: prefixCls + '-btn' }),
_react2["default"].createElement(
'div',
{ className: prefixCls + '-drag-container' },
children
)
)
),
uploadList
);
}
var uploadButtonCls = (0, _classnames2["default"])(prefixCls, (_classNames2 = {}, (0, _defineProperty3["default"])(_classNames2, prefixCls + '-select', true), (0, _defineProperty3["default"])(_classNames2, prefixCls + '-select-' + listType, true), (0, _defineProperty3["default"])(_classNames2, prefixCls + '-disabled', disabled), _classNames2));
var uploadButton = _react2["default"].createElement(
'div',
{ className: uploadButtonCls, style: { display: children ? '' : 'none' } },
_react2["default"].createElement(_rcUpload2["default"], (0, _extends3["default"])({}, rcUploadProps, { ref: 'upload' }))
);
if (listType === 'picture-card') {
return _react2["default"].createElement(
'span',
{ className: className },
uploadList,
uploadButton
);
}
return _react2["default"].createElement(
'span',
{ className: className },
uploadButton,
uploadList
);
};
return Upload;
}(_react2["default"].Component);
exports["default"] = Upload;
Upload.defaultProps = {
prefixCls: 'ant-upload',
type: 'select',
multiple: false,
action: '',
data: {},
accept: '',
beforeUpload: _utils.T,
showUploadList: true,
listType: 'text',
className: '',
disabled: false,
supportServerRender: true
};
Upload.contextTypes = {
antLocale: _react2["default"].PropTypes.object
};
/***/ },
/* 160 */
/***/ function(module, exports) {
module.exports = function(arr, obj){
if (arr.indexOf) return arr.indexOf(obj);
for (var i = 0; i < arr.length; ++i) {
if (arr[i] === obj) return i;
}
return -1;
};
/***/ },
/* 161 */
/***/ function(module, exports, __webpack_require__) {
// getting tag from 19.1.3.6 Object.prototype.toString()
var cof = __webpack_require__(92)
, TAG = __webpack_require__(24)('toStringTag')
// ES3 wrong here
, ARG = cof(function(){ return arguments; }()) == 'Arguments';
// fallback for IE11 Script Access Denied error
var tryGet = function(it, key){
try {
return it[key];
} catch(e){ /* empty */ }
};
module.exports = function(it){
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null'
// @@toStringTag case
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
// builtinTag case
: ARG ? cof(O)
// ES3 arguments fallback
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
/***/ },
/* 162 */
/***/ function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(57)
, document = __webpack_require__(29).document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
return is ? document.createElement(it) : {};
};
/***/ },
/* 163 */
/***/ function(module, exports, __webpack_require__) {
module.exports = !__webpack_require__(36) && !__webpack_require__(56)(function(){
return Object.defineProperty(__webpack_require__(162)('div'), 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ },
/* 164 */
/***/ function(module, exports, __webpack_require__) {
// fallback for non-array-like ES3 and non-enumerable old V8 strings
var cof = __webpack_require__(92);
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
return cof(it) == 'String' ? it.split('') : Object(it);
};
/***/ },
/* 165 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var LIBRARY = __webpack_require__(96)
, $export = __webpack_require__(37)
, redefine = __webpack_require__(169)
, hide = __webpack_require__(46)
, has = __webpack_require__(38)
, Iterators = __webpack_require__(47)
, $iterCreate = __webpack_require__(392)
, setToStringTag = __webpack_require__(99)
, getPrototypeOf = __webpack_require__(400)
, ITERATOR = __webpack_require__(24)('iterator')
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
, FF_ITERATOR = '@@iterator'
, KEYS = 'keys'
, VALUES = 'values';
var returnThis = function(){ return this; };
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
$iterCreate(Constructor, NAME, next);
var getMethod = function(kind){
if(!BUGGY && kind in proto)return proto[kind];
switch(kind){
case KEYS: return function keys(){ return new Constructor(this, kind); };
case VALUES: return function values(){ return new Constructor(this, kind); };
} return function entries(){ return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator'
, DEF_VALUES = DEFAULT == VALUES
, VALUES_BUG = false
, proto = Base.prototype
, $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
, $default = $native || getMethod(DEFAULT)
, $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
, $anyNative = NAME == 'Array' ? proto.entries || $native : $native
, methods, key, IteratorPrototype;
// Fix native
if($anyNative){
IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
if(IteratorPrototype !== Object.prototype){
// Set @@toStringTag to native iterators
setToStringTag(IteratorPrototype, TAG, true);
// fix for some old engines
if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
}
}
// fix Array#{values, @@iterator}.name in V8 / FF
if(DEF_VALUES && $native && $native.name !== VALUES){
VALUES_BUG = true;
$default = function values(){ return $native.call(this); };
}
// Define iterator
if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
hide(proto, ITERATOR, $default);
}
// Plug for library
Iterators[NAME] = $default;
Iterators[TAG] = returnThis;
if(DEFAULT){
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if(FORCED)for(key in methods){
if(!(key in proto))redefine(proto, key, methods[key]);
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
/***/ },
/* 166 */
/***/ function(module, exports, __webpack_require__) {
var pIE = __webpack_require__(70)
, createDesc = __webpack_require__(59)
, toIObject = __webpack_require__(39)
, toPrimitive = __webpack_require__(104)
, has = __webpack_require__(38)
, IE8_DOM_DEFINE = __webpack_require__(163)
, gOPD = Object.getOwnPropertyDescriptor;
exports.f = __webpack_require__(36) ? gOPD : function getOwnPropertyDescriptor(O, P){
O = toIObject(O);
P = toPrimitive(P, true);
if(IE8_DOM_DEFINE)try {
return gOPD(O, P);
} catch(e){ /* empty */ }
if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
};
/***/ },
/* 167 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
var $keys = __webpack_require__(168)
, hiddenKeys = __webpack_require__(95).concat('length', 'prototype');
exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
return $keys(O, hiddenKeys);
};
/***/ },
/* 168 */
/***/ function(module, exports, __webpack_require__) {
var has = __webpack_require__(38)
, toIObject = __webpack_require__(39)
, arrayIndexOf = __webpack_require__(385)(false)
, IE_PROTO = __webpack_require__(100)('IE_PROTO');
module.exports = function(object, names){
var O = toIObject(object)
, i = 0
, result = []
, key;
for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
// Don't enum bug & hidden keys
while(names.length > i)if(has(O, key = names[i++])){
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
/***/ },
/* 169 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(46);
/***/ },
/* 170 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.15 ToLength
var toInteger = __webpack_require__(102)
, min = Math.min;
module.exports = function(it){
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};
/***/ },
/* 171 */
/***/ function(module, exports, __webpack_require__) {
var classof = __webpack_require__(161)
, ITERATOR = __webpack_require__(24)('iterator')
, Iterators = __webpack_require__(47);
module.exports = __webpack_require__(23).getIteratorMethod = function(it){
if(it != undefined)return it[ITERATOR]
|| it['@@iterator']
|| Iterators[classof(it)];
};
/***/ },
/* 172 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _utils = __webpack_require__(60);
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/**
* å¾—åˆ°ä¼šå¯¼è‡´å…ƒç´ æ˜¾ç¤ºä¸å…¨çš„ç¥–å…ˆå…ƒç´
*/
function getOffsetParent(element) {
// ie 这个也不是完全可行
/*
<div style="width: 50px;height: 100px;overflow: hidden">
<div style="width: 50px;height: 100px;position: relative;" id="d6">
å…ƒç´ 6 高 100px 宽 50px<br/>
</div>
</div>
*/
// element.offsetParent does the right thing in ie7 and below. Return parent with layout!
// In other browsers it only includes elements with position absolute, relative or
// fixed, not elements with overflow set to auto or scroll.
// if (UA.ie && ieMode < 8) {
// return element.offsetParent;
// }
// 统一的 offsetParent 方法
var doc = element.ownerDocument;
var body = doc.body;
var parent = void 0;
var positionStyle = _utils2["default"].css(element, 'position');
var skipStatic = positionStyle === 'fixed' || positionStyle === 'absolute';
if (!skipStatic) {
return element.nodeName.toLowerCase() === 'html' ? null : element.parentNode;
}
for (parent = element.parentNode; parent && parent !== body; parent = parent.parentNode) {
positionStyle = _utils2["default"].css(parent, 'position');
if (positionStyle !== 'static') {
return parent;
}
}
return null;
}
exports["default"] = getOffsetParent;
module.exports = exports['default'];
/***/ },
/* 173 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule BlockTree
*
*/
'use strict';
var Immutable = __webpack_require__(11);
var emptyFunction = __webpack_require__(118);
var findRangesImmutable = __webpack_require__(76);
var List = Immutable.List;
var Repeat = Immutable.Repeat;
var Record = Immutable.Record;
var returnTrue = emptyFunction.thatReturnsTrue;
var FINGERPRINT_DELIMITER = '-';
var defaultLeafRange = {
start: null,
end: null
};
var LeafRange = Record(defaultLeafRange);
var defaultDecoratorRange = {
start: null,
end: null,
decoratorKey: null,
leaves: null
};
var DecoratorRange = Record(defaultDecoratorRange);
var BlockTree = {
/**
* Generate a block tree for a given ContentBlock/decorator pair.
*/
generate: function generate(contentState, block, decorator) {
var textLength = block.getLength();
if (!textLength) {
return List.of(new DecoratorRange({
start: 0,
end: 0,
decoratorKey: null,
leaves: List.of(new LeafRange({ start: 0, end: 0 }))
}));
}
var leafSets = [];
var decorations = decorator ? decorator.getDecorations(block, contentState) : List(Repeat(null, textLength));
var chars = block.getCharacterList();
findRangesImmutable(decorations, areEqual, returnTrue, function (start, end) {
leafSets.push(new DecoratorRange({
start: start,
end: end,
decoratorKey: decorations.get(start),
leaves: generateLeaves(chars.slice(start, end).toList(), start)
}));
});
return List(leafSets);
},
/**
* Create a string representation of the given tree map. This allows us
* to rapidly determine whether a tree has undergone a significant
* structural change.
*/
getFingerprint: function getFingerprint(tree) {
return tree.map(function (leafSet) {
var decoratorKey = leafSet.get('decoratorKey');
var fingerprintString = decoratorKey !== null ? decoratorKey + '.' + (leafSet.get('end') - leafSet.get('start')) : '';
return '' + fingerprintString + '.' + leafSet.get('leaves').size;
}).join(FINGERPRINT_DELIMITER);
}
};
/**
* Generate LeafRange records for a given character list.
*/
function generateLeaves(characters, offset) {
var leaves = [];
var inlineStyles = characters.map(function (c) {
return c.getStyle();
}).toList();
findRangesImmutable(inlineStyles, areEqual, returnTrue, function (start, end) {
leaves.push(new LeafRange({
start: start + offset,
end: end + offset
}));
});
return List(leaves);
}
function areEqual(a, b) {
return a === b;
}
module.exports = BlockTree;
/***/ },
/* 174 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DefaultDraftInlineStyle
*
*/
'use strict';
module.exports = {
BOLD: {
fontWeight: 'bold'
},
CODE: {
fontFamily: 'monospace',
wordWrap: 'break-word'
},
ITALIC: {
fontStyle: 'italic'
},
STRIKETHROUGH: {
textDecoration: 'line-through'
},
UNDERLINE: {
textDecoration: 'underline'
}
};
/***/ },
/* 175 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftEditorBlock.react
* @typechecks
*
*/
'use strict';
var _assign = __webpack_require__(8);
var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var ContentBlock = __webpack_require__(40);
var ContentState = __webpack_require__(74);
var DraftEditorLeaf = __webpack_require__(436);
var DraftOffsetKey = __webpack_require__(62);
var React = __webpack_require__(1);
var ReactDOM = __webpack_require__(9);
var Scroll = __webpack_require__(194);
var SelectionState = __webpack_require__(49);
var Style = __webpack_require__(116);
var UnicodeBidi = __webpack_require__(195);
var UnicodeBidiDirection = __webpack_require__(117);
var cx = __webpack_require__(64);
var getElementPosition = __webpack_require__(503);
var getScrollPosition = __webpack_require__(119);
var getViewportDimensions = __webpack_require__(507);
var nullthrows = __webpack_require__(21);
var SCROLL_BUFFER = 10;
/**
* The default block renderer for a `DraftEditor` component.
*
* A `DraftEditorBlock` is able to render a given `ContentBlock` to its
* appropriate decorator and inline style components.
*/
var DraftEditorBlock = function (_React$Component) {
_inherits(DraftEditorBlock, _React$Component);
function DraftEditorBlock() {
_classCallCheck(this, DraftEditorBlock);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
DraftEditorBlock.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return this.props.block !== nextProps.block || this.props.tree !== nextProps.tree || this.props.direction !== nextProps.direction || isBlockOnSelectionEdge(nextProps.selection, nextProps.block.getKey()) && nextProps.forceSelection;
};
/**
* When a block is mounted and overlaps the selection state, we need to make
* sure that the cursor is visible to match native behavior. This may not
* be the case if the user has pressed `RETURN` or pasted some content, since
* programatically creating these new blocks and setting the DOM selection
* will miss out on the browser natively scrolling to that position.
*
* To replicate native behavior, if the block overlaps the selection state
* on mount, force the scroll position. Check the scroll state of the scroll
* parent, and adjust it to align the entire block to the bottom of the
* scroll parent.
*/
DraftEditorBlock.prototype.componentDidMount = function componentDidMount() {
var selection = this.props.selection;
var endKey = selection.getEndKey();
if (!selection.getHasFocus() || endKey !== this.props.block.getKey()) {
return;
}
var blockNode = ReactDOM.findDOMNode(this);
var scrollParent = Style.getScrollParent(blockNode);
var scrollPosition = getScrollPosition(scrollParent);
var scrollDelta;
if (scrollParent === window) {
var nodePosition = getElementPosition(blockNode);
var nodeBottom = nodePosition.y + nodePosition.height;
var viewportHeight = getViewportDimensions().height;
scrollDelta = nodeBottom - viewportHeight;
if (scrollDelta > 0) {
window.scrollTo(scrollPosition.x, scrollPosition.y + scrollDelta + SCROLL_BUFFER);
}
} else {
var blockBottom = blockNode.offsetHeight + blockNode.offsetTop;
var scrollBottom = scrollParent.offsetHeight + scrollPosition.y;
scrollDelta = blockBottom - scrollBottom;
if (scrollDelta > 0) {
Scroll.setTop(scrollParent, Scroll.getTop(scrollParent) + scrollDelta + SCROLL_BUFFER);
}
}
};
DraftEditorBlock.prototype._renderChildren = function _renderChildren() {
var _this2 = this;
var block = this.props.block;
var blockKey = block.getKey();
var text = block.getText();
var lastLeafSet = this.props.tree.size - 1;
var hasSelection = isBlockOnSelectionEdge(this.props.selection, blockKey);
return this.props.tree.map(function (leafSet, ii) {
var leavesForLeafSet = leafSet.get('leaves');
var lastLeaf = leavesForLeafSet.size - 1;
var leaves = leavesForLeafSet.map(function (leaf, jj) {
var offsetKey = DraftOffsetKey.encode(blockKey, ii, jj);
var start = leaf.get('start');
var end = leaf.get('end');
return React.createElement(DraftEditorLeaf, {
key: offsetKey,
offsetKey: offsetKey,
blockKey: blockKey,
start: start,
selection: hasSelection ? _this2.props.selection : undefined,
forceSelection: _this2.props.forceSelection,
text: text.slice(start, end),
styleSet: block.getInlineStyleAt(start),
customStyleMap: _this2.props.customStyleMap,
customStyleFn: _this2.props.customStyleFn,
isLast: ii === lastLeafSet && jj === lastLeaf
});
}).toArray();
var decoratorKey = leafSet.get('decoratorKey');
if (decoratorKey == null) {
return leaves;
}
if (!_this2.props.decorator) {
return leaves;
}
var decorator = nullthrows(_this2.props.decorator);
var DecoratorComponent = decorator.getComponentForKey(decoratorKey);
if (!DecoratorComponent) {
return leaves;
}
var decoratorProps = decorator.getPropsForKey(decoratorKey);
var decoratorOffsetKey = DraftOffsetKey.encode(blockKey, ii, 0);
var decoratedText = text.slice(leavesForLeafSet.first().get('start'), leavesForLeafSet.last().get('end'));
// Resetting dir to the same value on a child node makes Chrome/Firefox
// confused on cursor movement. See http://jsfiddle.net/d157kLck/3/
var dir = UnicodeBidiDirection.getHTMLDirIfDifferent(UnicodeBidi.getDirection(decoratedText), _this2.props.direction);
return React.createElement(
DecoratorComponent,
_extends({}, decoratorProps, {
contentState: _this2.props.contentState,
decoratedText: decoratedText,
dir: dir,
key: decoratorOffsetKey,
entityKey: block.getEntityAt(leafSet.get('start')),
offsetKey: decoratorOffsetKey }),
leaves
);
}).toArray();
};
DraftEditorBlock.prototype.render = function render() {
var _props = this.props;
var direction = _props.direction;
var offsetKey = _props.offsetKey;
var className = cx({
'public/DraftStyleDefault/block': true,
'public/DraftStyleDefault/ltr': direction === 'LTR',
'public/DraftStyleDefault/rtl': direction === 'RTL'
});
return React.createElement(
'div',
{ 'data-offset-key': offsetKey, className: className },
this._renderChildren()
);
};
return DraftEditorBlock;
}(React.Component);
/**
* Return whether a block overlaps with either edge of the `SelectionState`.
*/
function isBlockOnSelectionEdge(selection, key) {
return selection.getAnchorKey() === key || selection.getFocusKey() === key;
}
module.exports = DraftEditorBlock;
/***/ },
/* 176 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftEntityInstance
*
*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Immutable = __webpack_require__(11);
var Record = Immutable.Record;
var DraftEntityInstanceRecord = Record({
type: 'TOKEN',
mutability: 'IMMUTABLE',
data: Object
});
/**
* An instance of a document entity, consisting of a `type` and relevant
* `data`, metadata about the entity.
*
* For instance, a "link" entity might provide a URI, and a "mention"
* entity might provide the mentioned user's ID. These pieces of data
* may be used when rendering the entity as part of a ContentBlock DOM
* representation. For a link, the data would be used as an href for
* the rendered anchor. For a mention, the ID could be used to retrieve
* a hovercard.
*/
var DraftEntityInstance = function (_DraftEntityInstanceR) {
_inherits(DraftEntityInstance, _DraftEntityInstanceR);
function DraftEntityInstance() {
_classCallCheck(this, DraftEntityInstance);
return _possibleConstructorReturn(this, _DraftEntityInstanceR.apply(this, arguments));
}
DraftEntityInstance.prototype.getType = function getType() {
return this.get('type');
};
DraftEntityInstance.prototype.getMutability = function getMutability() {
return this.get('mutability');
};
DraftEntityInstance.prototype.getData = function getData() {
return this.get('data');
};
return DraftEntityInstance;
}(DraftEntityInstanceRecord);
module.exports = DraftEntityInstance;
/***/ },
/* 177 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftRemovableWord
* @typechecks
*
*/
'use strict';
var TokenizeUtil = __webpack_require__(495);
var punctuation = TokenizeUtil.getPunctuation();
// The apostrophe and curly single quotes behave in a curious way: when
// surrounded on both sides by word characters, they behave as word chars; when
// either neighbor is punctuation or an end of the string, they behave as
// punctuation.
var CHAMELEON_CHARS = '[\'\u2018\u2019]';
// Remove the underscore, which should count as part of the removable word. The
// "chameleon chars" also count as punctuation in this regex.
var WHITESPACE_AND_PUNCTUATION = '\\s|(?![_])' + punctuation;
var DELETE_STRING = '^' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)';
var DELETE_REGEX = new RegExp(DELETE_STRING);
var BACKSPACE_STRING = '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '$';
var BACKSPACE_REGEX = new RegExp(BACKSPACE_STRING);
function getRemovableWord(text, isBackward) {
var matches = isBackward ? BACKSPACE_REGEX.exec(text) : DELETE_REGEX.exec(text);
return matches ? matches[0] : text;
}
var DraftRemovableWord = {
getBackward: function getBackward(text) {
return getRemovableWord(text, true);
},
getForward: function getForward(text) {
return getRemovableWord(text, false);
}
};
module.exports = DraftRemovableWord;
/***/ },
/* 178 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule DraftStringKey
* @typechecks
*
*/
'use strict';
var DraftStringKey = {
stringify: function stringify(key) {
return '_' + String(key);
},
unstringify: function unstringify(key) {
return key.slice(1);
}
};
module.exports = DraftStringKey;
/***/ },
/* 179 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule convertFromHTMLToContentBlocks
* @typechecks
*
*/
'use strict';
var CharacterMetadata = __webpack_require__(25);
var ContentBlock = __webpack_require__(40);
var DefaultDraftBlockRenderMap = __webpack_require__(109);
var DraftEntity = __webpack_require__(75);
var Immutable = __webpack_require__(11);
var URI = __webpack_require__(496);
var generateRandomKey = __webpack_require__(27);
var getSafeBodyFromHTML = __webpack_require__(184);
var invariant = __webpack_require__(16);
var nullthrows = __webpack_require__(21);
var sanitizeDraftText = __webpack_require__(114);
var _require = __webpack_require__(11);
var Set = _require.Set;
var List = Immutable.List;
var OrderedSet = Immutable.OrderedSet;
var NBSP = '&nbsp;';
var SPACE = ' ';
// Arbitrary max indent
var MAX_DEPTH = 4;
// used for replacing characters in HTML
var REGEX_CR = new RegExp('\r', 'g');
var REGEX_LF = new RegExp('\n', 'g');
var REGEX_NBSP = new RegExp(NBSP, 'g');
var REGEX_CARRIAGE = new RegExp('&#13;?', 'g');
var REGEX_ZWS = new RegExp('&#8203;?', 'g');
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
var boldValues = ['bold', 'bolder', '500', '600', '700', '800', '900'];
var notBoldValues = ['light', 'lighter', '100', '200', '300', '400'];
// Block tag flow is different because LIs do not have
// a deterministic style ;_;
var inlineTags = {
b: 'BOLD',
code: 'CODE',
del: 'STRIKETHROUGH',
em: 'ITALIC',
i: 'ITALIC',
s: 'STRIKETHROUGH',
strike: 'STRIKETHROUGH',
strong: 'BOLD',
u: 'UNDERLINE'
};
var anchorAttr = ['className', 'href', 'rel', 'target', 'title'];
var imgAttr = ['alt', 'className', 'height', 'src', 'width'];
var lastBlock;
function getEmptyChunk() {
return {
text: '',
inlines: [],
entities: [],
blocks: []
};
}
function getWhitespaceChunk(inEntity) {
var entities = new Array(1);
if (inEntity) {
entities[0] = inEntity;
}
return {
text: SPACE,
inlines: [OrderedSet()],
entities: entities,
blocks: []
};
}
function getSoftNewlineChunk() {
return {
text: '\n',
inlines: [OrderedSet()],
entities: new Array(1),
blocks: []
};
}
function getBlockDividerChunk(block, depth) {
return {
text: '\r',
inlines: [OrderedSet()],
entities: new Array(1),
blocks: [{
type: block,
depth: Math.max(0, Math.min(MAX_DEPTH, depth))
}]
};
}
function getListBlockType(tag, lastList) {
if (tag === 'li') {
return lastList === 'ol' ? 'ordered-list-item' : 'unordered-list-item';
}
return null;
}
function getBlockMapSupportedTags(blockRenderMap) {
var unstyledElement = blockRenderMap.get('unstyled').element;
var tags = new Set([]);
blockRenderMap.forEach(function (draftBlock) {
if (draftBlock.aliasedElements) {
draftBlock.aliasedElements.forEach(function (tag) {
tags = tags.add(tag);
});
}
tags = tags.add(draftBlock.element);
});
return tags.filter(function (tag) {
return tag && tag !== unstyledElement;
}).toArray().sort();
}
// custom element conversions
function getMultiMatchedType(tag, lastList, multiMatchExtractor) {
for (var ii = 0; ii < multiMatchExtractor.length; ii++) {
var matchType = multiMatchExtractor[ii](tag, lastList);
if (matchType) {
return matchType;
}
}
return null;
}
function getBlockTypeForTag(tag, lastList, blockRenderMap) {
var matchedTypes = blockRenderMap.filter(function (draftBlock) {
return draftBlock.element === tag || draftBlock.wrapper === tag || draftBlock.aliasedElements && draftBlock.aliasedElements.some(function (alias) {
return alias === tag;
});
}).keySeq().toSet().toArray().sort();
// if we dont have any matched type, return unstyled
// if we have one matched type return it
// if we have multi matched types use the multi-match function to gather type
switch (matchedTypes.length) {
case 0:
return 'unstyled';
case 1:
return matchedTypes[0];
default:
return getMultiMatchedType(tag, lastList, [getListBlockType]) || 'unstyled';
}
}
function processInlineTag(tag, node, currentStyle) {
var styleToCheck = inlineTags[tag];
if (styleToCheck) {
currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
} else if (node instanceof HTMLElement) {
(function () {
var htmlElement = node;
currentStyle = currentStyle.withMutations(function (style) {
var fontWeight = htmlElement.style.fontWeight;
var fontStyle = htmlElement.style.fontStyle;
var textDecoration = htmlElement.style.textDecoration;
if (boldValues.indexOf(fontWeight) >= 0) {
style.add('BOLD');
} else if (notBoldValues.indexOf(fontWeight) >= 0) {
style.remove('BOLD');
}
if (fontStyle === 'italic') {
style.add('ITALIC');
} else if (fontStyle === 'normal') {
style.remove('ITALIC');
}
if (textDecoration === 'underline') {
style.add('UNDERLINE');
}
if (textDecoration === 'line-through') {
style.add('STRIKETHROUGH');
}
if (textDecoration === 'none') {
style.remove('UNDERLINE');
style.remove('STRIKETHROUGH');
}
}).toOrderedSet();
})();
}
return currentStyle;
}
function joinChunks(A, B) {
// Sometimes two blocks will touch in the DOM and we need to strip the
// extra delimiter to preserve niceness.
var lastInA = A.text.slice(-1);
var firstInB = B.text.slice(0, 1);
if (lastInA === '\r' && firstInB === '\r') {
A.text = A.text.slice(0, -1);
A.inlines.pop();
A.entities.pop();
A.blocks.pop();
}
// Kill whitespace after blocks
if (lastInA === '\r') {
if (B.text === SPACE || B.text === '\n') {
return A;
} else if (firstInB === SPACE || firstInB === '\n') {
B.text = B.text.slice(1);
B.inlines.shift();
B.entities.shift();
}
}
return {
text: A.text + B.text,
inlines: A.inlines.concat(B.inlines),
entities: A.entities.concat(B.entities),
blocks: A.blocks.concat(B.blocks)
};
}
/**
* Check to see if we have anything like <p> <blockquote> <h1>... to create
* block tags from. If we do, we can use those and ignore <div> tags. If we
* don't, we can treat <div> tags as meaningful (unstyled) blocks.
*/
function containsSemanticBlockMarkup(html, blockTags) {
return blockTags.some(function (tag) {
return html.indexOf('<' + tag) !== -1;
});
}
function hasValidLinkText(link) {
!(link instanceof HTMLAnchorElement) ? true ? invariant(false, 'Link must be an HTMLAnchorElement.') : invariant(false) : void 0;
var protocol = link.protocol;
return protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:';
}
function genFragment(entityMap, node, inlineStyle, lastList, inBlock, blockTags, depth, blockRenderMap, inEntity) {
var nodeName = node.nodeName.toLowerCase();
var newBlock = false;
var nextBlockType = 'unstyled';
var lastLastBlock = lastBlock;
var newEntityMap = entityMap;
// Base Case
if (nodeName === '#text') {
var text = node.textContent;
if (text.trim() === '' && inBlock !== 'pre') {
return { chunk: getWhitespaceChunk(inEntity), entityMap: entityMap };
}
if (inBlock !== 'pre') {
// Can't use empty string because MSWord
text = text.replace(REGEX_LF, SPACE);
}
// save the last block so we can use it later
lastBlock = nodeName;
return {
chunk: {
text: text,
inlines: Array(text.length).fill(inlineStyle),
entities: Array(text.length).fill(inEntity),
blocks: []
},
entityMap: entityMap
};
}
// save the last block so we can use it later
lastBlock = nodeName;
// BR tags
if (nodeName === 'br') {
if (lastLastBlock === 'br' && (!inBlock || getBlockTypeForTag(inBlock, lastList, blockRenderMap) === 'unstyled')) {
return { chunk: getBlockDividerChunk('unstyled', depth), entityMap: entityMap };
}
return { chunk: getSoftNewlineChunk(), entityMap: entityMap };
}
// IMG tags
if (nodeName === 'img' && node instanceof HTMLImageElement && node.attributes.getNamedItem('src') && node.attributes.getNamedItem('src').value) {
(function () {
var image = node;
var entityConfig = {};
imgAttr.forEach(function (attr) {
var imageAttribute = image.getAttribute(attr);
if (imageAttribute) {
entityConfig[attr] = imageAttribute;
}
});
var imageURI = new URI(entityConfig.src).toString();
node.textContent = imageURI; // Output src if no decorator
// TODO: update this when we remove DraftEntity entirely
inEntity = DraftEntity.__create('IMAGE', 'MUTABLE', entityConfig || {});
})();
}
var chunk = getEmptyChunk();
var newChunk = null;
// Inline tags
inlineStyle = processInlineTag(nodeName, node, inlineStyle);
// Handle lists
if (nodeName === 'ul' || nodeName === 'ol') {
if (lastList) {
depth += 1;
}
lastList = nodeName;
}
// Block Tags
if (!inBlock && blockTags.indexOf(nodeName) !== -1) {
chunk = getBlockDividerChunk(getBlockTypeForTag(nodeName, lastList, blockRenderMap), depth);
inBlock = nodeName;
newBlock = true;
} else if (lastList && inBlock === 'li' && nodeName === 'li') {
chunk = getBlockDividerChunk(getBlockTypeForTag(nodeName, lastList, blockRenderMap), depth);
inBlock = nodeName;
newBlock = true;
nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
}
// Recurse through children
var child = node.firstChild;
if (child != null) {
nodeName = child.nodeName.toLowerCase();
}
var entityId = null;
while (child) {
if (child instanceof HTMLAnchorElement && child.href && hasValidLinkText(child)) {
(function () {
var anchor = child;
var entityConfig = {};
anchorAttr.forEach(function (attr) {
var anchorAttribute = anchor.getAttribute(attr);
if (anchorAttribute) {
entityConfig[attr] = anchorAttribute;
}
});
entityConfig.url = new URI(anchor.href).toString();
// TODO: update this when we remove DraftEntity completely
entityId = DraftEntity.__create('LINK', 'MUTABLE', entityConfig || {});
})();
} else {
entityId = undefined;
}
var _genFragment = genFragment(newEntityMap, child, inlineStyle, lastList, inBlock, blockTags, depth, blockRenderMap, entityId || inEntity);
var generatedChunk = _genFragment.chunk;
var maybeUpdatedEntityMap = _genFragment.entityMap;
newChunk = generatedChunk;
newEntityMap = maybeUpdatedEntityMap;
chunk = joinChunks(chunk, newChunk);
var sibling = child.nextSibling;
// Put in a newline to break up blocks inside blocks
if (sibling && blockTags.indexOf(nodeName) >= 0 && inBlock) {
chunk = joinChunks(chunk, getSoftNewlineChunk());
}
if (sibling) {
nodeName = sibling.nodeName.toLowerCase();
}
child = sibling;
}
if (newBlock) {
chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth));
}
return { chunk: chunk, entityMap: newEntityMap };
}
function getChunkForHTML(html, DOMBuilder, blockRenderMap, entityMap) {
html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE).replace(REGEX_CARRIAGE, '').replace(REGEX_ZWS, '');
var supportedBlockTags = getBlockMapSupportedTags(blockRenderMap);
var safeBody = DOMBuilder(html);
if (!safeBody) {
return null;
}
lastBlock = null;
// Sometimes we aren't dealing with content that contains nice semantic
// tags. In this case, use divs to separate everything out into paragraphs
// and hope for the best.
var workingBlocks = containsSemanticBlockMarkup(html, supportedBlockTags) ? supportedBlockTags : ['div'];
// Start with -1 block depth to offset the fact that we are passing in a fake
// UL block to start with.
var _genFragment2 = genFragment(entityMap, safeBody, OrderedSet(), 'ul', null, workingBlocks, -1, blockRenderMap);
var chunk = _genFragment2.chunk;
var newEntityMap = _genFragment2.entityMap;
// join with previous block to prevent weirdness on paste
if (chunk.text.indexOf('\r') === 0) {
chunk = {
text: chunk.text.slice(1),
inlines: chunk.inlines.slice(1),
entities: chunk.entities.slice(1),
blocks: chunk.blocks
};
}
// Kill block delimiter at the end
if (chunk.text.slice(-1) === '\r') {
chunk.text = chunk.text.slice(0, -1);
chunk.inlines = chunk.inlines.slice(0, -1);
chunk.entities = chunk.entities.slice(0, -1);
chunk.blocks.pop();
}
// If we saw no block tags, put an unstyled one in
if (chunk.blocks.length === 0) {
chunk.blocks.push({ type: 'unstyled', depth: 0 });
}
// Sometimes we start with text that isn't in a block, which is then
// followed by blocks. Need to fix up the blocks to add in
// an unstyled block for this content
if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
chunk.blocks.unshift({ type: 'unstyled', depth: 0 });
}
return { chunk: chunk, entityMap: newEntityMap };
}
function convertFromHTMLtoContentBlocks(html) {
var DOMBuilder = arguments.length <= 1 || arguments[1] === undefined ? getSafeBodyFromHTML : arguments[1];
var blockRenderMap = arguments.length <= 2 || arguments[2] === undefined ? DefaultDraftBlockRenderMap : arguments[2];
// Be ABSOLUTELY SURE that the dom builder you pass here won't execute
// arbitrary code in whatever environment you're running this in. For an
// example of how we try to do this in-browser, see getSafeBodyFromHTML.
// TODO: replace DraftEntity with an OrderedMap here
var chunkData = getChunkForHTML(html, DOMBuilder, blockRenderMap, DraftEntity);
if (chunkData == null) {
return null;
}
var chunk = chunkData.chunk;
var newEntityMap = chunkData.entityMap;
var start = 0;
return {
contentBlocks: chunk.text.split('\r').map(function (textBlock, ii) {
// Make absolutely certain that our text is acceptable.
textBlock = sanitizeDraftText(textBlock);
var end = start + textBlock.length;
var inlines = nullthrows(chunk).inlines.slice(start, end);
var entities = nullthrows(chunk).entities.slice(start, end);
var characterList = List(inlines.map(function (style, ii) {
var data = { style: style, entity: null };
if (entities[ii]) {
data.entity = entities[ii];
}
return CharacterMetadata.create(data);
}));
start = end + 1;
return new ContentBlock({
key: generateRandomKey(),
type: nullthrows(chunk).blocks[ii].type,
depth: nullthrows(chunk).blocks[ii].depth,
text: textBlock,
characterList: characterList
});
}),
entityMap: newEntityMap
};
}
module.exports = convertFromHTMLtoContentBlocks;
/***/ },
/* 180 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getDefaultKeyBinding
* @typechecks
*
*/
'use strict';
var KeyBindingUtil = __webpack_require__(110);
var Keys = __webpack_require__(115);
var UserAgent = __webpack_require__(28);
var isOSX = UserAgent.isPlatform('Mac OS X');
var isWindows = UserAgent.isPlatform('Windows');
// Firefox on OSX had a bug resulting in navigation instead of cursor movement.
// This bug was fixed in Firefox 29. Feature detection is virtually impossible
// so we just check the version number. See #342765.
var shouldFixFirefoxMovement = isOSX && UserAgent.isBrowser('Firefox < 29');
var hasCommandModifier = KeyBindingUtil.hasCommandModifier;
var isCtrlKeyCommand = KeyBindingUtil.isCtrlKeyCommand;
function shouldRemoveWord(e) {
return isOSX && e.altKey || isCtrlKeyCommand(e);
}
/**
* Get the appropriate undo/redo command for a Z key command.
*/
function getZCommand(e) {
if (!hasCommandModifier(e)) {
return null;
}
return e.shiftKey ? 'redo' : 'undo';
}
function getDeleteCommand(e) {
// Allow default "cut" behavior for Windows on Shift + Delete.
if (isWindows && e.shiftKey) {
return null;
}
return shouldRemoveWord(e) ? 'delete-word' : 'delete';
}
function getBackspaceCommand(e) {
if (hasCommandModifier(e) && isOSX) {
return 'backspace-to-start-of-line';
}
return shouldRemoveWord(e) ? 'backspace-word' : 'backspace';
}
/**
* Retrieve a bound key command for the given event.
*/
function getDefaultKeyBinding(e) {
switch (e.keyCode) {
case 66:
// B
return hasCommandModifier(e) ? 'bold' : null;
case 68:
// D
return isCtrlKeyCommand(e) ? 'delete' : null;
case 72:
// H
return isCtrlKeyCommand(e) ? 'backspace' : null;
case 73:
// I
return hasCommandModifier(e) ? 'italic' : null;
case 74:
// J
return hasCommandModifier(e) ? 'code' : null;
case 75:
// K
return !isWindows && isCtrlKeyCommand(e) ? 'secondary-cut' : null;
case 77:
// M
return isCtrlKeyCommand(e) ? 'split-block' : null;
case 79:
// O
return isCtrlKeyCommand(e) ? 'split-block' : null;
case 84:
// T
return isOSX && isCtrlKeyCommand(e) ? 'transpose-characters' : null;
case 85:
// U
return hasCommandModifier(e) ? 'underline' : null;
case 87:
// W
return isOSX && isCtrlKeyCommand(e) ? 'backspace-word' : null;
case 89:
// Y
if (isCtrlKeyCommand(e)) {
return isWindows ? 'redo' : 'secondary-paste';
}
return null;
case 90:
// Z
return getZCommand(e) || null;
case Keys.RETURN:
return 'split-block';
case Keys.DELETE:
return getDeleteCommand(e);
case Keys.BACKSPACE:
return getBackspaceCommand(e);
// LEFT/RIGHT handlers serve as a workaround for a Firefox bug.
case Keys.LEFT:
return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-start-of-block' : null;
case Keys.RIGHT:
return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-end-of-block' : null;
default:
return null;
}
}
module.exports = getDefaultKeyBinding;
/***/ },
/* 181 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getDraftEditorSelectionWithNodes
* @typechecks
*
*/
'use strict';
var findAncestorOffsetKey = __webpack_require__(111);
var getSelectionOffsetKeyForNode = __webpack_require__(185);
var getUpdatedSelectionState = __webpack_require__(187);
var invariant = __webpack_require__(16);
var nullthrows = __webpack_require__(21);
/**
* Convert the current selection range to an anchor/focus pair of offset keys
* and values that can be interpreted by components.
*/
function getDraftEditorSelectionWithNodes(editorState, root, anchorNode, anchorOffset, focusNode, focusOffset) {
var anchorIsTextNode = anchorNode.nodeType === Node.TEXT_NODE;
var focusIsTextNode = focusNode.nodeType === Node.TEXT_NODE;
// If the selection range lies only on text nodes, the task is simple.
// Find the nearest offset-aware elements and use the
// offset values supplied by the selection range.
if (anchorIsTextNode && focusIsTextNode) {
return {
selectionState: getUpdatedSelectionState(editorState, nullthrows(findAncestorOffsetKey(anchorNode)), anchorOffset, nullthrows(findAncestorOffsetKey(focusNode)), focusOffset),
needsRecovery: false
};
}
var anchorPoint = null;
var focusPoint = null;
var needsRecovery = true;
// An element is selected. Convert this selection range into leaf offset
// keys and offset values for consumption at the component level. This
// is common in Firefox, where select-all and triple click behavior leads
// to entire elements being selected.
//
// Note that we use the `needsRecovery` parameter in the callback here. This
// is because when certain elements are selected, the behavior for subsequent
// cursor movement (e.g. via arrow keys) is uncertain and may not match
// expectations at the component level. For example, if an entire <div> is
// selected and the user presses the right arrow, Firefox keeps the selection
// on the <div>. If we allow subsequent keypresses to insert characters
// natively, they will be inserted into a browser-created text node to the
// right of that <div>. This is obviously undesirable.
//
// With the `needsRecovery` flag, we inform the caller that it is responsible
// for manually setting the selection state on the rendered document to
// ensure proper selection state maintenance.
if (anchorIsTextNode) {
anchorPoint = {
key: nullthrows(findAncestorOffsetKey(anchorNode)),
offset: anchorOffset
};
focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
} else if (focusIsTextNode) {
focusPoint = {
key: nullthrows(findAncestorOffsetKey(focusNode)),
offset: focusOffset
};
anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
} else {
anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
// If the selection is collapsed on an empty block, don't force recovery.
// This way, on arrow key selection changes, the browser can move the
// cursor from a non-zero offset on one block, through empty blocks,
// to a matching non-zero offset on other text blocks.
if (anchorNode === focusNode && anchorOffset === focusOffset) {
needsRecovery = !!anchorNode.firstChild && anchorNode.firstChild.nodeName !== 'BR';
}
}
return {
selectionState: getUpdatedSelectionState(editorState, anchorPoint.key, anchorPoint.offset, focusPoint.key, focusPoint.offset),
needsRecovery: needsRecovery
};
}
/**
* Identify the first leaf descendant for the given node.
*/
function getFirstLeaf(node) {
while (node.firstChild && getSelectionOffsetKeyForNode(node.firstChild)) {
node = node.firstChild;
}
return node;
}
/**
* Identify the last leaf descendant for the given node.
*/
function getLastLeaf(node) {
while (node.lastChild && getSelectionOffsetKeyForNode(node.lastChild)) {
node = node.lastChild;
}
return node;
}
function getPointForNonTextNode(editorRoot, startNode, childOffset) {
var node = startNode;
var offsetKey = findAncestorOffsetKey(node);
!(offsetKey != null || editorRoot && (editorRoot === node || editorRoot.firstChild === node)) ? true ? invariant(false, 'Unknown node in selection range.') : invariant(false) : void 0;
// If the editorRoot is the selection, step downward into the content
// wrapper.
if (editorRoot === node) {
node = node.firstChild;
!(node instanceof Element && node.getAttribute('data-contents') === 'true') ? true ? invariant(false, 'Invalid DraftEditorContents structure.') : invariant(false) : void 0;
if (childOffset > 0) {
childOffset = node.childNodes.length;
}
}
// If the child offset is zero and we have an offset key, we're done.
// If there's no offset key because the entire editor is selected,
// find the leftmost ("first") leaf in the tree and use that as the offset
// key.
if (childOffset === 0) {
var key = null;
if (offsetKey != null) {
key = offsetKey;
} else {
var firstLeaf = getFirstLeaf(node);
key = nullthrows(getSelectionOffsetKeyForNode(firstLeaf));
}
return { key: key, offset: 0 };
}
var nodeBeforeCursor = node.childNodes[childOffset - 1];
var leafKey = null;
var textLength = null;
if (!getSelectionOffsetKeyForNode(nodeBeforeCursor)) {
// Our target node may be a leaf or a text node, in which case we're
// already where we want to be and can just use the child's length as
// our offset.
leafKey = nullthrows(offsetKey);
textLength = getTextContentLength(nodeBeforeCursor);
} else {
// Otherwise, we'll look at the child to the left of the cursor and find
// the last leaf node in its subtree.
var lastLeaf = getLastLeaf(nodeBeforeCursor);
leafKey = nullthrows(getSelectionOffsetKeyForNode(lastLeaf));
textLength = getTextContentLength(lastLeaf);
}
return {
key: leafKey,
offset: textLength
};
}
/**
* Return the length of a node's textContent, regarding single newline
* characters as zero-length. This allows us to avoid problems with identifying
* the correct selection offset for empty blocks in IE, in which we
* render newlines instead of break tags.
*/
function getTextContentLength(node) {
var textContent = node.textContent;
return textContent === '\n' ? 0 : textContent.length;
}
module.exports = getDraftEditorSelectionWithNodes;
/***/ },
/* 182 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getFragmentFromSelection
*
*/
'use strict';
var getContentStateFragment = __webpack_require__(77);
function getFragmentFromSelection(editorState) {
var selectionState = editorState.getSelection();
if (selectionState.isCollapsed()) {
return null;
}
return getContentStateFragment(editorState.getCurrentContent(), selectionState);
}
module.exports = getFragmentFromSelection;
/***/ },
/* 183 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getRangeClientRects
* @typechecks
*
*/
'use strict';
var UserAgent = __webpack_require__(28);
var invariant = __webpack_require__(16);
var isChrome = UserAgent.isBrowser('Chrome');
// In Chrome, the client rects will include the entire bounds of all nodes that
// begin (have a start tag) within the selection, even if the selection does
// not overlap the entire node. To resolve this, we split the range at each
// start tag and join the client rects together.
// https://code.google.com/p/chromium/issues/detail?id=324437
/* eslint-disable consistent-return */
function getRangeClientRectsChrome(range) {
var tempRange = range.cloneRange();
var clientRects = [];
for (var ancestor = range.endContainer; ancestor != null; ancestor = ancestor.parentNode) {
// If we've climbed up to the common ancestor, we can now use the
// original start point and stop climbing the tree.
var atCommonAncestor = ancestor === range.commonAncestorContainer;
if (atCommonAncestor) {
tempRange.setStart(range.startContainer, range.startOffset);
} else {
tempRange.setStart(tempRange.endContainer, 0);
}
var rects = Array.from(tempRange.getClientRects());
clientRects.push(rects);
if (atCommonAncestor) {
var _ref;
clientRects.reverse();
return (_ref = []).concat.apply(_ref, clientRects);
}
tempRange.setEndBefore(ancestor);
}
true ? true ? invariant(false, 'Found an unexpected detached subtree when getting range client rects.') : invariant(false) : void 0;
}
/* eslint-enable consistent-return */
/**
* Like range.getClientRects() but normalizes for browser bugs.
*/
var getRangeClientRects = isChrome ? getRangeClientRectsChrome : function (range) {
return Array.from(range.getClientRects());
};
module.exports = getRangeClientRects;
/***/ },
/* 184 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getSafeBodyFromHTML
*
*/
'use strict';
var UserAgent = __webpack_require__(28);
var isOldIE = UserAgent.isBrowser('IE <= 9');
// Provides a dom node that will not execute scripts
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation.createHTMLDocument
// https://developer.mozilla.org/en-US/Add-ons/Code_snippets/HTML_to_DOM
function getSafeBodyFromHTML(html) {
var doc;
var root = null;
// Provides a safe context
if (!isOldIE && document.implementation && document.implementation.createHTMLDocument) {
doc = document.implementation.createHTMLDocument('foo');
doc.documentElement.innerHTML = html;
root = doc.getElementsByTagName('body')[0];
}
return root;
}
module.exports = getSafeBodyFromHTML;
/***/ },
/* 185 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getSelectionOffsetKeyForNode
* @typechecks
*
*/
'use strict';
/**
* Get offset key from a node or it's child nodes. Return the first offset key
* found on the DOM tree of given node.
*/
function getSelectionOffsetKeyForNode(node) {
if (node instanceof Element) {
var offsetKey = node.getAttribute('data-offset-key');
if (offsetKey) {
return offsetKey;
}
for (var ii = 0; ii < node.childNodes.length; ii++) {
var childOffsetKey = getSelectionOffsetKeyForNode(node.childNodes[ii]);
if (childOffsetKey) {
return childOffsetKey;
}
}
}
return null;
}
module.exports = getSelectionOffsetKeyForNode;
/***/ },
/* 186 */
/***/ function(module, exports) {
/* WEBPACK VAR INJECTION */(function(global) {/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getTextContentFromFiles
*
*/
'use strict';
var TEXT_CLIPPING_REGEX = /\.textClipping$/;
var TEXT_TYPES = {
'text/plain': true,
'text/html': true,
'text/rtf': true
};
// Somewhat arbitrary upper bound on text size. Let's not lock up the browser.
var TEXT_SIZE_UPPER_BOUND = 5000;
/**
* Extract the text content from a file list.
*/
function getTextContentFromFiles(files, callback) {
var readCount = 0;
var results = [];
files.forEach(function ( /*blob*/file) {
readFile(file, function ( /*string*/text) {
readCount++;
text && results.push(text.slice(0, TEXT_SIZE_UPPER_BOUND));
if (readCount == files.length) {
callback(results.join('\r'));
}
});
});
}
/**
* todo isaac: Do work to turn html/rtf into a content fragment.
*/
function readFile(file, callback) {
if (!global.FileReader || file.type && !(file.type in TEXT_TYPES)) {
callback('');
return;
}
if (file.type === '') {
var contents = '';
// Special-case text clippings, which have an empty type but include
// `.textClipping` in the file name. `readAsText` results in an empty
// string for text clippings, so we force the file name to serve
// as the text value for the file.
if (TEXT_CLIPPING_REGEX.test(file.name)) {
contents = file.name.replace(TEXT_CLIPPING_REGEX, '');
}
callback(contents);
return;
}
var reader = new FileReader();
reader.onload = function () {
callback(reader.result);
};
reader.onerror = function () {
callback('');
};
reader.readAsText(file);
}
module.exports = getTextContentFromFiles;
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ },
/* 187 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule getUpdatedSelectionState
*
*/
'use strict';
var DraftOffsetKey = __webpack_require__(62);
var nullthrows = __webpack_require__(21);
function getUpdatedSelectionState(editorState, anchorKey, anchorOffset, focusKey, focusOffset) {
var selection = nullthrows(editorState.getSelection());
if (true) {
if (!anchorKey || !focusKey) {
/*eslint-disable no-console */
console.warn('Invalid selection state.', arguments, editorState.toJS());
/*eslint-enable no-console */
return selection;
}
}
var anchorPath = DraftOffsetKey.decode(anchorKey);
var anchorBlockKey = anchorPath.blockKey;
var anchorLeaf = editorState.getBlockTree(anchorBlockKey).getIn([anchorPath.decoratorKey, 'leaves', anchorPath.leafKey]);
var focusPath = DraftOffsetKey.decode(focusKey);
var focusBlockKey = focusPath.blockKey;
var focusLeaf = editorState.getBlockTree(focusBlockKey).getIn([focusPath.decoratorKey, 'leaves', focusPath.leafKey]);
var anchorLeafStart = anchorLeaf.get('start');
var focusLeafStart = focusLeaf.get('start');
var anchorBlockOffset = anchorLeaf ? anchorLeafStart + anchorOffset : null;
var focusBlockOffset = focusLeaf ? focusLeafStart + focusOffset : null;
var areEqual = selection.getAnchorKey() === anchorBlockKey && selection.getAnchorOffset() === anchorBlockOffset && selection.getFocusKey() === focusBlockKey && selection.getFocusOffset() === focusBlockOffset;
if (areEqual) {
return selection;
}
var isBackward = false;
if (anchorBlockKey === focusBlockKey) {
var anchorLeafEnd = anchorLeaf.get('end');
var focusLeafEnd = focusLeaf.get('end');
if (focusLeafStart === anchorLeafStart && focusLeafEnd === anchorLeafEnd) {
isBackward = focusOffset < anchorOffset;
} else {
isBackward = focusLeafStart < anchorLeafStart;
}
} else {
var startKey = editorState.getCurrentContent().getBlockMap().keySeq().skipUntil(function (v) {
return v === anchorBlockKey || v === focusBlockKey;
}).first();
isBackward = startKey === focusBlockKey;
}
return selection.merge({
anchorKey: anchorBlockKey,
anchorOffset: anchorBlockOffset,
focusKey: focusBlockKey,
focusOffset: focusBlockOffset,
isBackward: isBackward
});
}
module.exports = getUpdatedSelectionState;
/***/ },
/* 188 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule insertIntoList
*
*/
'use strict';
/**
* Maintain persistence for target list when appending and prepending.
*/
function insertIntoList(targetList, toInsert, offset) {
if (offset === targetList.count()) {
toInsert.forEach(function (c) {
targetList = targetList.push(c);
});
} else if (offset === 0) {
toInsert.reverse().forEach(function (c) {
targetList = targetList.unshift(c);
});
} else {
var head = targetList.slice(0, offset);
var tail = targetList.slice(offset);
targetList = head.concat(toInsert, tail).toList();
}
return targetList;
}
module.exports = insertIntoList;
/***/ },
/* 189 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule isSelectionAtLeafStart
* @typechecks
*
*/
'use strict';
function isSelectionAtLeafStart(editorState) {
var selection = editorState.getSelection();
var anchorKey = selection.getAnchorKey();
var blockTree = editorState.getBlockTree(anchorKey);
var offset = selection.getStartOffset();
var isAtStart = false;
blockTree.some(function (leafSet) {
if (offset === leafSet.get('start')) {
isAtStart = true;
return true;
}
if (offset < leafSet.get('end')) {
return leafSet.get('leaves').some(function (leaf) {
var leafStart = leaf.get('start');
if (offset === leafStart) {
isAtStart = true;
return true;
}
return false;
});
}
return false;
});
return isAtStart;
}
module.exports = isSelectionAtLeafStart;
/***/ },
/* 190 */
/***/ function(module, exports) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule moveSelectionForward
*
*/
'use strict';
/**
* Given a collapsed selection, move the focus `maxDistance` forward within
* the selected block. If the selection will go beyond the end of the block,
* move focus to the start of the next block, but no further.
*
* This function is not Unicode-aware, so surrogate pairs will be treated
* as having length 2.
*/
function moveSelectionForward(editorState, maxDistance) {
var selection = editorState.getSelection();
var key = selection.getStartKey();
var offset = selection.getStartOffset();
var content = editorState.getCurrentContent();
var focusKey = key;
var focusOffset;
var block = content.getBlockForKey(key);
if (maxDistance > block.getText().length - offset) {
focusKey = content.getKeyAfter(key);
focusOffset = 0;
} else {
focusOffset = offset + maxDistance;
}
return selection.merge({ focusKey: focusKey, focusOffset: focusOffset });
}
module.exports = moveSelectionForward;
/***/ },
/* 191 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule removeEntitiesAtEdges
*
*/
'use strict';
var CharacterMetadata = __webpack_require__(25);
var findRangesImmutable = __webpack_require__(76);
var invariant = __webpack_require__(16);
function removeEntitiesAtEdges(contentState, selectionState) {
var blockMap = contentState.getBlockMap();
var entityMap = contentState.getEntityMap();
var updatedBlocks = {};
var startKey = selectionState.getStartKey();
var startOffset = selectionState.getStartOffset();
var startBlock = blockMap.get(startKey);
var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
if (updatedStart !== startBlock) {
updatedBlocks[startKey] = updatedStart;
}
var endKey = selectionState.getEndKey();
var endOffset = selectionState.getEndOffset();
var endBlock = blockMap.get(endKey);
if (startKey === endKey) {
endBlock = updatedStart;
}
var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
if (updatedEnd !== endBlock) {
updatedBlocks[endKey] = updatedEnd;
}
if (!Object.keys(updatedBlocks).length) {
return contentState.set('selectionAfter', selectionState);
}
return contentState.merge({
blockMap: blockMap.merge(updatedBlocks),
selectionAfter: selectionState
});
}
function getRemovalRange(characters, key, offset) {
var removalRange;
findRangesImmutable(characters, function (a, b) {
return a.getEntity() === b.getEntity();
}, function (element) {
return element.getEntity() === key;
}, function (start, end) {
if (start <= offset && end >= offset) {
removalRange = { start: start, end: end };
}
});
!(typeof removalRange === 'object') ? true ? invariant(false, 'Removal range must exist within character list.') : invariant(false) : void 0;
return removalRange;
}
function removeForBlock(entityMap, block, offset) {
var chars = block.getCharacterList();
var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
var entity = entityMap.__get(entityAfterCursor);
if (entity.getMutability() !== 'MUTABLE') {
var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset);
var start = _getRemovalRange.start;
var end = _getRemovalRange.end;
var current;
while (start < end) {
current = chars.get(start);
chars = chars.set(start, CharacterMetadata.applyEntity(current, null));
start++;
}
return block.set('characterList', chars);
}
}
return block;
}
module.exports = removeEntitiesAtEdges;
/***/ },
/* 192 */
/***/ function(module, exports) {
/**
* Helper function for iterating over a collection
*
* @param collection
* @param fn
*/
function each(collection, fn) {
var i = 0,
length = collection.length,
cont;
for(i; i < length; i++) {
cont = fn(collection[i], i);
if(cont === false) {
break; //allow early exit
}
}
}
/**
* Helper function for determining whether target object is an array
*
* @param target the object under test
* @return {Boolean} true if array, false otherwise
*/
function isArray(target) {
return Object.prototype.toString.apply(target) === '[object Array]';
}
/**
* Helper function for determining whether target object is a function
*
* @param target the object under test
* @return {Boolean} true if function, false otherwise
*/
function isFunction(target) {
return typeof target === 'function';
}
module.exports = {
isFunction : isFunction,
isArray : isArray,
each : each
};
/***/ },
/* 193 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
var PhotosMimeType = __webpack_require__(494);
var createArrayFromMixed = __webpack_require__(501);
var emptyFunction = __webpack_require__(118);
var CR_LF_REGEX = new RegExp('\r\n', 'g');
var LF_ONLY = '\n';
var RICH_TEXT_TYPES = {
'text/rtf': 1,
'text/html': 1
};
/**
* If DataTransferItem is a file then return the Blob of data.
*
* @param {object} item
* @return {?blob}
*/
function getFileFromDataTransfer(item) {
if (item.kind == 'file') {
return item.getAsFile();
}
}
var DataTransfer = function () {
/**
* @param {object} data
*/
function DataTransfer(data) {
_classCallCheck(this, DataTransfer);
this.data = data;
// Types could be DOMStringList or array
this.types = data.types ? createArrayFromMixed(data.types) : [];
}
/**
* Is this likely to be a rich text data transfer?
*
* @return {boolean}
*/
DataTransfer.prototype.isRichText = function isRichText() {
// If HTML is available, treat this data as rich text. This way, we avoid
// using a pasted image if it is packaged with HTML -- this may occur with
// pastes from MS Word, for example. However this is only rich text if
// there's accompanying text.
if (this.getHTML() && this.getText()) {
return true;
}
// When an image is copied from a preview window, you end up with two
// DataTransferItems one of which is a file's metadata as text. Skip those.
if (this.isImage()) {
return false;
}
return this.types.some(function (type) {
return RICH_TEXT_TYPES[type];
});
};
/**
* Get raw text.
*
* @return {?string}
*/
DataTransfer.prototype.getText = function getText() {
var text;
if (this.data.getData) {
if (!this.types.length) {
text = this.data.getData('Text');
} else if (this.types.indexOf('text/plain') != -1) {
text = this.data.getData('text/plain');
}
}
return text ? text.replace(CR_LF_REGEX, LF_ONLY) : null;
};
/**
* Get HTML paste data
*
* @return {?string}
*/
DataTransfer.prototype.getHTML = function getHTML() {
if (this.data.getData) {
if (!this.types.length) {
return this.data.getData('Text');
} else if (this.types.indexOf('text/html') != -1) {
return this.data.getData('text/html');
}
}
};
/**
* Is this a link data transfer?
*
* @return {boolean}
*/
DataTransfer.prototype.isLink = function isLink() {
return this.types.some(function (type) {
return type.indexOf('Url') != -1 || type.indexOf('text/uri-list') != -1 || type.indexOf('text/x-moz-url');
});
};
/**
* Get a link url.
*
* @return {?string}
*/
DataTransfer.prototype.getLink = function getLink() {
if (this.data.getData) {
if (this.types.indexOf('text/x-moz-url') != -1) {
var url = this.data.getData('text/x-moz-url').split('\n');
return url[0];
}
return this.types.indexOf('text/uri-list') != -1 ? this.data.getData('text/uri-list') : this.data.getData('url');
}
return null;
};
/**
* Is this an image data transfer?
*
* @return {boolean}
*/
DataTransfer.prototype.isImage = function isImage() {
var isImage = this.types.some(function (type) {
// Firefox will have a type of application/x-moz-file for images during
// dragging
return type.indexOf('application/x-moz-file') != -1;
});
if (isImage) {
return true;
}
var items = this.getFiles();
for (var i = 0; i < items.length; i++) {
var type = items[i].type;
if (!PhotosMimeType.isImage(type)) {
return false;
}
}
return true;
};
DataTransfer.prototype.getCount = function getCount() {
if (this.data.hasOwnProperty('items')) {
return this.data.items.length;
} else if (this.data.hasOwnProperty('mozItemCount')) {
return this.data.mozItemCount;
} else if (this.data.files) {
return this.data.files.length;
}
return null;
};
/**
* Get files.
*
* @return {array}
*/
DataTransfer.prototype.getFiles = function getFiles() {
if (this.data.items) {
// createArrayFromMixed doesn't properly handle DataTransferItemLists.
return Array.prototype.slice.call(this.data.items).map(getFileFromDataTransfer).filter(emptyFunction.thatReturnsArgument);
} else if (this.data.files) {
return Array.prototype.slice.call(this.data.files);
} else {
return [];
}
};
/**
* Are there any files to fetch?
*
* @return {boolean}
*/
DataTransfer.prototype.hasFiles = function hasFiles() {
return this.getFiles().length > 0;
};
return DataTransfer;
}();
module.exports = DataTransfer;
/***/ },
/* 194 */
/***/ function(module, exports) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
/**
* @param {DOMElement} element
* @param {DOMDocument} doc
* @return {boolean}
*/
function _isViewportScrollElement(element, doc) {
return !!doc && (element === doc.documentElement || element === doc.body);
}
/**
* Scroll Module. This class contains 4 simple static functions
* to be used to access Element.scrollTop/scrollLeft properties.
* To solve the inconsistencies between browsers when either
* document.body or document.documentElement is supplied,
* below logic will be used to alleviate the issue:
*
* 1. If 'element' is either 'document.body' or 'document.documentElement,
* get whichever element's 'scroll{Top,Left}' is larger.
* 2. If 'element' is either 'document.body' or 'document.documentElement',
* set the 'scroll{Top,Left}' on both elements.
*/
var Scroll = {
/**
* @param {DOMElement} element
* @return {number}
*/
getTop: function getTop(element) {
var doc = element.ownerDocument;
return _isViewportScrollElement(element, doc) ?
// In practice, they will either both have the same value,
// or one will be zero and the other will be the scroll position
// of the viewport. So we can use `X || Y` instead of `Math.max(X, Y)`
doc.body.scrollTop || doc.documentElement.scrollTop : element.scrollTop;
},
/**
* @param {DOMElement} element
* @param {number} newTop
*/
setTop: function setTop(element, newTop) {
var doc = element.ownerDocument;
if (_isViewportScrollElement(element, doc)) {
doc.body.scrollTop = doc.documentElement.scrollTop = newTop;
} else {
element.scrollTop = newTop;
}
},
/**
* @param {DOMElement} element
* @return {number}
*/
getLeft: function getLeft(element) {
var doc = element.ownerDocument;
return _isViewportScrollElement(element, doc) ? doc.body.scrollLeft || doc.documentElement.scrollLeft : element.scrollLeft;
},
/**
* @param {DOMElement} element
* @param {number} newLeft
*/
setLeft: function setLeft(element, newLeft) {
var doc = element.ownerDocument;
if (_isViewportScrollElement(element, doc)) {
doc.body.scrollLeft = doc.documentElement.scrollLeft = newLeft;
} else {
element.scrollLeft = newLeft;
}
}
};
module.exports = Scroll;
/***/ },
/* 195 */
/***/ function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*
*/
/**
* Basic (stateless) API for text direction detection
*
* Part of our implementation of Unicode Bidirectional Algorithm (UBA)
* Unicode Standard Annex #9 (UAX9)
* http://www.unicode.org/reports/tr9/
*/
'use strict';
var UnicodeBidiDirection = __webpack_require__(117);
var invariant = __webpack_require__(16);
/**
* RegExp ranges of characters with a *Strong* Bidi_Class value.
*
* Data is based on DerivedBidiClass.txt in UCD version 7.0.0.
*
* NOTE: For performance reasons, we only support Unicode's
* Basic Multilingual Plane (BMP) for now.
*/
var RANGE_BY_BIDI_TYPE = {
L: 'A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u01BA\u01BB' + '\u01BC-\u01BF\u01C0-\u01C3\u01C4-\u0293\u0294\u0295-\u02AF\u02B0-\u02B8' + '\u02BB-\u02C1\u02D0-\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376-\u0377' + '\u037A\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1' + '\u03A3-\u03F5\u03F7-\u0481\u0482\u048A-\u052F\u0531-\u0556\u0559' + '\u055A-\u055F\u0561-\u0587\u0589\u0903\u0904-\u0939\u093B\u093D' + '\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0950\u0958-\u0961\u0964-\u0965' + '\u0966-\u096F\u0970\u0971\u0972-\u0980\u0982-\u0983\u0985-\u098C' + '\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD' + '\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09CE\u09D7\u09DC-\u09DD' + '\u09DF-\u09E1\u09E6-\u09EF\u09F0-\u09F1\u09F4-\u09F9\u09FA\u0A03' + '\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33' + '\u0A35-\u0A36\u0A38-\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F' + '\u0A72-\u0A74\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0' + '\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0AD0' + '\u0AE0-\u0AE1\u0AE6-\u0AEF\u0AF0\u0B02-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10' + '\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40' + '\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F' + '\u0B70\u0B71\u0B72-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95' + '\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9' + '\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7' + '\u0BE6-\u0BEF\u0BF0-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10' + '\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C59\u0C60-\u0C61' + '\u0C66-\u0C6F\u0C7F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8' + '\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CBE\u0CBF\u0CC0-\u0CC4\u0CC6' + '\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF' + '\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D' + '\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D57\u0D60-\u0D61' + '\u0D66-\u0D6F\u0D70-\u0D75\u0D79\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96' + '\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF' + '\u0DE6-\u0DEF\u0DF2-\u0DF3\u0DF4\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45' + '\u0E46\u0E4F\u0E50-\u0E59\u0E5A-\u0E5B\u0E81-\u0E82\u0E84\u0E87-\u0E88' + '\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7' + '\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6' + '\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F01-\u0F03\u0F04-\u0F12\u0F13\u0F14' + '\u0F15-\u0F17\u0F1A-\u0F1F\u0F20-\u0F29\u0F2A-\u0F33\u0F34\u0F36\u0F38' + '\u0F3E-\u0F3F\u0F40-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C' + '\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FCF\u0FD0-\u0FD4\u0FD5-\u0FD8' + '\u0FD9-\u0FDA\u1000-\u102A\u102B-\u102C\u1031\u1038\u103B-\u103C\u103F' + '\u1040-\u1049\u104A-\u104F\u1050-\u1055\u1056-\u1057\u105A-\u105D\u1061' + '\u1062-\u1064\u1065-\u1066\u1067-\u106D\u106E-\u1070\u1075-\u1081' + '\u1083-\u1084\u1087-\u108C\u108E\u108F\u1090-\u1099\u109A-\u109C' + '\u109E-\u109F\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FB\u10FC' + '\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288' + '\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5' + '\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u1368' + '\u1369-\u137C\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166D-\u166E' + '\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EB-\u16ED\u16EE-\u16F0' + '\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1735-\u1736' + '\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5' + '\u17C7-\u17C8\u17D4-\u17D6\u17D7\u17D8-\u17DA\u17DC\u17E0-\u17E9' + '\u1810-\u1819\u1820-\u1842\u1843\u1844-\u1877\u1880-\u18A8\u18AA' + '\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930-\u1931' + '\u1933-\u1938\u1946-\u194F\u1950-\u196D\u1970-\u1974\u1980-\u19AB' + '\u19B0-\u19C0\u19C1-\u19C7\u19C8-\u19C9\u19D0-\u19D9\u19DA\u1A00-\u1A16' + '\u1A19-\u1A1A\u1A1E-\u1A1F\u1A20-\u1A54\u1A55\u1A57\u1A61\u1A63-\u1A64' + '\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA7\u1AA8-\u1AAD' + '\u1B04\u1B05-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B45-\u1B4B' + '\u1B50-\u1B59\u1B5A-\u1B60\u1B61-\u1B6A\u1B74-\u1B7C\u1B82\u1B83-\u1BA0' + '\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAE-\u1BAF\u1BB0-\u1BB9\u1BBA-\u1BE5\u1BE7' + '\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1BFC-\u1BFF\u1C00-\u1C23\u1C24-\u1C2B' + '\u1C34-\u1C35\u1C3B-\u1C3F\u1C40-\u1C49\u1C4D-\u1C4F\u1C50-\u1C59' + '\u1C5A-\u1C77\u1C78-\u1C7D\u1C7E-\u1C7F\u1CC0-\u1CC7\u1CD3\u1CE1' + '\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF2-\u1CF3\u1CF5-\u1CF6\u1D00-\u1D2B' + '\u1D2C-\u1D6A\u1D6B-\u1D77\u1D78\u1D79-\u1D9A\u1D9B-\u1DBF\u1E00-\u1F15' + '\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D' + '\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC' + '\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E' + '\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D' + '\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2135-\u2138\u2139' + '\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2182\u2183-\u2184' + '\u2185-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF' + '\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C7B\u2C7C-\u2C7D\u2C7E-\u2CE4' + '\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F' + '\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE' + '\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005\u3006\u3007' + '\u3021-\u3029\u302E-\u302F\u3031-\u3035\u3038-\u303A\u303B\u303C' + '\u3041-\u3096\u309D-\u309E\u309F\u30A1-\u30FA\u30FC-\u30FE\u30FF' + '\u3105-\u312D\u3131-\u318E\u3190-\u3191\u3192-\u3195\u3196-\u319F' + '\u31A0-\u31BA\u31F0-\u31FF\u3200-\u321C\u3220-\u3229\u322A-\u3247' + '\u3248-\u324F\u3260-\u327B\u327F\u3280-\u3289\u328A-\u32B0\u32C0-\u32CB' + '\u32D0-\u32FE\u3300-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DB5' + '\u4E00-\u9FCC\uA000-\uA014\uA015\uA016-\uA48C\uA4D0-\uA4F7\uA4F8-\uA4FD' + '\uA4FE-\uA4FF\uA500-\uA60B\uA60C\uA610-\uA61F\uA620-\uA629\uA62A-\uA62B' + '\uA640-\uA66D\uA66E\uA680-\uA69B\uA69C-\uA69D\uA6A0-\uA6E5\uA6E6-\uA6EF' + '\uA6F2-\uA6F7\uA722-\uA76F\uA770\uA771-\uA787\uA789-\uA78A\uA78B-\uA78E' + '\uA790-\uA7AD\uA7B0-\uA7B1\uA7F7\uA7F8-\uA7F9\uA7FA\uA7FB-\uA801' + '\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA823-\uA824\uA827\uA830-\uA835' + '\uA836-\uA837\uA840-\uA873\uA880-\uA881\uA882-\uA8B3\uA8B4-\uA8C3' + '\uA8CE-\uA8CF\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8F8-\uA8FA\uA8FB\uA900-\uA909' + '\uA90A-\uA925\uA92E-\uA92F\uA930-\uA946\uA952-\uA953\uA95F\uA960-\uA97C' + '\uA983\uA984-\uA9B2\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uA9C1-\uA9CD' + '\uA9CF\uA9D0-\uA9D9\uA9DE-\uA9DF\uA9E0-\uA9E4\uA9E6\uA9E7-\uA9EF' + '\uA9F0-\uA9F9\uA9FA-\uA9FE\uAA00-\uAA28\uAA2F-\uAA30\uAA33-\uAA34' + '\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uAA60-\uAA6F' + '\uAA70\uAA71-\uAA76\uAA77-\uAA79\uAA7A\uAA7B\uAA7D\uAA7E-\uAAAF\uAAB1' + '\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAADD\uAADE-\uAADF' + '\uAAE0-\uAAEA\uAAEB\uAAEE-\uAAEF\uAAF0-\uAAF1\uAAF2\uAAF3-\uAAF4\uAAF5' + '\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E' + '\uAB30-\uAB5A\uAB5B\uAB5C-\uAB5F\uAB64-\uAB65\uABC0-\uABE2\uABE3-\uABE4' + '\uABE6-\uABE7\uABE9-\uABEA\uABEB\uABEC\uABF0-\uABF9\uAC00-\uD7A3' + '\uD7B0-\uD7C6\uD7CB-\uD7FB\uE000-\uF8FF\uF900-\uFA6D\uFA70-\uFAD9' + '\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFF6F\uFF70' + '\uFF71-\uFF9D\uFF9E-\uFF9F\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF' + '\uFFD2-\uFFD7\uFFDA-\uFFDC',
R: '\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05D0-\u05EA\u05EB-\u05EF' + '\u05F0-\u05F2\u05F3-\u05F4\u05F5-\u05FF\u07C0-\u07C9\u07CA-\u07EA' + '\u07F4-\u07F5\u07FA\u07FB-\u07FF\u0800-\u0815\u081A\u0824\u0828' + '\u082E-\u082F\u0830-\u083E\u083F\u0840-\u0858\u085C-\u085D\u085E' + '\u085F-\u089F\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB37\uFB38-\uFB3C' + '\uFB3D\uFB3E\uFB3F\uFB40-\uFB41\uFB42\uFB43-\uFB44\uFB45\uFB46-\uFB4F',
AL: '\u0608\u060B\u060D\u061B\u061C\u061D\u061E-\u061F\u0620-\u063F\u0640' + '\u0641-\u064A\u066D\u066E-\u066F\u0671-\u06D3\u06D4\u06D5\u06E5-\u06E6' + '\u06EE-\u06EF\u06FA-\u06FC\u06FD-\u06FE\u06FF\u0700-\u070D\u070E\u070F' + '\u0710\u0712-\u072F\u074B-\u074C\u074D-\u07A5\u07B1\u07B2-\u07BF' + '\u08A0-\u08B2\u08B3-\u08E3\uFB50-\uFBB1\uFBB2-\uFBC1\uFBC2-\uFBD2' + '\uFBD3-\uFD3D\uFD40-\uFD4F\uFD50-\uFD8F\uFD90-\uFD91\uFD92-\uFDC7' + '\uFDC8-\uFDCF\uFDF0-\uFDFB\uFDFC\uFDFE-\uFDFF\uFE70-\uFE74\uFE75' + '\uFE76-\uFEFC\uFEFD-\uFEFE'
};
var REGEX_STRONG = new RegExp('[' + RANGE_BY_BIDI_TYPE.L + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
var REGEX_RTL = new RegExp('[' + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
/**
* Returns the first strong character (has Bidi_Class value of L, R, or AL).
*
* @param str A text block; e.g. paragraph, table cell, tag
* @return A character with strong bidi direction, or null if not found
*/
function firstStrongChar(str) {
var match = REGEX_STRONG.exec(str);
return match == null ? null : match[0];
}
/**
* Returns the direction of a block of text, based on the direction of its
* first strong character (has Bidi_Class value of L, R, or AL).
*
* @param str A text block; e.g. paragraph, table cell, tag
* @return The resolved direction
*/
function firstStrongCharDir(str) {
var strongChar = firstStrongChar(str);
if (strongChar == null) {
return UnicodeBidiDirection.NEUTRAL;
}
return REGEX_RTL.exec(strongChar) ? UnicodeBidiDirection.RTL : UnicodeBidiDirection.LTR;
}
/**
* Returns the direction of a block of text, based on the direction of its
* first strong character (has Bidi_Class value of L, R, or AL), or a fallback
* direction, if no strong character is found.
*
* This function is supposed to be used in respect to Higher-Level Protocol
* rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
*
* @param str A text block; e.g. paragraph, table cell, tag
* @param fallback Fallback direction, used if no strong direction detected
* for the block (default = NEUTRAL)
* @return The resolved direction
*/
function resolveBlockDir(str, fallback) {
fallback = fallback || UnicodeBidiDirection.NEUTRAL;
if (!str.length) {
return fallback;
}
var blockDir = firstStrongCharDir(str);
return blockDir === UnicodeBidiDirection.NEUTRAL ? fallback : blockDir;
}
/**
* Returns the direction of a block of text, based on the direction of its
* first strong character (has Bidi_Class value of L, R, or AL), or a fallback
* direction, if no strong character is found.
*
* NOTE: This function is similar to resolveBlockDir(), but uses the global
* direction as the fallback, so it *always* returns a Strong direction,
* making it useful for integration in places that you need to make the final
* decision, like setting some CSS class.
*
* This function is supposed to be used in respect to Higher-Level Protocol
* rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
*
* @param str A text block; e.g. paragraph, table cell
* @param strongFallback Fallback direction, used if no strong direction
* detected for the block (default = global direction)
* @return The resolved Strong direction
*/
function getDirection(str, strongFallback) {
if (!strongFallback) {
strongFallback = UnicodeBidiDirection.getGlobalDir();
}
!UnicodeBidiDirection.isStrong(strongFallback) ? true ? invariant(false, 'Fallback direction must be a strong direction') : invariant(false) : void 0;
return resolveBlockDir(str, strongFallback);
}
/**
* Returns true if getDirection(arguments...) returns LTR.
*
* @param str A text block; e.g. paragraph, table cell
* @param strongFallback Fallback direction, used if no strong direction
* detected for the block (default = global direction)
* @return True if the resolved direction is LTR
*/
function isDirectionLTR(str, strongFallback) {
return getDirection(str, strongFallback) === UnicodeBidiDirection.LTR;
}
/**
* Returns true if getDirection(arguments...) returns RTL.
*
* @param str A text block; e.g. paragraph, table cell
* @param strongFallback Fallback direction, used if no strong direction
* detected for the block (default = global direction)
* @return True if the resolved direction is RTL
*/
function isDirectionRTL(str, strongFallback) {
return getDirection(str, strongFallback) === UnicodeBidiDirection.RTL;
}
var UnicodeBidi = {
firstStrongChar: firstStrongChar,
firstStrongCharDir: firstStrongCharDir,
resolveBlockDir: resolveBlockDir,
getDirection: getDirection,
isDirectionLTR: isDirectionLTR,
isDirectionRTL: isDirectionRTL
};
module.exports = UnicodeBidi;
/***/ },
/* 196 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
var isTextNode = __webpack_require__(510);
/*eslint-disable no-bitwise */
/**
* Checks if a given DOM node contains or is another DOM node.
*/
function containsNode(outerNode, innerNode) {
if (!outerNode || !innerNode) {
return false;
} else if (outerNode === innerNode) {
return true;
} else if (isTextNode(outerNode)) {
return false;
} else if (isTextNode(innerNode)) {
return containsNode(outerNode, innerNode.parentNode);
} else if ('contains' in outerNode) {
return outerNode.contains(innerNode);
} else if (outerNode.compareDocumentPosition) {
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
} else {
return false;
}
}
module.exports = containsNode;
/***/ },
/* 197 */
/***/ function(module, exports) {
'use strict';
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
/* eslint-disable fb-www/typeof-undefined */
/**
* Same as document.activeElement but wraps in a try-catch block. In IE it is
* not safe to call document.activeElement if there is nothing focused.
*
* The activeElement will be null only if the document or document body is not
* yet defined.
*
* @param {?DOMDocument} doc Defaults to current document.
* @return {?DOMElement}
*/
function getActiveElement(doc) /*?DOMElement*/{
doc = doc || (typeof document !== 'undefined' ? document : undefined);
if (typeof doc === 'undefined') {
return null;
}
try {
return doc.activeElement || doc.body;
} catch (e) {
return doc.body;
}
}
module.exports = getActiveElement;
/***/ },
/* 198 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
'use strict';
// setimmediate adds setImmediate to the global. We want to make sure we export
// the actual function.
__webpack_require__(683);
module.exports = global.setImmediate;
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ },
/* 199 */
/***/ function(module, exports, __webpack_require__) {
var camel2hyphen = __webpack_require__(684);
var isDimension = function (feature) {
var re = /[height|width]$/;
return re.test(feature);
};
var obj2mq = function (obj) {
var mq = '';
var features = Object.keys(obj);
features.forEach(function (feature, index) {
var value = obj[feature];
feature = camel2hyphen(feature);
// Add px to dimension features
if (isDimension(feature) && typeof value === 'number') {
value = value + 'px';
}
if (value === true) {
mq += feature;
} else if (value === false) {
mq += 'not ' + feature;
} else {
mq += '(' + feature + ': ' + value + ')';
}
if (index < features.length-1) {
mq += ' and '
}
});
return mq;
};
var json2mq = function (query) {
var mq = '';
if (typeof query === 'string') {
return query;
}
// Handling array of media queries
if (query instanceof Array) {
query.forEach(function (q, index) {
mq += obj2mq(q);
if (index < query.length-1) {
mq += ', '
}
});
return mq;
}
// Handling single media query
return obj2mq(query);
};
module.exports = json2mq;
/***/ },
/* 200 */
/***/ function(module, exports) {
/* WEBPACK VAR INJECTION */(function(global) {/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/,
reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
function isHostObject(value) {
// Many host objects are `Object` objects that can coerce to strings
// despite having improperly defined `toString` methods.
var result = false;
if (value != null && typeof value.toString != 'function') {
try {
result = !!(value + '');
} catch (e) {}
}
return result;
}
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/** Built-in value references. */
var Symbol = root.Symbol,
splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
}
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {
var data = this.__data__;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
return this;
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
}
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index == lastIndex) {
data.pop();
} else {
splice.call(data, index, 1);
}
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
'string': new Hash
};
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
/**
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;
while (object != null && index < length) {
object = object[toKey(path[index++])];
}
return (index && index == length) ? object : undefined;
}
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {
if (isArray(value)) {
return false;
}
var type = typeof value;
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
return true;
}
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
(object != null && value in Object(object));
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
}
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
}
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoize(function(string) {
string = toString(string);
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;
});
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {
if (typeof value == 'string' || isSymbol(value)) {
return value;
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return '';
}
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result);
return result;
};
memoized.cache = new (memoize.Cache || MapCache);
return memoized;
}
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 8-9 which returns 'object' for typed array and other constructors.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
function get(object, path, defaultValue) {
var result = object == null ? undefined : baseGet(object, path);
return result === undefined ? defaultValue : result;
}
module.exports = get;
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ },
/* 201 */
/***/ function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var util = {
isAppearSupported: function isAppearSupported(props) {
return props.transitionName && props.transitionAppear || props.animation.appear;
},
isEnterSupported: function isEnterSupported(props) {
return props.transitionName && props.transitionEnter || props.animation.enter;
},
isLeaveSupported: function isLeaveSupported(props) {
return props.transitionName && props.transitionLeave || props.animation.leave;
},
allowAppearCallback: function allowAppearCallback(props) {
return props.transitionAppear || props.animation.appear;
},
allowEnterCallback: function allowEnterCallback(props) {
return props.transitionEnter || props.animation.enter;
},
allowLeaveCallback: function allowLeaveCallback(props) {
return props.transitionLeave || props.animation.leave;
}
};
exports["default"] = util;
module.exports = exports['default'];
/***/ },
/* 202 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _MonthPanel = __webpack_require__(213);
var _MonthPanel2 = _interopRequireDefault(_MonthPanel);
var _CalendarMixin = __webpack_require__(122);
var _CalendarMixin2 = _interopRequireDefault(_CalendarMixin);
var _CommonMixin = __webpack_require__(79);
var _CommonMixin2 = _interopRequireDefault(_CommonMixin);
var _KeyCode = __webpack_require__(123);
var _KeyCode2 = _interopRequireDefault(_KeyCode);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var MonthCalendar = _react2["default"].createClass({
displayName: 'MonthCalendar',
propTypes: {
monthCellRender: _react.PropTypes.func,
dateCellRender: _react.PropTypes.func
},
mixins: [_CommonMixin2["default"], _CalendarMixin2["default"]],
onKeyDown: function onKeyDown(event) {
var keyCode = event.keyCode;
var ctrlKey = event.ctrlKey || event.metaKey;
var stateValue = this.state.value;
var value = stateValue;
switch (keyCode) {
case _KeyCode2["default"].DOWN:
value = stateValue.clone();
value.add(3, 'months');
break;
case _KeyCode2["default"].UP:
value = stateValue.clone();
value.add(-3, 'months');
break;
case _KeyCode2["default"].LEFT:
value = stateValue.clone();
if (ctrlKey) {
value.add(-1, 'years');
} else {
value.add(-1, 'months');
}
break;
case _KeyCode2["default"].RIGHT:
value = stateValue.clone();
if (ctrlKey) {
value.add(1, 'years');
} else {
value.add(1, 'months');
}
break;
case _KeyCode2["default"].ENTER:
this.onSelect(stateValue);
event.preventDefault();
return 1;
default:
return undefined;
}
if (value !== stateValue) {
this.setValue(value);
event.preventDefault();
return 1;
}
},
render: function render() {
var props = this.props;
var children = _react2["default"].createElement(_MonthPanel2["default"], {
locale: props.locale,
disabledDate: props.disabledDate,
style: { position: 'relative' },
value: this.state.value,
cellRender: props.monthCellRender,
contentRender: props.monthCellContentRender,
rootPrefixCls: props.prefixCls,
onChange: this.setValue,
onSelect: this.onSelect
});
return this.renderRoot({
children: children
});
}
});
exports["default"] = MonthCalendar;
module.exports = exports['default'];
/***/ },
/* 203 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(9);
var _reactDom2 = _interopRequireDefault(_reactDom);
var _createChainedFunction = __webpack_require__(541);
var _createChainedFunction2 = _interopRequireDefault(_createChainedFunction);
var _KeyCode = __webpack_require__(123);
var _KeyCode2 = _interopRequireDefault(_KeyCode);
var _placements = __webpack_require__(539);
var _placements2 = _interopRequireDefault(_placements);
var _rcTrigger = __webpack_require__(42);
var _rcTrigger2 = _interopRequireDefault(_rcTrigger);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function noop() {}
function refFn(field, component) {
this[field] = component;
}
var Picker = _react2["default"].createClass({
displayName: 'Picker',
propTypes: {
animation: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.string]),
disabled: _react.PropTypes.bool,
transitionName: _react.PropTypes.string,
onChange: _react.PropTypes.func,
onOpenChange: _react.PropTypes.func,
children: _react.PropTypes.func,
getCalendarContainer: _react.PropTypes.func,
calendar: _react.PropTypes.element,
style: _react.PropTypes.object,
open: _react.PropTypes.bool,
defaultOpen: _react.PropTypes.bool,
prefixCls: _react.PropTypes.string,
placement: _react.PropTypes.any,
value: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.array]),
defaultValue: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.array]),
align: _react.PropTypes.object
},
getDefaultProps: function getDefaultProps() {
return {
prefixCls: 'rc-calendar-picker',
style: {},
align: {},
placement: 'bottomLeft',
defaultOpen: false,
onChange: noop,
onOpenChange: noop
};
},
getInitialState: function getInitialState() {
var props = this.props;
var open = void 0;
if ('open' in props) {
open = props.open;
} else {
open = props.defaultOpen;
}
var value = props.value || props.defaultValue;
this.saveCalendarRef = refFn.bind(this, 'calendarInstance');
return {
open: open,
value: value
};
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
var value = nextProps.value,
open = nextProps.open;
if ('value' in nextProps) {
this.setState({
value: value
});
}
if (open !== undefined) {
this.setState({
open: open
});
}
},
componentDidUpdate: function componentDidUpdate(_, prevState) {
if (!prevState.open && this.state.open) {
this.focusCalendar();
}
},
onCalendarKeyDown: function onCalendarKeyDown(event) {
if (event.keyCode === _KeyCode2["default"].ESC) {
event.stopPropagation();
this.close(this.focus);
}
},
onCalendarSelect: function onCalendarSelect(value) {
var cause = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var props = this.props;
if (!('value' in props)) {
this.setState({
value: value
});
}
if (cause.source === 'keyboard' || !props.calendar.props.timePicker && cause.source !== 'dateInput' || cause.source === 'todayButton') {
this.close(this.focus);
}
props.onChange(value);
},
onKeyDown: function onKeyDown(event) {
if (event.keyCode === _KeyCode2["default"].DOWN && !this.state.open) {
this.open();
event.preventDefault();
}
},
onCalendarOk: function onCalendarOk() {
this.close(this.focus);
},
onCalendarClear: function onCalendarClear() {
this.close(this.focus);
},
onVisibleChange: function onVisibleChange(open) {
this.setOpen(open);
},
getCalendarElement: function getCalendarElement() {
var props = this.props;
var state = this.state;
var calendarProps = props.calendar.props;
var value = state.value;
var defaultValue = void 0;
// RangeCalendar
if (Array.isArray(value)) {
defaultValue = value[0];
} else {
defaultValue = value;
}
var extraProps = {
ref: this.saveCalendarRef,
defaultValue: defaultValue || calendarProps.defaultValue,
selectedValue: value,
onKeyDown: this.onCalendarKeyDown,
onOk: (0, _createChainedFunction2["default"])(calendarProps.onOk, this.onCalendarOk),
onSelect: (0, _createChainedFunction2["default"])(calendarProps.onSelect, this.onCalendarSelect),
onClear: (0, _createChainedFunction2["default"])(calendarProps.onClear, this.onCalendarClear)
};
return _react2["default"].cloneElement(props.calendar, extraProps);
},
setOpen: function setOpen(open, callback) {
var onOpenChange = this.props.onOpenChange;
if (this.state.open !== open) {
if (!('open' in this.props)) {
this.setState({
open: open
}, callback);
}
onOpenChange(open);
}
},
open: function open(callback) {
this.setOpen(true, callback);
},
close: function close(callback) {
this.setOpen(false, callback);
},
focus: function focus() {
if (!this.state.open) {
_reactDom2["default"].findDOMNode(this).focus();
}
},
focusCalendar: function focusCalendar() {
if (this.state.open && this.calendarInstance !== null) {
this.calendarInstance.focus();
}
},
render: function render() {
var props = this.props;
var prefixCls = props.prefixCls,
placement = props.placement,
style = props.style,
getCalendarContainer = props.getCalendarContainer,
align = props.align,
animation = props.animation,
disabled = props.disabled,
transitionName = props.transitionName,
children = props.children;
var state = this.state;
return _react2["default"].createElement(
_rcTrigger2["default"],
{
popup: this.getCalendarElement(),
popupAlign: align,
builtinPlacements: _placements2["default"],
popupPlacement: placement,
action: disabled && !state.open ? [] : ['click'],
destroyPopupOnHide: true,
getPopupContainer: getCalendarContainer,
popupStyle: style,
popupAnimation: animation,
popupTransitionName: transitionName,
popupVisible: state.open,
onPopupVisibleChange: this.onVisibleChange,
prefixCls: prefixCls
},
_react2["default"].cloneElement(children(state, props), { onKeyDown: this.onKeyDown })
);
}
});
exports["default"] = Picker;
module.exports = exports['default'];
/***/ },
/* 204 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _MonthPanel = __webpack_require__(213);
var _MonthPanel2 = _interopRequireDefault(_MonthPanel);
var _YearPanel = __webpack_require__(215);
var _YearPanel2 = _interopRequireDefault(_YearPanel);
var _mapSelf = __webpack_require__(216);
var _mapSelf2 = _interopRequireDefault(_mapSelf);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function goMonth(direction) {
var next = this.props.value.clone();
next.add(direction, 'months');
this.props.onValueChange(next);
}
function goYear(direction) {
var next = this.props.value.clone();
next.add(direction, 'years');
this.props.onValueChange(next);
}
function showIf(condition, el) {
return condition ? el : null;
}
var CalendarHeader = _react2["default"].createClass({
displayName: 'CalendarHeader',
propTypes: {
enablePrev: _react.PropTypes.any,
enableNext: _react.PropTypes.any,
prefixCls: _react.PropTypes.string,
showTimePicker: _react.PropTypes.bool,
locale: _react.PropTypes.object,
value: _react.PropTypes.object,
onValueChange: _react.PropTypes.func
},
getDefaultProps: function getDefaultProps() {
return {
enableNext: 1,
enablePrev: 1
};
},
getInitialState: function getInitialState() {
this.nextMonth = goMonth.bind(this, 1);
this.previousMonth = goMonth.bind(this, -1);
this.nextYear = goYear.bind(this, 1);
this.previousYear = goYear.bind(this, -1);
return {};
},
onSelect: function onSelect(value) {
this.setState({
showMonthPanel: 0,
showYearPanel: 0
});
this.props.onValueChange(value);
},
monthYearElement: function monthYearElement(showTimePicker) {
var props = this.props;
var prefixCls = props.prefixCls;
var locale = props.locale;
var value = props.value;
var localeData = value.localeData();
var monthBeforeYear = locale.monthBeforeYear;
var selectClassName = prefixCls + '-' + (monthBeforeYear ? 'my-select' : 'ym-select');
var year = _react2["default"].createElement(
'a',
{
className: prefixCls + '-year-select',
role: 'button',
onClick: showTimePicker ? null : this.showYearPanel,
title: locale.yearSelect
},
value.format(locale.yearFormat)
);
var month = _react2["default"].createElement(
'a',
{
className: prefixCls + '-month-select',
role: 'button',
onClick: showTimePicker ? null : this.showMonthPanel,
title: locale.monthSelect
},
localeData.months(value)
);
var day = void 0;
if (showTimePicker) {
day = _react2["default"].createElement(
'a',
{
className: prefixCls + '-day-select',
role: 'button'
},
value.format(locale.dayFormat)
);
}
var my = [];
if (monthBeforeYear) {
my = [month, day, year];
} else {
my = [year, month, day];
}
return _react2["default"].createElement(
'span',
{ className: selectClassName },
(0, _mapSelf2["default"])(my)
);
},
showMonthPanel: function showMonthPanel() {
this.setState({
showMonthPanel: 1,
showYearPanel: 0
});
},
showYearPanel: function showYearPanel() {
this.setState({
showMonthPanel: 0,
showYearPanel: 1
});
},
render: function render() {
var props = this.props;
var enableNext = props.enableNext,
enablePrev = props.enablePrev,
prefixCls = props.prefixCls,
locale = props.locale,
value = props.value,
showTimePicker = props.showTimePicker;
var state = this.state;
var PanelClass = null;
if (state.showMonthPanel) {
PanelClass = _MonthPanel2["default"];
} else if (state.showYearPanel) {
PanelClass = _YearPanel2["default"];
}
var panel = void 0;
if (PanelClass) {
panel = _react2["default"].createElement(PanelClass, {
locale: locale,
defaultValue: value,
rootPrefixCls: prefixCls,
onSelect: this.onSelect
});
}
return _react2["default"].createElement(
'div',
{ className: prefixCls + '-header' },
_react2["default"].createElement(
'div',
{ style: { position: 'relative' } },
showIf(enablePrev && !showTimePicker, _react2["default"].createElement('a', {
className: prefixCls + '-prev-year-btn',
role: 'button',
onClick: this.previousYear,
title: locale.previousYear
})),
showIf(enablePrev && !showTimePicker, _react2["default"].createElement('a', {
className: prefixCls + '-prev-month-btn',
role: 'button',
onClick: this.previousMonth,
title: locale.previousMonth
})),
this.monthYearElement(showTimePicker),
showIf(enableNext && !showTimePicker, _react2["default"].createElement('a', {
className: prefixCls + '-next-month-btn',
onClick: this.nextMonth,
title: locale.nextMonth
})),
showIf(enableNext && !showTimePicker, _react2["default"].createElement('a', {
className: prefixCls + '-next-year-btn',
onClick: this.nextYear,
title: locale.nextYear
}))
),
panel
);
}
});
exports["default"] = CalendarHeader;
module.exports = exports['default'];
/***/ },
/* 205 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = OkButton;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function OkButton(_ref) {
var prefixCls = _ref.prefixCls,
locale = _ref.locale,
okDisabled = _ref.okDisabled,
onOk = _ref.onOk;
var className = prefixCls + "-ok-btn";
if (okDisabled) {
className += " " + prefixCls + "-ok-btn-disabled";
}
return _react2["default"].createElement(
"a",
{
className: className,
role: "button",
onClick: okDisabled ? null : onOk
},
locale.ok
);
}
module.exports = exports['default'];
/***/ },
/* 206 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = __webpack_require__(7);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
exports["default"] = TimePickerButton;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _classnames2 = __webpack_require__(2);
var _classnames3 = _interopRequireDefault(_classnames2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function TimePickerButton(_ref) {
var _classnames;
var prefixCls = _ref.prefixCls,
locale = _ref.locale,
showTimePicker = _ref.showTimePicker,
onOpenTimePicker = _ref.onOpenTimePicker,
onCloseTimePicker = _ref.onCloseTimePicker,
timePickerDisabled = _ref.timePickerDisabled;
var className = (0, _classnames3["default"])((_classnames = {}, (0, _defineProperty3["default"])(_classnames, prefixCls + '-time-picker-btn', true), (0, _defineProperty3["default"])(_classnames, prefixCls + '-time-picker-btn-disabled', timePickerDisabled), _classnames));
var onClick = null;
if (!timePickerDisabled) {
onClick = showTimePicker ? onCloseTimePicker : onOpenTimePicker;
}
return _react2["default"].createElement(
'a',
{
className: className,
role: 'button',
onClick: onClick
},
showTimePicker ? locale.dateSelect : locale.timeSelect
);
}
module.exports = exports['default'];
/***/ },
/* 207 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = TodayButton;
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _util = __webpack_require__(31);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function TodayButton(_ref) {
var prefixCls = _ref.prefixCls,
locale = _ref.locale,
value = _ref.value,
timePicker = _ref.timePicker,
disabled = _ref.disabled,
disabledDate = _ref.disabledDate,
onToday = _ref.onToday,
text = _ref.text;
var localeNow = (!text && timePicker ? locale.now : text) || locale.today;
var disabledToday = disabledDate && !(0, _util.isAllowedDate)((0, _util.getTodayTime)(value), disabledDate);
var isDisabled = disabledToday || disabled;
var disabledTodayClass = isDisabled ? prefixCls + '-today-btn-disabled' : '';
return _react2["default"].createElement(
'a',
{
className: prefixCls + '-today-btn ' + disabledTodayClass,
role: 'button',
onClick: isDisabled ? null : onToday,
title: (0, _util.getTodayTimeStr)(value)
},
localeNow
);
}
module.exports = exports['default'];
/***/ },
/* 208 */
/***/ function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = {
DATE_ROW_COUNT: 6,
DATE_COL_COUNT: 7
};
module.exports = exports['default'];
/***/ },
/* 209 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(9);
var _reactDom2 = _interopRequireDefault(_reactDom);
var _moment = __webpack_require__(14);
var _moment2 = _interopRequireDefault(_moment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var DateInput = _react2["default"].createClass({
displayName: 'DateInput',
propTypes: {
prefixCls: _react.PropTypes.string,
timePicker: _react.PropTypes.object,
value: _react.PropTypes.object,
disabledTime: _react.PropTypes.any,
format: _react.PropTypes.string,
locale: _react.PropTypes.object,
disabledDate: _react.PropTypes.func,
onChange: _react.PropTypes.func,
onClear: _react.PropTypes.func,
placeholder: _react.PropTypes.string,
onSelect: _react.PropTypes.func,
selectedValue: _react.PropTypes.object
},
getInitialState: function getInitialState() {
var selectedValue = this.props.selectedValue;
return {
str: selectedValue && selectedValue.format(this.props.format) || '',
invalid: false
};
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
// when popup show, click body will call this, bug!
var selectedValue = nextProps.selectedValue;
this.setState({
str: selectedValue && selectedValue.format(nextProps.format) || '',
invalid: false
});
},
onInputChange: function onInputChange(event) {
var str = event.target.value;
this.setState({
str: str
});
var value = void 0;
var _props = this.props,
disabledDate = _props.disabledDate,
format = _props.format,
onChange = _props.onChange;
if (str) {
var parsed = (0, _moment2["default"])(str, format, true);
if (!parsed.isValid()) {
this.setState({
invalid: true
});
return;
}
value = this.props.value.clone();
value.year(parsed.year()).month(parsed.month()).date(parsed.date()).hour(parsed.hour()).minute(parsed.minute()).second(parsed.second());
if (value && (!disabledDate || !disabledDate(value))) {
var originalValue = this.props.selectedValue;
if (originalValue && value) {
if (!originalValue.isSame(value)) {
onChange(value);
}
} else if (originalValue !== value) {
onChange(value);
}
} else {
this.setState({
invalid: true
});
return;
}
} else {
onChange(null);
}
this.setState({
invalid: false
});
},
onClear: function onClear() {
this.setState({
str: ''
});
this.props.onClear(null);
},
getRootDOMNode: function getRootDOMNode() {
return _reactDom2["default"].findDOMNode(this);
},
focus: function focus() {
this.refs.dateInput.focus();
},
render: function render() {
var props = this.props;
var _state = this.state,
invalid = _state.invalid,
str = _state.str;
var locale = props.locale,
prefixCls = props.prefixCls,
placeholder = props.placeholder;
var invalidClass = invalid ? prefixCls + '-input-invalid' : '';
return _react2["default"].createElement(
'div',
{ className: prefixCls + '-input-wrap' },
_react2["default"].createElement(
'div',
{ className: prefixCls + '-date-input-wrap' },
_react2["default"].createElement('input', {
ref: 'dateInput',
className: prefixCls + '-input ' + invalidClass,
value: str,
disabled: props.disabled,
placeholder: placeholder,
onChange: this.onInputChange
})
),
props.showClear ? _react2["default"].createElement('a', {
className: prefixCls + '-clear-btn',
role: 'button',
title: locale.clear,
onClick: this.onClear
}) : null
);
}
});
exports["default"] = DateInput;
module.exports = exports['default'];
/***/ },
/* 210 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Calendar = __webpack_require__(531);
var _Calendar2 = _interopRequireDefault(_Calendar);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = _Calendar2["default"];
module.exports = exports['default'];
/***/ },
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment