import { UmbNameWriteGuardManager } from '../namable/index.js';
import { UmbEntityDetailWorkspaceContextBase } from './entity-detail-workspace-base.js';
export class UmbEntityNamedDetailWorkspaceContextBase extends UmbEntityDetailWorkspaceContextBase {
    constructor(host, args) {
        super(host, args);
        // Just for context token safety:
        this.IS_ENTITY_NAMED_DETAIL_WORKSPACE_CONTEXT = true;
        this.name = this._data.createObservablePartOfCurrent((data) => data?.name);
        this.nameWriteGuard = new UmbNameWriteGuardManager(this);
        this.nameWriteGuard.fallbackToPermitted();
        this.observe(this.name, (name) => {
            this.view.setTitle(name);
        }, null);
    }
    getName() {
        return this._data.getCurrent()?.name;
    }
    setName(name) {
        // We have to cast to Partial because TypeScript doesn't understand that the model has a name property due to generic sub-types
        this._data.updateCurrent({ name });
    }
}
