"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnAttached = exports.UIScroll = exports.UILink = exports.UIPaper = exports.UILine = exports.UIClip = exports.UIShow = exports.UIHide = exports.UIGutter = exports.UIAlign = exports.UIText = exports.UIWeight = exports.UIFont = exports.UIBorder = exports.UIMargin = exports.UIPadding = exports.UIShadow = exports.UIHover = exports.UIColor = exports.UIBg = exports.UITheme = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var ui_internal_1 = require("../utils/ui-internal");
var BaseAttribute = (function () {
    function BaseAttribute(element) {
        this.element = element;
        this.prefix = "";
        this.value = "default";
        this.oldValue = "default";
        this.singular = false;
    }
    BaseAttribute.prototype.bind = function () {
        this.toggleClass();
    };
    BaseAttribute.prototype.valueChanged = function () {
        this.toggleClass();
    };
    BaseAttribute.prototype.toggleClass = function () {
        var _this = this;
        var el = this.element;
        var vm = getViewModel(this.element);
        if (vm && vm.vmElement) {
            el = vm.vmElement;
        }
        if (el.classList) {
            if (this.oldValue && !this.singular) {
                this.oldValue.split(" ").forEach(function (p) { return el.classList.remove("".concat(_this.prefix, "--").concat(p.trim())); });
            }
            else {
                el.classList.remove("".concat(this.prefix));
            }
            this.oldValue = this.value;
            if (this.value && !this.singular) {
                this.value.split(" ").forEach(function (p) { return el.classList.add("".concat(_this.prefix, "--").concat(p.trim())); });
            }
            else if (!isFalse(this.value)) {
                el.classList.add("".concat(this.prefix));
            }
        }
    };
    BaseAttribute = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        __metadata("design:paramtypes", [Element])
    ], BaseAttribute);
    return BaseAttribute;
}());
var UITheme = exports.UITheme = (function (_super) {
    __extends(UITheme, _super);
    function UITheme() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-theme";
        return _this;
    }
    UITheme = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-theme")
    ], UITheme);
    return UITheme;
}(BaseAttribute));
var UIBg = exports.UIBg = (function (_super) {
    __extends(UIBg, _super);
    function UIBg() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-bg";
        return _this;
    }
    UIBg = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-bg")
    ], UIBg);
    return UIBg;
}(BaseAttribute));
var UIColor = exports.UIColor = (function (_super) {
    __extends(UIColor, _super);
    function UIColor() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-color";
        return _this;
    }
    UIColor = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-color")
    ], UIColor);
    return UIColor;
}(BaseAttribute));
var UIHover = exports.UIHover = (function (_super) {
    __extends(UIHover, _super);
    function UIHover() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-hover";
        return _this;
    }
    UIHover = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-hover")
    ], UIHover);
    return UIHover;
}(BaseAttribute));
var UIShadow = exports.UIShadow = (function (_super) {
    __extends(UIShadow, _super);
    function UIShadow() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-shadow";
        return _this;
    }
    UIShadow = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-shadow")
    ], UIShadow);
    return UIShadow;
}(BaseAttribute));
var UIPadding = exports.UIPadding = (function (_super) {
    __extends(UIPadding, _super);
    function UIPadding() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-padding";
        return _this;
    }
    UIPadding = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-padding")
    ], UIPadding);
    return UIPadding;
}(BaseAttribute));
var UIMargin = exports.UIMargin = (function (_super) {
    __extends(UIMargin, _super);
    function UIMargin() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-margin";
        return _this;
    }
    UIMargin = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-margin")
    ], UIMargin);
    return UIMargin;
}(BaseAttribute));
var UIBorder = exports.UIBorder = (function (_super) {
    __extends(UIBorder, _super);
    function UIBorder() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-border";
        return _this;
    }
    UIBorder = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-border")
    ], UIBorder);
    return UIBorder;
}(BaseAttribute));
var UIFont = exports.UIFont = (function (_super) {
    __extends(UIFont, _super);
    function UIFont() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-font";
        return _this;
    }
    UIFont = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-font")
    ], UIFont);
    return UIFont;
}(BaseAttribute));
var UIWeight = exports.UIWeight = (function (_super) {
    __extends(UIWeight, _super);
    function UIWeight() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-weight";
        return _this;
    }
    UIWeight = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-weight")
    ], UIWeight);
    return UIWeight;
}(BaseAttribute));
var UIText = exports.UIText = (function (_super) {
    __extends(UIText, _super);
    function UIText() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-text";
        return _this;
    }
    UIText = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-text")
    ], UIText);
    return UIText;
}(BaseAttribute));
var UIAlign = exports.UIAlign = (function (_super) {
    __extends(UIAlign, _super);
    function UIAlign() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-align";
        return _this;
    }
    UIAlign = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-align")
    ], UIAlign);
    return UIAlign;
}(BaseAttribute));
var UIGutter = exports.UIGutter = (function (_super) {
    __extends(UIGutter, _super);
    function UIGutter() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-gutter";
        return _this;
    }
    UIGutter = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-gutter")
    ], UIGutter);
    return UIGutter;
}(BaseAttribute));
var UIHide = exports.UIHide = (function (_super) {
    __extends(UIHide, _super);
    function UIHide() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-hide";
        return _this;
    }
    UIHide = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-hide")
    ], UIHide);
    return UIHide;
}(BaseAttribute));
var UIShow = exports.UIShow = (function (_super) {
    __extends(UIShow, _super);
    function UIShow() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-show";
        return _this;
    }
    UIShow = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-show")
    ], UIShow);
    return UIShow;
}(BaseAttribute));
var UIClip = exports.UIClip = (function (_super) {
    __extends(UIClip, _super);
    function UIClip() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-clip";
        _this.singular = true;
        return _this;
    }
    UIClip.prototype.bind = function () {
        _super.prototype.bind.call(this);
        this.valueChanged();
    };
    UIClip.prototype.valueChanged = function () {
        this.element.style.cssText = "--line-clamp: ".concat(this.value, ";");
    };
    UIClip = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-clip")
    ], UIClip);
    return UIClip;
}(BaseAttribute));
var UILine = exports.UILine = (function (_super) {
    __extends(UILine, _super);
    function UILine() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-line";
        _this.singular = true;
        return _this;
    }
    UILine.prototype.bind = function () {
        _super.prototype.bind.call(this);
        this.valueChanged();
    };
    UILine.prototype.valueChanged = function () {
        this.element.style.cssText = "line-height: ".concat(this.value, ";");
    };
    UILine = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-line")
    ], UILine);
    return UILine;
}(BaseAttribute));
var UIPaper = exports.UIPaper = (function (_super) {
    __extends(UIPaper, _super);
    function UIPaper() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-paper";
        _this.singular = true;
        return _this;
    }
    UIPaper = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-paper")
    ], UIPaper);
    return UIPaper;
}(BaseAttribute));
var UILink = exports.UILink = (function (_super) {
    __extends(UILink, _super);
    function UILink() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-link";
        _this.singular = true;
        return _this;
    }
    UILink = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-link")
    ], UILink);
    return UILink;
}(BaseAttribute));
var UIScroll = exports.UIScroll = (function (_super) {
    __extends(UIScroll, _super);
    function UIScroll() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.prefix = "ui-scroll";
        return _this;
    }
    UIScroll = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("ui-scroll")
    ], UIScroll);
    return UIScroll;
}(BaseAttribute));
var OnAttached = exports.OnAttached = (function () {
    function OnAttached(taskQueue, element) {
        this.taskQueue = taskQueue;
        this.element = element;
    }
    OnAttached.prototype.attached = function () {
        var _this = this;
        this.taskQueue.queueTask(function () {
            if (_this.event != null) {
                ui_internal_1.UIInternal.broadcast(_this.event, _this.element);
            }
            if (_this.handler != null) {
                _this.handler({ element: _this.element });
            }
        });
    };
    __decorate([
        (0, aurelia_framework_1.bindable)({ primaryProperty: true }),
        __metadata("design:type", String)
    ], OnAttached.prototype, "event", void 0);
    __decorate([
        aurelia_framework_1.bindable,
        __metadata("design:type", Function)
    ], OnAttached.prototype, "handler", void 0);
    OnAttached = __decorate([
        (0, aurelia_framework_1.autoinject)(),
        (0, aurelia_framework_1.customAttribute)("on-attached"),
        __metadata("design:paramtypes", [aurelia_framework_1.TaskQueue, Element])
    ], OnAttached);
    return OnAttached;
}());

//# sourceMappingURL=ui-helpers.js.map
