<commit_before>'use strict';

import defaultOptions from './defaults/options.js';

import ColumnManager from './ColumnManager.js';
import RowManager from './RowManager.js';
import FooterManager from './FooterManager.js';

import InteractionMonitor from './tools/InteractionMonitor.js';
import ComponentFuctionBinder from './tools/ComponentFuctionBinder.js';

import ExternalEventBus from './tools/ExternalEventBus.js';
import InternalEventBus from './tools/InternalEventBus.js';

import TableRegistry from './tools/TableRegistry.js';
import ModuleBinder from './tools/ModuleBinder.js';

import OptionsList from './tools/OptionsList.js';

import VirtualDomHorizontal from './rendering/renderers/VirtualDomHorizontal.js';

class Tabulator {

	constructor(element, options){

		this.options = {};

		this.columnManager = null; // hold Column Manager
		this.rowManager = null; //hold Row Manager
		this.footerManager = null; //holder Footer Manager
		this.vdomHoz  = null; //holder horizontal virtual dom
		this.externalEvents = null; //handle external event messaging
		this.eventBus = null; //handle internal event messaging
		this.interactionMonitor = false; //track user interaction
		this.browser = ""; //hold current browser type
		this.browserSlow = false; //handle reduced functionality for slower browsers
		this.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence
		this.rtl = false; //check if the table is in RTL mode

		this.componentFunctionBinder = new ComponentFuctionBinder(this); //bind component functions

		this.modules = {}; //hold all modules bound to this table
		this.modulesCore = {}; //hold core modules bound to this table (for initialization purposes)
		this.modulesRegular = {}; //hold regular modules bound to this table (for initialization purposes)

		this.optionsList = new OptionsList(this, "table constructor");

		if(this.initializeElement(element)){

			this.initialzeCoreSystems(options);

			//delay table creation to allow event bindings immediatly after the constructor
			setTimeout(() => {
				this._create();
			})
		}

		TableRegistry.register(this); //register table for inderdevice communication
	}

	initializeElement(element){
		if(typeof HTMLElement !== "undefined" && element instanceof HTMLElement){
			this.element = element;
			return true;
		}else if(typeof element === "string"){
			this.element = document.querySelector(element);

			if(this.element){
				return true;
			}else{
				console.error("Tabulator Creation Error - no element found matching selector: ", element);
				return false;
			}
		}else{
			console.error("Tabulator Creation Error - Invalid element provided:", element);
			return false;
		}
	}

	initialzeCoreSystems(options){
		this.bindModules();

		this.options = this.optionsList.generate(Tabulator.defaultOptions, options)

		this._clearObjectPointers();

		this._mapDepricatedFunctionality();

		this.externalEvents = new ExternalEventBus(this.options, this.options.debugEvents);
		this.eventBus = new InternalEventBus(this.options.debugEventsInternal);
	}

	rtlCheck(){
		var style = window.getComputedStyle(this.element);

		switch(this.options.textDirection){
			case"auto":
			if(style.direction !== "rtl"){
				break;
			};

			case "rtl":
			this.element.classList.add("tabulator-rtl");
			this.rtl = true;
			break;

			case "ltr":
			this.element.classList.add("tabulator-ltr");

			default:
			this.rtl = false;
		}
	}

	//convert depricated functionality to new functions
	_mapDepricatedFunctionality(){
		//all previously deprecated functionality removed in the 5.0 release
	}

	_clearSelection(){

		this.element.classList.add("tabulator-block-select");

		if (window.getSelection) {
		  if (window.getSelection().empty) {  // Chrome
		  	window.getSelection().empty();
		  } else if (window.getSelection().removeAllRanges) {  // Firefox
		  	window.getSelection().removeAllRanges();
		  }
		} else if (document.selection) {  // IE?
			document.selection.empty();
		}

		this.element.classList.remove("tabulator-block-select");
	}

	//concreate table
	_create(){
		this.InteractionMonitor = new InteractionMonitor(this);

		this.rtlCheck();

		if(this.element.tagName === "TABLE"){
			if(this.modExists("htmlTableImport", true)){
				this.modules.htmlTableImport.parseTable();
			}
		}

		this.columnManager = new ColumnManager(this);
		this.rowManager = new RowManager(this);
		this.footerManager = new FooterManager(this);

		this.columnManager.setRowManager(this.rowManager);
		this.rowManager.setColumnManager(this.columnManager);

		if(this.options.virtualDomHoz){
			this.vdomHoz = new VirtualDomHorizontal(this);
		}

		this._buildElement();

		this._loadInitialData();
	}

	//clear pointers to objects in default config object
	_clearObjectPointers(){
		this.options.columns = this.options.columns.slice(0);

		if(!this.options.reactiveData){
			this.options.data = this.options.data.slice(0);
		}
	}

	//build tabulator element
	_buildElement(){
		var element = this.element,
		mods = this.modules,<commit_msg>move manager instatiation into core systems initialization<commit_after>'use strict';

import defaultOptions from './defaults/options.js';

import ColumnManager from './ColumnManager.js';
import RowManager from './RowManager.js';
import FooterManager from './FooterManager.js';

import InteractionMonitor from './tools/InteractionMonitor.js';
import ComponentFuctionBinder from './tools/ComponentFuctionBinder.js';

import ExternalEventBus from './tools/ExternalEventBus.js';
import InternalEventBus from './tools/InternalEventBus.js';

import TableRegistry from './tools/TableRegistry.js';
import ModuleBinder from './tools/ModuleBinder.js';

import OptionsList from './tools/OptionsList.js';

import VirtualDomHorizontal from './rendering/renderers/VirtualDomHorizontal.js';

class Tabulator {

	constructor(element, options){

		this.options = {};

		this.columnManager = null; // hold Column Manager
		this.rowManager = null; //hold Row Manager
		this.footerManager = null; //holder Footer Manager
		this.vdomHoz  = null; //holder horizontal virtual dom
		this.externalEvents = null; //handle external event messaging
		this.eventBus = null; //handle internal event messaging
		this.interactionMonitor = false; //track user interaction
		this.browser = ""; //hold current browser type
		this.browserSlow = false; //handle reduced functionality for slower browsers
		this.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence
		this.rtl = false; //check if the table is in RTL mode

		this.componentFunctionBinder = new ComponentFuctionBinder(this); //bind component functions

		this.modules = {}; //hold all modules bound to this table
		this.modulesCore = {}; //hold core modules bound to this table (for initialization purposes)
		this.modulesRegular = {}; //hold regular modules bound to this table (for initialization purposes)

		this.optionsList = new OptionsList(this, "table constructor");

		if(this.initializeElement(element)){

			this.initialzeCoreSystems(options);

			//delay table creation to allow event bindings immediatly after the constructor
			setTimeout(() => {
				this._create();
			})
		}

		TableRegistry.register(this); //register table for inderdevice communication
	}

	initializeElement(element){
		if(typeof HTMLElement !== "undefined" && element instanceof HTMLElement){
			this.element = element;
			return true;
		}else if(typeof element === "string"){
			this.element = document.querySelector(element);

			if(this.element){
				return true;
			}else{
				console.error("Tabulator Creation Error - no element found matching selector: ", element);
				return false;
			}
		}else{
			console.error("Tabulator Creation Error - Invalid element provided:", element);
			return false;
		}
	}

	initialzeCoreSystems(options){
		this.bindModules();

		this.options = this.optionsList.generate(Tabulator.defaultOptions, options)

		this._clearObjectPointers();

		this._mapDepricatedFunctionality();

		this.externalEvents = new ExternalEventBus(this.options, this.options.debugEvents);
		this.eventBus = new InternalEventBus(this.options.debugEventsInternal);

		this.interactionMonitor = new InteractionMonitor(this);

		this.columnManager = new ColumnManager(this);
		this.rowManager = new RowManager(this);
		this.footerManager = new FooterManager(this);
	}

	rtlCheck(){
		var style = window.getComputedStyle(this.element);

		switch(this.options.textDirection){
			case"auto":
			if(style.direction !== "rtl"){
				break;
			};

			case "rtl":
			this.element.classList.add("tabulator-rtl");
			this.rtl = true;
			break;

			case "ltr":
			this.element.classList.add("tabulator-ltr");

			default:
			this.rtl = false;
		}
	}

	//convert depricated functionality to new functions
	_mapDepricatedFunctionality(){
		//all previously deprecated functionality removed in the 5.0 release
	}

	_clearSelection(){

		this.element.classList.add("tabulator-block-select");

		if (window.getSelection) {
		  if (window.getSelection().empty) {  // Chrome
		  	window.getSelection().empty();
		  } else if (window.getSelection().removeAllRanges) {  // Firefox
		  	window.getSelection().removeAllRanges();
		  }
		} else if (document.selection) {  // IE?
			document.selection.empty();
		}

		this.element.classList.remove("tabulator-block-select");
	}

	//concreate table
	_create(){

		this.rtlCheck();

		if(this.element.tagName === "TABLE"){
			if(this.modExists("htmlTableImport", true)){
				this.modules.htmlTableImport.parseTable();
			}
		}

		this.columnManager.setRowManager(this.rowManager);
		this.rowManager.setColumnManager(this.columnManager);

		if(this.options.virtualDomHoz){
			this.vdomHoz = new VirtualDomHorizontal(this);
		}

		this._buildElement();

		this._loadInitialData();
	}

	//clear pointers to objects in default config object
	_clearObjectPointers(){
		this.options.columns = this.options.columns.slice(0);

		if(!this.options.reactiveData){
			this.options.data = this.options.data.slice(0);
		}
	}

	//build tabulator element
	_buildElement(){
		var element = this.element,
		mods = this.modules,
{'fraction_non_alphanumeric': 0.11991350501277767, 'fraction_numerical': 0.0007863180656575585, 'mean_word_length': 4.261116856256463, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '206113', 'n_tokens_mistral': 3260, 'n_tokens_neox': 2854, 'n_words': 717}