import { __require as requireObjectAssign } from '../../../../object-assign@4.1.1/node_modules/object-assign/index.js';
import { __require as requireDraftOffsetKey } from './DraftOffsetKey.js';
import React__default from 'react';
import { __require as requireUnicodeBidi } from '../../../../fbjs@2.0.0/node_modules/fbjs/lib/UnicodeBidi.js';
import { __require as requireUnicodeBidiDirection } from '../../../../fbjs@2.0.0/node_modules/fbjs/lib/UnicodeBidiDirection.js';

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * 
 * @emails oncall+draft_js
 *
 * This is unstable and not part of the public API and should not be used by
 * production systems. This file may be update/removed without notice.
 */

var DraftEditorDecoratedLeaves_react;
var hasRequiredDraftEditorDecoratedLeaves_react;

function requireDraftEditorDecoratedLeaves_react () {
	if (hasRequiredDraftEditorDecoratedLeaves_react) return DraftEditorDecoratedLeaves_react;
	hasRequiredDraftEditorDecoratedLeaves_react = 1;

	var _assign = requireObjectAssign();

	function _extends() { _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; }; return _extends.apply(this, arguments); }

	function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }

	var DraftOffsetKey = requireDraftOffsetKey();

	var React = React__default;

	var UnicodeBidi = requireUnicodeBidi();

	var UnicodeBidiDirection = requireUnicodeBidiDirection();

	var DraftEditorDecoratedLeaves = /*#__PURE__*/function (_React$Component) {
	  _inheritsLoose(DraftEditorDecoratedLeaves, _React$Component);

	  function DraftEditorDecoratedLeaves() {
	    return _React$Component.apply(this, arguments) || this;
	  }

	  var _proto = DraftEditorDecoratedLeaves.prototype;

	  _proto.render = function render() {
	    var _this$props = this.props,
	        block = _this$props.block,
	        children = _this$props.children,
	        contentState = _this$props.contentState,
	        decorator = _this$props.decorator,
	        decoratorKey = _this$props.decoratorKey,
	        direction = _this$props.direction,
	        leafSet = _this$props.leafSet,
	        text = _this$props.text;
	    var blockKey = block.getKey();
	    var leavesForLeafSet = leafSet.get('leaves');
	    var DecoratorComponent = decorator.getComponentForKey(decoratorKey);
	    var decoratorProps = decorator.getPropsForKey(decoratorKey);
	    var decoratorOffsetKey = DraftOffsetKey.encode(blockKey, parseInt(decoratorKey, 10), 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), direction);
	    return React.createElement(DecoratorComponent, _extends({}, decoratorProps, {
	      contentState: contentState,
	      decoratedText: decoratedText,
	      dir: dir,
	      key: decoratorOffsetKey,
	      entityKey: block.getEntityAt(leafSet.get('start')),
	      offsetKey: decoratorOffsetKey
	    }), children);
	  };

	  return DraftEditorDecoratedLeaves;
	}(React.Component);

	DraftEditorDecoratedLeaves_react = DraftEditorDecoratedLeaves;
	return DraftEditorDecoratedLeaves_react;
}

export { requireDraftEditorDecoratedLeaves_react as __require };
//# sourceMappingURL=DraftEditorDecoratedLeaves.react.js.map
