var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/booking/forms/format.ts
var format_exports = {};
__export(format_exports, {
  changeFormValues: () => changeFormValues,
  formatAddFormValues: () => formatAddFormValues,
  sortFormValues: () => sortFormValues
});
module.exports = __toCommonJS(format_exports);
var changeFormValues = ({
  clientId,
  values,
  forms
}) => {
  let _values = {};
  for (let form of forms || []) {
    let value = values[form.form_id] || [];
    if (form.data_range === "customer") {
      _values[form.form_id] = [];
    } else {
      _values[form.form_id] = value;
    }
  }
  return _values;
};
var sortFormValues = (list, clientId) => {
  return (list || []).sort((a, b) => {
    var _a, _b, _c, _d, _e, _f;
    if (((_a = a == null ? void 0 : a.customer) == null ? void 0 : _a.id) === clientId && ((_b = b == null ? void 0 : b.customer) == null ? void 0 : _b.id) !== clientId) {
      return -1;
    } else if (((_c = b == null ? void 0 : b.customer) == null ? void 0 : _c.id) === clientId && ((_d = a == null ? void 0 : a.customer) == null ? void 0 : _d.id) !== clientId) {
      return 1;
    } else {
      return ((_e = a == null ? void 0 : a.customer) == null ? void 0 : _e.id) - ((_f = b == null ? void 0 : b.customer) == null ? void 0 : _f.id);
    }
  });
};
var formatAddFormValues = ({
  clientId,
  value,
  data_range
}) => {
  let _value = [...value];
  if (data_range === "customer") {
    _value = _value.map((d) => {
      return {
        ...d,
        client_id: clientId
      };
    });
  }
  _value = sortFormValues(_value, clientId);
  return _value;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  changeFormValues,
  formatAddFormValues,
  sortFormValues
});
