define(['exports', 'aurelia-framework', 'aurelia-event-aggregator', './schema', './model', './toolbar-items'], function (exports, _aureliaFramework, _aureliaEventAggregator, _schema, _model, _toolbarItems) {
    'use strict';

    exports.__esModule = true;
    exports.SchemaMasterDetail = 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, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;

    let SchemaMasterDetail = exports.SchemaMasterDetail = (_dec = (0, _aureliaFramework.inject)(_aureliaEventAggregator.EventAggregator), _dec(_class = (_class2 = class SchemaMasterDetail {

        constructor(eventAggregator) {
            _initDefineProp(this, 'toolbarItems', _descriptor, this);

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

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

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

            _initDefineProp(this, 'context', _descriptor5, this);

            _initDefineProp(this, 'items', _descriptor6, this);

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

            this.eventAggregator = eventAggregator;
            this.schema = _schema.template;
            this.context = this;
        }

        debug() {
            debugger;
        }

        attached() {
            this.toolbarItems = _toolbarItems.toolbarItems;

            this.items = [{
                id: 1,
                code: "Item 1",
                description: "Item description 1"
            }, {
                id: 2,
                code: "Item 2",
                description: "Item description 2"
            }, {
                id: 3,
                code: "Item 3",
                description: "Item description 3"
            }, {
                id: 4,
                code: "Item 4",
                description: "Item description 4"
            }, {
                id: 5,
                code: "Item 5",
                description: "Item description 5"
            }];

            this.fetch(1);

            this.formUpdatedHandler = this.formUpdated.bind(this);
            this.formUpdatedSubscription = this.eventAggregator.subscribe("form-updated", this.formUpdatedHandler);
        }

        formUpdated() {
            this.selectedId = 1;
        }

        detached() {
            this.schema = null;
            this.model = null;
            this.toolbarItems = null;
        }

        detailToolbarSelectedIdChanged(newValue) {
            alert(newValue);
        }

        fetch(id) {
            return new Promise(_ => {
                this.model = new _model.Model();
                this.model.id = id;
                this.model.code = `Code ${id}`;
                this.model.description = `Description ${id}`;
            });
        }
    }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'toolbarItems', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'detailToolbarSelectedId', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'schema', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'model', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, 'context', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, 'items', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, 'selectedId', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    })), _class2)) || _class);
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64, 