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 { h } from '@stencil/core';
import { MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
import { VegaInternalTranslation } from '../../../../../helpers/translation/internal-translation-controller';
export class PageSizeSelectorMobileRenderer extends VegaSlimmer {
  render() {
    if (this.type === 'pageSizeSelectorMobile') {
      return this.renderPageSizeSelectorMobile();
    }
    else {
      return this.renderPageSizeSelectorMobileAndCurrentPageLabel();
    }
  }
  renderPageSizeSelectorMobile() {
    const preservedTranslationOutput = VegaInternalTranslation.tWithPreservedBlocks('Show [{0} items / page]', PageSizeSelectorMobileRenderer.clickableReg, this.pageSize);
    return this.renderTranslatedMessage(preservedTranslationOutput);
  }
  renderPageSizeSelectorMobileAndCurrentPageLabel() {
    const rangeFrom = this.total > 0 ? this.pageSize * (this.current - 1) + 1 : 0;
    const rangeTo = Math.min(this.current * this.pageSize, this.total);
    const preservedTranslationOutput = VegaInternalTranslation.tWithPreservedBlocks('Viewing [{0}-{1}] of {2}', PageSizeSelectorMobileRenderer.clickableReg, rangeFrom, rangeTo, this.total);
    return this.renderTranslatedMessage(preservedTranslationOutput);
  }
  renderTranslatedMessage(preservedTranslationOutput) {
    return (h("vega-flex", { alignItems: "center", justifyContent: "center", gap: "size-4" }, preservedTranslationOutput.map((outPut) => {
      if (outPut.isPreserved) {
        return this.pageSizeSelectorMobileDropdownRenderer.render(h("vega-button-link", { label: outPut.content }));
      }
      else {
        return (h("vega-font", { variant: "font-field-label", color: "text-primary" }, outPut.content));
      }
    })));
  }
}
PageSizeSelectorMobileRenderer.clickableReg = /(\[[^\]]*\])/g;
__decorate([
  MapToComponentField()
], PageSizeSelectorMobileRenderer.prototype, "translationSlimmer", void 0);
__decorate([
  MapToComponentField()
], PageSizeSelectorMobileRenderer.prototype, "type", void 0);
__decorate([
  MapToComponentField()
], PageSizeSelectorMobileRenderer.prototype, "pageSize", void 0);
__decorate([
  MapToComponentField()
], PageSizeSelectorMobileRenderer.prototype, "total", void 0);
__decorate([
  MapToComponentField()
], PageSizeSelectorMobileRenderer.prototype, "current", void 0);
__decorate([
  MapToComponentField()
], PageSizeSelectorMobileRenderer.prototype, "pageSizeSelectorMobileDropdownRenderer", void 0);
