pagegraph 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +325 -66
  2. package/dist/anthropic-messages-TqKpKmfW.js +1067 -0
  3. package/dist/anthropic-messages-TqKpKmfW.js.map +1 -0
  4. package/dist/audit.d.ts +4 -2
  5. package/dist/audit.js +5 -5
  6. package/dist/audit.js.map +1 -1
  7. package/dist/azure-openai-responses-DJjBLwoI.js +231 -0
  8. package/dist/azure-openai-responses-DJjBLwoI.js.map +1 -0
  9. package/dist/build-only/audit.js +1 -1
  10. package/dist/build-only/claims.d.ts +1 -0
  11. package/dist/build-only/claims.js +6 -0
  12. package/dist/build-only/claims.js.map +1 -0
  13. package/dist/build-only/config.js +1 -1
  14. package/dist/build-only/oxlint.d.ts +1 -0
  15. package/dist/build-only/oxlint.js +6 -0
  16. package/dist/build-only/oxlint.js.map +1 -0
  17. package/dist/build-only/tanstack-start.js +1 -1
  18. package/dist/build-only/vite.js +1 -1
  19. package/dist/{checks-uZk5Em9A.js → checks-BS-aDXB_.js} +2 -2
  20. package/dist/checks-BS-aDXB_.js.map +1 -0
  21. package/dist/claims-Bch7Lxlo.d.ts +92 -0
  22. package/dist/claims-Bv7voeEV.js +431 -0
  23. package/dist/claims-Bv7voeEV.js.map +1 -0
  24. package/dist/claims.d.ts +94 -0
  25. package/dist/claims.js +2 -0
  26. package/dist/cli.js +17607 -43387
  27. package/dist/cli.js.map +1 -1
  28. package/dist/cloudflare-workers-ai-system-one-f3ZrvNYZ.js +41 -0
  29. package/dist/cloudflare-workers-ai-system-one-f3ZrvNYZ.js.map +1 -0
  30. package/dist/config.d.ts +9 -29
  31. package/dist/config.js +2 -2
  32. package/dist/config.js.map +1 -1
  33. package/dist/{content-kcEnQdfi.js → content-CHd0X4s6.js} +2 -2
  34. package/dist/{content-kcEnQdfi.js.map → content-CHd0X4s6.js.map} +1 -1
  35. package/dist/{content-B1cPtL8b.d.ts → content-DgNr7apS.d.ts} +4 -5
  36. package/dist/declare-D5o7hwmv.js.map +1 -1
  37. package/dist/diagnostics-Wt5faNDM.js +108 -0
  38. package/dist/diagnostics-Wt5faNDM.js.map +1 -0
  39. package/dist/dist-B6zg_Z3Z.js +4794 -0
  40. package/dist/dist-B6zg_Z3Z.js.map +1 -0
  41. package/dist/document-CztEu3Vd.d.ts +109 -0
  42. package/dist/document-Dvemcv7V.js +379 -0
  43. package/dist/document-Dvemcv7V.js.map +1 -0
  44. package/dist/env-api-keys-C-OA0yM-.js +124 -0
  45. package/dist/env-api-keys-C-OA0yM-.js.map +1 -0
  46. package/dist/error-body-CyiejW4b.js +103 -0
  47. package/dist/error-body-CyiejW4b.js.map +1 -0
  48. package/dist/facts-1OKclPOk.js +115 -0
  49. package/dist/facts-1OKclPOk.js.map +1 -0
  50. package/dist/github-copilot-headers-CEpMOpQF.js +24 -0
  51. package/dist/github-copilot-headers-CEpMOpQF.js.map +1 -0
  52. package/dist/google-generative-ai-BxABKIKO.js +330 -0
  53. package/dist/google-generative-ai-BxABKIKO.js.map +1 -0
  54. package/dist/google-shared-0gpM2jFi.js +19471 -0
  55. package/dist/google-shared-0gpM2jFi.js.map +1 -0
  56. package/dist/google-vertex-D8Eb5cbu.js +376 -0
  57. package/dist/google-vertex-D8Eb5cbu.js.map +1 -0
  58. package/dist/{declare-DVgdEdOL.d.ts → graph-D1PIndsC.d.ts} +117 -6
  59. package/dist/{graph-Bcsourlv.js → graph-DMNOLXLu.js} +23 -13
  60. package/dist/graph-DMNOLXLu.js.map +1 -0
  61. package/dist/hash-Dp7EzZUo.js +18 -0
  62. package/dist/hash-Dp7EzZUo.js.map +1 -0
  63. package/dist/headers-BRNMVpzu.js +19 -0
  64. package/dist/headers-BRNMVpzu.js.map +1 -0
  65. package/dist/index-C5w9ripz.d.ts +204 -0
  66. package/dist/index.d.ts +6 -160
  67. package/dist/index.js +37 -5
  68. package/dist/index.js.map +1 -1
  69. package/dist/inline-BbS93GAT.js +682 -0
  70. package/dist/inline-BbS93GAT.js.map +1 -0
  71. package/dist/json-parse-C10znB7l.js +383 -0
  72. package/dist/json-parse-C10znB7l.js.map +1 -0
  73. package/dist/llms-Dhr_5u2O.js +19 -0
  74. package/dist/llms-Dhr_5u2O.js.map +1 -0
  75. package/dist/markdown-C6dRE9zD.js +168 -0
  76. package/dist/markdown-C6dRE9zD.js.map +1 -0
  77. package/dist/markdown-path-lJB9BAVZ.js +6 -0
  78. package/dist/markdown-path-lJB9BAVZ.js.map +1 -0
  79. package/dist/{message-DT_CjUdt.js → message-CuBjgZ74.js} +2 -2
  80. package/dist/{message-DT_CjUdt.js.map → message-CuBjgZ74.js.map} +1 -1
  81. package/dist/mistral-conversations-CvaqBWjR.js +690 -0
  82. package/dist/mistral-conversations-CvaqBWjR.js.map +1 -0
  83. package/dist/models-DcT5qOEL.js +1203 -0
  84. package/dist/models-DcT5qOEL.js.map +1 -0
  85. package/dist/node-Ccvru9GE.js +26 -0
  86. package/dist/node-Ccvru9GE.js.map +1 -0
  87. package/dist/node-MEosBOF2.js +2403 -0
  88. package/dist/node-MEosBOF2.js.map +1 -0
  89. package/dist/openai-BCBEd2eO.js +17350 -0
  90. package/dist/openai-BCBEd2eO.js.map +1 -0
  91. package/dist/openai-codex-responses-vJqxeeRC.js +1268 -0
  92. package/dist/openai-codex-responses-vJqxeeRC.js.map +1 -0
  93. package/dist/openai-completions-Cb_fRAbI.js +989 -0
  94. package/dist/openai-completions-Cb_fRAbI.js.map +1 -0
  95. package/dist/openai-prompt-cache-Bc6qNWt0.js +10 -0
  96. package/dist/openai-prompt-cache-Bc6qNWt0.js.map +1 -0
  97. package/dist/openai-responses-sDuh82G5.js +268 -0
  98. package/dist/openai-responses-sDuh82G5.js.map +1 -0
  99. package/dist/openai-responses-shared-mhuo1Jov.js +599 -0
  100. package/dist/openai-responses-shared-mhuo1Jov.js.map +1 -0
  101. package/dist/openrouter-images-CRmBkzpX.js +127 -0
  102. package/dist/openrouter-images-CRmBkzpX.js.map +1 -0
  103. package/dist/oxlint.d.ts +58 -0
  104. package/dist/oxlint.js +202 -0
  105. package/dist/oxlint.js.map +1 -0
  106. package/dist/page-heads-BfjWQvau.d.ts +108 -0
  107. package/dist/{page-heads-6y-CARRQ.js → page-heads-BgbaIjj9.js} +3 -3
  108. package/dist/page-heads-BgbaIjj9.js.map +1 -0
  109. package/dist/pi-Bvw6J0gh.js +56795 -0
  110. package/dist/pi-Bvw6J0gh.js.map +1 -0
  111. package/dist/pi-messages-CejiVYvO.js +308 -0
  112. package/dist/pi-messages-CejiVYvO.js.map +1 -0
  113. package/dist/{projections-DeEFe7XT.d.ts → projections-Bk-qOOsR.d.ts} +2 -2
  114. package/dist/provider-env-t38GK5FF.js +39 -0
  115. package/dist/provider-env-t38GK5FF.js.map +1 -0
  116. package/dist/provider-retry-DzKoh1X7.js +80 -0
  117. package/dist/provider-retry-DzKoh1X7.js.map +1 -0
  118. package/dist/react.d.ts +3 -2
  119. package/dist/react.js +2 -1
  120. package/dist/react.js.map +1 -1
  121. package/dist/rolldown-runtime-B-lAHAz2.js +37 -0
  122. package/dist/sanitize-unicode-Ds14l9Om.js +28 -0
  123. package/dist/sanitize-unicode-Ds14l9Om.js.map +1 -0
  124. package/dist/sdk-C9_wiO6w.js +12503 -0
  125. package/dist/sdk-C9_wiO6w.js.map +1 -0
  126. package/dist/state-BuJP_3Lr.js +28102 -0
  127. package/dist/state-BuJP_3Lr.js.map +1 -0
  128. package/dist/system-one-shared-Dl10ZF7Z.js +167 -0
  129. package/dist/system-one-shared-Dl10ZF7Z.js.map +1 -0
  130. package/dist/tanstack-start/index.d.ts +29 -13
  131. package/dist/tanstack-start/index.js +391 -42
  132. package/dist/tanstack-start/index.js.map +1 -1
  133. package/dist/tanstack-start/markdown.d.ts +12 -0
  134. package/dist/tanstack-start/markdown.js +149 -0
  135. package/dist/tanstack-start/markdown.js.map +1 -0
  136. package/dist/tanstack-start/prerender-worker.d.ts +2 -0
  137. package/dist/tanstack-start/prerender-worker.js +7 -0
  138. package/dist/tanstack-start/prerender-worker.js.map +1 -0
  139. package/dist/tanstack-start/react.d.ts +7 -0
  140. package/dist/tanstack-start/react.js +12 -0
  141. package/dist/tanstack-start/react.js.map +1 -0
  142. package/dist/tanstack-start/server.d.ts +9 -3
  143. package/dist/tanstack-start/server.js +26 -2
  144. package/dist/tanstack-start/server.js.map +1 -1
  145. package/dist/transform-messages-BLJ8EfK6.js +468 -0
  146. package/dist/transform-messages-BLJ8EfK6.js.map +1 -0
  147. package/dist/typesafe-system-one-CwEWMV8P.js +25 -0
  148. package/dist/typesafe-system-one-CwEWMV8P.js.map +1 -0
  149. package/dist/{vite-graph-loader-01p1WxEq.js → vite-graph-loader-CsGiYNWE.js} +6 -5
  150. package/dist/vite-graph-loader-CsGiYNWE.js.map +1 -0
  151. package/dist/vite-graph-loader-DZCwejuJ.d.ts +133 -0
  152. package/package.json +47 -10
  153. package/dist/checks-uZk5Em9A.js.map +0 -1
  154. package/dist/graph-Bcsourlv.js.map +0 -1
  155. package/dist/graph-BxCY90vq.d.ts +0 -104
  156. package/dist/graph-CBIY71w6.d.ts +0 -57
  157. package/dist/page-heads-6y-CARRQ.js.map +0 -1
  158. package/dist/page-heads-DNkjMUEN.d.ts +0 -21
  159. package/dist/vite-graph-loader-01p1WxEq.js.map +0 -1
  160. package/dist/vite-graph-loader-Btgjz5RH.d.ts +0 -56
@@ -0,0 +1,682 @@
1
+ //#region node_modules/@noble/hashes/_u64.js
2
+ const fromNumH = (n) => n / 2 ** 32 | 0;
3
+ const fromNumL = (n) => n >>> 0;
4
+ function setU64FromNum(view, byteOffset, n, isLE) {
5
+ const h = fromNumH(n);
6
+ const l = fromNumL(n);
7
+ view.setUint32(byteOffset, isLE ? l : h, isLE);
8
+ view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
9
+ }
10
+ //#endregion
11
+ //#region node_modules/@noble/hashes/utils.js
12
+ /**
13
+ * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.
14
+ * @param a - value to test
15
+ * @returns `true` when the value is a Uint8Array-compatible view.
16
+ * @example
17
+ * Check whether a value is a Uint8Array-compatible view.
18
+ * ```ts
19
+ * isBytes(new Uint8Array([1, 2, 3]));
20
+ * ```
21
+ */
22
+ function isBytes(a) {
23
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
24
+ }
25
+ const atitle = (title) => title ? `"${title}" ` : "";
26
+ /**
27
+ * Asserts something is a non-negative integer.
28
+ * @param n - number to validate
29
+ * @param title - label included in thrown errors
30
+ * @returns The validated number.
31
+ * @throws On wrong argument types. {@link TypeError}
32
+ * @throws On wrong argument ranges or values. {@link RangeError}
33
+ * @example
34
+ * Validate a non-negative integer option.
35
+ * ```ts
36
+ * anumber(32, 'length');
37
+ * ```
38
+ */
39
+ function anumber(n, title = "") {
40
+ if (typeof n !== "number") throw new TypeError(atitle(title) + "expected number, got " + typeof n);
41
+ if (!Number.isSafeInteger(n) || n < 0) throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
42
+ return n;
43
+ }
44
+ /**
45
+ * Asserts something is Uint8Array.
46
+ * @param value - value to validate
47
+ * @param length - optional exact length constraint
48
+ * @param title - label included in thrown errors
49
+ * @returns The validated byte array.
50
+ * @throws On wrong argument types. {@link TypeError}
51
+ * @throws On wrong argument ranges or values. {@link RangeError}
52
+ * @example
53
+ * Validate that a value is a byte array.
54
+ * ```ts
55
+ * abytes(new Uint8Array([1, 2, 3]));
56
+ * ```
57
+ */
58
+ function abytes(value, length, title = "") {
59
+ if (isBytes(value) && (length === void 0 || value.length === length)) return value;
60
+ if (length !== void 0) anumber(length, "length");
61
+ const bytes = isBytes(value);
62
+ const ofLen = length !== void 0 ? ` of length ${length}` : "";
63
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
64
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
65
+ if (!bytes) throw new TypeError(message);
66
+ throw new RangeError(message);
67
+ }
68
+ const aobject = (value, label) => {
69
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
70
+ };
71
+ const aopts = (value, label) => {
72
+ aobject(value, label);
73
+ const proto = Object.getPrototypeOf(value);
74
+ if (proto !== Object.prototype && proto !== null) throw new TypeError(`"${label}" expected plain object`);
75
+ if (Object.hasOwn(value, "__proto__")) throw new TypeError(`"${label}.__proto__" is not allowed`);
76
+ };
77
+ /**
78
+ * Asserts a hash instance has not been destroyed or finished.
79
+ * @param instance - hash instance to validate
80
+ * @param checkFinished - whether to reject finalized instances
81
+ * @throws If the hash instance has already been destroyed or finalized. {@link Error}
82
+ * @example
83
+ * Validate that a hash instance is still usable.
84
+ * ```ts
85
+ * import { aexists } from '@noble/hashes/utils.js';
86
+ * import { sha256 } from '@noble/hashes/sha2.js';
87
+ * const hash = sha256.create();
88
+ * aexists(hash);
89
+ * ```
90
+ */
91
+ function aexists(instance, checkFinished = true) {
92
+ if (instance.destroyed) throw new Error("hash was destroyed");
93
+ if (checkFinished && instance.finished) throw new Error("digest() was already called");
94
+ }
95
+ /**
96
+ * Asserts output is a sufficiently-sized byte array.
97
+ * @param out - destination buffer
98
+ * @param instance - hash instance providing output length
99
+ * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
100
+ * @throws On wrong argument types. {@link TypeError}
101
+ * @throws On wrong argument ranges or values. {@link RangeError}
102
+ * @example
103
+ * Validate a caller-provided digest buffer.
104
+ * ```ts
105
+ * import { aoutput } from '@noble/hashes/utils.js';
106
+ * import { sha256 } from '@noble/hashes/sha2.js';
107
+ * const hash = sha256.create();
108
+ * aoutput(new Uint8Array(hash.outputLen), hash);
109
+ * ```
110
+ */
111
+ function aoutput(out, instance) {
112
+ abytes(out, void 0, "output");
113
+ const min = instance.outputLen;
114
+ if (!(out.length >= min)) throw new RangeError("\"output\" expected length >= " + min);
115
+ }
116
+ /**
117
+ * Zeroizes typed arrays in place. Warning: JS provides no guarantees.
118
+ * @param arrays - arrays to overwrite with zeros
119
+ * @example
120
+ * Zeroize sensitive buffers in place.
121
+ * ```ts
122
+ * clean(new Uint8Array([1, 2, 3]));
123
+ * ```
124
+ */
125
+ function clean(...arrays) {
126
+ for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
127
+ }
128
+ /**
129
+ * Creates a DataView for byte-level manipulation.
130
+ * @param arr - source typed array
131
+ * @returns DataView over the same buffer region.
132
+ * @example
133
+ * Create a DataView over an existing buffer.
134
+ * ```ts
135
+ * createView(new Uint8Array(4));
136
+ * ```
137
+ */
138
+ function createView(arr) {
139
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
140
+ }
141
+ /**
142
+ * Rotate-right operation for uint32 values.
143
+ * @param word - source word
144
+ * @param shift - shift amount in bits
145
+ * @returns Rotated word.
146
+ * @example
147
+ * Rotate a 32-bit word to the right.
148
+ * ```ts
149
+ * rotr(0x12345678, 8);
150
+ * ```
151
+ */
152
+ function rotr(word, shift) {
153
+ return word << 32 - shift | word >>> shift;
154
+ }
155
+ const hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
156
+ const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
157
+ /**
158
+ * Convert byte array to hex string.
159
+ * Uses the built-in function when available and assumes it matches the tested
160
+ * fallback semantics.
161
+ * @param bytes - bytes to encode
162
+ * @returns Lowercase hexadecimal string.
163
+ * @throws On wrong argument types. {@link TypeError}
164
+ * @example
165
+ * Convert bytes to lowercase hexadecimal.
166
+ * ```ts
167
+ * bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'
168
+ * ```
169
+ */
170
+ function bytesToHex(bytes) {
171
+ abytes(bytes);
172
+ if (hasHexBuiltin) return bytes.toHex();
173
+ let hex = "";
174
+ for (let i = 0; i < bytes.length; i++) hex += hexes[bytes[i]];
175
+ return hex;
176
+ }
177
+ /**
178
+ * Merges default options and passed options.
179
+ * @param defaults - base option object
180
+ * @param opts - user overrides
181
+ * @param title - label included in thrown override errors
182
+ * @returns Fresh merged option object with a null prototype.
183
+ * @throws On wrong argument types. {@link TypeError}
184
+ * @example
185
+ * Merge user overrides onto default options.
186
+ * ```ts
187
+ * checkOpts({ dkLen: 32 }, { asyncTick: 10 });
188
+ * ```
189
+ */
190
+ function checkOpts(defaults, opts, title = "opts") {
191
+ aopts(defaults, "defaults");
192
+ if (opts !== void 0) aopts(opts, title);
193
+ return Object.assign(Object.create(null), defaults, opts);
194
+ }
195
+ /**
196
+ * Creates a callable hash function from a stateful class constructor.
197
+ * @param hashCons - hash constructor or factory
198
+ * @param info - optional metadata such as DER OID
199
+ * @returns Frozen callable hash wrapper with `.create()`.
200
+ * Wrapper construction eagerly calls `hashCons(undefined)` once to read
201
+ * `outputLen` / `blockLen`, so constructor side effects happen at module
202
+ * init time.
203
+ * @throws On wrong argument types. {@link TypeError}
204
+ * @example
205
+ * Wrap a stateful hash constructor into a callable helper.
206
+ * ```ts
207
+ * import { createHasher } from '@noble/hashes/utils.js';
208
+ * import { sha256 } from '@noble/hashes/sha2.js';
209
+ * const wrapped = createHasher(sha256.create, { oid: sha256.oid });
210
+ * wrapped(new Uint8Array([1]));
211
+ * ```
212
+ */
213
+ function createHasher(hashCons, info = {}) {
214
+ if (typeof hashCons !== "function") throw new TypeError("\"hashCons\" expected function, got type=" + typeof hashCons);
215
+ info = checkOpts({}, info, "info");
216
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
217
+ const tmp = hashCons(void 0);
218
+ hashC.outputLen = tmp.outputLen;
219
+ hashC.blockLen = tmp.blockLen;
220
+ hashC.canXOF = tmp.canXOF;
221
+ hashC.create = (opts) => hashCons(opts);
222
+ Object.assign(hashC, info);
223
+ return Object.freeze(hashC);
224
+ }
225
+ /**
226
+ * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.
227
+ * @param suffix - final OID byte for the selected hash.
228
+ * The helper accepts any byte even though only the documented NIST hash
229
+ * suffixes are meaningful downstream.
230
+ * @returns Object containing the DER-encoded OID.
231
+ * @example
232
+ * Build OID metadata for a NIST hash.
233
+ * ```ts
234
+ * oidNist(0x01);
235
+ * ```
236
+ */
237
+ const oidNist = (suffix) => ({ oid: Uint8Array.from([
238
+ 6,
239
+ 9,
240
+ 96,
241
+ 134,
242
+ 72,
243
+ 1,
244
+ 101,
245
+ 3,
246
+ 4,
247
+ 2,
248
+ suffix
249
+ ]) });
250
+ //#endregion
251
+ //#region node_modules/@noble/hashes/_md.js
252
+ /**
253
+ * Internal Merkle-Damgard hash utils.
254
+ * @module
255
+ */
256
+ /**
257
+ * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
258
+ * Returns bits from `b` when `a` is set, otherwise from `c`.
259
+ * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
260
+ * set the same bit.
261
+ * @param a - selector word
262
+ * @param b - word chosen when selector bit is set
263
+ * @param c - word chosen when selector bit is clear
264
+ * @returns Mixed 32-bit word.
265
+ * @example
266
+ * Combine three words with the shared 32-bit choice primitive.
267
+ * ```ts
268
+ * Chi(0xffffffff, 0x12345678, 0x87654321);
269
+ * ```
270
+ */
271
+ function Chi(a, b, c) {
272
+ return a & b ^ ~a & c;
273
+ }
274
+ /**
275
+ * Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
276
+ * Returns bits shared by at least two inputs.
277
+ * @param a - first input word
278
+ * @param b - second input word
279
+ * @param c - third input word
280
+ * @returns Mixed 32-bit word.
281
+ * @example
282
+ * Combine three words with the shared 32-bit majority primitive.
283
+ * ```ts
284
+ * Maj(0xffffffff, 0x12345678, 0x87654321);
285
+ * ```
286
+ */
287
+ function Maj(a, b, c) {
288
+ return a & b ^ a & c ^ b & c;
289
+ }
290
+ /**
291
+ * Merkle-Damgard hash construction base class.
292
+ * Could be used to create MD5, RIPEMD, SHA1, SHA2.
293
+ * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
294
+ * strings with partial-byte tails.
295
+ * @param blockLen - internal block size in bytes
296
+ * @param outputLen - digest size in bytes
297
+ * @param padOffset - trailing length field size in bytes
298
+ * @param isLE - whether length and state words are encoded in little-endian
299
+ * @example
300
+ * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
301
+ * ```ts
302
+ * import { _SHA1 } from '@noble/hashes/legacy.js';
303
+ * const hash = new _SHA1();
304
+ * hash.update(new Uint8Array([97, 98, 99]));
305
+ * hash.digest();
306
+ * ```
307
+ */
308
+ var HashMD = class {
309
+ blockLen;
310
+ outputLen;
311
+ canXOF = false;
312
+ padOffset;
313
+ isLE;
314
+ buffer;
315
+ view;
316
+ finished = false;
317
+ length = 0;
318
+ pos = 0;
319
+ destroyed = false;
320
+ constructor(blockLen, outputLen, padOffset, isLE) {
321
+ this.blockLen = blockLen;
322
+ this.outputLen = outputLen;
323
+ this.padOffset = padOffset;
324
+ this.isLE = isLE;
325
+ this.buffer = new Uint8Array(blockLen);
326
+ this.view = createView(this.buffer);
327
+ }
328
+ update(data) {
329
+ aexists(this);
330
+ abytes(data);
331
+ const { view, buffer, blockLen } = this;
332
+ const len = data.length;
333
+ let processed = false;
334
+ for (let pos = 0; pos < len;) {
335
+ const take = Math.min(blockLen - this.pos, len - pos);
336
+ if (take === blockLen) {
337
+ const dataView = createView(data);
338
+ for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
339
+ processed = true;
340
+ continue;
341
+ }
342
+ buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
343
+ this.pos += take;
344
+ pos += take;
345
+ if (this.pos === blockLen) {
346
+ this.process(view, 0);
347
+ this.pos = 0;
348
+ processed = true;
349
+ }
350
+ }
351
+ this.length += data.length;
352
+ if (processed) this.roundClean();
353
+ return this;
354
+ }
355
+ digestInto(out) {
356
+ aexists(this);
357
+ aoutput(out, this);
358
+ this.finished = true;
359
+ const { buffer, view, blockLen, isLE } = this;
360
+ let { pos } = this;
361
+ buffer[pos++] = 128;
362
+ buffer.fill(0, pos);
363
+ if (this.padOffset > blockLen - pos) {
364
+ this.process(view, 0);
365
+ buffer.fill(0);
366
+ }
367
+ setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
368
+ this.process(view, 0);
369
+ this.roundClean();
370
+ const oview = out === buffer ? view : createView(out);
371
+ const len = this.outputLen;
372
+ const outLen = len / 4;
373
+ const state = this.get();
374
+ if (len % 4 || outLen > state.length) throw new Error("invalid outputLen");
375
+ for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
376
+ }
377
+ digest() {
378
+ const { buffer, outputLen } = this;
379
+ this.digestInto(buffer);
380
+ const res = buffer.slice(0, outputLen);
381
+ this.destroy();
382
+ return res;
383
+ }
384
+ _cloneIntoMeta(to) {
385
+ const { buffer, length, finished, destroyed, pos } = this;
386
+ to.destroyed = destroyed;
387
+ to.finished = finished;
388
+ to.length = length;
389
+ to.pos = pos;
390
+ if (pos) to.buffer.set(buffer);
391
+ return to;
392
+ }
393
+ clone() {
394
+ return this._cloneInto();
395
+ }
396
+ };
397
+ /**
398
+ * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
399
+ * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
400
+ */
401
+ /** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
402
+ * square roots of the first eight prime numbers. Exported as a shared table; callers must treat
403
+ * it as read-only because constructors copy words from it by index. */
404
+ const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
405
+ 1779033703,
406
+ 3144134277,
407
+ 1013904242,
408
+ 2773480762,
409
+ 1359893119,
410
+ 2600822924,
411
+ 528734635,
412
+ 1541459225
413
+ ]);
414
+ //#endregion
415
+ //#region node_modules/@noble/hashes/sha2.js
416
+ /**
417
+ * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
418
+ * SHA256 is the fastest hash implementable in JS, even faster than Blake3.
419
+ * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and
420
+ * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.
421
+ * @module
422
+ */
423
+ /**
424
+ * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits
425
+ * of the cube roots of the first 64 primes (2..311).
426
+ */
427
+ const SHA256_K = /* @__PURE__ */ Uint32Array.from([
428
+ 1116352408,
429
+ 1899447441,
430
+ 3049323471,
431
+ 3921009573,
432
+ 961987163,
433
+ 1508970993,
434
+ 2453635748,
435
+ 2870763221,
436
+ 3624381080,
437
+ 310598401,
438
+ 607225278,
439
+ 1426881987,
440
+ 1925078388,
441
+ 2162078206,
442
+ 2614888103,
443
+ 3248222580,
444
+ 3835390401,
445
+ 4022224774,
446
+ 264347078,
447
+ 604807628,
448
+ 770255983,
449
+ 1249150122,
450
+ 1555081692,
451
+ 1996064986,
452
+ 2554220882,
453
+ 2821834349,
454
+ 2952996808,
455
+ 3210313671,
456
+ 3336571891,
457
+ 3584528711,
458
+ 113926993,
459
+ 338241895,
460
+ 666307205,
461
+ 773529912,
462
+ 1294757372,
463
+ 1396182291,
464
+ 1695183700,
465
+ 1986661051,
466
+ 2177026350,
467
+ 2456956037,
468
+ 2730485921,
469
+ 2820302411,
470
+ 3259730800,
471
+ 3345764771,
472
+ 3516065817,
473
+ 3600352804,
474
+ 4094571909,
475
+ 275423344,
476
+ 430227734,
477
+ 506948616,
478
+ 659060556,
479
+ 883997877,
480
+ 958139571,
481
+ 1322822218,
482
+ 1537002063,
483
+ 1747873779,
484
+ 1955562222,
485
+ 2024104815,
486
+ 2227730452,
487
+ 2361852424,
488
+ 2428436474,
489
+ 2756734187,
490
+ 3204031479,
491
+ 3329325298
492
+ ]);
493
+ /** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */
494
+ const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
495
+ /** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */
496
+ var SHA2_32B = class extends HashMD {
497
+ A = 0;
498
+ B = 0;
499
+ C = 0;
500
+ D = 0;
501
+ E = 0;
502
+ F = 0;
503
+ G = 0;
504
+ H = 0;
505
+ constructor(outputLen, IV) {
506
+ super(64, outputLen, 8, false);
507
+ this.A = IV[0] | 0;
508
+ this.B = IV[1] | 0;
509
+ this.C = IV[2] | 0;
510
+ this.D = IV[3] | 0;
511
+ this.E = IV[4] | 0;
512
+ this.F = IV[5] | 0;
513
+ this.G = IV[6] | 0;
514
+ this.H = IV[7] | 0;
515
+ }
516
+ get() {
517
+ const { A, B, C, D, E, F, G, H } = this;
518
+ return [
519
+ A,
520
+ B,
521
+ C,
522
+ D,
523
+ E,
524
+ F,
525
+ G,
526
+ H
527
+ ];
528
+ }
529
+ set(A, B, C, D, E, F, G, H) {
530
+ this.A = A | 0;
531
+ this.B = B | 0;
532
+ this.C = C | 0;
533
+ this.D = D | 0;
534
+ this.E = E | 0;
535
+ this.F = F | 0;
536
+ this.G = G | 0;
537
+ this.H = H | 0;
538
+ }
539
+ _cloneInto(to) {
540
+ (to ||= new this.constructor()).set(...this.get());
541
+ return this._cloneIntoMeta(to);
542
+ }
543
+ process(view, offset) {
544
+ for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
545
+ for (let i = 16; i < 64; i++) {
546
+ const W15 = SHA256_W[i - 15];
547
+ const W2 = SHA256_W[i - 2];
548
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
549
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
550
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
551
+ }
552
+ let { A, B, C, D, E, F, G, H } = this;
553
+ for (let i = 0; i < 64; i++) {
554
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
555
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
556
+ const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
557
+ H = G;
558
+ G = F;
559
+ F = E;
560
+ E = D + T1 | 0;
561
+ D = C;
562
+ C = B;
563
+ B = A;
564
+ A = T1 + T2 | 0;
565
+ }
566
+ A = A + this.A | 0;
567
+ B = B + this.B | 0;
568
+ C = C + this.C | 0;
569
+ D = D + this.D | 0;
570
+ E = E + this.E | 0;
571
+ F = F + this.F | 0;
572
+ G = G + this.G | 0;
573
+ H = H + this.H | 0;
574
+ this.set(A, B, C, D, E, F, G, H);
575
+ }
576
+ roundClean() {
577
+ clean(SHA256_W);
578
+ }
579
+ destroy() {
580
+ this.destroyed = true;
581
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
582
+ clean(this.buffer);
583
+ }
584
+ };
585
+ /** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */
586
+ var _SHA256 = class extends SHA2_32B {
587
+ constructor() {
588
+ super(32, SHA256_IV);
589
+ }
590
+ };
591
+ /**
592
+ * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:
593
+ *
594
+ * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.
595
+ * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
596
+ * - Each sha256 hash is executing 2^18 bit operations.
597
+ * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.
598
+ * @param msg - message bytes to hash
599
+ * @param opts - Reserved hash options.
600
+ * @returns Digest bytes.
601
+ * @example
602
+ * Hash a message with SHA2-256.
603
+ * ```ts
604
+ * sha256(new Uint8Array([97, 98, 99]));
605
+ * ```
606
+ */
607
+ const sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), /* @__PURE__ */ oidNist(1));
608
+ //#endregion
609
+ //#region src/markdown/hash.ts
610
+ /** Key order is not content; array order is. Reject values JSON cannot represent. */
611
+ function stableJson(value) {
612
+ if (value === null || typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
613
+ if (typeof value === "number" && Number.isFinite(value)) return JSON.stringify(value);
614
+ if (Array.isArray(value)) return `[${Array.from(value, stableJson).join(",")}]`;
615
+ if (typeof value === "object" && value !== null) return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, entry]) => `${JSON.stringify(key)}:${stableJson(entry)}`).join(",")}}`;
616
+ throw new Error(`Document content is not JSON: ${String(value)}`);
617
+ }
618
+ const contentHash = (value) => bytesToHex(sha256(new TextEncoder().encode(stableJson(value))));
619
+ //#endregion
620
+ //#region src/markdown/document.ts
621
+ /** Reserved for synthetic sections; capture rejects authored ids in this namespace. */
622
+ const RESERVED_SECTION_ID_PREFIX = "__pagegraph:";
623
+ const HEAD_SECTION_ID = `${RESERVED_SECTION_ID_PREFIX}head`;
624
+ /** The document includes resolved values; source relocation alone is not a content edit. */
625
+ function hashDocument(document) {
626
+ const withoutSource = (value) => {
627
+ if (Array.isArray(value)) return value.map(withoutSource);
628
+ if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).filter(([key]) => key !== "source").map(([key, entry]) => [key, withoutSource(entry)]));
629
+ return value;
630
+ };
631
+ return contentHash(withoutSource(document));
632
+ }
633
+ //#endregion
634
+ //#region src/markdown/inline.ts
635
+ const unsafeMarkdownChars = /[()\\<> \u0000-\u001f\u007f]/g;
636
+ function documentLinkHref(value, base) {
637
+ const scheme = /^([a-z][a-z\d+.-]*):/i.exec(value.trim())?.[1]?.toLowerCase();
638
+ if (scheme !== void 0 && ![
639
+ "http",
640
+ "https",
641
+ "mailto",
642
+ "tel"
643
+ ].includes(scheme)) throw new Error(`Unsafe document link protocol "${scheme}:"`);
644
+ const encoded = value.replace(unsafeMarkdownChars, (character) => `%${character.charCodeAt(0).toString(16).padStart(2, "0").toUpperCase()}`);
645
+ if (base !== void 0) return new URL(encoded, base).href;
646
+ if (scheme !== void 0) return new URL(encoded).href;
647
+ return encoded;
648
+ }
649
+ function plainText(tree) {
650
+ return tree.map((node) => {
651
+ if (typeof node === "string") return node;
652
+ if ("fact" in node) return node.text;
653
+ if (node.tag === "br") return "\n";
654
+ return plainText(node.children);
655
+ }).join("");
656
+ }
657
+ const escapeMarkdown = (text) => text.replace(/([\\`*_[\]<>])/g, "\\$1");
658
+ function inlineMarkdown(tree, options = {}) {
659
+ return tree.map((node) => {
660
+ if (typeof node === "string") return escapeMarkdown(node);
661
+ if ("fact" in node) return escapeMarkdown(node.text);
662
+ const children = inlineMarkdown(node.children, options);
663
+ switch (node.tag) {
664
+ case "em": return options.emphasis === false ? children : `*${children}*`;
665
+ case "strong": return options.emphasis === false ? children : `**${children}**`;
666
+ case "a":
667
+ if (node.href === void 0) throw new Error("An anchor in T needs a string href");
668
+ return `[${children}](${documentLinkHref(node.href)})`;
669
+ case "code": {
670
+ const text = plainText(node.children);
671
+ const runs = text.match(/`+/g) ?? [];
672
+ const fence = "`".repeat(Math.max(0, ...runs.map((run) => run.length)) + 1);
673
+ return `${fence}${text.includes("`") ? " " : ""}${text}${text.includes("`") ? " " : ""}${fence}`;
674
+ }
675
+ case "br": return " \n";
676
+ }
677
+ }).join("");
678
+ }
679
+ //#endregion
680
+ export { RESERVED_SECTION_ID_PREFIX as a, HEAD_SECTION_ID as i, inlineMarkdown as n, hashDocument as o, plainText as r, contentHash as s, documentLinkHref as t };
681
+
682
+ //# sourceMappingURL=inline-BbS93GAT.js.map