import { r as registerInstance, j as createEvent, h, g as getElement } from './index-aeac5cad.js';
import './_commonjsHelpers-91fffb88.js';
import { d as dist } from './index-fdd60c34.js';

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

function create(language) {
  return 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) {
    registerInstance(this, hostRef);
    this.edit = createEvent(this, "edit", 7);
    this.delete = 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 [
      h("smoothly-popup", null, h("smoothly-icon", { name: "ellipsis-vertical-outline", size: "small" }), h("div", { color: "light", slot: "popup" }, h("smoothly-icon", { size: "small", name: "pencil-outline", toolTip: t("Edit"), onClick: () => (this.mode = "edit") }), h("smoothly-icon", { size: "small", name: "trash", toolTip: "Delete", onClick: () => this.onDelete() }))),
      this.mode == "edit"
        ? [
          h("label", null, t(this.type)),
          h("payfunc-address-input", { onEdit: (e) => this.onChange(e), value: this.value }),
        ]
        : [h("label", null, t(this.type)), h("payfunc-address-display", { value: this.value })],
    ];
  }
  get element() { return getElement(this); }
};
PayfuncAddress.style = styleCss;

export { PayfuncAddress as payfunc_address };
