import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty, b as _defineProperty } from '../../../_rollupPluginBabelHelpers-9wjJaosZ.js';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { helper } from '@ember/component/helper';
import { inject } from '@ember/service';
import { eq } from 'ember-truth-helpers';
import EuiTabbedContentComponent from '../../eui-tabbed-content.js';
import { toAbsoluteString, getDateMode } from '../utils/index.js';
import { useI18nTimeOptions } from '../utils/time-options.js';
import AbsoluteTab from './absolute-tab.js';
import EuiSuperDatePickerDatePopoverNowTab from './now-tab.js';
import RelativeTab from './relative-tab.js';

var _class, _descriptor, _descriptor2;
const toAbsoluteStringHelper = helper(function ([value, roundUp]) {
  return toAbsoluteString(value, roundUp);
});
let EuiDatePopoverContent = setComponentTemplate(precompileTemplate(`
    <EuiTabbedContent
      @className="euiDatePopoverContent"
      @tabs={{this.tabs}}
      @initialSelectedTab={{this.initialSelectedTab}}
      @autoFocus="selected"
      @expand={{true}}
      @size="s"
    >
      <:selectedTabContent as |selected|>
        {{#if (eq selected.id "relative")}}
          <RelativeTab
            @value={{this.toAbsoluteStringHelper @value this.roundUp}}
            @onChange={{@onChange}}
            @labelPrefix={{this.labelPrefix}}
            @roundUp={{this.roundUp}}
            @dateFormat={{@dateFormat}}
            @locale={{@locale}}
            @position={{@position}}
            @timeOptions={{this.timeOptions}}
          />
        {{else if (eq selected.id "now")}}
          <NowTab @position={{@position}} @onChange={{@onChange}} />
        {{else if (eq selected.id "absolute")}}
          <AbsoluteTab
            @value={{@value}}
            @roundUp={{this.roundUp}}
            @dateFormat={{@dateFormat}}
            @locale={{@locale}}
            @position={{@position}}
            @onChange={{@onChange}}
            @labelPrefix={{this.labelPrefix}}
          />
        {{/if}}
      </:selectedTabContent>
    </EuiTabbedContent>
  `, {
  strictMode: true,
  scope: () => ({
    EuiTabbedContent: EuiTabbedContentComponent,
    eq,
    RelativeTab,
    NowTab: EuiSuperDatePickerDatePopoverNowTab,
    AbsoluteTab
  })
}), (_class = class EuiDatePopoverContent extends Component {
  constructor(...args) {
    super(...args);
    _initializerDefineProperty(this, "euiI18n", _descriptor, this);
    _initializerDefineProperty(this, "selectedTab", _descriptor2, this);
    _defineProperty(this, "toAbsoluteStringHelper", toAbsoluteStringHelper);
  }
  get labelPrefix() {
    return this.args.position === 'start' ? this.euiI18n.lookupToken('euiDatePopoverContent.startDateLabel', 'Start date') : this.euiI18n.lookupToken('euiDatePopoverContent.endDateLabel', 'End date');
  }
  get tabs() {
    return [{
      id: 'absolute',
      name: this.euiI18n.lookupToken('euiDatePopoverContent.absoluteTabLabel', 'Absolute')
    }, {
      id: 'relative',
      name: this.euiI18n.lookupToken('euiDatePopoverContent.relativeTabLabel', 'Relative')
    }, {
      id: 'now',
      name: this.euiI18n.lookupToken('euiDatePopoverContent.nowTabLabel', 'Now')
    }];
  }
  get initialSelectedTab() {
    return this.tabs.find(tab => tab.id === getDateMode(this.args.value));
  }
  get roundUp() {
    return this.args.roundUp ?? false;
  }
  get timeOptions() {
    return this.args.timeOptions || useI18nTimeOptions(this.euiI18n);
  }
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "euiI18n", [inject], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "selectedTab", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return 0;
  }
})), _class));

export { EuiDatePopoverContent as default };
//# sourceMappingURL=eui-date-popover-content.js.map
