'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index$1 = require('./index-df541290.js');
const index$2 = require('./index-c12b8888.js');
const index = require('./index-b7493032.js');
require('./index-0b6f1dd9.js');
require('./_commonjsHelpers-10109b76.js');
require('./index-fe328b96.js');

const sv = {
  Date: "Datum",
  Month: "Månad",
  Weekday: "Dag",
  Monday: "Måndag",
  Tuesday: "Tisdag",
  Wednesday: "Onsdag",
  Thursday: "Torsdag",
  Friday: "Fredag",
  Saturday: "Lördag",
  Sunday: "Söndag",
  January: "Januari",
  February: "Februari",
  March: "Mars",
  May: "Maj",
  June: "Juni",
  July: "Juli",
  August: "Augusti",
  October: "Oktober",
  First: "Första",
  Second: "Andra",
  Third: "Tredje",
};

function create(language) {
  return index.dist.create({
    sv,
  }, language);
}

const styleCss = ".sc-ig-select-offset-h{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}[frequency=daily].sc-ig-select-offset-h{display:none}smoothly-select.sc-ig-select-offset{display:grid;-ms-flex-positive:2;flex-grow:2}smoothly-select.sc-ig-select-offset:nth-of-type(2){border-left:1px solid rgb(var(--smoothly-medium-color))}";

const IntergiroSelectOffset = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.offsetChanged = index$1.createEvent(this, "offsetChanged", 7);
    this.days = [];
  }
  componentWillLoad() {
    this.t = create(this.element);
    this.weekdays = ["Weekday", ...index$2.Schedule.weekdays];
    this.quarterly = ["Month", ...index$2.Schedule.quarterly];
    this.months = ["Month", ...index$2.Schedule.months];
    const days = ["Date", ...index$2.Schedule.daysOfMonth.map(day => (day >= 0 ? (day + 1).toString() : day.toString()))];
    this.days = days;
    this.setValues();
  }
  onSelectionChanged(e) {
    const value = Number(e.detail.value);
    e.detail.value = value != undefined && value >= 0 ? (value - 1).toString() : e.detail.value;
    if (e.detail.identifier == "offset") {
      this.value = e.detail.value;
      this.offsetChanged.emit(this.value2 ? [this.value, this.value2] : this.value);
    }
    else if (e.detail.identifier == "offset2") {
      this.value2 = e.detail.value;
      this.offsetChanged.emit([this.value, this.value2]);
    }
  }
  setValues() {
    switch (this.frequency) {
      case "weekly":
        this.values = this.weekdays;
        this.value = "Weekday";
        this.value2 = undefined;
        break;
      case "monthly":
        this.values = this.days;
        this.value = "Date";
        this.value2 = undefined;
        break;
      case "quarterly":
        this.values = this.quarterly;
        this.value = "Month";
        this.values2 = this.days;
        this.value2 = "Date";
        break;
      case "yearly":
        this.values = this.months;
        this.value = "Month";
        this.values2 = this.days;
        this.value2 = "Date";
        break;
      default:
        break;
    }
  }
  render() {
    return [
      this.values && this.value ? (index$1.h("smoothly-select", { identifier: "offset", background: "transparent" }, this.values.map(option => this.value == option ? (index$1.h("option", { value: option, selected: true }, this.t(option))) : (index$1.h("option", { value: option }, this.t(option)))))) : ([]),
      this.values2 && this.value2 && this.value != "Month" ? (index$1.h("smoothly-select", { identifier: "offset2", background: "transparent" }, this.values2.map(option => this.value2 == option ? (index$1.h("option", { value: option, selected: true }, this.t(option))) : (index$1.h("option", { value: option }, this.t(option)))))) : ([]),
    ];
  }
  get element() { return index$1.getElement(this); }
  static get watchers() { return {
    "frequency": ["setValues"]
  }; }
};
IntergiroSelectOffset.style = styleCss;

exports.ig_select_offset = IntergiroSelectOffset;
