'use strict';

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

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

const sv = {
  Edit: "Redigera",
  Delete: "Radera",
  primary: "primär",
  billing: "fakturering",
  delivery: "leverans",
  visit: "besök",
};

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

const styleCss = ".sc-payfunc-address-h{display:block;position:relative}[hidden].sc-payfunc-address-h{display:none}smoothly-icon.sc-payfunc-address{cursor:pointer;margin-top:.3em}label.sc-payfunc-address{display:inline-block;margin-block-start:.6em;margin-block-end:.2em;text-transform:capitalize;margin-bottom:.2em}smoothly-popup.sc-payfunc-address{display:none;position:absolute;right:0}.sc-payfunc-address-h:hover smoothly-popup.sc-payfunc-address{display:inline}";

const PayfuncAddress = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.edit = index$1.createEvent(this, "edit", 7);
    this.delete = index$1.createEvent(this, "delete", 7);
    this.type = "primary";
    this.mode = "display";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  onChange(event) {
    event.stopPropagation();
    this.value = event.detail;
    this.mode = "display";
    this.edit.emit(Object.assign({ type: this.type }, this.value));
  }
  onDelete() {
    this.delete.emit(this.type);
  }
  render() {
    const t = this.t;
    return [
      index$1.h("smoothly-popup", null, index$1.h("smoothly-icon", { name: "ellipsis-vertical-outline", size: "small" }), index$1.h("div", { color: "light", slot: "popup" }, index$1.h("smoothly-icon", { size: "small", name: "pencil-outline", toolTip: t("Edit"), onClick: () => (this.mode = "edit") }), index$1.h("smoothly-icon", { size: "small", name: "trash", toolTip: "Delete", onClick: () => this.onDelete() }))),
      this.mode == "edit"
        ? [
          index$1.h("label", null, t(this.type)),
          index$1.h("payfunc-address-input", { onEdit: (e) => this.onChange(e), value: this.value }),
        ]
        : [index$1.h("label", null, t(this.type)), index$1.h("payfunc-address-display", { value: this.value })],
    ];
  }
  get element() { return index$1.getElement(this); }
};
PayfuncAddress.style = styleCss;

exports.payfunc_address = PayfuncAddress;
