"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
|