import { __require as requireUnicodeBidiService } from '../../../../fbjs@2.0.0/node_modules/fbjs/lib/UnicodeBidiService.js';
import { __require as requireImmutable } from '../../../../immutable@3.7.6/node_modules/immutable/dist/immutable.js';
import { __require as requireNullthrows } from '../../../../fbjs@2.0.0/node_modules/fbjs/lib/nullthrows.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
 */

var EditorBidiService_1;
var hasRequiredEditorBidiService;

function requireEditorBidiService () {
	if (hasRequiredEditorBidiService) return EditorBidiService_1;
	hasRequiredEditorBidiService = 1;

	var UnicodeBidiService = requireUnicodeBidiService();

	var Immutable = requireImmutable();

	var nullthrows = requireNullthrows();

	var OrderedMap = Immutable.OrderedMap;
	var bidiService;
	var EditorBidiService = {
	  getDirectionMap: function getDirectionMap(content, prevBidiMap) {
	    if (!bidiService) {
	      bidiService = new UnicodeBidiService();
	    } else {
	      bidiService.reset();
	    }

	    var blockMap = content.getBlockMap();
	    var nextBidi = blockMap.valueSeq().map(function (block) {
	      return nullthrows(bidiService).getDirection(block.getText());
	    });
	    var bidiMap = OrderedMap(blockMap.keySeq().zip(nextBidi));

	    if (prevBidiMap != null && Immutable.is(prevBidiMap, bidiMap)) {
	      return prevBidiMap;
	    }

	    return bidiMap;
	  }
	};
	EditorBidiService_1 = EditorBidiService;
	return EditorBidiService_1;
}

export { requireEditorBidiService as __require };
//# sourceMappingURL=EditorBidiService.js.map
