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Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/tables-js@1.1.19/tables.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\r\n * Parses a string (csv, tsv, etc.) into an object\r\n * @param {String} str String to parse into object \r\n * @param {String} delimeter Delimeter to split the rows by\r\n * @param {String} escape Escape character to escape delimeters \r\n * @returns {Object[]} Array of objects\r\n */\r\nconst parseSV = (str, delimeter, escape) => {\r\n    // return [{a: 1, b: 2}, {a: 3, b: 4}]\r\n    // include \" in the string to escape it\r\n\r\n    // headers is first row, it could have \" in it to escape commas\r\n    // data is the rest of the rows\r\n\r\n    // split the string into rows\r\n    const data = str.split('\\n');\r\n\r\n    // get the headers\r\n    const headers = data[0].split(delimeter).map((h) => {\r\n        if (h[0] === escape && h[h.length - 1] === escape) {\r\n            return h.substring(1, h.length - 1);\r\n        } else {\r\n            return h;\r\n        }\r\n    });\r\n\r\n    data.shift();\r\n\r\n    // get the data\r\n    return data.map((row) => {\r\n        const splitRow = row.split(delimeter).map(r => {\r\n            if (r[0] === escape && r[r.length - 1] === escape) {\r\n                return r.substring(1, r.length - 1);\r\n            } else {\r\n                return r;\r\n            }\r\n        });\r\n\r\n        console.log(splitRow);\r\n\r\n        return splitRow.reduce((acc, curr, i) => {\r\n            acc[headers[i]] = curr.trim();\r\n            return acc;\r\n        }, {});\r\n    });\r\n}\r\n\r\nconst parseHTML = (str) => {\r\n    const div = document.createElement('div');\r\n    div.innerHTML = str;\r\n    return div.firstChild;\r\n}\r\n\r\n\r\n/**\r\n *  A class that handles the state of a table\r\n */\r\nclass Table_StateStack {\r\n    constructor() {\r\n        this.states = [];\r\n        this.currentState = null;\r\n        this.currentIndex = -1;\r\n        this.locked = false;\r\n\r\n        this.currentUnsavedState = null;\r\n        this.currentUnsavedIndex = -1;\r\n\r\n        this.unsavedStates = [];\r\n    }\r\n\r\n    /**\r\n     * \r\n     * @param {Any} state Anything\r\n     * @returns Copied state with no dependencies\r\n     */\r\n    copyState(state) {\r\n        if (Array.isArray(state)) {\r\n            return [...state];\r\n        }\r\n\r\n        switch (typeof state) {\r\n            case 'object':\r\n                return {...state };\r\n            default:\r\n                return JSON.parse(JSON.stringify(state));\r\n        }\r\n    }\r\n\r\n    /**\r\n     * \r\n     * @param {Any} state This can be anything, it will be passed to onChange()\r\n     */\r\n    addState(state) {\r\n        if (this.currentIndex < this.states.length - 1) {\r\n            // remove all states after currentIndex\r\n            this.states = this.states.splice(0, this.currentIndex + 1);\r\n\r\n            this.states.push(this.copyState(state));\r\n            this.currentIndex = this.states.length - 1;\r\n            this.currentState = this.states[this.currentIndex];\r\n        } else {\r\n            this.states.push(this.copyState(state));\r\n            this.currentIndex = this.states.length - 1;\r\n            this.currentState = this.states[this.currentIndex];\r\n        }\r\n\r\n        this.resolve();\r\n    }\r\n\r\n    /**\r\n     * \r\n     * @param {Any} state This can be anything, it will be passed to onChange() \r\n     */\r\n    addUnsavedState(state) {\r\n        if (this.currentUnsavedIndex < this.unsavedStates.length - 1) {\r\n            // remove all states after currentIndex\r\n            this.unsavedStates = this.unsavedStates.splice(0, this.currentUnsavedIndex + 1);\r\n\r\n            this.unsavedStates.push(this.copyState(state));\r\n            this.currentUnsavedIndex = this.unsavedStates.length - 1;\r\n            this.currentUnsavedState = this.unsavedStates[this.currentUnsavedIndex];\r\n        } else {\r\n            this.unsavedStates.push(this.copyState(state));\r\n            this.currentUnsavedIndex = this.unsavedStates.length - 1;\r\n            this.currentUnsavedState = this.unsavedStates[this.currentUnsavedIndex];\r\n        }\r\n\r\n        this.unsavedStates = this.unsavedStates.filter((s, i) => this.unsavedStates.indexOf(s) === i);\r\n\r\n        this.resolveUnsaved();\r\n    }\r\n\r\n    /**\r\n     *  This is called when the stack is cleared\r\n     */\r\n    nextUnsaved() {\r\n        if (this.unsavedStates.length > 0 && this.currentUnsavedIndex < this.unsavedStates.length - 1) {\r\n            this.currentUnsavedState = this.unsavedStates[this.currentUnsavedIndex + 1];\r\n            this.currentUnsavedIndex++;\r\n\r\n            this.resolveUnsaved();\r\n        } else {\r\n            return null;\r\n        }\r\n    }\r\n\r\n    /**\r\n     *  This is called when the stack is cleared\r\n     */\r\n    prevUnsaved() {\r\n        if (this.unsavedStates.length > 0 && this.currentUnsavedIndex > 0) {\r\n            this.currentUnsavedState = this.unsavedStates[this.currentUnsavedIndex - 1];\r\n            this.currentUnsavedIndex--;\r\n\r\n            this.resolveUnsaved();\r\n        } else {\r\n            return null;\r\n        }\r\n    }\r\n\r\n    /**\r\n     *   Destroys the stack and calls onClear()\r\n     */\r\n    clearStates() {\r\n        this.states = [];\r\n        this.currentIndex = -1;\r\n        this.onClear();\r\n        this.currentState = null;\r\n        this.unsavedStates = [];\r\n    }\r\n\r\n    /**\r\n     *  Goes to the next state in the stack\r\n     */\r\n    next() {\r\n        if (this.states.length > 0 && this.currentIndex < this.states.length - 1) {\r\n            this.currentState = this.states[this.currentIndex + 1];\r\n            this.currentIndex++;\r\n\r\n            this.resolve();\r\n        } else {\r\n            this.onReject(this.currentState);\r\n        }\r\n    }\r\n\r\n    /**\r\n     *  Goes to the previous state in the stack\r\n     */\r\n    prev() {\r\n        if (this.states.length > 0 && this.currentIndex > 0) {\r\n            this.currentState = this.states[this.currentIndex - 1];\r\n            this.currentIndex--;\r\n            // this.findBranch(this.currentIndex);\r\n            this.resolve();\r\n        } else {\r\n            this.onReject(this.currentState);\r\n        }\r\n    }\r\n\r\n    /**\r\n     *  Gets the number of states in the current stack\r\n     */\r\n    get numStacks() {\r\n        return this.states.length;\r\n    }\r\n\r\n    /**\r\n     *  Resolves the current state\r\n     */\r\n    resolve() {\r\n        if (this.locked) {\r\n            this.onReject(this.currentState);\r\n        } else {\r\n            this.onChange(this.currentState);\r\n        }\r\n    }\r\n\r\n    resolveUnsaved() {\r\n        if (this.locked) {\r\n            this.onRejectUnsaved(this.currentUnsavedState);\r\n        } else {\r\n            this.onChangeUnsaved(this.currentUnsavedState);\r\n        }\r\n    }\r\n\r\n    /**\r\n     *   Customizable callback for when the state changes\r\n     */\r\n    onChange() {}\r\n\r\n    /**\r\n     *  Customizable callback for when the state changes\r\n     */\r\n    onChangeUnsaved() {}\r\n\r\n    /**\r\n     *   Customizable callback for when the state changes to a rejected state\r\n     */\r\n    onReject() {\r\n        throw new Error('State does not exist, nothing has changed');\r\n    }\r\n\r\n    /**\r\n     *  Customizable callback for when the state changes to a rejected state\r\n     */\r\n    onRejectUnsaved() {\r\n        throw new Error('State does not exist, nothing has changed');\r\n    }\r\n\r\n    /**\r\n     *  Customizable callback for when the stack is cleared\r\n     */\r\n    onClear() {}\r\n\r\n    /**\r\n     *  Customizable callback for when the stack is locked\r\n     */\r\n    get hasNext() {\r\n        return this.currentIndex < this.states.length - 1;\r\n    }\r\n\r\n    /**\r\n     *  Customizable callback for when the stack is locked\r\n     */\r\n    get hasPrev() {\r\n        return this.currentIndex > 0;\r\n    }\r\n\r\n    /**\r\n     *  Customizable callback for when the stack is locked\r\n     */\r\n    get hasUnsavedNext() {\r\n        return this.currentUnsavedIndex < this.unsavedStates.length - 1;\r\n    }\r\n\r\n    /**\r\n     *  Customizable callback for when the stack is locked\r\n     */\r\n    get hasUnsavedPrev() {\r\n        return this.currentUnsavedIndex > 0;\r\n    }\r\n}\r\n\r\n/**\r\n *  A class for creating a table\r\n * @public\r\n * @class\r\n * @classdesc A class for creating a table\r\n * \r\n * @since 1.1.0\r\n * \r\n * @example\r\n * const table = new Table('table', [], [], {});\r\n */\r\nclass Table {\r\n    /**\r\n     * @param {HTMLElement | String} table The table element or css selector for the table\r\n     * \r\n     * \r\n     * \r\n     * @param {Object[]} headers The headers for the table\r\n     * \r\n     * @param {String} headers[].title The title of the header\r\n     * @param {String} headers[].name The name of the header (used the same as title)\r\n     * @param {String} headers[].key The key of the header (used the same as name)\r\n     * \r\n     * @param {Function} headers[].getData A function that returns the data for the td element (takes in the row data)\r\n     * @param {Function} headers[].sort A function that returns the data for the column (takes in (TableRow, TableRow))\r\n     * @param {Boolean} headers[].minimize Whether or not to add minimize functionality to the header\r\n     * @param {Object} headers.th An object with properties for the th element\r\n     * @param {String[]} headers[].th.classes An array of classes to add to the td elements\r\n     * \r\n     * @param {Object} headers[].td An object with properties for the td elements\r\n     * @param {String[]} headers[].td.lasses An array of classes to add to the th elements\r\n     * @param {Object[]} headers[].td.classTests An array of objects with class tests for the td elements\r\n     * @param {String} headers[].td.classTests[].class The class to add to the td element\r\n     * @param {String[]} headers[].td.classTests[].classes The class to add to the td element\r\n     * @param {Function} headers[].td.classTests[].test A function that returns a boolean for whether or not to add the class to the td element (takes in the row data)\r\n     * @todo Divide td and th into separate objects within the headers array\r\n     * \r\n     * @param {Object[]} headers[].th.listeners An array of objects with event listeners for the th elements\r\n     * @param {String} headers[].th.listeners[].listener The event listener type\r\n     * @param {Function} headers[].th.listeners[].callback The callback function for the event listener (uses 1.1.0+ data structure)\r\n     * @param {Function} headers[].th.listeners[].action The action function for the event listener (takes in the 1.0.0 data structure)\r\n     * \r\n     * @param {Object[]} headers[].td.listeners An array of objects with event listeners for the td elements\r\n     * @param {String} headers[].td.listeners[].listener The event listener type\r\n     * @param {Function} headers[].td.listeners[].callback The callback function for the event listener (uses 1.1.0+ data structure)\r\n     * @param {Function} headers[].td.listeners[].action The action function for the event listener (takes in the 1.0.0 data structure)\r\n     * \r\n     * @param {Any[]} data The data for the table\r\n     * \r\n     * \r\n     * \r\n     * @param {Object} options The options for the table\r\n     * \r\n     * \r\n     * @param {Function} options.appendTest A function that returns a boolean for whether or not to append a row, takes in the row data\r\n     *\r\n     * @param {Object} options.tr The options for the tr elements\r\n     * @param {Object[]} options.tr.isteners An array of objects with event listeners for the table rows\r\n     * @param {String} options.tr.listeners[].listener The event listener type\r\n     * @param {Function} options.tr.listeners[].callback The callback function for the event listener (uses 1.1.0+ data structure)\r\n     * @param {Function} options.tr.listeners[].action The action function for the event listener (takes in the 1.0.0 data structure)\r\n     * \r\n     * @param {Object[]} options.tr.attributes An array of objects with attributes for the table rows\r\n     * @param {String} options.tr.attributes[].attribute The attribute name\r\n     * @param {String | Function} options.tr.attributes[].value The attribute value or a function that returns the attribute value (takes in the row data)\r\n     * \r\n     * \r\n     * @param {String[]} options.trClasses An array of classes to add to the table rows\r\n     * \r\n     * \r\n     * @param {Object[]} options.colGroup An array of objects with colGroup for the table\r\n     * @param {String} options.colGroup[].span The span of the colGroup\r\n     * @param {String} options.colGroup[].classes The classes of the colGroup\r\n     * \r\n     * \r\n     * @param {Object[]} options.tr.classTests An array of objects with tests for the table rows\r\n     * @param {String} options.tr.classTests[].class The class to add to the row\r\n     * @param {String[]} options.tr.classTests[].classes The classes to add to the row\r\n     * @param {Function} options.tr.classTests[].test A function that returns a boolean for whether or not to add the class to the row (takes in the row data)\r\n     * \r\n     * \r\n     * @param {Boolean} options.fixedHeaders Whether or not to use style.position = 'sticky' for the headers\r\n     * @param {String[]} options.classes An array of classes to add to the table element\r\n     * \r\n     * \r\n     * @param {Object} options.dataTable Options for the DataTables library (use with JQuery and DataTables) Or just set it to true to use the default options\r\n     * @param {Object} options.datatable Options for the DataTables library (use with JQuery and DataTables) Or just set it to true to use the default options\r\n     * \r\n     * \r\n     * @param {Object} options.reorder Under Construction: Options for the drag/drop reorder functionality\r\n     * \r\n     * @param {Object} options.reorder.listeners An object with event listeners for each drag event\r\n     * @param {Function} options.reorder.listeners.onDragStart The event listener for when a row is dragged (uses event)\r\n     * @param {Function} options.reorder.listeners.onDrag The event listener for when a row is dragged over (uses event)\r\n     * @param {Function} options.reorder.listeners.onDragEnd The event listener for when a row is dropped (uses event)\r\n     * @param {Function} options.reorder.listeners.onDrop The event listener for when a row is dropped (uses event)\r\n     * @param {Function} options.reorder.listeners.onDragEnter The event listener for when a row is dragged over (uses event)\r\n     * @param {Function} options.reorder.listeners.onDragLeave The event listener for when a row is dragged over (uses event)\r\n     * \r\n     * @param {Object} options.reorder.classes An object with classes for each drag event\r\n     * @param {String[]} options.reorder.classes.dragging The class for when a row is being dragged\r\n     * @param {String[]} options.reorder.classes.dragover The class for when a row is being dragged over\r\n     * @param {String[]} options.reorder.classes.dragenter The class for when a row is being dragged over\r\n     * @param {String[]} options.reorder.classes.dragleave The class for when a row is being dragged over\r\n     * @param {String[]} options.reorder.classes.dragstart The class for when a row is being dragged\r\n     * @param {String[]} options.reorder.classes.dragend The class for when a row is being dragged\r\n     * @param {String[]} options.reorder.classes.drop The class for when a row is being dropped\r\n     * \r\n     * @param {HTMLElement | String} options.reorder.handle The element that is used to drag the row\r\n     * \r\n     * \r\n     * @param {Object} options.sort Options for the sorting functionality (each header must containt a sort property)\r\n     * @param {String[]} options.sort.classes The classes for the sorting buttons\r\n     * \r\n     * \r\n     * @param {Object} options.editable Options for the editable functionality, applies contenteditable=\"true\" to all td elements. Each getData() in the header must return a string\r\n     * @param {Function} options.onChange The function to call when the data changes\r\n     * @param {Function} options.onCancel The function to call when the data changes\r\n     * \r\n     * \r\n     * // TODO: do all of these below here\r\n     * @param {Object} options.search Under Construction: Options for the search functionality\r\n     * @param {String} options.search.placeholder The placeholder for the search input\r\n     * @param {String[]} options.search.classes The classes for the search input\r\n     * \r\n     * \r\n     * @param {Object} options.pagination Under Construction: Options for the pagination functionality\r\n     * @param {Number} options.pagination.perPage The number of rows to show per page\r\n     * @param {String[]} options.pagination.classes The classes for the search input\r\n     * @param {Object} options.pagination.icons The icons for the pagination buttons\r\n     * @param {String} options.pagination.icons.first The icon for the first page button\r\n     * @param {String} options.pagination.icons.prev The icon for the previous page button\r\n     * @param {String} options.pagination.icons.next The icon for the next page button\r\n     * @param {String} options.pagination.icons.last The icon for the last page button\r\n     * \r\n     * \r\n     * @param {String | HTMLElement} options.caption Under Construction: The caption for the table\r\n     * \r\n     * \r\n     * @param {Object} options.insert Under Construction: Options for the insert functionality\r\n     * \r\n     * @param {Object} options.insert.row Options for inserting rows\r\n     * @param {Object} options.insert.row.classes The classes for the insert row button\r\n     * @param {String | HTMLElement} options.insert.row.icon The icon for the insert row button\r\n     * @param {Function} options.insert.row.onClick The function to call when the insert row button is clicked\r\n     * \r\n     * @param {Object} options.insert.column Options for inserting columns\r\n     * @param {Object} options.insert.column.classes The classes for the insert column button\r\n     * @param {String | HTMLElement} options.insert.column.icon The icon for the insert column button\r\n     * @param {Function} options.insert.column.onClick The function to call when the insert column button is clicked\r\n     * \r\n     * \r\n     * @param {Object} options.delete Under Construction: Options for the delete functionality\r\n     * \r\n     * @param {Object} options.delete.row Options for deleting rows\r\n     * @param {Object} options.delete.row.classes The classes for the delete row button\r\n     * @param {String | HTMLElement} options.delete.row.icon The icon for the delete row button\r\n     * @param {Function} options.delete.row.onClick The function to call when the delete row button is clicked\r\n     * \r\n     * @param {Object} options.delete.column Options for deleting columns\r\n     * @param {Object} options.delete.column.classes The classes for the delete column button\r\n     * @param {String | HTMLElement} options.delete.column.icon The icon for the delete column button\r\n     * @param {Function} options.delete.column.onClick The function to call when the delete column button is clicked\r\n     */\r\n    constructor(table, headers, data, options) {\r\n        if (typeof table === 'string') table = document.querySelector(table);\r\n\r\n        if (!table || !table.querySelector) {\r\n            throw new Error('Table must be an HTML element');\r\n        }\r\n\r\n        if (!headers) {\r\n            throw new Error('Headers must be provided');\r\n        }\r\n\r\n        if (!data) {\r\n            throw new Error('Data must be provided');\r\n        }\r\n\r\n        /**\r\n         *  Whether the table has been rendered\r\n         * @type {Boolean}\r\n         * @private\r\n         */\r\n        this.rendered = false;\r\n\r\n        /**\r\n         *  The table element\r\n         * @type {HTMLElement}\r\n         * @public\r\n         */\r\n        this.el = table;\r\n\r\n        /**\r\n         *  The rows in the table\r\n         * @type {Array<TableRow>}\r\n         * @public\r\n         */\r\n        this.rows = [];\r\n\r\n        /**\r\n         *  The columns in the table\r\n         * @type {Array<TableColumn>}\r\n         * @public\r\n         */\r\n        this.columns = new Array(headers.length).fill();\r\n\r\n        /**\r\n         *  The headers in the table (passed in the constructor)\r\n         * @type {Array<Object>}\r\n         * @public\r\n         */\r\n        this.headers = Array.isArray(headers) ? headers.map(h => {\r\n            return typeof headers == 'string' ? { title: h } : h;\r\n        }) : (typeof headers === 'object' ? Object.keys(headers).map(h => {\r\n            return {\r\n                title: h,\r\n                ...headers[h]\r\n            }\r\n        }) : [])\r\n\r\n        /**\r\n         *  The options for the table (passed in the constructor)\r\n         * @type {Object}\r\n         * @public\r\n         */\r\n        this.options = options || {};\r\n\r\n        /**\r\n         *  The original data in the table (passed in the constructor)\r\n         * @type {Array<Any>}\r\n         * @public\r\n         */\r\n        this.originalData = [...data];\r\n\r\n        /**\r\n         *  The data in the table (passed in the constructor)\r\n         * @type {Array<Any>}\r\n         * @public\r\n         */\r\n        this.data = data;\r\n\r\n        /**\r\n         *  The rows for insert on a reordering table\r\n         * @type {Array<ReorderInsertRow>}\r\n         * @public\r\n         */\r\n        this.insertRows = [];\r\n\r\n        /**\r\n         *  The shown rows for insert on a reordering table\r\n         * @type {Array<ReorderInsertRow>}\r\n         * @public\r\n         */\r\n        this.shownInsertRows = [];\r\n\r\n        /**\r\n         *  The sections of the table (thead, tbody, tfoot, etc.)\r\n         * @type {Object}\r\n         * @public\r\n         */\r\n        this.sections = {}\r\n\r\n        /**\r\n         *  The state stack for the table\r\n         * @type {Table_StateStack}\r\n         * @public\r\n         */\r\n        this.stack = new Table_StateStack();\r\n        this.stack.onChange = () => {\r\n            this.renderFromContent();\r\n        }\r\n\r\n        this.stack.onClear = () => {\r\n            this.destroy(true);\r\n        }\r\n\r\n        this.stack.onReject = () => {};\r\n\r\n        if (this.options.__render !== false) this.stack.addState(this);\r\n    }\r\n\r\n    /**\r\n     *  Erases all elements in the table\r\n     * @param {Boolean} removeData Whether or not to remove the data from the table class\r\n     * @memberof Table\r\n     * @returns {void}\r\n     * @example\r\n     * table.destroy();\r\n     */\r\n    destroy(removeData = false) {\r\n        this.el.innerHTML = '';\r\n\r\n        if (removeData) {\r\n            this.data = [];\r\n            this.rows = [];\r\n            this.headers = [];\r\n            this.columns = [];\r\n            this.insertRows = [];\r\n        }\r\n    }\r\n\r\n    /**\r\n     *  Renders the table\r\n     * @memberof Table\r\n     * @returns {void}\r\n     * @example\r\n     * table.render();\r\n     */\r\n    render() {\r\n        const {\r\n            evenColumns,\r\n            reorder,\r\n            caption\r\n        } = this.options;\r\n        this.destroy();\r\n\r\n        // add classes to the table\r\n        if (Array.isArray(this.options.classes)) {\r\n            this.el.classList.add(...this.options.classes);\r\n        }\r\n\r\n        if (reorder) {\r\n            // reorder logic\r\n            if (!this.options.trAttributes) this.options.trAttributes = [];\r\n\r\n            let {\r\n                listeners,\r\n                handle,\r\n                tdClassChanges\r\n            } = this.options.reorder;\r\n\r\n            if (!listeners) listeners = {};\r\n            if (!tdClassChanges) tdClassChanges = {};\r\n\r\n            // returns {x,y} from event regardless of whether it is a touch event or not\r\n            const getXY = (e) => {\r\n                if (e.touches) {\r\n                    return {\r\n                        x: e.touches[0].clientX,\r\n                        y: e.touches[0].clientY\r\n                    };\r\n                }\r\n                return {\r\n                    x: e.clientX,\r\n                    y: e.clientY\r\n                };\r\n            };\r\n\r\n            let isDragging = false;\r\n            // utilizes v1.0 event listener type\r\n            const dragStart = ({ event }) => {\r\n                event.preventDefault();\r\n                isDragging = true;\r\n                const tempTr = document.createElement('tr');\r\n                const td = document.createElement('td');\r\n                td.colSpan = this.headers.length;\r\n                td.style.height = '100%';\r\n                td.classList.add(...(tdClassChanges.tempTr ? tdClassChanges.tempTr : []));\r\n                tempTr.appendChild(td);\r\n\r\n                tempTr.id = 'temp-tr';\r\n\r\n                const tr = event.target.closest('tr');\r\n                tempTr.style.height = `${tr.offsetHeight}px`;\r\n                tr.style.transition = '';\r\n                tr.insertAdjacentElement('afterend', tempTr);\r\n                tr.querySelectorAll('td').forEach(td => {\r\n                    td.classList.add(...(tdClassChanges.dragging ? tdClassChanges.dragging : []));\r\n                    td.style.zIndex = '99999';\r\n                });\r\n\r\n                tr.style.cursor = 'grabbing !important';\r\n                tr.style.userSelect = 'none';\r\n                tr.style.position = 'fixed';\r\n\r\n                const { x, y } = getXY(event);\r\n                tr.dataset.x = x;\r\n                tr.dataset.y = y;\r\n            };\r\n\r\n            let lastTr;\r\n\r\n            const dragging = ({ event }) => {\r\n                if (!isDragging) return;\r\n                // console.log('dragging');\r\n                event.preventDefault();\r\n                const tr = event.target.closest('tr');\r\n                if (tr.style.position !== 'fixed') return;\r\n\r\n                const { x, y } = getXY(event);\r\n                const dx = x - tr.dataset.x;\r\n                const dy = y - tr.dataset.y;\r\n\r\n                tr.style.transform = `translate(${dx}px, ${dy}px)`;\r\n\r\n                // return;\r\n                const foundTr = this.rows.find(r => {\r\n                    if (r.el == tr) return;\r\n\r\n                    const rRect = r.el.getBoundingClientRect();\r\n                    const trRect = tr.getBoundingClientRect();\r\n\r\n                    return trRect.y + trRect.height / 2 > rRect.y && trRect.y + trRect.height / 2 < rRect.y + rRect.height;\r\n                });\r\n\r\n                if (foundTr) {\r\n                    if (foundTr != lastTr) {\r\n                        this.hideInsertRows();\r\n\r\n                        if (lastTr) {\r\n                            lastTr.el.querySelectorAll('td').forEach(td => {\r\n                                td.classList.remove(...(tdClassChanges.swap ? tdClassChanges.swap : []));\r\n                            });\r\n                        }\r\n\r\n                        foundTr.el.querySelectorAll('td').forEach(td => {\r\n                            td.classList.add(...(tdClassChanges.swap ? tdClassChanges.swap : []));\r\n                        });\r\n                        // return;\r\n                        this.showInsertRows(foundTr);\r\n\r\n                    }\r\n                    lastTr = foundTr;\r\n\r\n                    const { above, below } = foundTr.insertRows;\r\n\r\n                    const trRect = tr.getBoundingClientRect();\r\n                    const aboveRect = above.el.getBoundingClientRect();\r\n                    const belowRect = below.el.getBoundingClientRect();\r\n\r\n                    if (trRect.y + trRect.height / 2 > aboveRect.y + aboveRect.height / 2) {\r\n                        above.el.classList.add(...(tdClassChanges.insert ? tdClassChanges.insert : []));\r\n                        // allowDragEnd = false;\r\n                    } else {\r\n                        above.el.classList.remove(...(tdClassChanges.insert ? tdClassChanges.insert : []));\r\n                        // allowDragEnd = true;\r\n                    }\r\n\r\n                    if (trRect.y + trRect.height / 2 < belowRect.y + belowRect.height / 2) {\r\n                        below.el.classList.add(...(tdClassChanges.insert ? tdClassChanges.insert : []));\r\n                        allowDragEnd = false;\r\n                    } else {\r\n                        below.el.classList.remove(...(tdClassChanges.insert ? tdClassChanges.insert : []));\r\n                        // allowDragEnd = true;\r\n                    }\r\n                }\r\n            };\r\n\r\n            // let allowDragEnd = true;\r\n\r\n            const dragEnd = (e) => {\r\n                if (!isDragging) return;\r\n                e.event.preventDefault();\r\n                // console.log('Drag end');\r\n                const tr = e.event.target.closest('tr');\r\n                tr.style.cursor = '';\r\n                tr.style.userSelect = '';\r\n                tr.style.position = '';\r\n\r\n                // animate back to original position\r\n                tr.style.transition = 'transform 0.2s ease-in-out';\r\n                tr.style.transform = '';\r\n\r\n                const tempTr = this.el.querySelector('#temp-tr');\r\n                if (tempTr) tempTr.remove();\r\n\r\n\r\n                this.hideInsertRows();\r\n\r\n                this.el.querySelectorAll('td').forEach(td => {\r\n                    td.classList.remove(...(tdClassChanges.swap ? tdClassChanges.swap : []));\r\n                    td.classList.remove(...(tdClassChanges.dragging ? tdClassChanges.dragging : []));\r\n                    td.classList.remove(...(tdClassChanges.insert ? tdClassChanges.insert : []));\r\n                    td.style.zIndex = '';\r\n                });\r\n\r\n                isDragging = false;\r\n            };\r\n\r\n            this.options.trAttributes.push({\r\n                attribute: 'data-swap',\r\n                value: 'false'\r\n            }, {\r\n                attribute: 'data-insert',\r\n                value: 'false'\r\n            });\r\n\r\n            this.headers.unshift({\r\n                __drag: true,\r\n                title: 'Drag',\r\n                getData: () => {\r\n                    if (handle) return handle;\r\n\r\n                    const i = document.createElement('i');\r\n                    i.classList.add('material-icons');\r\n                    i.innerText = 'drag_indicator';\r\n                    return i;\r\n                },\r\n                td: {\r\n                    listeners: [{\r\n                        event: 'mousedown',\r\n                        action: dragStart,\r\n                        callback: listeners.onDragStart ? listeners.onDragStart : () => {}\r\n                    }, {\r\n                        event: 'touchstart',\r\n                        action: dragStart,\r\n                        callback: listeners.onDragStart ? listeners.onDragStart : () => {}\r\n                    }, {\r\n                        event: 'mousemove',\r\n                        action: dragging,\r\n                        callback: listeners.onDrag ? listeners.onDrag : () => {}\r\n                    }, {\r\n                        event: 'touchmove',\r\n                        action: dragging,\r\n                        callback: listeners.onDrag ? listeners.onDrag : () => {}\r\n                    }, {\r\n                        event: 'mouseup',\r\n                        action: dragEnd,\r\n                        callback: listeners.onDragEnd ? listeners.onDragEnd : () => {}\r\n                    }, {\r\n                        event: 'touchend',\r\n                        action: dragEnd,\r\n                        callback: listeners.onDragEnd ? listeners.onDragEnd : () => {}\r\n                    }, {\r\n                        event: 'mouseleave',\r\n                        action: dragEnd,\r\n                        callback: listeners.onDragEnd ? listeners.onDragEnd : () => {}\r\n                    }, {\r\n                        event: 'touchcancel',\r\n                        action: dragEnd,\r\n                        callback: listeners.onDragEnd ? listeners.onDragEnd : () => {}\r\n                    }],\r\n                    attributes: [{\r\n                        attribute: 'style',\r\n                        value: 'cursor: grab; user-select: none;'\r\n                    }]\r\n                }\r\n            });\r\n\r\n            this.headers = this.headers.filter((h, i) => this.headers.findIndex(h2 => h2.title === h.title) === i);\r\n\r\n            // insert 2 full span rows between each row\r\n            this.data = this.data.reduce((a, c, i) => {\r\n                if (i === 0) return [{\r\n                    __insertRow: true\r\n                }, c, {\r\n                    __insertRow: true\r\n                }];\r\n                return [...a, { // insert 2 for stripes\r\n                        __insertRow: true\r\n                    },\r\n                    c,\r\n                    {\r\n                        __insertRow: true\r\n                    }\r\n                ];\r\n            }, []);\r\n        }\r\n\r\n        this.renderHeaders();\r\n        this.renderRows();\r\n\r\n        if (caption) {\r\n\r\n            if (typeof caption == 'object') {\r\n\r\n                const {\r\n                    content,\r\n                    attributes,\r\n                    listeners,\r\n                    classes\r\n                } = caption;\r\n\r\n                const captionEl = document.createElement('caption');\r\n                if (typeof content == string) captionEl.innerText = content;\r\n                else captionEl.appendChild(content);\r\n\r\n                if (attributes) attributes.forEach(attr => {\r\n                    captionEl.setAttribute(attr.attribute, attr.value);\r\n                });\r\n\r\n                if (listeners) listeners.forEach(listener => {\r\n                    captionEl.addEventListener(listener.event, listener.action);\r\n                });\r\n\r\n                if (classes) captionEl.classList.add(...classes);\r\n\r\n                // append at top\r\n                this.el.insertBefore(captionEl, this.el.firstChild);\r\n            } else {\r\n                const captionEl = document.createElement('caption');\r\n                captionEl.innerText = caption;\r\n                this.el.insertBefore(captionEl, this.el.firstChild);\r\n            }\r\n        }\r\n\r\n        // makes all columns the same width\r\n        if (evenColumns) {\r\n            const width = this.el.offsetWidth;\r\n            this.columns.forEach(col => {\r\n                col.cells.forEach(cell => {\r\n                    cell.el.style.width = `${width / this.columns.length}px`;\r\n                });\r\n            });\r\n        }\r\n\r\n        // JQuery DataTables\r\n        if (this.options.dataTable || this.options.datatable) {\r\n            $(this.el).DataTable(this.options.dataTable || this.options.datatable);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * \r\n     * @param {TableRow} row Shows the insert rows above and below the given row\r\n     * @returns {Array<TableRow>} The insert rows\r\n     * @memberof Table\r\n     * @private\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @example\r\n     * table.showInsertRows(table.rows[0]);\r\n     */\r\n    showInsertRows(row) {\r\n        console.log('Showing insert rows', row);\r\n        row.insertRows.above.show();\r\n        row.insertRows.below.show();\r\n\r\n        row.insertRows.above.el.style.height = row.el.offsetHeight + 'px';\r\n        row.insertRows.below.el.style.height = row.el.offsetHeight + 'px';\r\n\r\n        this.shownInsertRows.push(row.insertRows.above, row.insertRows.below);\r\n\r\n        return [row.insertRows.above, row.insertRows.below];\r\n    }\r\n\r\n    /**\r\n     * Hides all the insert rows\r\n     * @returns {void}\r\n     * @memberof Table\r\n     * @private\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @example\r\n     * table.hideInsertRows();\r\n     */\r\n    hideInsertRows() {\r\n        let { reorder: { tdClassChanges } } = this.options;\r\n\r\n        if (!tdClassChanges) tdClassChanges = {};\r\n\r\n        this.shownInsertRows.forEach(r => {\r\n            r.hide();\r\n            r.el.classList.remove(...(tdClassChanges.insert ? tdClassChanges.insert : []));\r\n        });\r\n        this.shownInsertRows = [];\r\n    }\r\n\r\n    /**\r\n     *  Renders the table headers (Automatically called by `Table.render`)\r\n     * @returns {void}\r\n     * @memberof Table\r\n     * @private\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @example\r\n     * table.renderHeaders();\r\n     */\r\n    renderHeaders() {\r\n        const thead = document.createElement('thead');\r\n        const tr = document.createElement('tr');\r\n        const tfoot = document.createElement('tfoot');\r\n        const tfootTr = document.createElement('tr');\r\n\r\n        const {\r\n            fixedHeaders,\r\n            editable,\r\n            minimize\r\n        } = this.options;\r\n\r\n        // test if duplicate h.title || h.key || h.name\r\n        const hasDuplicates = this.headers.some((h, i) => this.headers.findIndex(h2 => h2.title === h.title) !== i);\r\n\r\n        if (hasDuplicates && editable) {\r\n            console.warn('Duplicate header titles found. This may cause unexpected behavior on `Table.content`.');\r\n        }\r\n\r\n        this.tableHeaders = new TableRow([]);\r\n\r\n        this.columns = this.headers.map((h, i) => {\r\n            if (!h) return;\r\n            const th = new TableHeader(h.title);\r\n\r\n            const {\r\n                minimize,\r\n                sort,\r\n                th: _thInfo\r\n            } = h;\r\n\r\n            let thClasses,\r\n                thAttributes;\r\n\r\n            if (_thInfo) {\r\n                thClasses = _thInfo.classes;\r\n                thAttributes = _thInfo.attributes;\r\n            }\r\n\r\n            if (minimize) {\r\n                const i = document.createElement('i');\r\n                i.classList.add('material-icons');\r\n                if (h.__minimized) {\r\n                    i.innerText = 'chevron_right';\r\n                    th.el.innerHTML = '';\r\n                    th.el.appendChild(i);\r\n                } else {\r\n                    i.innerText = 'chevron_left';\r\n\r\n                    const newTh = document.createElement('th');\r\n                    const div = document.createElement('div');\r\n                    div.classList.add('d-flex', 'align-items-center', 'justify-content-between');\r\n\r\n                    const headerWrap = document.createElement('div');\r\n                    if (typeof th.content == 'string') headerWrap.innerText = th.content;\r\n                    else headerWrap.appendChild(th.content);\r\n\r\n                    div.appendChild(headerWrap);\r\n                    div.appendChild(i);\r\n                    newTh.appendChild(div);\r\n\r\n                    th.el = newTh;\r\n                }\r\n\r\n                i.style.cursor = 'pointer';\r\n\r\n                i.addEventListener('click', () => {\r\n                    if (h.__minimized) {\r\n                        // i.innerText = 'chevron_left';\r\n                        h.__minimized = false;\r\n                        h.__reverse = 0;\r\n                    } else {\r\n                        // i.innerText = 'chevron_right';\r\n                        h.__minimized = true;\r\n                    }\r\n\r\n                    this.render();\r\n                });\r\n\r\n                th.el.style.whiteSpace = 'nowrap';\r\n            }\r\n\r\n            if (sort) {\r\n                th.el.style.cursor = 'pointer';\r\n                th.el.addEventListener('click', () => {\r\n                    let { __reverse } = h;\r\n                    h.__sorted = true;\r\n\r\n                    if (typeof __reverse === 'undefined') __reverse = true;\r\n                    else if (+__reverse === 1) __reverse = false;\r\n                    else if (+__reverse === 0) {\r\n                        __reverse = undefined;\r\n                        h.__sorted = false;\r\n                    }\r\n\r\n                    h.__reverse = __reverse;\r\n\r\n                    this.data = this.sort(h.sort, __reverse, i);\r\n                    this.render();\r\n                });\r\n            }\r\n\r\n            if (Array.isArray(thClasses)) th.el.classList.add(...thClasses);\r\n\r\n            if (Array.isArray(thAttributes)) {\r\n                thAttributes.forEach(attr => {\r\n                    th.el.setAttribute(attr.attribute, attr.value);\r\n                });\r\n            }\r\n\r\n            tr.appendChild(th.el);\r\n            tfootTr.appendChild(th.el.cloneNode(true));\r\n            this.tableHeaders.cells.push(th);\r\n            return new TableColumn([th], h);\r\n        }).filter(h => h);\r\n\r\n        if (fixedHeaders) {\r\n            tr.style.position = 'sticky';\r\n            tr.style.top = 0;\r\n            tr.style.zIndex = 1;\r\n        }\r\n\r\n        thead.appendChild(tr);\r\n        this.el.appendChild(thead);\r\n        if (this.options.footer) {\r\n            tfoot.appendChild(tfootTr);\r\n            this.el.appendChild(tfoot);\r\n        }\r\n    }\r\n\r\n    /**'\r\n     *  Renders the table rows (Automatically called by `Table.render`)\r\n     * @returns {void}\r\n     * @memberof Table\r\n     * @private\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @example\r\n     * table.renderRows();\r\n     */\r\n    renderRows() {\r\n        const tbody = document.createElement('tbody');\r\n\r\n        const {\r\n            tr: trInfo,\r\n            appendTest,\r\n            colGroup,\r\n            editable\r\n        } = this.options;\r\n\r\n        let tdTooltip = false;\r\n\r\n        let attributes,\r\n            classes,\r\n            classTests,\r\n            listeners;\r\n\r\n        if (trInfo) {\r\n            attributes = trInfo.attributes;\r\n\r\n            if (attributes && !Array.isArray(attributes)) {\r\n                attributes = Object.entries(attributes).map(([attribute, value]) => {\r\n                    return {\r\n                        attribute,\r\n                        value\r\n                    }\r\n                });\r\n            }\r\n\r\n            classes = trInfo.classes;\r\n            classTests = trInfo.classTests;\r\n            listeners = trInfo.listeners;\r\n        }\r\n\r\n        let i = -1,\r\n            fullSpanPos = 0;\r\n        this.rows = this.data.map(row => {\r\n            if (appendTest && !appendTest(row)) return;\r\n            if (row.__insertRow) {\r\n                // full span row (no columns)\r\n                const tr = document.createElement('tr');\r\n                const td = document.createElement('td');\r\n                td.colSpan = this.headers.filter(h => h).length;\r\n                tr.style.display = 'none';\r\n                if (!fullSpanPos % 2) tr.classList.add('table-insert');\r\n                tr.appendChild(td);\r\n                tbody.appendChild(tr);\r\n                fullSpanPos++;\r\n\r\n                this.insertRows.push(new ReorderInsertRow(tr));\r\n                return;\r\n            }\r\n            i++;\r\n            let colPos = -1;\r\n            const r = new TableRow(this.headers.map((h, j) => {\r\n                if (!h) return;\r\n                colPos++;\r\n                const c = new TableCell('td', h, row, {\r\n                    rowPos: i,\r\n                    colPos,\r\n                    header: h.title || h.name || h.key,\r\n                    minimized: h.__minimized,\r\n                    editable\r\n                });\r\n\r\n                const {\r\n                    td\r\n                } = h;\r\n\r\n                let listeners,\r\n                    attributes,\r\n                    classes,\r\n                    classTests,\r\n                    tooltip;\r\n\r\n                if (td) {\r\n                    listeners = td.listeners;\r\n                    attributes = td.attributes;\r\n\r\n                    if (attributes && !Array.isArray(attributes)) {\r\n                        attributes = Object.entries(attributes).map(([attribute, value]) => {\r\n                            return {\r\n                                attribute,\r\n                                value\r\n                            }\r\n                        });\r\n                    }\r\n\r\n                    classes = td.classes;\r\n                    classTests = td.classTests;\r\n                    tooltip = td.tooltip;\r\n                }\r\n\r\n                this.columns[j].cells.push(c);\r\n\r\n                if (Array.isArray(listeners)) {\r\n                    listeners.forEach(l => {\r\n                        c.el.addEventListener(l.event, (e) => {\r\n                            if (l.action) {\r\n                                l.action({\r\n                                    event: e,\r\n                                    e,\r\n                                    data: row,\r\n                                    row,\r\n                                    tableRow: r,\r\n                                    tableCell: c\r\n                                });\r\n                            }\r\n\r\n                            if (l.callback) {\r\n                                l.callback({\r\n                                    ...e,\r\n                                    __header: this.headers[j],\r\n                                    __row: r,\r\n                                    __cell: c\r\n                                });\r\n                            }\r\n                        });\r\n                    });\r\n                }\r\n\r\n                if (Array.isArray(attributes)) {\r\n                    attributes.forEach(a => {\r\n                        c.el.setAttribute(a.name || a.attribute, typeof a.value === 'function' ? a.value(row) : a.value);\r\n                    });\r\n                }\r\n\r\n                if (Array.isArray(classTests)) {\r\n                    classTests.forEach(t => {\r\n                        if (t.test(row)) c.el.classList.add(\r\n                            ...(Array.isArray(t.classes) ? t.classes : [t.value])\r\n                        );\r\n                    });\r\n                }\r\n\r\n                if (Array.isArray(classes)) {\r\n                    c.el.classList.add(...classes);\r\n                }\r\n\r\n                if (Array.isArray(colGroup)) {\r\n                    let col = colGroup.find(c => c.index == j);\r\n                    if (col) {\r\n                        c.el.classList.add(...(Array.isArray(col.classes ? col.classes : [])));\r\n\r\n                        if (col.span) {\r\n                            c.el.colSpan = col.span;\r\n                            colPos += col.span - 1;\r\n                        }\r\n                    }\r\n                }\r\n\r\n                if (h.__sorted) {\r\n                    if (this.options.sort) {\r\n                        if (Array.isArray(this.options.sort.classes)) c.el.classList.add(...this.options.sort.classes);\r\n                    }\r\n                }\r\n\r\n                try {\r\n                    if (tooltip) {\r\n                        const tooltip = tooltip(row, h.title || h.name || h.key);\r\n                        if (tooltip) {\r\n                            c.el.title = tooltip;\r\n                            tdTooltip = true;\r\n                        }\r\n                    }\r\n                } catch {}\r\n\r\n                return c;\r\n            }).filter(c => c));\r\n\r\n            row._rowPos = i;\r\n            r.data = row;\r\n            r.index = i;\r\n\r\n            if (Array.isArray(listeners)) {\r\n                listeners.forEach(l => {\r\n                    r.el.addEventListener(l.event || l.type, (e) => {\r\n                        if (l.action) {\r\n                            l.action({\r\n                                event: e,\r\n                                e,\r\n                                data: row,\r\n                                row,\r\n                                tableRow: r\r\n                            });\r\n                        }\r\n\r\n                        if (l.callback) {\r\n                            l.callback({\r\n                                ...e,\r\n                                __row: r\r\n                            });\r\n                        }\r\n                    });\r\n                });\r\n            }\r\n\r\n            if (Array.isArray(attributes)) {\r\n                attributes.forEach(a => {\r\n                    r.el.setAttribute(a.name || a.attribute, typeof a.value === 'function' ? a.value(row) : a.value);\r\n                });\r\n            }\r\n\r\n            if (Array.isArray(classTests)) {\r\n                classTests.forEach(t => {\r\n                    if (t.test(row)) trInfo.classList.add(\r\n                        ...(Array.isArray(t.classes) ? t.classes : [t.class || t.value])\r\n                    );\r\n                });\r\n            }\r\n\r\n            if (Array.isArray(classes)) {\r\n                r.el.classList.add(...classes);\r\n            }\r\n\r\n            tbody.appendChild(r.el);\r\n            return r;\r\n        }).filter(r => r);\r\n\r\n        this.rows.forEach((r, i) => {\r\n            r.el.setAttribute('data-row-pos', i);\r\n            r.cells.forEach((c, j) => {\r\n                c.__row = r;\r\n                c.el.setAttribute('data-row-pos', i);\r\n                c.el.setAttribute('data-col-pos', j);\r\n\r\n                c.left = r.cells[j - 1];\r\n                c.right = r.cells[j + 1];\r\n                c.up = this.rows[i - 1] ? this.rows[i - 1].cells[j] : null;\r\n                c.down = this.rows[i + 1] ? this.rows[i + 1].cells[j] : null;\r\n                c.__table = this;\r\n            });\r\n\r\n            r.insertRows = {};\r\n\r\n            /*\r\n                row 0 => above: insertRows[0], bottom: insertRows[1]\r\n                row 1 => above: insertRows[2], bottom: insertRows[3]\r\n                row 2 => above: insertRows[4], bottom: insertRows[5]\r\n                row 3 => above: insertRows[6], bottom: insertRows[7]\r\n                etc.\r\n            */\r\n\r\n            r.insertRows.above = this.insertRows[i * 2];\r\n            r.insertRows.below = this.insertRows[i * 2 + 1];\r\n\r\n            if (r.insertRows.above) r.insertRows.above.row = r;\r\n            if (r.insertRows.below) r.insertRows.below.row = r;\r\n        });\r\n\r\n        this.el.appendChild(tbody);\r\n    }\r\n\r\n    /**\r\n     *  Render the table from the content (useful only with `options.editable`)\r\n     * @returns {void}\r\n     * @memberof Table\r\n     * @private\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @example\r\n     * table.renderFromContent();\r\n     */\r\n    renderFromContent() {\r\n        if (!this.rendered) return this.render();\r\n\r\n        this.destroy(false);\r\n\r\n        [this.this.tableHeaders, ...this.rows].forEach((r, i) => {\r\n            const tr = document.createElement('tr');\r\n            r.cells.forEach((c, j) => {\r\n                const td = document.createElement(i === 0 ? 'th' : 'td');\r\n                td.appendChild(c.el.cloneNode(true));\r\n                tr.appendChild(td);\r\n            });\r\n            this.el.appendChild(tr);\r\n        });\r\n    }\r\n\r\n\r\n\r\n\r\n    /**\r\n     *  Sort the table (Called when user clicks on a header)\r\n     * @param {function} [sortFunction] - The function to use to sort the table\r\n     * @param {boolean} [reverse] - Reverse the sort\r\n     * @param {number} [index] - The index of the column to sort\r\n     * @returns {Array} The sorted data\r\n     * @memberof Table\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @private\r\n     * @example\r\n     * table.sort((a, b) => a.content[0] - b.content[0], true, 0);\r\n     * table.sort((a, b) => a.content[0].localeCompare(b.content[0]), false, 0);\r\n     * table.sort((a, b) => a.content[0] - b.content[0], true);\r\n     * table.sort((a, b) => a.content[0].localeCompare(b.content[0]), false);\r\n     * table.sort((a, b) => a.content[0] - b.content[0]);\r\n     */\r\n    sort(sortFunction, reverse, index) {\r\n        if (typeof sortFunction !== 'function') {\r\n            sortFunction = (a, b) => {\r\n                if (isNaN(a[index]) || isNaN(b[index])) {\r\n                    return a.content[index].localeCompare(b.content[index]);\r\n                } else {\r\n                    return a.content[index] - b.content[index]\r\n                }\r\n            }\r\n        }\r\n\r\n        if (typeof reverse !== 'boolean') {\r\n            // cancel sort\r\n            this.sorted = false;\r\n            return this.originalData;\r\n        }\r\n\r\n        this.sorted = true;\r\n\r\n        // sort this.data the same way as this.data\r\n        const { rows } = this;\r\n        const newRows = rows.sort(sortFunction);\r\n        if (reverse) newRows.reverse();\r\n        return newRows.map(r => r.data);\r\n    }\r\n\r\n    /**\r\n     *  Get the content of the table\r\n     * @returns {Array} The content of the table\r\n     * @memberof Table\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @public\r\n     * @example\r\n     * table.content;\r\n     * // => [\r\n     * //     ['Header 1', 'Header 2', 'Header 3'],\r\n     * //     ['Row 1, Col 1', 'Row 1, Col 2', 'Row 1, Col 3']\r\n     * // ]\r\n     */\r\n    get content() {\r\n        return [this.tableHeaders, ...this.rows].map(r => {\r\n            return r.content;\r\n        });\r\n    }\r\n\r\n    /**\r\n     *  Adds a state to the table if it is sorted (used for reorder or editable tables)\r\n     */\r\n    update() {\r\n        if (this.sorted) this.stack.addState(this);\r\n    }\r\n\r\n    /**\r\n     * Get the content of the table as a JSON string\r\n     * @returns {String} The content of the table as a JSON string\r\n     * @memberof Table\r\n     * @since 1.0.0\r\n     * @version 1.0.0\r\n     * @public\r\n     * @example\r\n     * table.jsonify();\r\n     */\r\n    get json() {\r\n        return JSON.stringify(this.content.filter((_, i) => i !== 0));\r\n    }\r\n\r\n    /**\r\n     * Creates a table from various data types (can automatically detect the type)\r\n     * @param {HTMLElement} table - The table element (if using html, must be already populated)\r\n     * @param {String} data - The data to use to populate the table (not needed for html)\r\n     * @param {Object} options - The options to use to create the table\r\n     * @param {String} type - The type of data (json, csv, tsv, html) (if not specified, will be automatically detected, but this may not work for all cases)\r\n     * @returns {Table} The table\r\n     * @memberof Table\r\n     * @since 1.0.0\r\n     * @public\r\n     */\r\n    static from(table, data, options, type) {\r\n        if (!table) {\r\n            throw new Error('Table.from() requires a table element');\r\n        }\r\n\r\n        if (!table.querySelector) {\r\n            throw new Error('Table.from() requires a table element');\r\n        }\r\n\r\n        if (!type) {\r\n            if (!data) type = 'html';\r\n            else {\r\n                try {\r\n                    JSON.parse(data);\r\n                    type = 'json';\r\n                } catch {\r\n                    // get all commas\r\n                    const commas = data.split(',').length - 1;\r\n                    // get all tabs\r\n                    const tabs = data.split('\\t').length - 1;\r\n\r\n                    if (commas > tabs) type = 'csv';\r\n                    else type = 'tsv';\r\n                }\r\n            }\r\n        }\r\n\r\n        type = type.toLowerCase();\r\n\r\n        switch (type) {\r\n            case 'json':\r\n                return Table.fromJSON(table, data, options);\r\n            case 'html':\r\n                return Table.fromHTML(table, options);\r\n            case 'csv':\r\n                return Table.fromCSV(table, data, options);\r\n            case 'tsv':\r\n                return Table.fromTSV(table, data, options);\r\n            default:\r\n                throw new Error('Invalid type, allowed types are: json, html, csv, and tsv. received: ' + type);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Create a table from JSON data\r\n     * @param {String} data - The JSON data (must be an array of arrays or an array of objects with consistent keys)\r\n     * @param {Object} options - The options to use\r\n     * @returns {Table} The table\r\n     * @memberof Table\r\n     * @since 1.1.4\r\n     * @public\r\n     */\r\n    static fromJSON(table, data, options) {\r\n        data = JSON.parse(data);\r\n\r\n        let headers = data[0];\r\n\r\n        if (Array.isArray(headers)) {\r\n            headers = headers.map(h => {\r\n                return {\r\n                    title: h,\r\n                    getData: d => d[h]\r\n                }\r\n            });\r\n\r\n            data.shift();\r\n        } else {\r\n            headers = Object.keys(headers).map(k => {\r\n                return {\r\n                    title: k,\r\n                    getData: d => d[k]\r\n                }\r\n            });\r\n        }\r\n\r\n        data = data.map(d => {\r\n            if (Array.isArray(d)) {\r\n                return d.reduce((acc, cur, i) => {\r\n                    acc[headers[i].title] = cur;\r\n                    return acc;\r\n                }, {});\r\n            } else {\r\n                return d;\r\n            }\r\n        });\r\n\r\n        return new Table(table, headers, data, options);\r\n    }\r\n\r\n    /**\r\n     * Create a table from rendered HTML Table\r\n     * @param {HTMLElement} table Element to get data from \r\n     * @param {Object} options  Options to pass to the table\r\n     * @returns {Table}\r\n     * @memberof Table\r\n     * @since 1.1.4\r\n     * @public\r\n     */\r\n    static fromHTML(table, options) {\r\n        const headers = Array.from(table.querySelectorAll('thead th')).map(h => {\r\n            return {\r\n                title: h.textContent\r\n            }\r\n        });\r\n\r\n        const data = Array.from(table.querySelectorAll('tbody tr')).map(tr => {\r\n            return Array.from(tr.querySelectorAll('td')).reduce((acc, cur, i) => {\r\n                acc[headers[i].title] = cur.textContent;\r\n                return acc;\r\n            }, {});\r\n        });\r\n\r\n        return new Table(table, headers, data, {\r\n            ...options,\r\n            __render: false\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Create a table from CSV data\r\n     * @param {HTMLElement} table the table element\r\n     * @param {String} data CSV string\r\n     * @param {Object} options Options to pass to the table\r\n     * @returns {Table}\r\n     * @memberof Table\r\n     * @public\r\n     * @since 1.1.4\r\n     */\r\n    static fromCSV(table, data, options) {\r\n        const json = JSON.stringify(parseSV(data, ',', '\"'));\r\n        return Table.fromJSON(table, json, options);\r\n    }\r\n\r\n    /**\r\n     * Create a table from TSV data\r\n     * @param {HTMLElement} table the table element\r\n     * @param {String} data TSV string \r\n     * @param {Object} options Options to pass to the table\r\n     * @returns {Table}\r\n     * @memberof Table\r\n     * @since 1.1.4\r\n     * @public\r\n     */\r\n    static fromTSV(table, data, options) {\r\n        const json = JSON.stringify(parseSV(data, '\\t', '\"'));\r\n        return Table.fromJSON(table, json, options);\r\n    }\r\n}\r\n\r\n/**\r\n *  A table row used for reorderable tables\r\n */\r\nclass ReorderInsertRow {\r\n    constructor(el, row) {\r\n        if (!el.querySelector) throw new Error('Element must be a DOM element');\r\n\r\n        this.el = el;\r\n\r\n        this.row = row;\r\n    }\r\n\r\n    /**\r\n     *  Shows the insert row\r\n     */\r\n    show() {\r\n        this.el.style.display = '';\r\n    }\r\n\r\n    /**\r\n     *  Hides the insert row\r\n     */\r\n    hide() {\r\n        this.el.style.display = 'none';\r\n    }\r\n}\r\n\r\n/**\r\n *  A table row\r\n * @private\r\n */\r\nclass TableRow {\r\n    /**\r\n     * \r\n     * @param {Array<TableCell>} cells The cells of the row \r\n     */\r\n    constructor(cells) {\r\n        this.cells = cells;\r\n\r\n        this.render();\r\n    }\r\n\r\n    /**\r\n     *  Render the row\r\n     */\r\n    render() {\r\n        this.el = document.createElement('tr');\r\n        this.cells.forEach(cell => {\r\n            this.el.appendChild(cell.el);\r\n        });\r\n    }\r\n\r\n    /**\r\n     *  Get the content of the row\r\n     *  @returns {Object} The content of the row\r\n     */\r\n    get content() {\r\n        return this.cells.reduce((acc, cur) => {\r\n            acc[cur.headerTitle] = cur.content;\r\n            return acc;\r\n        }, {});\r\n    }\r\n}\r\n\r\n/**\r\n *  A table column\r\n * @private\r\n */\r\nclass TableColumn {\r\n    /**\r\n     * \r\n     * @param {Array<TableCell>} cells The cells of the column\r\n     * @param {TableHeader} header The header of the column\r\n     */\r\n    constructor(cells, header) {\r\n        this.cells = cells;\r\n        this.header = header;\r\n    }\r\n\r\n    get content() {\r\n        return this.cells.map(c => c.content);\r\n    }\r\n}\r\n\r\n/**\r\n *  A table cell\r\n * @private\r\n */\r\nclass TableCell {\r\n    /**\r\n     * \r\n     * @param {String} type The type of the cell (td or th)\r\n     * @param {TableHeader} header The header of the cell \r\n     * @param {TableRow} row The row of the cell \r\n     * @param {Object} options The options for the cell\r\n     * @param {Number} options.rowPos The position of the row\r\n     * @param {Number} options.colPos The position of the column\r\n     * @param {Boolean} options.minimized Whether or not the cell is minimized\r\n     * @param {Object} options.editable The editable options for the cell\r\n     * @param {Function} options.editable.onChange The function to call when the cell is changed\r\n     * @param {Function} options.editable.onCancel The function to call when the cell is canceled\r\n     */\r\n    constructor(type, header, row, {\r\n        rowPos,\r\n        colPos,\r\n        minimized,\r\n        editable\r\n    }) {\r\n        this.content = header.getData ? header.getData(row) : row[header.title || header.name || header.key];\r\n        this.type = type;\r\n        this.colPos = colPos;\r\n        this.rowPos = rowPos;\r\n        this.headerTitle = header.title;\r\n        this.header = header;\r\n        this.editable = editable;\r\n        this.onChange = editable ? editable.onChange : () => {};\r\n        this.onCancel = editable ? editable.onCancel : () => {};\r\n\r\n        if (!minimized) this.render();\r\n        else this.el = document.createElement('td');\r\n\r\n        this.stack = new Table_StateStack();\r\n        this.stack.addState(this.content);\r\n\r\n        this.stack.onChange = (state) => {\r\n            console.log('state changed');\r\n            this.content = state;\r\n\r\n            this.render();\r\n        }\r\n\r\n        this.stack.onChangeUnsaved = (state) => {\r\n            if (!this.viewingUnsaved) return;\r\n            if (state || state == '') {\r\n                console.log('Rendering unsaved state: ', state);\r\n                this.el.innerText = state;\r\n            }\r\n        }\r\n    }\r\n\r\n    /**\r\n     *  Render the cell\r\n     */\r\n    render() {\r\n        this.el = document.createElement(this.type);\r\n\r\n        this.el.dataset.colPos = this.colPos;\r\n        this.el.dataset.rowPos = this.rowPos;\r\n        this.el.dataset.header = this.headerTitle;\r\n\r\n\r\n        if (this.content.querySelector) {\r\n            if (this.editable) throw new Error('Editable cells cannot contain HTML elements');\r\n            this.el.appendChild(this.content);\r\n        } else {\r\n            this.el.innerHTML = this.content;\r\n            if (this.editable) {\r\n                this.el.setAttribute('title', `\r\nPress Ctrl + Enter to save\r\nPress Escape to cancel\r\nPress Ctrl + Z to undo\r\nPress Ctrl + Y to redo\r\nPress Ctrl + Arrow Keys to move between cells\r\nLeaving the cell will cancel the changes\r\n                `);\r\n\r\n                let edit = false;\r\n\r\n                this.el.setAttribute('contenteditable', 'true');\r\n\r\n                const change = () => {\r\n                    this.onChange({\r\n                        row: this.__row,\r\n                        cell: this,\r\n                        value: this.el.innerText,\r\n                        previousValue: this.content\r\n                    });\r\n                    this.stack.addState(this.el.innerText);\r\n                    this.el.blur();\r\n                }\r\n\r\n                const cancel = () => {\r\n                    if (edit) return edit = false;\r\n                    this.viewingUnsaved = false;\r\n                    this.stack.addUnsavedState(this.el.innerText);\r\n                    this.el.innerHTML = this.content;\r\n                    this.onCancel({\r\n                        row: this.__row,\r\n                        cell: this,\r\n                        value: this.el.innerText\r\n                    });\r\n\r\n                    edit = true;\r\n                    this.el.blur();\r\n                }\r\n\r\n                this.el.onblur = cancel;\r\n\r\n                this.el.addEventListener('keyup', (e) => {\r\n                    if (e.key == 'Alt') {\r\n                        e.preventDefault();\r\n                        this.el.innerText = this.stack.currentState;\r\n                        return this.viewingUnsaved = false;\r\n                    }\r\n                });\r\n\r\n                this.el.addEventListener('keydown', (e) => {\r\n                    switch (e.key) {\r\n                        case 'Escape':\r\n                            cancel();\r\n                            break;\r\n                    }\r\n                    if (e.altKey) {\r\n                        e.preventDefault();\r\n                        this.viewingUnsaved = true;\r\n                        this.stack.resolveUnsaved();\r\n                        console.log(this.stack.currentUnsavedState, this.stack.currentUnsavedIndex);\r\n                        switch (e.key) {\r\n                            case 'ArrowUp':\r\n                                e.preventDefault();\r\n                                this.stack.prevUnsaved();\r\n                                break;\r\n                            case 'ArrowDown':\r\n                                e.preventDefault();\r\n                                this.stack.nextUnsaved();\r\n                                break;\r\n                        }\r\n                        // this.stack.onChangeUnsaved();\r\n                        // switch (e.key) {\r\n                        //     case 'ArrowLeft':\r\n\r\n                        // }\r\n                        return;\r\n                    }\r\n                    if (e.ctrlKey) {\r\n                        // shift key\r\n\r\n                        switch (e.key) {\r\n                            case 'z':\r\n                                this.stack.prev();\r\n                                break;\r\n                            case 'y':\r\n                                this.stack.next();\r\n                                break;\r\n                            case 'Enter':\r\n                                change();\r\n                                edit = true;\r\n                                break;\r\n                                // arrow keys\r\n                            case 'ArrowUp':\r\n                                e.preventDefault();\r\n                                if (this.up) this.up.el.focus();\r\n                                break;\r\n                            case 'ArrowDown':\r\n                                e.preventDefault();\r\n                                if (this.down) this.down.el.focus();\r\n                                break;\r\n                            case 'ArrowLeft':\r\n                                e.preventDefault();\r\n                                if (this.left) this.left.el.focus();\r\n                                break;\r\n                            case 'ArrowRight':\r\n                                e.preventDefault();\r\n                                if (this.right) this.right.el.focus();\r\n                                break;\r\n                        }\r\n                    }\r\n                });\r\n            }\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Change the content of the cell\r\n     * @param {String} content The new content of the cell\r\n     */\r\n    changeContent(content) {\r\n        this.stack.addState(content);\r\n    }\r\n}\r\n\r\n/**\r\n *  A table header\r\n * @private\r\n */\r\nclass TableHeader {\r\n    /**\r\n     * \r\n     * @param {HTMLElement | String} content The content of the header\r\n     * @param {Object} options The options for the header \r\n     */\r\n    constructor(content, options) {\r\n        this.options = options || {};\r\n        this.el = document.createElement('th');\r\n\r\n        this.content = content;\r\n\r\n        this.render();\r\n    }\r\n\r\n    render() {\r\n        if (this.content.querySelector) {\r\n            this.el.appendChild(this.content);\r\n        } else {\r\n            this.el.innerHTML = this.content;\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Change the content of the header\r\n     * @param {HTMLElement | String} content The new content of the header\r\n     */\r\n    changeContent(content) {\r\n        this.content = content;\r\n        this.render();\r\n    }\r\n}\r\n\r\n/**\r\n *  A table footer\r\n * @private\r\n * @extends TableHeader\r\n */\r\nclass TableFooter extends TableHeader {\r\n    /**\r\n     * \r\n     * @param  {...any} args The arguments for the header\r\n     */\r\n    constructor(...args) {\r\n        super(...args);\r\n    }\r\n}"]}