define(['exports', 'aurelia-framework'], function (exports, _aureliaFramework) {
    'use strict';

    exports.__esModule = true;
    exports.ModelSelector = undefined;

    function _initDefineProp(target, property, descriptor, context) {
        if (!descriptor) return;
        Object.defineProperty(target, property, {
            enumerable: descriptor.enumerable,
            configurable: descriptor.configurable,
            writable: descriptor.writable,
            value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
        });
    }

    function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
        var desc = {};
        Object['ke' + 'ys'](descriptor).forEach(function (key) {
            desc[key] = descriptor[key];
        });
        desc.enumerable = !!desc.enumerable;
        desc.configurable = !!desc.configurable;

        if ('value' in desc || desc.initializer) {
            desc.writable = true;
        }

        desc = decorators.slice().reverse().reduce(function (desc, decorator) {
            return decorator(target, property, desc) || desc;
        }, desc);

        if (context && desc.initializer !== void 0) {
            desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
            desc.initializer = undefined;
        }

        if (desc.initializer === void 0) {
            Object['define' + 'Property'](target, property, desc);
            desc = null;
        }

        return desc;
    }

    function _initializerWarningHelper(descriptor, context) {
        throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
    }

    var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3;

    let ModelSelector = exports.ModelSelector = (_dec = (0, _aureliaFramework.customAttribute)('model-selector'), _dec2 = (0, _aureliaFramework.inject)(_aureliaFramework.DOM.Element), _dec(_class = _dec2(_class = (_class2 = class ModelSelector {

        constructor(element) {
            _initDefineProp(this, 'datasource', _descriptor, this);

            _initDefineProp(this, 'model', _descriptor2, this);

            _initDefineProp(this, 'selectedId', _descriptor3, this);

            this.element = element;
        }

        selectedIdChanged(newValue) {
            if (newValue != undefined) {
                this.model = this.datasource.find(item => item.id == newValue);
            }
        }
    }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'datasource', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'model', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'selectedId', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    })), _class2)) || _class) || _class);
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm1vZGVsLXNlbGVjdG9yLmpzIl0sIm5hbWVzIjpbIk1vZGVsU2VsZWN0b3IiLCJFbGVtZW50IiwiY29uc3RydWN0b3IiLCJlbGVtZW50Iiwic2VsZWN0ZWRJZENoYW5nZWQiLCJuZXdWYWx1ZSIsInVuZGVmaW5lZCIsIm1vZGVsIiwiZGF0YXNvdXJjZSIsImZpbmQiLCJpdGVtIiwiaWQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztRQUlhQSxhLFdBQUFBLGEsV0FGWix1Q0FBZ0IsZ0JBQWhCLEMsVUFDQSw4QkFBTyxzQkFBSUMsT0FBWCxDLDBDQUNNLE1BQU1ELGFBQU4sQ0FBb0I7O0FBS3ZCRSxvQkFBWUMsT0FBWixFQUFxQjtBQUFBOztBQUFBOztBQUFBOztBQUNqQixpQkFBS0EsT0FBTCxHQUFlQSxPQUFmO0FBQ0g7O0FBRURDLDBCQUFrQkMsUUFBbEIsRUFBNEI7QUFDeEIsZ0JBQUlBLFlBQVlDLFNBQWhCLEVBQTJCO0FBQ3ZCLHFCQUFLQyxLQUFMLEdBQWEsS0FBS0MsVUFBTCxDQUFnQkMsSUFBaEIsQ0FBcUJDLFFBQVFBLEtBQUtDLEVBQUwsSUFBV04sUUFBeEMsQ0FBYjtBQUNIO0FBQ0o7QUFic0IsSyIsImZpbGUiOiJtb2RlbC1zZWxlY3Rvci5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7YmluZGFibGUsIGluamVjdCwgY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