wangzhibo
2025-10-23 cad64c1de2c45856b0774933c5801b05b64984e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"use strict";
function generateUUIDv4() {
  if (typeof crypto !== "undefined" && crypto.getRandomValues) {
    const buf = new Uint8Array(16);
    crypto.getRandomValues(buf);
    buf[6] = buf[6] & 15 | 64;
    buf[8] = buf[8] & 63 | 128;
    const hex = Array.from(buf).map((b) => b.toString(16).padStart(2, "0")).join("");
    return `${hex.substr(0, 8)}-${hex.substr(8, 4)}-${hex.substr(12, 4)}-${hex.substr(16, 4)}-${hex.substr(20, 12)}`;
  } else {
    let d = (/* @__PURE__ */ new Date()).getTime();
    if (typeof performance !== "undefined" && typeof performance.now === "function") {
      d += performance.now();
    }
    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
      const r = (d + Math.random() * 16) % 16 | 0;
      d = Math.floor(d / 16);
      return (c === "x" ? r : r & 3 | 8).toString(16);
    });
  }
}
exports.generateUUIDv4 = generateUUIDv4;
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/uuid.js.map