define(['exports', 'aurelia-framework', 'aurelia-event-aggregator', './schema', '../../lib/dataset-factory'], function (exports, _aureliaFramework, _aureliaEventAggregator, _schema, _datasetFactory) {
    'use strict';

    exports.__esModule = true;
    exports.Styling = 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;

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

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

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

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

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

        attached() {

            this.factory = new _datasetFactory.DatasetFactory(this.schema, null, null);
            this.fetch(0);
        }

        detached() {
            this.schema = null;
            this.model = null;
            this.factory.dispose();
            this.factory = null;
            this.context = null;
        }

        fetch(id) {
            this.model = this.factory.createDataSet(id);

            const d = this.model.defaultFromDefinition();
            this.model.setInitialValues(d);
            this.model.code = 'Button';
        }
    }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'schema', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'context', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'model', [_aureliaFramework.bindable], {
        enumerable: true,
        initializer: null
    })), _class2)) || _class);
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxpbmcuanMiXSwibmFtZXMiOlsiU3R5bGluZyIsImNvbnN0cnVjdG9yIiwiZXZlbnRBZ2dyZWdhdG9yIiwiY29udGV4dCIsInNjaGVtYSIsImF0dGFjaGVkIiwiZmFjdG9yeSIsImZldGNoIiwiZGV0YWNoZWQiLCJtb2RlbCIsImRpc3Bvc2UiLCJpZCIsImNyZWF0ZURhdGFTZXQiLCJkIiwiZGVmYXVsdEZyb21EZWZpbml0aW9uIiwic2V0SW5pdGlhbFZhbHVlcyIsImNvZGUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztRQU1hQSxPLFdBQUFBLE8sV0FEWixzRSwyQkFDTSxNQUFNQSxPQUFOLENBQWM7O0FBS2pCQyxvQkFBWUMsZUFBWixFQUE2QjtBQUFBOztBQUFBOztBQUFBOztBQUN6QixpQkFBS0EsZUFBTCxHQUF1QkEsZUFBdkI7QUFDQSxpQkFBS0MsT0FBTCxHQUFlLElBQWY7QUFDQSxpQkFBS0MsTUFBTDtBQUNIOztBQUVEQyxtQkFBVzs7QUFFUCxpQkFBS0MsT0FBTCxHQUFlLG1DQUFtQixLQUFLRixNQUF4QixFQUFnQyxJQUFoQyxFQUFzQyxJQ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