'use strict';

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

const index$1 = require('./index-0b1e2673.js');
require('./_commonjsHelpers-937cd5b3.js');
const index$2 = require('./index-2eb96242.js');
const index = require('./index-36cf3884.js');

const en = {
  "-2": "third to last",
  "-1": "second to last",
  "0": "last",
};

const sv = {
  frequency: "frekvens",
  offset: "offset",
  daily: "daglig",
  weekly: "veckovis",
  monthly: "månadsvis",
  quarterly: "kvartalsvis",
  yearly: "årlig",
  date: "datum",
  month: "månad",
  weekday: "veckodag",
  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",
  "-2": "tredje sista dagen",
  "-1": "andra sista dagen",
  "0": "sista dagen",
};

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

const styleCss = ".sc-payfunc-schedule-h{width:100%;display:flex;flex-direction:row;justify-content:space-around}[hidden].sc-payfunc-schedule-h{display:none}.sc-payfunc-schedule-h>section.sc-payfunc-schedule{width:100%}.sc-payfunc-schedule-h>section.sc-payfunc-schedule>label.sc-payfunc-schedule{font-weight:bold;text-align:left;padding-bottom:.2em;text-transform:capitalize}.sc-payfunc-schedule-h>section.sc-payfunc-schedule>smoothly-display.sc-payfunc-schedule{width:10em;max-width:10em;text-transform:capitalize;align-self:flex-start}";

const PayfuncSchedule = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.notice = index$1.createEvent(this, "notice", 7);
    this.advanced = false;
  }
  componentWillLoad() {
    this.t = create(this.element);
    this.frequency = typeof this.schedule == "object" ? this.schedule.frequency : this.schedule;
    this.offset = index$2.Schedule.is(this.schedule) && this.schedule.frequency != "daily" ? this.schedule.offset : undefined;
    this.divisor = index$2.Schedule.is(this.schedule) ? this.schedule.divisor : undefined;
  }
  render() {
    return [
      index$1.h("section", null, index$1.h("label", null, this.t("frequency")), index$1.h("smoothly-display", { type: "text", value: this.t(this.frequency) })),
      (this.frequency == "quarterly" || this.frequency == "yearly") && this.offset != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("month")), index$1.h("smoothly-display", { type: "text", value: this.t(Array.isArray(this.offset) ? index$2.Schedule.months[this.offset[0]] : index$2.Schedule.months[this.offset]) }))) : ([]),
      (this.frequency == "monthly" ||
        ((this.frequency == "yearly" || this.frequency == "quarterly") && Array.isArray(this.offset))) &&
        this.offset != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("date")), index$1.h("smoothly-display", { type: "text", value: this.t(Array.isArray(this.offset) ? (this.offset[1] + 1).toString() : (this.offset + 1).toString()) }))) : ([]),
      this.frequency == "weekly" && !Array.isArray(this.offset) && this.offset != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("weekday")), index$1.h("smoothly-display", { type: "text", value: this.t(index$2.Schedule.weekdays[this.offset - 1]) }))) : ([]),
      this.divisor != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("divisor")), index$1.h("smoothly-display", { type: "text", value: Array.isArray(this.divisor)
          ? this.divisor[0].toString() + " / " + this.divisor[1].toString()
          : this.divisor.toString() }))) : ([]),
    ];
  }
  get element() { return index$1.getElement(this); }
};
PayfuncSchedule.style = styleCss;

exports.payfunc_schedule = PayfuncSchedule;
