@stream-mdx/react 0.5.0 → 1.0.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 (99) hide show
  1. package/CHANGELOG.md +371 -0
  2. package/README.md +79 -4
  3. package/dist/blocks-renderer-DAOBFBfi.d.ts +29 -0
  4. package/dist/blocks-renderer-DQEL1kJW.d.cts +29 -0
  5. package/dist/components/bottom-stick-scroll-area.cjs +117 -193
  6. package/dist/components/bottom-stick-scroll-area.mjs +112 -183
  7. package/dist/components/diff-renderer.cjs +86 -0
  8. package/dist/components/diff-renderer.d.cts +11 -0
  9. package/dist/components/diff-renderer.d.ts +11 -0
  10. package/dist/components/diff-renderer.mjs +66 -0
  11. package/dist/components/index.cjs +2761 -1508
  12. package/dist/components/index.d.cts +7 -2
  13. package/dist/components/index.d.ts +7 -2
  14. package/dist/components/index.mjs +2730 -1493
  15. package/dist/components/katex-math.cjs +220 -0
  16. package/dist/components/katex-math.d.cts +10 -0
  17. package/dist/components/katex-math.d.ts +10 -0
  18. package/dist/components/katex-math.mjs +188 -0
  19. package/dist/contexts/math-tracker.cjs +240 -521
  20. package/dist/contexts/math-tracker.mjs +235 -513
  21. package/dist/index-Cmne1yUK.d.cts +723 -0
  22. package/dist/index-D7dyyu3q.d.ts +723 -0
  23. package/dist/index.cjs +13029 -6475
  24. package/dist/index.d.cts +69 -39
  25. package/dist/index.d.ts +69 -39
  26. package/dist/index.mjs +13007 -6442
  27. package/dist/math/display-wrapper.cjs +7 -15
  28. package/dist/math/display-wrapper.d.cts +2 -2
  29. package/dist/math/display-wrapper.d.ts +2 -2
  30. package/dist/math/display-wrapper.mjs +2 -6
  31. package/dist/node-views-Bpc6Gkgl.d.cts +13 -0
  32. package/dist/node-views-DpnYdaAS.d.ts +13 -0
  33. package/dist/renderer/hooks.cjs +35 -20
  34. package/dist/renderer/hooks.d.cts +22 -1
  35. package/dist/renderer/hooks.d.ts +22 -1
  36. package/dist/renderer/hooks.mjs +27 -12
  37. package/dist/renderer/patch-batching.cjs +5 -8
  38. package/dist/renderer/patch-coalescing.cjs +5 -8
  39. package/dist/renderer/patch-commit-scheduler.cjs +138 -356
  40. package/dist/renderer/patch-commit-scheduler.d.cts +13 -1
  41. package/dist/renderer/patch-commit-scheduler.d.ts +13 -1
  42. package/dist/renderer/patch-commit-scheduler.mjs +133 -348
  43. package/dist/renderer/store.cjs +3775 -1373
  44. package/dist/renderer/store.d.cts +108 -3
  45. package/dist/renderer/store.d.ts +108 -3
  46. package/dist/renderer/store.mjs +3778 -1362
  47. package/dist/renderer/virtualized-code.cjs +415 -71
  48. package/dist/renderer/virtualized-code.d.cts +24 -23
  49. package/dist/renderer/virtualized-code.d.ts +24 -23
  50. package/dist/renderer/virtualized-code.mjs +409 -62
  51. package/dist/renderer.cjs +10655 -4334
  52. package/dist/renderer.d.cts +98 -29
  53. package/dist/renderer.d.ts +98 -29
  54. package/dist/renderer.mjs +10582 -4212
  55. package/dist/server-regions-CPLHGli0.d.cts +32 -0
  56. package/dist/server-regions-mUhyoKi7.d.ts +32 -0
  57. package/dist/server.cjs +10195 -3872
  58. package/dist/server.d.cts +17 -252
  59. package/dist/server.d.ts +17 -252
  60. package/dist/server.mjs +9997 -3649
  61. package/dist/{streaming-markdown-CEI9eDZm.d.ts → streaming-markdown-yELbJxyH.d.ts} +49 -55
  62. package/dist/{streaming-markdown-DRisClXb.d.cts → streaming-markdown-zVwFuaJG.d.cts} +49 -55
  63. package/dist/streaming-markdown.cjs +11660 -5378
  64. package/dist/streaming-markdown.d.cts +7 -2
  65. package/dist/streaming-markdown.d.ts +7 -2
  66. package/dist/streaming-markdown.mjs +11679 -5347
  67. package/dist/trusted-mdx/index.cjs +833 -0
  68. package/dist/trusted-mdx/index.d.cts +11 -0
  69. package/dist/trusted-mdx/index.d.ts +11 -0
  70. package/dist/trusted-mdx/index.mjs +807 -0
  71. package/dist/trusted-mdx/native-children-slot.cjs +45 -0
  72. package/dist/trusted-mdx/native-children-slot.d.cts +11 -0
  73. package/dist/trusted-mdx/native-children-slot.d.ts +11 -0
  74. package/dist/trusted-mdx/native-children-slot.mjs +24 -0
  75. package/dist/trusted-mdx/server.cjs +752 -0
  76. package/dist/trusted-mdx/server.d.cts +24 -0
  77. package/dist/trusted-mdx/server.d.ts +24 -0
  78. package/dist/trusted-mdx/server.mjs +724 -0
  79. package/dist/trusted-mdx-contract-ElKpkDI5.d.cts +113 -0
  80. package/dist/trusted-mdx-contract-ElKpkDI5.d.ts +113 -0
  81. package/dist/utils/inline-html.cjs +246 -147
  82. package/dist/utils/inline-html.d.cts +37 -6
  83. package/dist/utils/inline-html.d.ts +37 -6
  84. package/dist/utils/inline-html.mjs +237 -134
  85. package/package.json +41 -18
  86. package/dist/index-BVhp_pcF.d.ts +0 -251
  87. package/dist/index-EaeouYp2.d.cts +0 -251
  88. package/dist/mdx-client.cjs +0 -408
  89. package/dist/mdx-client.d.cts +0 -113
  90. package/dist/mdx-client.d.ts +0 -113
  91. package/dist/mdx-client.mjs +0 -369
  92. package/dist/mdx-coordinator.cjs +0 -584
  93. package/dist/mdx-coordinator.d.cts +0 -21
  94. package/dist/mdx-coordinator.d.ts +0 -21
  95. package/dist/mdx-coordinator.mjs +0 -550
  96. package/dist/renderer/node-views.cjs +0 -1887
  97. package/dist/renderer/node-views.d.cts +0 -14
  98. package/dist/renderer/node-views.d.ts +0 -14
  99. package/dist/renderer/node-views.mjs +0 -1861
@@ -0,0 +1,752 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+
25
+ // src/trusted-mdx/server.tsx
26
+ var server_exports = {};
27
+ __export(server_exports, {
28
+ projectTrustedMdxServerDocument: () => projectTrustedMdxServerDocument
29
+ });
30
+ module.exports = __toCommonJS(server_exports);
31
+ var import_react2 = __toESM(require("react"), 1);
32
+
33
+ // src/trusted-mdx-contract.ts
34
+ function assertTrustedMdxNativeChildContinuations(owners, flowChildren) {
35
+ if (owners.length !== flowChildren.length)
36
+ throw new Error("A trusted MDX native child continuation has misaligned owner and source spans.");
37
+ let continuationOwnerIndex;
38
+ for (let index = 0; index < owners.length; index++) {
39
+ let owner = owners[index];
40
+ if (owner?.kind !== "continuation") {
41
+ continuationOwnerIndex = void 0;
42
+ continue;
43
+ }
44
+ let ownerIndex = owner.ownerIndex, ownerForRun = owners[ownerIndex], previousChild = flowChildren[index - 1], child = flowChildren[index];
45
+ if (!Number.isSafeInteger(ownerIndex) || ownerIndex < 0 || ownerIndex >= index || (continuationOwnerIndex === void 0 ? ownerIndex !== index - 1 : ownerIndex !== continuationOwnerIndex) || ownerForRun === null || ownerForRun === void 0 || ownerForRun.kind === "continuation" || previousChild?.kind !== "inline" || child?.kind !== "inline" || previousChild.to <= previousChild.from || child.to <= child.from || previousChild.to !== child.from)
46
+ throw new Error("A trusted MDX native child continuation does not cover one exact contiguous inline run.");
47
+ continuationOwnerIndex = ownerIndex;
48
+ }
49
+ }
50
+
51
+ // src/trusted-mdx/evaluate.ts
52
+ var import_react = __toESM(require("react"), 1), jsxRuntime = __toESM(require("react/jsx-runtime"), 1), AsyncFunction = Object.getPrototypeOf(async function() {
53
+ }).constructor;
54
+ async function evaluateCompiledMdx(code, options, canInvoke) {
55
+ let hostImports = options.imports, resolveSyncHostImport = (specifier) => {
56
+ if (specifier === "react")
57
+ return { default: import_react.default, ...import_react.default };
58
+ if (specifier === "react/jsx-runtime")
59
+ return jsxRuntime;
60
+ if (hostImports && Object.prototype.hasOwnProperty.call(hostImports, specifier))
61
+ return hostImports[specifier];
62
+ throw new Error(
63
+ `Cannot resolve MDX import specifier "${specifier}": no host binding configured. Automatic fetching and network egress are disabled.`
64
+ );
65
+ };
66
+ async function resolveDynamicHostImport(specifier) {
67
+ return resolveSyncHostImport(specifier);
68
+ }
69
+ let runtime = {
70
+ Fragment: jsxRuntime.Fragment,
71
+ jsx: jsxRuntime.jsx,
72
+ jsxs: jsxRuntime.jsxs,
73
+ _resolveSyncHostImport: resolveSyncHostImport,
74
+ _resolveDynamicHostImport: resolveDynamicHostImport
75
+ }, fn = new AsyncFunction(code);
76
+ return canInvoke() ? fn(runtime) : null;
77
+ }
78
+
79
+ // src/trusted-mdx/server.tsx
80
+ var import_trusted_mdx_native_children = require("@stream-mdx/react/_internal/trusted-mdx-native-children");
81
+
82
+ // src/trusted-mdx/projection.ts
83
+ function getActiveTrustedMdxNativeTree(meta) {
84
+ if (Array.isArray(meta?.trustedMdxNativeChildren)) return meta.trustedMdxNativeChildren;
85
+ if (meta?.htmlOwnership === !0 && Array.isArray(meta.htmlTree)) return meta.htmlTree;
86
+ if (Array.isArray(meta?.htmlParagraphTree)) return meta.htmlParagraphTree;
87
+ if (Array.isArray(meta?.htmlTree)) return meta.htmlTree;
88
+ }
89
+ function readSourceRange(value, sourceLength) {
90
+ if (typeof value != "object" || value === null || Array.isArray(value) || !("from" in value) || !("to" in value))
91
+ return null;
92
+ let from = value.from, to = value.to;
93
+ return typeof from != "number" || typeof to != "number" || !Number.isSafeInteger(from) || !Number.isSafeInteger(to) || from < 0 || to <= from || to > sourceLength ? null : { from, to };
94
+ }
95
+ function readSnapshotFields(value) {
96
+ if (typeof value != "object" || value === null || Array.isArray(value) || !("id" in value) || !("type" in value))
97
+ return null;
98
+ let id = value.id, type = value.type;
99
+ return typeof id != "string" || typeof type != "string" ? null : {
100
+ id,
101
+ type,
102
+ range: "range" in value ? value.range : void 0,
103
+ props: "props" in value ? value.props : void 0,
104
+ children: "children" in value ? value.children : void 0
105
+ };
106
+ }
107
+ function hasNativeBlockOwner(tree) {
108
+ if (!Array.isArray(tree)) return !1;
109
+ let pending = [...tree];
110
+ for (; pending.length > 0; ) {
111
+ let current = pending.pop();
112
+ if (!(typeof current != "object" || current === null || Array.isArray(current))) {
113
+ if ("kind" in current && current.kind === "block" && "block" in current) return !0;
114
+ "children" in current && Array.isArray(current.children) && pending.push(...current.children);
115
+ }
116
+ }
117
+ return !1;
118
+ }
119
+ function collectInlineOwners(value, sourceLength, matches) {
120
+ if (!Array.isArray(value)) return;
121
+ let visited = /* @__PURE__ */ new WeakSet(), pending = [...value];
122
+ for (; pending.length > 0; ) {
123
+ let current = pending.pop();
124
+ if (!(typeof current != "object" || current === null || visited.has(current))) {
125
+ if (visited.add(current), Array.isArray(current)) {
126
+ pending.push(...current);
127
+ continue;
128
+ }
129
+ "kind" in current && current.kind === "trusted-mdx-inline" && "ownerId" in current && typeof current.ownerId == "string" && addMdxOwner(
130
+ matches,
131
+ current.ownerId,
132
+ "inline expression",
133
+ "sourceRange" in current ? current.sourceRange : void 0,
134
+ sourceLength
135
+ ), "children" in current && Array.isArray(current.children) && pending.push(...current.children);
136
+ }
137
+ }
138
+ }
139
+ function isNestedMdxType(type) {
140
+ return type === "paragraph-mdx" || type === "blockquote-mdx" || type === "list-item-mdx";
141
+ }
142
+ function addMdxOwner(matches, id, label, range, sourceLength) {
143
+ let sourceRange = readSourceRange(range, sourceLength);
144
+ matches.push({
145
+ id,
146
+ label,
147
+ from: sourceRange?.from ?? null,
148
+ to: sourceRange?.to ?? null,
149
+ regions: [],
150
+ placement: null,
151
+ rootElementName: void 0,
152
+ nativeChildren: !1,
153
+ nativeChildOwners: [],
154
+ flowChildren: void 0,
155
+ nativeFlowOwnedBlockIds: [],
156
+ wholeBlockFlowRoot: !1,
157
+ ambiguous: !1
158
+ });
159
+ }
160
+ function readFlowChildRanges(flowChildren, flowRange, sourceLength) {
161
+ if (flowChildren === void 0) return;
162
+ let ranges = [], previousTo = flowRange.from;
163
+ for (let child of flowChildren) {
164
+ let range = readSourceRange(child, sourceLength);
165
+ if (!range || range.from < flowRange.from || range.to > flowRange.to || range.from < previousTo)
166
+ return null;
167
+ ranges.push(range), previousTo = range.to;
168
+ }
169
+ return ranges;
170
+ }
171
+ function classifyFlowRange(range, childRanges) {
172
+ let directChildIndex;
173
+ for (let index = 0; index < childRanges.length; index++) {
174
+ let childRange = childRanges[index];
175
+ if (!childRange) return null;
176
+ if (range.from >= childRange.from && range.to <= childRange.to) {
177
+ if (directChildIndex !== void 0) return null;
178
+ directChildIndex = index;
179
+ } else if (range.from < childRange.to && range.to > childRange.from)
180
+ return null;
181
+ }
182
+ return directChildIndex ?? "root-syntax";
183
+ }
184
+ function findInlineChildRunForRange(range, flowChildren, childRanges) {
185
+ if (!(flowChildren === void 0 || childRanges === void 0 || range.to <= range.from))
186
+ for (let startIndex = 0; startIndex < flowChildren.length; startIndex++) {
187
+ let firstChild = flowChildren[startIndex], firstRange = childRanges[startIndex];
188
+ if (firstChild?.kind !== "inline" || !firstRange || firstRange.from !== range.from || firstRange.to <= firstRange.from) continue;
189
+ let previousRange = firstRange;
190
+ for (let endIndex = startIndex + 1; endIndex < flowChildren.length; endIndex++) {
191
+ let child = flowChildren[endIndex], childRange = childRanges[endIndex];
192
+ if (child?.kind !== "inline" || !childRange || childRange.from !== previousRange.to || childRange.to <= childRange.from) break;
193
+ if (previousRange = childRange, previousRange.to === range.to)
194
+ return {
195
+ startIndex,
196
+ endIndex
197
+ };
198
+ if (previousRange.to > range.to) break;
199
+ }
200
+ }
201
+ }
202
+ function collectFlowOwnerBlocks(blocks) {
203
+ let flowOwnerBlocks = [], seenBlockIds = /* @__PURE__ */ new Set(), pendingBlocks = [...blocks], pendingNodes = [], visitedNodes = /* @__PURE__ */ new WeakSet();
204
+ for (let blockIndex = 0; blockIndex < pendingBlocks.length; blockIndex++) {
205
+ let block = pendingBlocks[blockIndex];
206
+ if (!block || seenBlockIds.has(block.id)) continue;
207
+ seenBlockIds.add(block.id), flowOwnerBlocks.push(block);
208
+ let meta = block.payload.meta, preparedTree = getActiveTrustedMdxNativeTree(meta);
209
+ for (preparedTree !== void 0 && pendingNodes.push(...preparedTree); pendingNodes.length > 0; ) {
210
+ let node = pendingNodes.pop();
211
+ !node || visitedNodes.has(node) || (visitedNodes.add(node), node.kind === "block" ? pendingBlocks.push(node.block) : (node.kind === "element" || node.kind === "component") && pendingNodes.push(...node.children));
212
+ }
213
+ }
214
+ return flowOwnerBlocks;
215
+ }
216
+ function hasWholeFlowRootMatch(block, childRange, matches) {
217
+ return matches.some(
218
+ (match) => match.wholeBlockFlowRoot && match.from === childRange.from && match.to === childRange.to && (match.id === block.id || block.payload.inline?.some(
219
+ (node) => node.kind === "trusted-mdx-inline" && node.ownerId === match.id && node.sourceRange?.from === childRange.from && node.sourceRange?.to === childRange.to
220
+ ) === !0)
221
+ );
222
+ }
223
+ function findPreparedTreeBlock(tree, childRange, sourceLength, exact = !1, wholeFlowRoots) {
224
+ if (!tree) return;
225
+ let pending = [...tree], owner, ownerWidth = -1;
226
+ for (; pending.length > 0; ) {
227
+ let node = pending.pop();
228
+ if (node)
229
+ if (node.kind === "block") {
230
+ let range = readSourceRange(node.block.payload.range, sourceLength);
231
+ if (!range) continue;
232
+ let wholeFlowRoot = wholeFlowRoots !== void 0 && hasWholeFlowRootMatch(node.block, childRange, wholeFlowRoots) && range.from === childRange.from && range.to <= childRange.to;
233
+ (exact ? range.from === childRange.from && range.to === childRange.to || wholeFlowRoot : range.from >= childRange.from && range.to <= childRange.to) && (wholeFlowRoots === void 0 || node.block.type === "mdx" || wholeFlowRoot) && range.to - range.from > ownerWidth && (owner = node.block, ownerWidth = range.to - range.from);
234
+ } else (node.kind === "element" || node.kind === "component") && pending.push(...node.children);
235
+ }
236
+ return owner;
237
+ }
238
+ function assertPreparedTreeOwnersFitFlowChildren(tree, childRanges, flowChildren, flowRange, sourceLength) {
239
+ if (!tree) return;
240
+ let pending = [...tree];
241
+ for (; pending.length > 0; ) {
242
+ let node = pending.pop();
243
+ if (node)
244
+ if (node.kind === "block") {
245
+ let range = readSourceRange(node.block.payload.range, sourceLength);
246
+ if (!range)
247
+ throw new Error("A trusted MDX flow region has a prepared worker block without a source span.");
248
+ if (range.from < flowRange.from || range.to > flowRange.to || range.from === flowRange.from && range.to === flowRange.to) continue;
249
+ if (childRanges === void 0)
250
+ throw new Error("A trusted MDX flow region has prepared tree owners but no direct-child spans.");
251
+ let inlineRun = node.block.type === "paragraph" && Array.isArray(node.block.payload.inline) && node.block.payload.inline.length > 0 ? findInlineChildRunForRange(range, flowChildren, childRanges) : void 0;
252
+ if (classifyFlowRange(range, childRanges) === null && inlineRun === void 0)
253
+ throw new Error("A trusted MDX flow region has prepared tree owners crossing direct-child boundaries.");
254
+ } else (node.kind === "element" || node.kind === "component") && pending.push(...node.children);
255
+ }
256
+ }
257
+ function collectFlowNativeBlocks(flowChildren, flowRange, blocks, rootOwnerId, sourceLength, matches, flowOwnerBlocks) {
258
+ let childRanges = readFlowChildRanges(flowChildren, flowRange, sourceLength);
259
+ if (childRanges === null)
260
+ throw new Error("A trusted MDX flow region has invalid or overlapping direct-child spans.");
261
+ let meta = flowOwnerBlocks.find((block) => block.id === rootOwnerId)?.payload.meta, preparedTree = getActiveTrustedMdxNativeTree(meta), preparedTrees = preparedTree === void 0 ? [] : [preparedTree], ownedBlockIds = [];
262
+ for (let block of blocks) {
263
+ if (block.id === rootOwnerId) continue;
264
+ let blockRange = readSourceRange(block.payload.range, sourceLength);
265
+ if (!blockRange || blockRange.from < flowRange.from || blockRange.to > flowRange.to || blockRange.from === flowRange.from && blockRange.to === flowRange.to) continue;
266
+ if (childRanges === void 0)
267
+ throw new Error("A trusted MDX flow region has worker owners but no direct-child spans.");
268
+ let ownership = classifyFlowRange(blockRange, childRanges), inlineRun = block.type === "paragraph" && Array.isArray(block.payload.inline) && block.payload.inline.length > 0 ? findInlineChildRunForRange(blockRange, flowChildren, childRanges) : void 0;
269
+ if (ownership === null && inlineRun === void 0)
270
+ throw new Error("A trusted MDX flow region has worker owners crossing direct-child boundaries.");
271
+ ownedBlockIds.push(block.id);
272
+ }
273
+ for (let tree of preparedTrees)
274
+ hasNativeBlockOwner(tree) && assertPreparedTreeOwnersFitFlowChildren(tree, childRanges, flowChildren, flowRange, sourceLength);
275
+ if (flowChildren === void 0 || flowChildren.length === 0)
276
+ return { childOwners: [], ownedBlockIds };
277
+ if (childRanges === void 0)
278
+ throw new Error("A trusted MDX flow region has native children but no direct-child spans.");
279
+ let groupedInlineOwners, registerGroupedInlineOwner = (block, kind) => {
280
+ if (block.id === rootOwnerId || block.type !== "paragraph" || !Array.isArray(block.payload.inline) || block.payload.inline.length === 0)
281
+ return;
282
+ let range = readSourceRange(block.payload.range, sourceLength);
283
+ if (!range) return;
284
+ let run = findInlineChildRunForRange(range, flowChildren, childRanges);
285
+ if (!run) return;
286
+ let groupedOwners = groupedInlineOwners ?? (groupedInlineOwners = new Array(flowChildren.length));
287
+ for (let index = run.startIndex; index <= run.endIndex; index++) {
288
+ let existing2 = groupedOwners[index];
289
+ if (existing2 && (existing2.block.id !== block.id || existing2.startIndex !== run.startIndex || existing2.endIndex !== run.endIndex))
290
+ throw new Error("A trusted MDX flow region has duplicate native owners for one inline child run.");
291
+ }
292
+ if (groupedOwners[run.startIndex]?.owner.kind === "block" && kind === "prepared-tree") return;
293
+ let candidate = {
294
+ startIndex: run.startIndex,
295
+ endIndex: run.endIndex,
296
+ block,
297
+ owner: kind === "block" ? { kind: "block", blockId: block.id } : { kind: "prepared-tree", blockId: block.id }
298
+ };
299
+ for (let index = run.startIndex; index <= run.endIndex; index++)
300
+ groupedOwners[index] = candidate;
301
+ };
302
+ for (let block of blocks)
303
+ registerGroupedInlineOwner(block, "block");
304
+ for (let tree of preparedTrees) {
305
+ let pending = [...tree], visited = /* @__PURE__ */ new WeakSet();
306
+ for (; pending.length > 0; ) {
307
+ let node = pending.pop();
308
+ !node || visited.has(node) || (visited.add(node), node.kind === "block" ? registerGroupedInlineOwner(node.block, "prepared-tree") : (node.kind === "element" || node.kind === "component") && pending.push(...node.children));
309
+ }
310
+ }
311
+ let groupedChildRanges;
312
+ for (let startIndex = 0; startIndex < (groupedInlineOwners?.length ?? 0); startIndex++) {
313
+ let groupedOwner = groupedInlineOwners?.[startIndex];
314
+ if (!(!groupedOwner || groupedOwner.startIndex !== startIndex))
315
+ for (let childIndex = groupedOwner.startIndex; childIndex <= groupedOwner.endIndex; childIndex++) {
316
+ let childRange = childRanges[childIndex];
317
+ if (!childRange)
318
+ throw new Error("A trusted MDX flow region has an invalid grouped inline child span.");
319
+ groupedChildRanges ?? (groupedChildRanges = /* @__PURE__ */ new Map()), groupedChildRanges.set(childRange.from, childRange.to);
320
+ }
321
+ }
322
+ if (groupedChildRanges !== void 0) {
323
+ for (let block of blocks) {
324
+ if (block.id === rootOwnerId) continue;
325
+ let blockRange = readSourceRange(block.payload.range, sourceLength);
326
+ if (blockRange && groupedChildRanges.get(blockRange.from) === blockRange.to)
327
+ throw new Error("A trusted MDX flow region has duplicate native owners inside a grouped inline run.");
328
+ }
329
+ for (let tree of preparedTrees) {
330
+ let pending = [...tree], visited = /* @__PURE__ */ new WeakSet();
331
+ for (; pending.length > 0; ) {
332
+ let node = pending.pop();
333
+ if (!(!node || visited.has(node)))
334
+ if (visited.add(node), node.kind === "block") {
335
+ let blockRange = readSourceRange(node.block.payload.range, sourceLength);
336
+ if (blockRange && groupedChildRanges.get(blockRange.from) === blockRange.to)
337
+ throw new Error("A trusted MDX flow region has duplicate native owners inside a grouped inline run.");
338
+ } else (node.kind === "element" || node.kind === "component") && pending.push(...node.children);
339
+ }
340
+ }
341
+ }
342
+ let childOwners = [];
343
+ for (let childIndex = 0; childIndex < flowChildren.length; childIndex++) {
344
+ let child = flowChildren[childIndex], childRange = childRanges?.[childIndex];
345
+ if (!child || !childRange)
346
+ throw new Error("A trusted MDX flow region has invalid direct-child spans.");
347
+ let groupedOwner = groupedInlineOwners?.[childIndex];
348
+ if (groupedOwner) {
349
+ if (groupedOwner.startIndex !== childIndex || child.kind !== "inline")
350
+ throw new Error("A trusted MDX flow region has an invalid grouped inline native owner.");
351
+ childOwners.push(groupedOwner.owner);
352
+ for (let coveredIndex = childIndex + 1; coveredIndex <= groupedOwner.endIndex; coveredIndex++)
353
+ childOwners.push({ kind: "continuation", ownerIndex: childIndex });
354
+ childIndex = groupedOwner.endIndex;
355
+ continue;
356
+ }
357
+ let ownerId, ownerWidth = -1;
358
+ if (child.kind !== "expression")
359
+ for (let block of blocks) {
360
+ if (block.id === rootOwnerId) continue;
361
+ let blockRange = readSourceRange(block.payload.range, sourceLength);
362
+ if (!blockRange || blockRange.from === flowRange.from && blockRange.to === flowRange.to || !(child.kind === "markdown" ? blockRange.from >= childRange.from && blockRange.to <= childRange.to : child.kind === "inline" || block.type === "mdx" ? blockRange.from === childRange.from && blockRange.to === childRange.to : blockRange.from === childRange.from && hasWholeFlowRootMatch(block, childRange, matches))) continue;
363
+ let width = blockRange.to - blockRange.from;
364
+ width > ownerWidth && (ownerId = block.id, ownerWidth = width);
365
+ }
366
+ if (ownerId !== void 0) {
367
+ childOwners.push({ kind: "block", blockId: ownerId });
368
+ continue;
369
+ }
370
+ if (child.kind !== "expression") {
371
+ let preparedOwner;
372
+ for (let tree of preparedTrees)
373
+ if (preparedOwner = findPreparedTreeBlock(
374
+ tree,
375
+ childRange,
376
+ sourceLength,
377
+ child.kind === "jsx",
378
+ child.kind === "jsx" ? matches : void 0
379
+ ), preparedOwner) break;
380
+ if (preparedOwner) {
381
+ if (child.kind === "inline") {
382
+ let preparedRange = readSourceRange(preparedOwner.payload.range, sourceLength);
383
+ if (preparedRange?.from !== childRange.from || preparedRange.to !== childRange.to)
384
+ throw new Error("A compiler-authored inline child has no exact prepared native owner.");
385
+ }
386
+ childOwners.push({ kind: "prepared-tree", blockId: preparedOwner.id });
387
+ continue;
388
+ }
389
+ }
390
+ if (child.kind === "markdown" || child.kind === "inline")
391
+ throw new Error("A compiler-authored Markdown child has no prepared native block owner.");
392
+ childOwners.push(null);
393
+ }
394
+ return { childOwners, ownedBlockIds };
395
+ }
396
+ function collectCompilerFlowBlockOwners(source, blocks, regions, matches) {
397
+ let ownerIds = new Set(matches.map((match) => match.id));
398
+ for (let region of regions) {
399
+ if (region.kind !== "render" || region.placement !== "flow" || !("rootElementName" in region)) continue;
400
+ let range = readSourceRange(region, source.length);
401
+ if (!range) continue;
402
+ let exactMatches = matches.filter((match) => match.from === range.from && match.to === range.to);
403
+ if (exactMatches.length > 0) {
404
+ for (let match of exactMatches) match.wholeBlockFlowRoot = !0;
405
+ continue;
406
+ }
407
+ let block = blocks.find((candidate) => {
408
+ let blockRange = readSourceRange(candidate.payload.range, source.length);
409
+ return blockRange !== null && blockRange.from === range.from && blockRange.to <= range.to;
410
+ });
411
+ !block || ownerIds.has(block.id) || (addMdxOwner(matches, block.id, `${block.type} compiler flow root`, range, source.length), matches[matches.length - 1].wholeBlockFlowRoot = !0, ownerIds.add(block.id));
412
+ }
413
+ }
414
+ function collectPreparedNestedOwners(prepared, sourceLength, matches) {
415
+ if (typeof prepared != "object" || prepared === null || Array.isArray(prepared) || !("children" in prepared) || !Array.isArray(prepared.children))
416
+ return;
417
+ let visited = /* @__PURE__ */ new WeakSet(), pending = [];
418
+ for (let index = 0; index < prepared.children.length; index++) {
419
+ let child = prepared.children[index];
420
+ pending.push(child);
421
+ }
422
+ for (; pending.length > 0; ) {
423
+ let value = pending.pop();
424
+ if (typeof value != "object" || value === null || Array.isArray(value) || visited.has(value))
425
+ continue;
426
+ visited.add(value);
427
+ let node = readSnapshotFields(value), nodeProps = node?.props && typeof node.props == "object" ? node.props : void 0;
428
+ if (nodeProps && "inline" in nodeProps && collectInlineOwners(nodeProps.inline, sourceLength, matches), node && isNestedMdxType(node.type) && addMdxOwner(matches, node.id, `${node.type} segment`, node.range, sourceLength), !(!node || !Array.isArray(node.children)))
429
+ for (let index = 0; index < node.children.length; index++) {
430
+ let child = node.children[index];
431
+ pending.push(child);
432
+ }
433
+ }
434
+ }
435
+ function collectHtmlTreeOwners(tree, sourceLength, matches) {
436
+ if (!Array.isArray(tree)) return;
437
+ let pending = [...tree], visited = /* @__PURE__ */ new WeakSet();
438
+ for (; pending.length > 0; ) {
439
+ let current = pending.pop();
440
+ if (!(typeof current != "object" || current === null || visited.has(current))) {
441
+ if (visited.add(current), Array.isArray(current)) {
442
+ pending.push(...current);
443
+ continue;
444
+ }
445
+ if ("kind" in current && current.kind === "block" && "block" in current) {
446
+ let candidate = current.block;
447
+ if (typeof candidate == "object" && candidate !== null && !Array.isArray(candidate) && "id" in candidate && typeof candidate.id == "string" && "type" in candidate && typeof candidate.type == "string" && "payload" in candidate && typeof candidate.payload == "object" && candidate.payload !== null) {
448
+ let block = candidate, meta = block.payload.meta;
449
+ if (block.type === "mdx" && addMdxOwner(
450
+ matches,
451
+ block.id,
452
+ "nested block",
453
+ block.payload.range,
454
+ sourceLength
455
+ ), collectInlineOwners(block.payload.inline, sourceLength, matches), meta) {
456
+ if (block.type === "paragraph" && Array.isArray(meta.mixedSegments))
457
+ for (let index = 0; index < meta.mixedSegments.length; index++) {
458
+ let segment = meta.mixedSegments[index];
459
+ typeof segment != "object" || segment === null || Array.isArray(segment) || !("kind" in segment) || segment.kind !== "mdx" || addMdxOwner(
460
+ matches,
461
+ `${block.id}::paragraph:segment:${index}`,
462
+ "paragraph segment",
463
+ "range" in segment ? segment.range : void 0,
464
+ sourceLength
465
+ );
466
+ }
467
+ collectInlineOwners(meta.header, sourceLength, matches), collectInlineOwners(meta.rows, sourceLength, matches), collectPreparedNestedOwners(meta.preparedNested, sourceLength, matches);
468
+ let preparedTree = getActiveTrustedMdxNativeTree(meta);
469
+ preparedTree !== void 0 && pending.push(preparedTree);
470
+ }
471
+ }
472
+ }
473
+ "children" in current && Array.isArray(current.children) && pending.push(...current.children);
474
+ }
475
+ }
476
+ }
477
+ function collectMdxOwners(source, blocks) {
478
+ let matches = [];
479
+ for (let block of blocks) {
480
+ if (block.type === "mdx" && addMdxOwner(
481
+ matches,
482
+ block.id,
483
+ "block",
484
+ block.payload.range,
485
+ source.length
486
+ ), block.type === "paragraph") {
487
+ let segments = block.payload.meta?.mixedSegments;
488
+ if (Array.isArray(segments))
489
+ for (let index = 0; index < segments.length; index++) {
490
+ let segment = segments[index];
491
+ typeof segment != "object" || segment === null || Array.isArray(segment) || !("kind" in segment) || segment.kind !== "mdx" || addMdxOwner(
492
+ matches,
493
+ `${block.id}::paragraph:segment:${index}`,
494
+ "paragraph segment",
495
+ "range" in segment ? segment.range : void 0,
496
+ source.length
497
+ );
498
+ }
499
+ }
500
+ collectInlineOwners(block.payload.inline, source.length, matches);
501
+ let tableMeta = block.payload.meta;
502
+ if (tableMeta) {
503
+ collectInlineOwners(tableMeta.header, source.length, matches), collectInlineOwners(tableMeta.rows, source.length, matches), collectPreparedNestedOwners(tableMeta.preparedNested, source.length, matches);
504
+ let preparedTree = getActiveTrustedMdxNativeTree(tableMeta);
505
+ preparedTree !== void 0 && collectHtmlTreeOwners(preparedTree, source.length, matches);
506
+ }
507
+ }
508
+ let unique = /* @__PURE__ */ new Map();
509
+ for (let match of matches) {
510
+ let existing = unique.get(match.id);
511
+ existing ? (existing.from !== match.from || existing.to !== match.to) && (existing.ambiguous = !0) : unique.set(match.id, match);
512
+ }
513
+ return Array.from(unique.values());
514
+ }
515
+ function describeOwner(match) {
516
+ return match.label === "block" ? `MDX block "${match.id}"` : `MDX ${match.label} "${match.id}"`;
517
+ }
518
+ function isExactNativeMdxAliasRegion(region, owners) {
519
+ if (owners.length !== 2) return !1;
520
+ let first = owners[0], second = owners[1];
521
+ return !first || !second || first.from === null || first.to === null || first.from !== second.from || first.to !== second.to || region.from !== first.from || region.to !== first.to ? !1 : (first.label === "block" || first.label === "nested block") && second.label === "inline expression" && second.id.startsWith(`${first.id}::native-mdx:`) || (second.label === "block" || second.label === "nested block") && first.label === "inline expression" && first.id.startsWith(`${second.id}::native-mdx:`);
522
+ }
523
+ function placementFields(match) {
524
+ return match.placement === null ? {} : { placement: match.placement };
525
+ }
526
+ function projectMdxBlocks(source, blocks, regions, regionComponents) {
527
+ let projections = /* @__PURE__ */ new Map(), flowOwnerBlocks = collectFlowOwnerBlocks(blocks), matches = collectMdxOwners(source, blocks);
528
+ collectCompilerFlowBlockOwners(source, flowOwnerBlocks, regions, matches);
529
+ let ownersByRegion = /* @__PURE__ */ new Map();
530
+ for (let region of regions) {
531
+ let regionRange = readSourceRange(region, source.length);
532
+ if (!regionRange) continue;
533
+ let owners = [];
534
+ for (let match of matches) {
535
+ if (match.from === null || match.to === null) continue;
536
+ let ownerFrom = match.from, ownerTo = match.to;
537
+ if (regionRange.to <= match.from || regionRange.from >= match.to) continue;
538
+ let compilerFlowRoot = region.kind === "render" && "rootElementName" in region, regionContainsOwner = regionRange.from <= match.from && regionRange.to >= match.to;
539
+ if (region.kind !== "module" && (regionRange.from < match.from || regionRange.to > match.to)) {
540
+ if (compilerFlowRoot && regionContainsOwner) continue;
541
+ match.ambiguous = !0;
542
+ continue;
543
+ }
544
+ if (!(match.wholeBlockFlowRoot && regionRange.from >= ownerFrom && regionRange.to <= ownerTo && (regionRange.from > ownerFrom || regionRange.to < ownerTo)) && (match.regions.push(region), region.kind !== "module")) {
545
+ if (owners.push(match), region.placement !== "flow" && region.placement !== "inline" || match.placement !== null && match.placement !== region.placement ? match.ambiguous = !0 : match.placement = region.placement, region.kind === "render" && region.placement === "flow" && "rootElementName" in region && regionRange.from === match.from && regionRange.to === match.to && region.kind === "render" && "rootElementName" in region) {
546
+ match.wholeBlockFlowRoot = !0;
547
+ let flowNativeBlocks = collectFlowNativeBlocks(
548
+ region.flowChildren,
549
+ regionRange,
550
+ blocks,
551
+ match.id,
552
+ source.length,
553
+ matches,
554
+ flowOwnerBlocks
555
+ );
556
+ match.nativeFlowOwnedBlockIds = flowNativeBlocks.ownedBlockIds, match.nativeChildOwners = flowNativeBlocks.childOwners, match.flowChildren = region.flowChildren;
557
+ }
558
+ match.nativeChildren = match.nativeChildOwners.some((owner) => owner !== null) && match.placement === "flow", "rootElementName" in region && (match.rootElementName !== void 0 && match.rootElementName !== region.rootElementName ? match.ambiguous = !0 : match.rootElementName = region.rootElementName);
559
+ }
560
+ }
561
+ owners.length > 1 && ownersByRegion.set(region, owners);
562
+ }
563
+ for (let [region, owners] of ownersByRegion)
564
+ if (!isExactNativeMdxAliasRegion(region, owners))
565
+ for (let owner of owners) owner.ambiguous = !0;
566
+ for (let match of matches) {
567
+ let description = describeOwner(match);
568
+ if (match.from === null || match.to === null) {
569
+ projections.set(match.id, {
570
+ kind: "unmapped",
571
+ diagnostic: `${description} has no valid authored source range.`
572
+ });
573
+ continue;
574
+ }
575
+ if (!match.ambiguous && match.regions.length > 0) {
576
+ let orderedRegions = match.regions.slice().sort((left, right) => left.from - right.from || left.to - right.to), coveredUntil = match.from;
577
+ for (let region of orderedRegions) {
578
+ let from = Math.max(match.from, region.from), to = Math.min(match.to, region.to);
579
+ if (from < coveredUntil || source.slice(coveredUntil, from).trim().length > 0) {
580
+ match.ambiguous = !0;
581
+ break;
582
+ }
583
+ coveredUntil = to;
584
+ }
585
+ !match.ambiguous && source.slice(coveredUntil, match.to).trim().length > 0 && (match.ambiguous = !0);
586
+ }
587
+ if (match.ambiguous || match.regions.length === 0) {
588
+ projections.set(match.id, {
589
+ kind: "unmapped",
590
+ diagnostic: match.ambiguous ? `${description} cannot be mapped exactly to unique authored regions.` : `${description} (${match.from}..${match.to}) has no corresponding authored MDX region.`,
591
+ ...placementFields(match)
592
+ });
593
+ continue;
594
+ }
595
+ let renderRegions = match.regions.filter((region) => region.kind === "render");
596
+ if (renderRegions.length > 0) {
597
+ let placement = match.placement;
598
+ if (placement === null) {
599
+ projections.set(match.id, {
600
+ kind: "unmapped",
601
+ diagnostic: `${description} has render regions without compiler placement provenance.`
602
+ });
603
+ continue;
604
+ }
605
+ if (match.nativeChildren && match.rootElementName === void 0) {
606
+ projections.set(match.id, {
607
+ kind: "unmapped",
608
+ diagnostic: `${description} has prepared native children but no compiler-authored flow JSX root.`,
609
+ placement
610
+ });
611
+ continue;
612
+ }
613
+ let components = [], missingKey = null;
614
+ for (let region of renderRegions) {
615
+ if (!Object.prototype.hasOwnProperty.call(regionComponents, region.key)) {
616
+ missingKey = region.key;
617
+ break;
618
+ }
619
+ let component = regionComponents[region.key];
620
+ if (typeof component != "function") {
621
+ missingKey = region.key;
622
+ break;
623
+ }
624
+ components.push(component);
625
+ }
626
+ projections.set(
627
+ match.id,
628
+ missingKey === null ? {
629
+ kind: "render",
630
+ regions: Object.freeze(components),
631
+ placement,
632
+ ...match.nativeChildren ? { nativeChildren: !0 } : {},
633
+ ...match.nativeChildOwners.length > 0 ? { nativeChildOwners: Object.freeze([...match.nativeChildOwners]) } : {},
634
+ ...match.flowChildren ? { flowChildren: match.flowChildren } : {},
635
+ ...match.nativeFlowOwnedBlockIds.length > 0 ? { nativeFlowOwnedBlockIds: Object.freeze([...match.nativeFlowOwnedBlockIds]) } : {},
636
+ ...match.wholeBlockFlowRoot ? { wholeBlockFlowRoot: !0 } : {},
637
+ ...match.rootElementName === void 0 ? {} : { rootElementName: match.rootElementName }
638
+ } : {
639
+ kind: "unmapped",
640
+ diagnostic: `No evaluated renderer exists for MDX region "${missingKey}".`,
641
+ placement
642
+ }
643
+ );
644
+ continue;
645
+ }
646
+ if (match.regions.some((region) => region.kind === "module")) {
647
+ projections.set(match.id, { kind: "module" });
648
+ continue;
649
+ }
650
+ projections.set(match.id, {
651
+ kind: "unmapped",
652
+ diagnostic: `${description} has no renderable or module region.`
653
+ });
654
+ }
655
+ let moduleRanges = [];
656
+ for (let region of regions) {
657
+ if (region.kind !== "module") continue;
658
+ let range = readSourceRange(region, source.length);
659
+ range && moduleRanges.push(range);
660
+ }
661
+ for (let block of blocks) {
662
+ let range = readSourceRange(block.payload.range, source.length);
663
+ range && moduleRanges.some((module2) => module2.from <= range.from && module2.to >= range.to) && projections.set(block.id, { kind: "module" });
664
+ }
665
+ let nativeChildIds = /* @__PURE__ */ new Set();
666
+ for (let projection of projections.values())
667
+ if (projection.kind === "render")
668
+ for (let id of projection.nativeFlowOwnedBlockIds ?? []) nativeChildIds.add(id);
669
+ for (let id of nativeChildIds) {
670
+ let projection = projections.get(id);
671
+ projection ? projections.set(id, { ...projection, nativeFlowParent: !0 }) : projections.set(id, { kind: "native-child", nativeFlowParent: !0 });
672
+ }
673
+ return Object.freeze(Object.fromEntries(projections));
674
+ }
675
+
676
+ // src/trusted-mdx/server.tsx
677
+ async function projectTrustedMdxServerDocument(options) {
678
+ let components = options.components ? Object.freeze({ ...options.components }) : Object.freeze({}), evaluated = await evaluateCompiledMdx(options.artifact.code, { imports: options.imports }, () => !0);
679
+ if (!evaluated)
680
+ throw new Error("Trusted MDX server evaluation was unexpectedly cancelled.");
681
+ let regionComponents = evaluated.createRegions({ components }), projections = projectMdxBlocks(options.source, options.blocks, options.artifact.regions, regionComponents), regions = [];
682
+ for (let [ownerId, projection] of Object.entries(projections)) {
683
+ if (projection.kind === "native-child") {
684
+ regions.push(Object.freeze({ ownerId, kind: "native-child" }));
685
+ continue;
686
+ }
687
+ if (projection.kind === "module") {
688
+ regions.push(Object.freeze({ ownerId, kind: "module", ...projection.nativeFlowParent ? { nativeFlowParent: !0 } : {} }));
689
+ continue;
690
+ }
691
+ if (projection.kind === "unmapped")
692
+ throw new Error(projection.diagnostic);
693
+ if (projection.kind !== "render")
694
+ throw new Error(`Trusted MDX owner "${ownerId}" has no server-renderable compiler regions.`);
695
+ if (projection.nativeChildren && (projection.rootElementName === void 0 || projection.regions.length !== 1))
696
+ throw new Error(`Trusted MDX owner "${ownerId}" has no unique compiler-authored native-children root.`);
697
+ let nativeChildrenOverride = projection.nativeChildren ? (fallback) => {
698
+ let owners = projection.nativeChildOwners, flowChildren = projection.flowChildren;
699
+ if (!owners || !flowChildren || owners.length !== flowChildren.length)
700
+ throw new Error(`Trusted MDX owner "${ownerId}" has misaligned native child owners.`);
701
+ assertTrustedMdxNativeChildContinuations(owners, flowChildren);
702
+ let children = owners.map((owner, index) => {
703
+ if (owner?.kind === "continuation") return null;
704
+ if (owner !== null)
705
+ return import_react2.default.createElement(import_trusted_mdx_native_children.TrustedMdxNativeChildrenSlot, {
706
+ index,
707
+ key: `${owner.kind}:${owner.blockId}:${index}`
708
+ });
709
+ let flowChild = flowChildren[index];
710
+ if (flowChild === void 0)
711
+ throw new Error(`Trusted MDX owner "${ownerId}" has a missing native flow child at index ${index}.`);
712
+ return import_react2.default.createElement(
713
+ import_react2.default.Fragment,
714
+ { key: `source:${flowChild.kind}:${flowChild.from}:${flowChild.to}` },
715
+ fallback(index)
716
+ );
717
+ });
718
+ return import_react2.default.createElement(import_trusted_mdx_native_children.TrustedMdxNativeChildrenSlot, null, children);
719
+ } : void 0, content = import_react2.default.createElement(
720
+ import_react2.default.Fragment,
721
+ null,
722
+ ...projection.regions.map((Region, index) => import_react2.default.createElement(
723
+ import_react2.default.Fragment,
724
+ { key: `${ownerId}:${index}` },
725
+ Region({
726
+ components,
727
+ ...nativeChildrenOverride === void 0 ? {} : { children: nativeChildrenOverride }
728
+ })
729
+ ))
730
+ );
731
+ regions.push(
732
+ Object.freeze({
733
+ ownerId,
734
+ kind: "render",
735
+ content,
736
+ placement: projection.placement,
737
+ ...projection.nativeChildren ? { nativeChildren: !0 } : {},
738
+ ...projection.nativeChildOwners ? { nativeChildOwners: projection.nativeChildOwners } : {},
739
+ ...projection.flowChildren ? { flowChildren: projection.flowChildren } : {},
740
+ ...projection.nativeFlowOwnedBlockIds ? { nativeFlowOwnedBlockIds: projection.nativeFlowOwnedBlockIds } : {},
741
+ ...projection.wholeBlockFlowRoot ? { wholeBlockFlowRoot: !0 } : {},
742
+ ...projection.nativeFlowParent ? { nativeFlowParent: !0 } : {},
743
+ ...projection.rootElementName === void 0 ? {} : { rootElementName: projection.rootElementName }
744
+ })
745
+ );
746
+ }
747
+ return Object.freeze({ regions: Object.freeze(regions), layout: evaluated.layout ?? null });
748
+ }
749
+ // Annotate the CommonJS export names for ESM import in node:
750
+ 0 && (module.exports = {
751
+ projectTrustedMdxServerDocument
752
+ });