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/forms/footer.tsx
var footer_exports = {};
__export(footer_exports, {
  default: () => footer_default
});
module.exports = __toCommonJS(footer_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_icons = require("@ant-design/icons");
var import_useSendModal = __toESM(require("./sendModal/useSendModal"));
var import_sendModal = __toESM(require("./sendModal"));
var import_utils = require("@pisell/utils");
var Footer = ({ state, reload }) => {
  var _a, _b, _c, _d, _e;
  const { open, setOpen, handleOpen, handleValuesChange, handleOk } = (0, import_useSendModal.default)(state == null ? void 0 : state.bookingId);
  const handleReload = async () => {
    await reload();
    import_materials.message.success(import_utils.locales.getText("pisell2.text.send-form-reminder-refresh"));
  };
  const defaultValues = (0, import_react.useMemo)(() => {
    var _a2, _b2;
    const { email: contactsEmail, phone: contactsPhone } = ((_a2 = state.contacts_info) == null ? void 0 : _a2.value) || {};
    const {
      email: clientEmail,
      phone: clientPhone,
      country_calling_code: clientCode
    } = ((_b2 = state.client) == null ? void 0 : _b2.value) || {};
    let email = contactsEmail || clientEmail;
    let phone = (contactsPhone == null ? void 0 : contactsPhone.phone) || clientPhone;
    let code = (contactsPhone == null ? void 0 : contactsPhone.country_calling_code) || clientCode || "+61";
    if (!code.startsWith("+")) {
      code = `+${code}`;
    }
    return {
      sendSms: !!phone,
      sendEmail: !!email,
      email,
      phone: {
        code,
        phone
      }
    };
  }, [(_a = state.client) == null ? void 0 : _a.value, (_b = state.contacts_info) == null ? void 0 : _b.value]);
  if (!state.bookingId || !((_c = state == null ? void 0 : state.form) == null ? void 0 : _c.forms.length)) {
    return null;
  }
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-form-footer" }, /* @__PURE__ */ import_react.default.createElement(
    import_materials.Tooltip,
    {
      title: import_utils.locales.getText("pisell2.text.send-form-reminder-tooltip")
    },
    /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { size: "large", icon: /* @__PURE__ */ import_react.default.createElement(import_icons.ReloadOutlined, null), onClick: handleReload })
  ), /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { size: "large", block: true, type: "primary", onClick: handleOpen }, import_utils.locales.getText("pisell2.text.send-form-reminder")), open && /* @__PURE__ */ import_react.default.createElement(
    import_sendModal.default,
    {
      refreshKey: (_e = (_d = state.client) == null ? void 0 : _d.value) == null ? void 0 : _e.id,
      open,
      onCancel: () => setOpen(false),
      onOk: handleOk,
      onValuesChange: handleValuesChange,
      defaultValues
    }
  ));
};
var footer_default = Footer;
