'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var CryptoJS = require('crypto-js');

function normalizeData(obj) {
  if (obj === null || obj === void 0) {
    return "";
  }
  if (obj instanceof Date) {
    return obj.toISOString();
  }
  if (Array.isArray(obj)) {
    return obj.map((item) => normalizeData(item));
  }
  if (typeof obj === "object") {
    const normalized = {};
    const keys = Object.keys(obj).sort();
    for (const key of keys) {
      normalized[key] = normalizeData(obj[key]);
    }
    return normalized;
  }
  return String(obj);
}
function md5Signature(data) {
  if (!data) return "";
  try {
    const normalizedData = normalizeData(data);
    return CryptoJS.MD5(JSON.stringify(normalizedData)).toString();
  } catch (e) {
    console.error("\u8BA1\u7B97\u6570\u636E\u7B7E\u540D\u5931\u8D25:", e);
    return "";
  }
}

exports.default = md5Signature;
