import { r as registerInstance, j as createEvent, h, g as getElement } from './index-07845439.js';
import { I as Item, b as Schedule } from './index-0a60c67f.js';
import { d as dist } from './index-3cc80977.js';
import './_commonjsHelpers-9bc404fc.js';
import './index-614b6d2f.js';

const sv = {
  daily: "daglig",
  weekly: "veckovis",
  monthly: "månadsvis",
  quarterly: "kvartalsvis",
  yearly: "årlig",
  ongoing: "pågående",
};

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

const styleCss = ".sc-payfunc-subscription-table-row-h{display:table-row}[hidden].sc-payfunc-subscription-table-row-h{display:none}.sc-payfunc-subscription-table-row-h:hover{border-top:1px solid rgb(var(--smoothly-medium-color));border-bottom:1px solid rgb(var(--smoothly-medium-color));box-shadow:var(--smoothly-shadow)}.sc-payfunc-subscription-table-row-h>td.sc-payfunc-subscription-table-row>.openable.sc-payfunc-subscription-table-row{padding:.5em .3em;width:max-content;min-width:3em;display:inline-block}.opened.sc-payfunc-subscription-table-row,.openable.sc-payfunc-subscription-table-row{cursor:pointer}.opened.sc-payfunc-subscription-table-row{border:solid 1px rgb(var(--smoothly-medium-shade));background-color:rgb(var(--smoothly-dark-shade));border-bottom:3px solid rgb(var(--smoothly-dark-shade));border-radius:0 0 2px 2px;margin-bottom:-2px}.sc-payfunc-subscription-table-row-h>td.sc-payfunc-subscription-table-row:first-of-type>.opened.sc-payfunc-subscription-table-row{border-left:none}";

const PayfuncSubscriptionTableRow = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.columnClicked = createEvent(this, "columnClicked", 7);
    this.opened = "";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  handleColumnClick(column) {
    this.opened = column;
    this.columnClicked.emit({ id: this.subscription.id, column });
  }
  render() {
    var _a;
    return [
      h("td", null, h("section", { class: "openable" + (this.opened == "number" ? " opened" : ""), onClick: () => this.handleColumnClick("number") }, (_a = this.subscription.number) !== null && _a !== void 0 ? _a : this.subscription.id)),
      h("td", null, h("smoothly-display-amount", { class: "openable" + (this.opened == "amount" ? " opened" : ""), onClick: () => this.handleColumnClick("amount"), amount: Item.amount(this.subscription.items), currency: this.subscription.currency })),
      h("td", null, h("section", { class: "openable" + (this.opened == "schedule" ? " opened" : ""), onClick: () => this.handleColumnClick("schedule") }, this.t(typeof this.subscription.schedule == "object"
        ? this.subscription.schedule.frequency
        : this.subscription.schedule))),
      h("td", null, h("section", { class: "openable" + (this.opened == "start" ? " opened" : ""), onClick: () => this.handleColumnClick("start") }, this.subscription.start)),
      h("td", null, h("section", { class: "openable" + (this.opened == "end" ? " opened" : ""), onClick: () => this.handleColumnClick("end") }, this.subscription.end ? this.subscription.end : this.t("ongoing"))),
      h("td", null, h("section", { class: "openable" + (this.opened == "due" ? " opened" : ""), onClick: () => this.handleColumnClick("due") }, Schedule.next(this.subscription.schedule, this.subscription.start))),
    ];
  }
  get element() { return getElement(this); }
};
PayfuncSubscriptionTableRow.style = styleCss;

export { PayfuncSubscriptionTableRow as payfunc_subscription_table_row };
