const DIRECTIVE_SYNTAX_DEFAULT = 'disabled';
export class DirectiveSyntaxContext {
    #option;
    set option(value) {
        this.#option = value ?? DIRECTIVE_SYNTAX_DEFAULT;
    }
    get option() {
        return this.#option;
    }
    constructor(option) {
        this.option = option;
        this.#option = this.option;
    }
    valueFor(key) {
        let value;
        if (typeof this.option === 'object')
            value = this.option[key];
        if (typeof this.option === 'string')
            value = this.option;
        return value ?? DIRECTIVE_SYNTAX_DEFAULT;
    }
    mdPluginValueFor(key) {
        const value = this.valueFor(key);
        return value === 'preserve' || value === 'overwrite' ? 'enabled' : value;
    }
    /** helper for wisywig serializer */
    shouldSerializeToDirective(key, tokenMarkup) {
        const option = this.valueFor(key);
        if (option === 'overwrite' || option === 'only')
            return true;
        if (typeof tokenMarkup === 'string') {
            if (tokenMarkup.startsWith(':'))
                return true;
            if (tokenMarkup.startsWith('{'))
                return false;
        }
        if (option === 'preserve')
            return true;
        return false;
    }
    /** helper for markup-mode commands and actions */
    shouldInsertDirectiveMarkup(key) {
        const value = this.valueFor(key);
        if (value === 'disabled' || value === 'enabled')
            return false;
        return true;
    }
}
//# sourceMappingURL=directive.js.map
