import { createHash } from "node:crypto"; //#region ../../node_modules/.pnpm/c12@4.0.0-rc.2_dotenv@18.0.8_giget@3.3.1_jiti@2.7.0_magicast@0.5.5/node_modules/c12/dist/_chunks/libs/ohash.mjs var __defProp = Object.defineProperty; var __exportAll = (all, no_symbols) => { let target = {}; for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" }); return target; }; function serialize(input) { if (typeof input === "string") return `'${input}'`; return new Serializer().serialize(input); } const asciiOrder = " _-,;:!?.'\"()[]{}@*/\\&#%`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz"; const asciiWeights = /*@__PURE__*/ (function() { const weights = /* @__PURE__ */ new Uint8Array(128); for (let i = 0; i < 69; i++) weights[asciiOrder.charCodeAt(i)] = i + 1; for (let code = 65; code <= 90; code++) weights[code] = weights[code + 32]; return weights; })(); function compareStrings(a, b) { if (a === b) return 0; const length = Math.min(a.length, b.length); let tieBreaker = 0; for (let i = 0; i < length; i++) { const codeA = a.charCodeAt(i); const codeB = b.charCodeAt(i); if (codeA === codeB) continue; const weightA = codeA < 128 && asciiWeights[codeA] ? asciiWeights[codeA] : codeA + 128; const weightB = codeB < 128 && asciiWeights[codeB] ? asciiWeights[codeB] : codeB + 128; if (weightA !== weightB) return weightA < weightB ? -1 : 1; if (tieBreaker === 0) tieBreaker = codeA > codeB ? -1 : 1; } if (a.length !== b.length) return a.length < b.length ? -1 : 1; return tieBreaker; } const Serializer = /*@__PURE__*/ (function() { class Serializer { #context = /* @__PURE__ */ new Map(); compare(a, b) { const typeA = typeof a; const typeB = typeof b; if (typeA === "string" && typeB === "string") return compareStrings(a, b); if (typeA === "number" && typeB === "number") return a - b; return compareStrings(this.serialize(a, true), this.serialize(b, true)); } serialize(value, noQuotes) { if (value === null) return "null"; switch (typeof value) { case "string": return noQuotes ? value : `'${value}'`; case "bigint": return `${value}n`; case "object": return this.$object(value); case "function": return this.$function(value); } return String(value); } serializeObject(object) { const objString = Object.prototype.toString.call(object); if (objString !== "[object Object]") return this.serializeBuiltInType(objString.length < 10 ? `unknown:${objString}` : objString.slice(8, -1), object); const constructor = object.constructor; const objName = constructor === Object || constructor === void 0 ? "" : constructor.name; if (objName !== "" && globalThis[objName] === constructor) return this.serializeBuiltInType(objName, object); if ("toJSON" in object && typeof object.toJSON === "function") { const json = object.toJSON(); return objName + (json !== null && typeof json === "object" ? this.$object(json) : `(${this.serialize(json)})`); } const keys = Object.keys(object).sort(compareStrings); let content = `${objName}{`; for (let i = 0; i < keys.length; i++) { const key = keys[i]; content += `${key}:${this.serialize(object[key])}`; if (i < keys.length - 1) content += ","; } return content + "}"; } serializeBuiltInType(type, object) { const handler = this["$" + type]; if (handler) return handler.call(this, object); if (typeof object.entries === "function") return this.serializeObjectEntries(type, object.entries()); throw new Error(`Cannot serialize ${type}`); } serializeObjectEntries(type, entries) { const sortedEntries = Array.from(entries).sort((a, b) => this.compare(a[0], b[0])); let content = `${type}{`; for (let i = 0; i < sortedEntries.length; i++) { const [key, value] = sortedEntries[i]; content += `${this.serialize(key, true)}:${this.serialize(value)}`; if (i < sortedEntries.length - 1) content += ","; } return content + "}"; } $object(object) { let content = this.#context.get(object); if (content === void 0) { this.#context.set(object, `#${this.#context.size}`); content = this.serializeObject(object); this.#context.set(object, content); } return content; } $function(fn) { const fnStr = Function.prototype.toString.call(fn); if (fnStr.slice(-15) === "[native code] }") return `${fn.name || ""}()[native]`; return `${fn.name}(${fn.length})${fnStr.replace(/\s*\n\s*/g, "")}`; } $Array(arr) { let content = "["; for (let i = 0; i < arr.length; i++) { content += this.serialize(arr[i]); if (i < arr.length - 1) content += ","; } return content + "]"; } $Date(date) { try { return `Date(${date.toISOString()})`; } catch { return `Date(null)`; } } $ArrayBuffer(arr) { return `ArrayBuffer[${new Uint8Array(arr).join(",")}]`; } $Set(set) { return `Set${this.$Array(Array.from(set).sort((a, b) => this.compare(a, b)))}`; } $Map(map) { return this.serializeObjectEntries("Map", map.entries()); } } for (const type of [ "Error", "RegExp", "URL" ]) Serializer.prototype["$" + type] = function(val) { return `${type}(${val})`; }; for (const type of [ "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array" ]) Serializer.prototype["$" + type] = function(arr) { return `${type}[${arr.join(",")}]`; }; for (const type of ["BigInt64Array", "BigUint64Array"]) Serializer.prototype["$" + type] = function(arr) { return `${type}[${arr.join("n,")}${arr.length > 0 ? "n" : ""}]`; }; return Serializer; })(); const fastHash = /*@__PURE__*/ (() => globalThis.process?.getBuiltinModule?.("crypto")?.hash)(); const algorithm = "sha256"; const encoding = "base64url"; function digest(data) { if (fastHash) return fastHash(algorithm, data, encoding); const h = createHash(algorithm).update(data); return globalThis.process?.versions?.webcontainer ? h.digest().toString(encoding) : h.digest(encoding); } var dist_exports = /* @__PURE__ */ __exportAll({ digest: () => digest }); var utils_exports = /* @__PURE__ */ __exportAll({ diff: () => diff }); const PROTO_KEY = "__proto__"; function diff(obj1, obj2) { const diffs = []; _diff(obj1, obj2, "", diffs); return diffs; } function _diff(v1, v2, key, out) { if (v1 === v2) return; const leaf1 = v1 === null || typeof v1 !== "object"; const leaf2 = v2 === null || typeof v2 !== "object"; if (!leaf1 && !leaf2) { const entries1 = _entries(v1); const entries2 = _entries(v2); for (const [k, child1] of entries1) { const childKey = key ? `${key}.${k}` : k; if (entries2.has(k)) _diff(child1, entries2.get(k), childKey, out); else out.push(new DiffEntry(childKey, "removed", void 0, _toHashedObject(child1, childKey))); } for (const [k, child2] of entries2) { if (entries1.has(k)) continue; const childKey = key ? `${key}.${k}` : k; out.push(new DiffEntry(childKey, "added", _toHashedObject(child2, childKey))); } return; } if (_hasKeys(v1, leaf1) || _hasKeys(v2, leaf2)) return; const node1 = _emptyOrLeafNode(v1, key, leaf1); const node2 = _emptyOrLeafNode(v2, key, leaf2); if (node1.hash !== node2.hash) out.push(new DiffEntry(key, "changed", node2, node1)); } function _entries(value) { const entries = /* @__PURE__ */ new Map(); for (const key in value) if (key !== PROTO_KEY) entries.set(key, value[key]); return entries; } function _hasKeys(value, isLeaf) { if (isLeaf) return false; for (const key in value) if (key !== PROTO_KEY) return true; return false; } function _emptyOrLeafNode(value, key, isLeaf) { return isLeaf ? new DiffHashedObject(key, value, _leafHash(value)) : new DiffHashedObject(key, value, "{}", Object.create(null)); } function _toHashedObject(obj, key = "") { if (obj === null || typeof obj !== "object") return new DiffHashedObject(key, obj, _leafHash(obj)); const props = Object.create(null); const hashes = []; for (const _key in obj) { if (_key === PROTO_KEY) continue; const child = _toHashedObject(obj[_key], key ? `${key}.${_key}` : _key); props[_key] = child; hashes.push(child.hash); } return new DiffHashedObject(key, obj, `{${hashes.join(":")}}`, props); } function _leafHash(value) { switch (typeof value) { case "string": return `'${value}'`; case "number": case "boolean": return "" + value; case "bigint": return `${value}n`; default: return serialize(value); } } var DiffEntry = class { key; type; newValue; oldValue; constructor(key, type, newValue, oldValue) { this.key = key; this.type = type; this.newValue = newValue; this.oldValue = oldValue; } toString() { return this.toJSON(); } toJSON() { switch (this.type) { case "added": return `Added \`${this.key}\``; case "removed": return `Removed \`${this.key}\``; case "changed": return `Changed \`${this.key}\` from \`${this.oldValue?.toString() || "-"}\` to \`${this.newValue?.toString()}\``; } } }; var DiffHashedObject = class { key; value; hash; props; constructor(key, value, hash, props) { this.key = key; this.value = value; this.hash = hash; this.props = props; } toString() { if (this.props) return `{${Object.keys(this.props).join(",")}}`; else return JSON.stringify(this.value); } toJSON() { const k = this.key || "."; if (this.props) return `${k}({${Object.keys(this.props).join(",")}})`; return `${k}(${this.value})`; } }; //#endregion export { dist_exports, utils_exports };