var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/booking/info2/service/contactInfoMode/index.tsx
var contactInfoMode_exports = {};
__export(contactInfoMode_exports, {
  default: () => contactInfoMode_default
});
module.exports = __toCommonJS(contactInfoMode_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_contactInfo = __toESM(require("../../../../../plus/contactInfo"));
var import_model = require("../../../info/model");
var ContactInfoMode = () => {
  var _a, _b, _c;
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
  console.log("state>>>>>>>>>", state);
  (0, import_react.useEffect)(() => {
    var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i;
    console.log("state>>>>>>>>>111", (_a2 = state == null ? void 0 : state.contacts_info) == null ? void 0 : _a2.client_id);
    console.log("state>>>>>>>>>222", (_b2 = state.client.value) == null ? void 0 : _b2.id);
    if (((_c2 = state.client.value) == null ? void 0 : _c2.id) != ((_d = state == null ? void 0 : state.contacts_info) == null ? void 0 : _d.client_id)) {
      const contactInfo = (_f = (_e = state.client.value) == null ? void 0 : _e.contacts_info) == null ? void 0 : _f.value;
      if (!contactInfo) {
        const {
          first_name,
          last_name,
          phone,
          country_calling_code,
          country_code,
          email
        } = ((_g = state.client) == null ? void 0 : _g.value) || {};
        dispatch({
          type: "setContactsInfo",
          payload: {
            value: {
              first_name: first_name || "",
              last_name: last_name || "",
              phone: {
                phone: phone || "",
                country_calling_code: country_calling_code || "",
                country_code: country_code || ""
              },
              email: email || ""
            },
            client_id: (_h = state.client.value) == null ? void 0 : _h.id
          }
        });
      } else {
        dispatch({
          type: "setContactsInfo",
          payload: {
            value: { ...contactInfo || {} },
            client_id: (_i = state.client.value) == null ? void 0 : _i.id
          }
        });
      }
    }
  }, [(_a = state.client.value) == null ? void 0 : _a.id, (_b = state == null ? void 0 : state.contacts_info) == null ? void 0 : _b.client_id]);
  const handleSave = (value) => {
    dispatch({
      type: "setContactsInfo",
      payload: { value, edit: true }
    });
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { style: { marginTop: "24px" } }, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "pisell-lowcode__booking-contact-info-title",
      style: { fontSize: "16px", fontWeight: 500, marginBottom: "8px" }
    },
    import_utils.locales.getText("pisell2.booking.text.contact-info.title")
  ), /* @__PURE__ */ import_react.default.createElement(
    import_contactInfo.default,
    {
      dataSource: ((_c = state.contacts_info) == null ? void 0 : _c.value) || null,
      isShowDelete: false,
      isShowAvatar: false,
      isShowPhone: true,
      isShowEmail: true,
      style: { padding: "14px 0 14px 14px" },
      onSave: handleSave
    }
  ));
};
var contactInfoMode_default = ContactInfoMode;
