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/pro/skuDetailModal/components/weighing/useWeighing.ts
var useWeighing_exports = {};
__export(useWeighing_exports, {
  useWeighing: () => useWeighing
});
module.exports = __toCommonJS(useWeighing_exports);
var import_react = require("react");
var import_utils = require("./utils");
var useWeighing = ({
  productData,
  skuValue
}) => {
  return (0, import_react.useMemo)(() => {
    var _a;
    const pd = productData;
    const variantId = skuValue == null ? void 0 : skuValue.product_variant_id;
    const hasVariants = Array.isArray(pd == null ? void 0 : pd.variant) && pd.variant.length > 0;
    if (hasVariants && !variantId) {
      return { isWeighingProduct: false };
    }
    const source = (0, import_utils.resolveWeighingSource)(productData, variantId);
    const isWeighing = Number((source == null ? void 0 : source.open_sold_weight) || 0) === 1;
    if (!isWeighing) {
      return { isWeighingProduct: false };
    }
    const basePrice = variantId ? Number((source == null ? void 0 : source.base_price) ?? (source == null ? void 0 : source.original_price) ?? 0) : Number((pd == null ? void 0 : pd.base_price) ?? ((_a = pd == null ? void 0 : pd._extend) == null ? void 0 : _a.price) ?? 0);
    const _pd = {
      id: productData.id,
      variant_id: skuValue.product_variant_id,
      price: basePrice,
      unit: source == null ? void 0 : source.unit,
      unit_value: Number(source == null ? void 0 : source.unit_value) || 1
    };
    return { isWeighingProduct: true, scalePriceProduct: _pd };
  }, [productData, skuValue == null ? void 0 : skuValue.product_variant_id]);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useWeighing
});
