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;
};
import { Fragment, h } from '@stencil/core';
import { MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
export class VegaNavListRenderer extends VegaSlimmer {
  render() {
    var _a;
    return (h("div", { class: "vega-nav-list-container" }, ((_a = this.source) === null || _a === void 0 ? void 0 : _a.length) ? this.renderListBySource() : h("slot", null)));
  }
  renderListBySource() {
    return (h(Fragment, null, this.source.map((item) => {
      return h(Fragment, null, this.renderLeftNavSourceItem(item));
    })));
  }
  renderLeftNavSourceItem(item) {
    if (item.type == 'section') {
      return this.renderSection(item);
    }
    else if (item.type == 'group') {
      return this.renderGroup(item);
    }
    else {
      return this.renderLink(item);
    }
  }
  renderSection(section) {
    var _a;
    return (h("vega-left-nav-section", { itemKey: section.key, sectionHeader: section.sectionHeader }, (_a = section.children) === null || _a === void 0 ? void 0 : _a.map((item) => item.type == 'group' ? this.renderGroup(item) : this.renderLink(item))));
  }
  renderGroup(item) {
    var _a;
    return (h("vega-left-nav-group", { itemKey: item.key, key: item.key || item.name, icon: item.icon, label: item.name, "open-by-default": item.openByDefault }, (_a = item.children) === null || _a === void 0 ? void 0 : _a.map((child) => child.type == 'group' ? this.renderGroup(child) : this.renderLink(child))));
  }
  renderLink(item) {
    return (h("vega-left-nav-link", { itemKey: item.key, key: item.key || item.name, icon: item.icon, url: item.url, target: item.target, selected: item.selected, counterBadge: item.counterBadge }, item.name));
  }
}
__decorate([
  MapToComponentField()
], VegaNavListRenderer.prototype, "source", void 0);
