/*bit-tabs@2.0.1#unstyled*/
define([
    'exports',
    'can-define/map',
    'can-define/list',
    'can-stache',
    'can-component',
    './tabs.stache',
    './panel.stache',
    'can-view-model'
], function (exports, _map, _list, _canStache, _canComponent, _tabs, _panel, _canViewModel) {
    'use strict';
    Object.defineProperty(exports, '__esModule', { value: true });
    exports.BitTabsVM = exports.BitPanelVM = undefined;
    var _map2 = _interopRequireDefault(_map);
    var _list2 = _interopRequireDefault(_list);
    var _canStache2 = _interopRequireDefault(_canStache);
    var _canComponent2 = _interopRequireDefault(_canComponent);
    var _tabs2 = _interopRequireDefault(_tabs);
    var _panel2 = _interopRequireDefault(_panel);
    var _canViewModel2 = _interopRequireDefault(_canViewModel);
    function _interopRequireDefault(obj) {
        return obj && obj.__esModule ? obj : { default: obj };
    }
    var BitPanelVM = exports.BitPanelVM = _map2.default.extend({
        connectedCallback: function connectedCallback(element) {
            var _this = this;
            (0, _canViewModel2.default)(element.parentNode).addPanel(this);
            return function () {
                (0, _canViewModel2.default)(element.parentNode).removePanel(_this);
            };
        },
        title: 'string',
        active: { default: false }
    });
    _canComponent2.default.extend({
        tag: 'bit-panel',
        view: _panel2.default,
        ViewModel: BitPanelVM
    });
    var BitTabsVM = exports.BitTabsVM = _map2.default.extend({
        active: 'any',
        panels: {
            default: function _default() {
                return [];
            }
        },
        tabsClass: {
            type: 'string',
            default: ''
        },
        addPanel: function addPanel(panel) {
            if (this.panels.length === 0) {
                this.makeActive(panel);
            }
            this.panels.push(panel);
        },
        removePanel: function removePanel(panel) {
            var panels = this.panels;
            panels.splice(panels.indexOf(panel), 1);
            if (panel === this.active) {
                if (panels.length) {
                    this.makeActive(panels[0]);
                } else {
                    this.active = undefined;
                }
            }
        },
        makeActive: function makeActive(panel) {
            this.active = panel;
            this.panels.forEach(function (panel) {
                panel.active = false;
            });
            panel.active = true;
        },
        isActive: function isActive(panel) {
            return this.active == panel;
        }
    });
    exports.default = _canComponent2.default.extend({
        tag: 'bit-tabs',
        view: _tabs2.default,
        ViewModel: BitTabsVM
    });
});
//# sourceMappingURL=unstyled.js.map