import { extend } from '../../../helpers/object.mjs';
import { extendByMetaType } from '../utils.mjs';
import metaSchemaFactory from '../metaSchema.mjs';
/**
 * @typedef {Options} TableMeta
 */ /**
 * @returns {TableMeta} Returns an empty object. The holder for global meta object.
 */ function createTableMetaEmptyClass() {
    return class TableMeta {
    };
}
class GlobalMeta {
    /**
   * Gets constructor of the global meta object. Necessary for inheritance for creating the next meta layers.
   *
   * @returns {Function}
   */ getMetaConstructor() {
        return this.metaCtor;
    }
    /**
   * Gets settings object for this layer.
   *
   * @returns {object}
   */ getMeta() {
        return this.meta;
    }
    /**
   * Updates global settings object by merging settings with the current state.
   *
   * @param {object} settings An object to merge with.
   */ updateMeta(settings) {
        extend(this.meta, settings);
        extendByMetaType(this.meta, {
            ...settings,
            type: settings.type ?? this.meta.type
        }, settings);
    }
    constructor(hot){
        /**
   * An alias for the constructor. Necessary for inheritance for creating new layers.
   *
   * @type {TableMeta}
   */ this.metaCtor = createTableMetaEmptyClass();
        this.meta = this.metaCtor.prototype;
        extend(this.meta, metaSchemaFactory());
        this.meta.instance = hot;
    }
}
/**
 * The global meta object is a root of all default settings, which are recognizable by Handsontable.
 * Other layers are inherited from this object. Adding, removing, or changing property in that
 * object has a direct reflection to all layers such as: TableMeta, ColumnMeta, or CellMeta layers.
 *
 * +-------------+.
 * │ GlobalMeta  │
 * │ (prototype) │
 * +-------------+\
 *       │         \
 *       │          \
 *      \│/         _\|
 * +-------------+    +-------------+.
 * │ TableMeta   │    │ ColumnMeta  │
 * │ (instance)  │    │ (prototype) │
 * +-------------+    +-------------+.
 *                         │
 *                         │
 *                        \│/
 *                    +-------------+.
 *                    │  CellMeta   │
 *                    │ (instance)  │
 *                    +-------------+.
 */ export { GlobalMeta as default };
