'use strict';

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

const index$1 = require('./index-df541290.js');
const index$2 = require('./index-c12b8888.js');
const index = require('./index-b7493032.js');
require('./index-0b6f1dd9.js');
require('./_commonjsHelpers-10109b76.js');
require('./index-fe328b96.js');

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

function create(language) {
  return index.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) {
    index$1.registerInstance(this, hostRef);
    this.updateContact = index$1.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 (index$2.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 [
      index$1.h("section", null, index$1.h("label", null, this.t("Name")), index$1.h("ig-display-edit", { type: "text", name: this.t("Name"), value: (contact === null || contact === void 0 ? void 0 : contact.name) ? index$2.Name.get(contact.name) : undefined, onChanged: (e) => this.update("name", e.detail) })),
      index$1.h("section", null, index$1.h("label", null, this.t("Type")), index$1.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) })),
      index$1.h("section", null, index$1.h("label", null, this.t("Number")), index$1.h("smoothly-display", { type: "text", value: contact === null || contact === void 0 ? void 0 : contact.number })),
      index$1.h("section", null, index$1.h("label", null, this.t("Identity number")), index$1.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) })),
      index$1.h("section", null, index$1.h("label", null, this.t("Email")), index$1.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) })),
      index$1.h("section", null, index$1.h("label", null, this.t("Phone number")), index$1.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) })),
      index$1.h("section", null, index$1.h("label", null, this.t("Address")), index$1.h("ig-addresses", { value: contact === null || contact === void 0 ? void 0 : contact.address, onChanged: (e) => this.update("address", e.detail) })),
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroCustomerContact.style = styleCss;

exports.ig_customer_contact = IntergiroCustomerContact;
