import { UmbBooleanState } from '../../../../libs/observable-api/index.js';
import { UmbBlockManagerContext } from '../../block/index.js';
import { UMB_PROPERTY_SORT_MODE_CONTEXT } from '../../../core/property-sort-mode/index.js';
/**
 * A implementation of the Block Manager specifically for the Block List Editor.
 */
export class UmbBlockListManagerContext extends UmbBlockManagerContext {
    //
    #inlineEditingMode;
    setInlineEditingMode(inlineEditingMode) {
        this.#inlineEditingMode.setValue(inlineEditingMode ?? false);
    }
    getInlineEditingMode() {
        return this.#inlineEditingMode.getValue();
    }
    #sortModeContext;
    #isSortMode;
    setIsSortMode(isSortMode) {
        this.#sortModeContext?.setIsSortMode(isSortMode);
    }
    getIsSortMode() {
        return this.#sortModeContext?.getIsSortMode();
    }
    constructor(host) {
        super(host);
        //
        this.#inlineEditingMode = new UmbBooleanState(undefined);
        this.inlineEditingMode = this.#inlineEditingMode.asObservable();
        this.#isSortMode = new UmbBooleanState(undefined);
        this.isSortMode = this.#isSortMode.asObservable();
        this.consumeContext(UMB_PROPERTY_SORT_MODE_CONTEXT, (sortPropertyContext) => {
            this.#sortModeContext = sortPropertyContext;
            this.observe(this.#sortModeContext?.isSortMode, (isSortMode) => {
                this.#isSortMode.setValue(isSortMode);
            });
        });
    }
    /**
     * @param contentElementTypeKey
     * @param partialLayoutEntry
     * @param _originData
     */
    async createWithPresets(contentElementTypeKey, partialLayoutEntry, 
    // This property is used by some implementations, but not used in this. Do not remove. [NL]
    _originData) {
        return await super._createBlockData(contentElementTypeKey, partialLayoutEntry);
    }
    insert(layoutEntry, content, settings, originData) {
        this._layouts.appendOneAt(layoutEntry, originData.index ?? -1);
        this.insertBlockData(layoutEntry, content, settings, originData);
        this.notifyBlockInserted(layoutEntry, originData);
        return true;
    }
}
