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/plus/salesSdk/utils/productHolderConfig.ts
var productHolderConfig_exports = {};
__export(productHolderConfig_exports, {
  getProductHolderConfigFromSource: () => getProductHolderConfigFromSource,
  getProductHolderFormId: () => getProductHolderFormId,
  isProductHolderEnabled: () => isProductHolderEnabled,
  isProductHolderRequired: () => isProductHolderRequired,
  resolveProductHolderConfig: () => resolveProductHolderConfig
});
module.exports = __toCommonJS(productHolderConfig_exports);
function isObject(value) {
  return value !== null && typeof value === "object";
}
function normalizeHolderConfig(raw) {
  if (!isObject(raw)) return null;
  return raw;
}
function getProductHolderConfigFromSource(source) {
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
  if (!isObject(source)) return null;
  return normalizeHolderConfig(source.holder_config) || normalizeHolderConfig((_b = (_a = source.metadata) == null ? void 0 : _a.origin) == null ? void 0 : _b.holder_config) || normalizeHolderConfig((_c = source._origin) == null ? void 0 : _c.holder_config) || normalizeHolderConfig((_d = source._extend) == null ? void 0 : _d.holder_config) || normalizeHolderConfig((_f = (_e = source._extend) == null ? void 0 : _e.product) == null ? void 0 : _f.holder_config) || normalizeHolderConfig((_j = (_i = (_h = (_g = source._extend) == null ? void 0 : _g.product) == null ? void 0 : _h.metadata) == null ? void 0 : _i.origin) == null ? void 0 : _j.holder_config) || normalizeHolderConfig((_m = (_l = (_k = source._extend) == null ? void 0 : _k.product) == null ? void 0 : _l._origin) == null ? void 0 : _m.holder_config) || normalizeHolderConfig((_p = (_o = (_n = source._extend) == null ? void 0 : _n.product) == null ? void 0 : _o._extend) == null ? void 0 : _p.holder_config) || null;
}
function resolveProductHolderConfig(source) {
  const raw = getProductHolderConfigFromSource(source);
  const formId = (raw == null ? void 0 : raw.resource_id) ?? void 0;
  const enabled = (raw == null ? void 0 : raw.status) === "enable" && formId !== void 0 && formId !== null && formId !== "";
  const required = (raw == null ? void 0 : raw.required) === 1 || (raw == null ? void 0 : raw.required) === "1" || (raw == null ? void 0 : raw.required) === true;
  return {
    enabled,
    required: enabled && required,
    ...formId !== void 0 && formId !== null && formId !== "" ? { formId } : {},
    raw
  };
}
function isProductHolderEnabled(source) {
  return resolveProductHolderConfig(source).enabled;
}
function isProductHolderRequired(source) {
  return resolveProductHolderConfig(source).required;
}
function getProductHolderFormId(source) {
  return resolveProductHolderConfig(source).formId;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getProductHolderConfigFromSource,
  getProductHolderFormId,
  isProductHolderEnabled,
  isProductHolderRequired,
  resolveProductHolderConfig
});
