// #region
import { noChange } from 'lit';
import { PartType, directive } from 'lit/directive.js';
import { AsyncDirectiveBase } from './Abstracts/AsyncDirectiveBase';
class StyleSheetVarDirective extends AsyncDirectiveBase {
    // #region Ctor
    constructor(args) {
        super(args);
        if (args.type !== PartType.PROPERTY) {
            throw new Error('The `StyleSheetVar` directive can only be used in property bindings.');
        }
    }
    // #endregion
    // #region Methods
    render(variableName, fallback, transform) {
        if (this.internals.options.host && this.internals.options.host instanceof HTMLElement) {
            const variableValue = this.internals.options.host.computedStyleMap().get(variableName)
                ?.toString() ?? fallback;
            const result = transform
                ? transform(variableValue)
                : variableValue;
            return result;
        }
        return noChange;
    }
}
/**
 * @public
 */
export const styleSheetVar = directive(StyleSheetVarDirective);
//# sourceMappingURL=StyleSheetVarDirective.js.map