import { r as registerInstance, j as createEvent, h, g as getElement } from './index-07845439.js';
import { b as Contact, N as Name } from './index-e20749b7.js';
import { d as dist } from './index-63517df5.js';
import './index-b6cf748e.js';
import './_commonjsHelpers-8fe71198.js';
import './index-265fba1f.js';

const sv = {
  Name: "Namn",
  Type: "Typ",
  Number: "Nummer",
  "Identity number": "Personnummer",
  Email: "E-post",
  "Phone number": "Telefonnummer",
  Address: "Adress",
};

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

const styleCss = ".sc-ig-customer-contact-h{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:justify;justify-content:space-between}[hidden].sc-ig-customer-contact-h{display:none}.sc-ig-customer-contact-h>section.sc-ig-customer-contact{width:50%;min-width:17em;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.sc-ig-customer-contact-h>section.sc-ig-customer-contact>label.sc-ig-customer-contact{font-weight:bold}.sc-ig-customer-contact-h>section.sc-ig-customer-contact>ig-display-edit.sc-ig-customer-contact{padding-top:.5em}.sc-ig-customer-contact-h>section.sc-ig-customer-contact>*.sc-ig-customer-contact:not(label){min-height:5em;max-width:14em}.sc-ig-customer-contact-h>section.sc-ig-customer-contact>label.sc-ig-customer-contact{padding-top:1em}";

const IntergiroCustomerContact = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.updateContact = createEvent(this, "updateContact", 7);
    this.types = ["organization", "person"];
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async update(property, value) {
    var _a;
    if (!value || Object.keys(value).length == 0)
      (_a = this.customer.contact) === null || _a === void 0 ? true : delete _a[property];
    else {
      const update = { [property]: value };
      if (Contact.is(update))
        this.customer.contact = Object.assign(Object.assign({}, this.customer.contact), update);
    }
    this.updateContact.emit(this.customer.contact);
  }
  render() {
    var _a, _b;
    const contact = this.customer.contact;
    return [
      h("section", null, h("label", null, this.t("Name")), h("ig-display-edit", { type: "text", name: this.t("Name"), value: (contact === null || contact === void 0 ? void 0 : contact.name) ? Name.get(contact.name) : undefined, onChanged: (e) => this.update("name", e.detail) })),
      h("section", null, h("label", null, this.t("Type")), h("ig-display-edit", { type: "text", name: this.t("Type"), value: contact === null || contact === void 0 ? void 0 : contact.type, select: this.types, onChanged: (e) => this.update("type", e.detail) })),
      h("section", null, h("label", null, this.t("Number")), h("smoothly-display", { type: "text", value: contact === null || contact === void 0 ? void 0 : contact.number })),
      h("section", null, h("label", null, this.t("Identity number")), h("ig-display-edit", { type: "identity-number", name: this.t("Identity number"), value: contact === null || contact === void 0 ? void 0 : contact.identityNumber, onChanged: (e) => this.update("identityNumber", e.detail) })),
      h("section", null, h("label", null, this.t("Email")), h("ig-email-addresses", { value: (_a = contact === null || contact === void 0 ? void 0 : contact.email) !== null && _a !== void 0 ? _a : "", onChanged: (e) => this.update("email", e.detail) })),
      h("section", null, h("label", null, this.t("Phone number")), h("ig-phone-numbers", { value: (_b = contact === null || contact === void 0 ? void 0 : contact.phone) !== null && _b !== void 0 ? _b : "", onChanged: (e) => this.update("phone", e.detail) })),
      h("section", null, h("label", null, this.t("Address")), h("ig-addresses", { value: contact === null || contact === void 0 ? void 0 : contact.address, onChanged: (e) => this.update("address", e.detail) })),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroCustomerContact.style = styleCss;

export { IntergiroCustomerContact as ig_customer_contact };
