emdash 1.3.1 → 1.4.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 (1338) hide show
  1. package/dist/action-token-SK8zyN7w.mjs +26 -0
  2. package/dist/action-token-SK8zyN7w.mjs.map +1 -0
  3. package/dist/activation-CGlyigmg.mjs +387 -0
  4. package/dist/activation-CGlyigmg.mjs.map +1 -0
  5. package/dist/adapters-D9a1PfqH.d.mts +173 -0
  6. package/dist/adapters-D9a1PfqH.d.mts.map +1 -0
  7. package/dist/after-32yNRvd2.mjs +99 -0
  8. package/dist/after-32yNRvd2.mjs.map +1 -0
  9. package/dist/allowed-origins-CEug-p0t.mjs +116 -0
  10. package/dist/allowed-origins-CEug-p0t.mjs.map +1 -0
  11. package/dist/api/route-utils.d.mts +4 -4
  12. package/dist/api/route-utils.mjs +52 -53
  13. package/dist/api/route-utils.mjs.map +1 -1
  14. package/dist/api/schemas/index.d.mts +1 -1
  15. package/dist/api/schemas/index.mjs +9 -9
  16. package/dist/api--PYoyeTo.mjs +5098 -0
  17. package/dist/api--PYoyeTo.mjs.map +1 -0
  18. package/dist/api-tokens-DqSlkDVI.mjs +9 -0
  19. package/dist/api-tokens-DqSlkDVI.mjs.map +1 -0
  20. package/dist/api-tokens-GNCsIegW.mjs +173 -0
  21. package/dist/api-tokens-GNCsIegW.mjs.map +1 -0
  22. package/dist/apply-DVnupNeS.mjs +1760 -0
  23. package/dist/apply-DVnupNeS.mjs.map +1 -0
  24. package/dist/approvals-DTtYSB27.mjs +460 -0
  25. package/dist/approvals-DTtYSB27.mjs.map +1 -0
  26. package/dist/artifact-fetch-DIh7iyOV.mjs +659 -0
  27. package/dist/artifact-fetch-DIh7iyOV.mjs.map +1 -0
  28. package/dist/artifacts-Dvdp2KK-.mjs +323 -0
  29. package/dist/artifacts-Dvdp2KK-.mjs.map +1 -0
  30. package/dist/astro/index.d.mts +14 -13
  31. package/dist/astro/index.d.mts.map +1 -1
  32. package/dist/astro/index.mjs +52 -12
  33. package/dist/astro/index.mjs.map +1 -1
  34. package/dist/astro/middleware/auth.d.mts +12 -11
  35. package/dist/astro/middleware/auth.d.mts.map +1 -1
  36. package/dist/astro/middleware/auth.mjs +13 -11
  37. package/dist/astro/middleware/auth.mjs.map +1 -1
  38. package/dist/astro/middleware/media-usage-write-fence.mjs +5 -5
  39. package/dist/astro/middleware/redirect.mjs +17 -17
  40. package/dist/astro/middleware/request-context.mjs +12 -7
  41. package/dist/astro/middleware/request-context.mjs.map +1 -1
  42. package/dist/astro/middleware/setup.mjs +1 -1
  43. package/dist/astro/middleware.d.mts +12 -11
  44. package/dist/astro/middleware.d.mts.map +1 -1
  45. package/dist/astro/middleware.mjs +116 -116
  46. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +13 -13
  47. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +13 -13
  48. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +6 -6
  49. package/dist/astro/routes/api/admin/api-tokens/index.mjs +7 -7
  50. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +5 -5
  51. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +15 -15
  52. package/dist/astro/routes/api/admin/byline-fields/index.mjs +15 -15
  53. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +15 -15
  54. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +23 -24
  55. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  56. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +23 -24
  57. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  58. package/dist/astro/routes/api/admin/bylines/index.mjs +23 -24
  59. package/dist/astro/routes/api/admin/bylines/index.mjs.map +1 -1
  60. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +19 -19
  61. package/dist/astro/routes/api/admin/comments/_id_.mjs +8 -8
  62. package/dist/astro/routes/api/admin/comments/bulk.mjs +18 -18
  63. package/dist/astro/routes/api/admin/comments/counts.mjs +8 -8
  64. package/dist/astro/routes/api/admin/comments/index.mjs +18 -18
  65. package/dist/astro/routes/api/admin/core-update.mjs +7 -7
  66. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +5 -5
  67. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +4 -4
  68. package/dist/astro/routes/api/admin/media-usage/activation.mjs +20 -20
  69. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +21 -21
  70. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +21 -21
  71. package/dist/astro/routes/api/admin/media-usage/progress.mjs +24 -24
  72. package/dist/astro/routes/api/admin/media-usage/repair.mjs +30 -30
  73. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +21 -21
  74. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +21 -21
  75. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +5 -5
  76. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +5 -5
  77. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +8 -8
  78. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +8 -8
  79. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +74 -75
  80. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  81. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +6 -6
  82. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +73 -74
  83. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  84. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +73 -74
  85. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  86. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +84 -85
  87. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  88. package/dist/astro/routes/api/admin/plugins/index.mjs +74 -75
  89. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  90. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +6 -6
  91. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +73 -74
  92. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  93. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +83 -84
  94. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  95. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +73 -74
  96. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  97. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +73 -74
  98. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  99. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +85 -86
  100. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  101. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +8 -8
  102. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +75 -76
  103. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  104. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs +6 -6
  105. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +74 -75
  106. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -1
  107. package/dist/astro/routes/api/admin/plugins/updates.mjs +73 -74
  108. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  109. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +5 -5
  110. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +73 -74
  111. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  112. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +6 -6
  113. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +73 -74
  114. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  115. package/dist/astro/routes/api/admin/transfer/_...path_.mjs +3 -3
  116. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs +40 -41
  117. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs.map +1 -1
  118. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs +40 -41
  119. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs.map +1 -1
  120. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs +42 -43
  121. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs.map +1 -1
  122. package/dist/astro/routes/api/admin/transfer/capabilities.mjs +42 -43
  123. package/dist/astro/routes/api/admin/transfer/capabilities.mjs.map +1 -1
  124. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs +42 -43
  125. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs.map +1 -1
  126. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs +43 -44
  127. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs.map +1 -1
  128. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs +43 -44
  129. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs.map +1 -1
  130. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs +42 -43
  131. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs.map +1 -1
  132. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs +43 -44
  133. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs.map +1 -1
  134. package/dist/astro/routes/api/admin/transfer/exports/index.mjs +44 -45
  135. package/dist/astro/routes/api/admin/transfer/exports/index.mjs.map +1 -1
  136. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs +42 -43
  137. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs.map +1 -1
  138. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs +42 -43
  139. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs.map +1 -1
  140. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs +44 -45
  141. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs.map +1 -1
  142. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs +42 -43
  143. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs.map +1 -1
  144. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs +44 -45
  145. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs.map +1 -1
  146. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs +42 -43
  147. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs.map +1 -1
  148. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs +42 -43
  149. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs.map +1 -1
  150. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs +44 -45
  151. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs.map +1 -1
  152. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs +42 -43
  153. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs.map +1 -1
  154. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs +42 -43
  155. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs.map +1 -1
  156. package/dist/astro/routes/api/admin/transfer/imports/index.mjs +44 -45
  157. package/dist/astro/routes/api/admin/transfer/imports/index.mjs.map +1 -1
  158. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
  159. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +3 -3
  160. package/dist/astro/routes/api/admin/users/_id_/index.mjs +13 -13
  161. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +5 -5
  162. package/dist/astro/routes/api/admin/users/index.mjs +13 -13
  163. package/dist/astro/routes/api/auth/dev-bypass.mjs +5 -5
  164. package/dist/astro/routes/api/auth/handover.mjs +6 -6
  165. package/dist/astro/routes/api/auth/invite/accept.mjs +3 -3
  166. package/dist/astro/routes/api/auth/invite/complete.mjs +19 -19
  167. package/dist/astro/routes/api/auth/invite/index.mjs +15 -15
  168. package/dist/astro/routes/api/auth/invite/register-options.mjs +16 -16
  169. package/dist/astro/routes/api/auth/logout.mjs +4 -4
  170. package/dist/astro/routes/api/auth/magic-link/send.mjs +18 -18
  171. package/dist/astro/routes/api/auth/magic-link/verify.mjs +15 -15
  172. package/dist/astro/routes/api/auth/me.mjs +14 -14
  173. package/dist/astro/routes/api/auth/mode.mjs +4 -4
  174. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +9 -9
  175. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  176. package/dist/astro/routes/api/auth/passkey/_id_.mjs +13 -13
  177. package/dist/astro/routes/api/auth/passkey/index.mjs +3 -3
  178. package/dist/astro/routes/api/auth/passkey/options.mjs +19 -19
  179. package/dist/astro/routes/api/auth/passkey/register/options.mjs +16 -16
  180. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +17 -17
  181. package/dist/astro/routes/api/auth/passkey/verify.mjs +19 -19
  182. package/dist/astro/routes/api/auth/signup/complete.mjs +19 -19
  183. package/dist/astro/routes/api/auth/signup/request.mjs +17 -17
  184. package/dist/astro/routes/api/auth/signup/verify.mjs +3 -3
  185. package/dist/astro/routes/api/calendar.mjs +14 -14
  186. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +14 -14
  187. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +20 -20
  188. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +4 -4
  189. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +18 -18
  190. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +4 -4
  191. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +17 -17
  192. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +5 -5
  193. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +10 -10
  194. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +33 -33
  195. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +18 -18
  196. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +35 -35
  197. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +35 -35
  198. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +5 -5
  199. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +4 -4
  200. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +18 -18
  201. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +26 -26
  202. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +4 -4
  203. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +18 -18
  204. package/dist/astro/routes/api/content/_collection_/_id_.mjs +18 -18
  205. package/dist/astro/routes/api/content/_collection_/authors.mjs +4 -4
  206. package/dist/astro/routes/api/content/_collection_/index.mjs +14 -14
  207. package/dist/astro/routes/api/content/_collection_/trash.mjs +14 -14
  208. package/dist/astro/routes/api/dashboard.mjs +11 -11
  209. package/dist/astro/routes/api/dev/emails.mjs +4 -4
  210. package/dist/astro/routes/api/dev/scheduled-tasks.mjs +112 -112
  211. package/dist/astro/routes/api/health.mjs +5 -5
  212. package/dist/astro/routes/api/import/probe.d.mts +3 -2
  213. package/dist/astro/routes/api/import/probe.d.mts.map +1 -1
  214. package/dist/astro/routes/api/import/probe.mjs +28 -28
  215. package/dist/astro/routes/api/import/wordpress/analyze.d.mts +4 -3
  216. package/dist/astro/routes/api/import/wordpress/analyze.d.mts.map +1 -1
  217. package/dist/astro/routes/api/import/wordpress/analyze.mjs +6 -28
  218. package/dist/astro/routes/api/import/wordpress/analyze.mjs.map +1 -1
  219. package/dist/astro/routes/api/import/wordpress/execute.d.mts +12 -11
  220. package/dist/astro/routes/api/import/wordpress/execute.d.mts.map +1 -1
  221. package/dist/astro/routes/api/import/wordpress/execute.mjs +26 -27
  222. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  223. package/dist/astro/routes/api/import/wordpress/media.d.mts +12 -11
  224. package/dist/astro/routes/api/import/wordpress/media.d.mts.map +1 -1
  225. package/dist/astro/routes/api/import/wordpress/media.mjs +18 -18
  226. package/dist/astro/routes/api/import/wordpress/prepare.mjs +19 -19
  227. package/dist/astro/routes/api/import/wordpress/prepare.mjs.map +1 -1
  228. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +13 -12
  229. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts.map +1 -1
  230. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +29 -29
  231. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +28 -28
  232. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +12 -11
  233. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts.map +1 -1
  234. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +38 -39
  235. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  236. package/dist/astro/routes/api/manifest.mjs +5 -5
  237. package/dist/astro/routes/api/mcp.mjs +96 -97
  238. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  239. package/dist/astro/routes/api/media/_id_/confirm.mjs +19 -19
  240. package/dist/astro/routes/api/media/_id_/replace.mjs +15 -15
  241. package/dist/astro/routes/api/media/_id_/upload.mjs +8 -8
  242. package/dist/astro/routes/api/media/_id_/usage.mjs +32 -32
  243. package/dist/astro/routes/api/media/_id_.mjs +30 -30
  244. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +5 -5
  245. package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
  246. package/dist/astro/routes/api/media/file/_...key_.mjs +57 -11
  247. package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
  248. package/dist/astro/routes/api/media/folders/_id_.mjs +15 -15
  249. package/dist/astro/routes/api/media/folders/index.mjs +15 -15
  250. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +4 -4
  251. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +4 -4
  252. package/dist/astro/routes/api/media/providers/index.mjs +4 -4
  253. package/dist/astro/routes/api/media/upload-url.mjs +17 -17
  254. package/dist/astro/routes/api/media.mjs +34 -34
  255. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +20 -19
  256. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  257. package/dist/astro/routes/api/menus/_name_/items.mjs +20 -19
  258. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  259. package/dist/astro/routes/api/menus/_name_/reorder.mjs +20 -19
  260. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  261. package/dist/astro/routes/api/menus/_name_/translations.mjs +20 -19
  262. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  263. package/dist/astro/routes/api/menus/_name_.mjs +20 -19
  264. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  265. package/dist/astro/routes/api/menus/index.mjs +20 -19
  266. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  267. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  268. package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -7
  269. package/dist/astro/routes/api/oauth/device/code.mjs +11 -11
  270. package/dist/astro/routes/api/oauth/device/token.mjs +10 -10
  271. package/dist/astro/routes/api/oauth/register.mjs +7 -7
  272. package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -7
  273. package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -7
  274. package/dist/astro/routes/api/oauth/token.d.mts.map +1 -1
  275. package/dist/astro/routes/api/oauth/token.mjs +8 -8
  276. package/dist/astro/routes/api/oauth/token.mjs.map +1 -1
  277. package/dist/astro/routes/api/openapi.json.mjs +20 -20
  278. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +10 -10
  279. package/dist/astro/routes/api/redirects/404s/index.mjs +21 -21
  280. package/dist/astro/routes/api/redirects/404s/summary.mjs +21 -21
  281. package/dist/astro/routes/api/redirects/_id_.mjs +22 -22
  282. package/dist/astro/routes/api/redirects/index.mjs +22 -22
  283. package/dist/astro/routes/api/relations/_id_/index.mjs +35 -35
  284. package/dist/astro/routes/api/relations/index.mjs +35 -35
  285. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +4 -4
  286. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +17 -17
  287. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs +73 -74
  288. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs.map +1 -1
  289. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs +73 -74
  290. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs.map +1 -1
  291. package/dist/astro/routes/api/schema/block-types/index.mjs +73 -74
  292. package/dist/astro/routes/api/schema/block-types/index.mjs.map +1 -1
  293. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +73 -74
  294. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  295. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +73 -74
  296. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  297. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +73 -74
  298. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  299. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +73 -74
  300. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  301. package/dist/astro/routes/api/schema/collections/index.mjs +73 -74
  302. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  303. package/dist/astro/routes/api/schema/collections/reorder.mjs +73 -74
  304. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  305. package/dist/astro/routes/api/schema/index.mjs +17 -17
  306. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +73 -74
  307. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  308. package/dist/astro/routes/api/schema/orphans/index.mjs +73 -74
  309. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  310. package/dist/astro/routes/api/search/enable.mjs +20 -19
  311. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  312. package/dist/astro/routes/api/search/index.mjs +19 -18
  313. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  314. package/dist/astro/routes/api/search/rebuild.mjs +20 -19
  315. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  316. package/dist/astro/routes/api/search/stats.mjs +10 -9
  317. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  318. package/dist/astro/routes/api/search/suggest.mjs +19 -18
  319. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  320. package/dist/astro/routes/api/sections/_slug_.mjs +19 -18
  321. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  322. package/dist/astro/routes/api/sections/index.mjs +19 -18
  323. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  324. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -7
  325. package/dist/astro/routes/api/settings/backups/archives/index.mjs +7 -7
  326. package/dist/astro/routes/api/settings/backups/export.mjs +7 -7
  327. package/dist/astro/routes/api/settings/backups/index.mjs +8 -8
  328. package/dist/astro/routes/api/settings/domain-notify.mjs +9 -9
  329. package/dist/astro/routes/api/settings/domain.mjs +21 -21
  330. package/dist/astro/routes/api/settings/email.mjs +5 -5
  331. package/dist/astro/routes/api/settings.mjs +27 -27
  332. package/dist/astro/routes/api/setup/admin-verify.mjs +22 -22
  333. package/dist/astro/routes/api/setup/admin.mjs +17 -17
  334. package/dist/astro/routes/api/setup/dev-bypass.mjs +45 -46
  335. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  336. package/dist/astro/routes/api/setup/dev-reset.mjs +3 -3
  337. package/dist/astro/routes/api/setup/index.mjs +51 -52
  338. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  339. package/dist/astro/routes/api/setup/status.mjs +5 -5
  340. package/dist/astro/routes/api/site/domain-proof.mjs +15 -15
  341. package/dist/astro/routes/api/snapshot.mjs +10 -10
  342. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +25 -25
  343. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +25 -25
  344. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +25 -25
  345. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +25 -25
  346. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +23 -23
  347. package/dist/astro/routes/api/taxonomies/_name_.mjs +25 -25
  348. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs +36 -36
  349. package/dist/astro/routes/api/taxonomies/index.mjs +25 -25
  350. package/dist/astro/routes/api/themes/preview.mjs +7 -7
  351. package/dist/astro/routes/api/typegen.mjs +5 -5
  352. package/dist/astro/routes/api/visual-editing/action-token.mjs +7 -7
  353. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +21 -21
  354. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +3 -3
  355. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  356. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  357. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  358. package/dist/astro/routes/api/widget-areas/_name_/reorder.d.mts.map +1 -1
  359. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +28 -17
  360. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  361. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.d.mts.map +1 -1
  362. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +24 -20
  363. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  364. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +23 -20
  365. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  366. package/dist/astro/routes/api/widget-areas/_name_.mjs +13 -10
  367. package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
  368. package/dist/astro/routes/api/widget-areas/index.mjs +23 -20
  369. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  370. package/dist/astro/routes/api/widget-components.mjs +4 -4
  371. package/dist/astro/routes/robots.txt.mjs +14 -14
  372. package/dist/astro/routes/sitemap-_collection_.xml.mjs +17 -17
  373. package/dist/astro/routes/sitemap.xml.mjs +15 -15
  374. package/dist/astro/types.d.mts +21 -19
  375. package/dist/astro/types.d.mts.map +1 -1
  376. package/dist/auth/providers/github.d.mts +1 -1
  377. package/dist/auth/providers/google.d.mts +1 -1
  378. package/dist/auth/providers/microsoft.d.mts +1 -1
  379. package/dist/authoritative-records-CQlB3JzE.mjs +5183 -0
  380. package/dist/authoritative-records-CQlB3JzE.mjs.map +1 -0
  381. package/dist/authorize-NJgp8kLI.mjs +74 -0
  382. package/dist/authorize-NJgp8kLI.mjs.map +1 -0
  383. package/dist/backup-8rPSJ28a.mjs +246 -0
  384. package/dist/backup-8rPSJ28a.mjs.map +1 -0
  385. package/dist/block-types-BbOrfnWs.mjs +132 -0
  386. package/dist/block-types-BbOrfnWs.mjs.map +1 -0
  387. package/dist/block-values-Dg0-8PPS.mjs +215 -0
  388. package/dist/block-values-Dg0-8PPS.mjs.map +1 -0
  389. package/dist/byline-DHJS-GGb.mjs +994 -0
  390. package/dist/byline-DHJS-GGb.mjs.map +1 -0
  391. package/dist/byline-fields-CiR8FvvF.mjs +280 -0
  392. package/dist/byline-fields-CiR8FvvF.mjs.map +1 -0
  393. package/dist/byline-fields-D6KYsEa7.mjs +123 -0
  394. package/dist/byline-fields-D6KYsEa7.mjs.map +1 -0
  395. package/dist/bylines-Bsg5cH4S.mjs +234 -0
  396. package/dist/bylines-Bsg5cH4S.mjs.map +1 -0
  397. package/dist/bylines-f_ZEc6Sn.mjs +150 -0
  398. package/dist/bylines-f_ZEc6Sn.mjs.map +1 -0
  399. package/dist/cache-5DHbpEWu.mjs +151 -0
  400. package/dist/cache-5DHbpEWu.mjs.map +1 -0
  401. package/dist/canonical-BudtH-Fx.mjs +174 -0
  402. package/dist/canonical-BudtH-Fx.mjs.map +1 -0
  403. package/dist/capture-triggers-BezAvWcB.mjs +362 -0
  404. package/dist/capture-triggers-BezAvWcB.mjs.map +1 -0
  405. package/dist/challenge-store-B1C0V4b3.mjs +51 -0
  406. package/dist/challenge-store-B1C0V4b3.mjs.map +1 -0
  407. package/dist/checksum-CEqvfxGX.mjs +162 -0
  408. package/dist/checksum-CEqvfxGX.mjs.map +1 -0
  409. package/dist/chrome-tags-BIKBMZYO.mjs +24 -0
  410. package/dist/chrome-tags-BIKBMZYO.mjs.map +1 -0
  411. package/dist/chunks-DiW8VMwz.mjs +25 -0
  412. package/dist/chunks-DiW8VMwz.mjs.map +1 -0
  413. package/dist/cli/index.mjs +52 -53
  414. package/dist/cli/index.mjs.map +1 -1
  415. package/dist/client/index.d.mts +46 -46
  416. package/dist/client/index.mjs +2 -2
  417. package/dist/collection-slugs-cache-DIrLjqH-.mjs +91 -0
  418. package/dist/collection-slugs-cache-DIrLjqH-.mjs.map +1 -0
  419. package/dist/comment-DB74Zpa4.mjs +335 -0
  420. package/dist/comment-DB74Zpa4.mjs.map +1 -0
  421. package/dist/comment-reaction-BScxIWUn.mjs +85 -0
  422. package/dist/comment-reaction-BScxIWUn.mjs.map +1 -0
  423. package/dist/comments-Cor_zKml.mjs +195 -0
  424. package/dist/comments-Cor_zKml.mjs.map +1 -0
  425. package/dist/comments-yiRFx3w5.mjs +99 -0
  426. package/dist/comments-yiRFx3w5.mjs.map +1 -0
  427. package/dist/components-Brp__9xo.mjs +112 -0
  428. package/dist/components-Brp__9xo.mjs.map +1 -0
  429. package/dist/config-D44_8G9J.d.mts +41 -0
  430. package/dist/config-D44_8G9J.d.mts.map +1 -0
  431. package/dist/config-DBU6iUQB.mjs +228 -0
  432. package/dist/config-DBU6iUQB.mjs.map +1 -0
  433. package/dist/config-sDhZvkLR.d.mts +6835 -0
  434. package/dist/config-sDhZvkLR.d.mts.map +1 -0
  435. package/dist/connection-BtEN_lP9.mjs +36 -0
  436. package/dist/connection-BtEN_lP9.mjs.map +1 -0
  437. package/dist/content-BKHUVsE5.mjs +2112 -0
  438. package/dist/content-BKHUVsE5.mjs.map +1 -0
  439. package/dist/content-list-query-ByP4jRpZ.d.mts +26 -0
  440. package/dist/content-list-query-ByP4jRpZ.d.mts.map +1 -0
  441. package/dist/content-policy-BmE0MPZY.mjs +46 -0
  442. package/dist/content-policy-BmE0MPZY.mjs.map +1 -0
  443. package/dist/content-repair-Ukdxoq-R.mjs +442 -0
  444. package/dist/content-repair-Ukdxoq-R.mjs.map +1 -0
  445. package/dist/context-CzjejcsE.mjs +2089 -0
  446. package/dist/context-CzjejcsE.mjs.map +1 -0
  447. package/dist/credits-BKREepht.mjs +110 -0
  448. package/dist/credits-BKREepht.mjs.map +1 -0
  449. package/dist/cron-D7obTIfk.mjs +306 -0
  450. package/dist/cron-D7obTIfk.mjs.map +1 -0
  451. package/dist/dashboard-ynr1qJWM.mjs +168 -0
  452. package/dist/dashboard-ynr1qJWM.mjs.map +1 -0
  453. package/dist/db/index.d.mts +3 -3
  454. package/dist/db/index.mjs +2 -2
  455. package/dist/db/libsql-migrations.d.mts +1 -1
  456. package/dist/db/libsql-migrations.mjs +5 -5
  457. package/dist/db/libsql.d.mts +1 -1
  458. package/dist/db/postgres-migrations.d.mts +1 -1
  459. package/dist/db/postgres-migrations.mjs +5 -5
  460. package/dist/db/postgres.d.mts +1 -1
  461. package/dist/db/sqlite-migrations.d.mts +1 -1
  462. package/dist/db/sqlite-migrations.mjs +5 -5
  463. package/dist/db/sqlite.d.mts +1 -1
  464. package/dist/db/sqlite.mjs +1 -1
  465. package/dist/default-C0W-PhAp.mjs +81 -0
  466. package/dist/default-C0W-PhAp.mjs.map +1 -0
  467. package/dist/deferred-tasks-wlMFJL95.d.mts +10 -0
  468. package/dist/deferred-tasks-wlMFJL95.d.mts.map +1 -0
  469. package/dist/dev-typegen-EBni_pOQ.mjs +29 -0
  470. package/dist/dev-typegen-EBni_pOQ.mjs.map +1 -0
  471. package/dist/device-flow-D1U392GC.mjs +519 -0
  472. package/dist/device-flow-D1U392GC.mjs.map +1 -0
  473. package/dist/dialect-helpers-B1XN2HGB.mjs +314 -0
  474. package/dist/dialect-helpers-B1XN2HGB.mjs.map +1 -0
  475. package/dist/digest-DJ1tHCgy.mjs +194 -0
  476. package/dist/digest-DJ1tHCgy.mjs.map +1 -0
  477. package/dist/direct-executor-Bs2g0ake.mjs +117 -0
  478. package/dist/direct-executor-Bs2g0ake.mjs.map +1 -0
  479. package/dist/dist-BUmWMTbN.mjs +810 -0
  480. package/dist/dist-BUmWMTbN.mjs.map +1 -0
  481. package/dist/email-console-FFVJWb9N.mjs +50 -0
  482. package/dist/email-console-FFVJWb9N.mjs.map +1 -0
  483. package/dist/email-locale-Bs3HFdnq.mjs +25 -0
  484. package/dist/email-locale-Bs3HFdnq.mjs.map +1 -0
  485. package/dist/emdash-runtime-C8T-pZpS.mjs +4425 -0
  486. package/dist/emdash-runtime-C8T-pZpS.mjs.map +1 -0
  487. package/dist/enrich-DFlfnd3u.mjs +194 -0
  488. package/dist/enrich-DFlfnd3u.mjs.map +1 -0
  489. package/dist/entry-lock-BulbgPBX.d.mts +4568 -0
  490. package/dist/entry-lock-BulbgPBX.d.mts.map +1 -0
  491. package/dist/entry-lock-CRVmruM0.mjs +1211 -0
  492. package/dist/entry-lock-CRVmruM0.mjs.map +1 -0
  493. package/dist/entry-lock-D-zJQ4q6.mjs +163 -0
  494. package/dist/entry-lock-D-zJQ4q6.mjs.map +1 -0
  495. package/dist/entry-locks-CJ9uhqg1.mjs +167 -0
  496. package/dist/entry-locks-CJ9uhqg1.mjs.map +1 -0
  497. package/dist/env-types-BE3bCvfP.mjs +38 -0
  498. package/dist/env-types-BE3bCvfP.mjs.map +1 -0
  499. package/dist/error-BCMgPxdn.mjs +90 -0
  500. package/dist/error-BCMgPxdn.mjs.map +1 -0
  501. package/dist/errors-8gJqv-XV.mjs +492 -0
  502. package/dist/errors-8gJqv-XV.mjs.map +1 -0
  503. package/dist/errors-B4f4It-2.mjs +120 -0
  504. package/dist/errors-B4f4It-2.mjs.map +1 -0
  505. package/dist/escape-lsNq38PP.mjs +9 -0
  506. package/dist/escape-lsNq38PP.mjs.map +1 -0
  507. package/dist/fence-Dagicj14.mjs +162 -0
  508. package/dist/fence-Dagicj14.mjs.map +1 -0
  509. package/dist/field-map-BSXdNGt5.mjs +84 -0
  510. package/dist/field-map-BSXdNGt5.mjs.map +1 -0
  511. package/dist/fts-manager-6861qcwk.mjs +489 -0
  512. package/dist/fts-manager-6861qcwk.mjs.map +1 -0
  513. package/dist/gc-CNkXB3mE.mjs +75 -0
  514. package/dist/gc-CNkXB3mE.mjs.map +1 -0
  515. package/dist/hash-BJaeek87.mjs +37 -0
  516. package/dist/hash-BJaeek87.mjs.map +1 -0
  517. package/dist/hreflang-8dUOJAPJ.d.mts +50 -0
  518. package/dist/hreflang-8dUOJAPJ.d.mts.map +1 -0
  519. package/dist/hreflang-BW5A4FLK.mjs +105 -0
  520. package/dist/hreflang-BW5A4FLK.mjs.map +1 -0
  521. package/dist/http-route-dispatch-rXKvTNm9.mjs +342 -0
  522. package/dist/http-route-dispatch-rXKvTNm9.mjs.map +1 -0
  523. package/dist/identity-CPRRSovU.mjs +35 -0
  524. package/dist/identity-CPRRSovU.mjs.map +1 -0
  525. package/dist/import-yVbfPyfd.mjs +2126 -0
  526. package/dist/import-yVbfPyfd.mjs.map +1 -0
  527. package/dist/index-VM7Fzxwe.d.mts +260 -0
  528. package/dist/index-VM7Fzxwe.d.mts.map +1 -0
  529. package/dist/index.d.mts +23 -22
  530. package/dist/index.mjs +104 -105
  531. package/dist/install-finalization-RU6VrHOX.mjs +58 -0
  532. package/dist/install-finalization-RU6VrHOX.mjs.map +1 -0
  533. package/dist/json-recordset-D0WhN2UA.mjs +12 -0
  534. package/dist/json-recordset-D0WhN2UA.mjs.map +1 -0
  535. package/dist/json-schema-v_D_pPNG.mjs +15 -0
  536. package/dist/json-schema-v_D_pPNG.mjs.map +1 -0
  537. package/dist/keys-CifIkT0N.mjs +61 -0
  538. package/dist/keys-CifIkT0N.mjs.map +1 -0
  539. package/dist/kinds-B_Qcl5pz.mjs +974 -0
  540. package/dist/kinds-B_Qcl5pz.mjs.map +1 -0
  541. package/dist/lifecycle-B8d7Rdqx.mjs +25 -0
  542. package/dist/lifecycle-B8d7Rdqx.mjs.map +1 -0
  543. package/dist/load-D4xtzm6h.mjs +28 -0
  544. package/dist/load-D4xtzm6h.mjs.map +1 -0
  545. package/dist/loader-DhnedqY4.mjs +1478 -0
  546. package/dist/loader-DhnedqY4.mjs.map +1 -0
  547. package/dist/loops-B2YS-Zzr.mjs +205 -0
  548. package/dist/loops-B2YS-Zzr.mjs.map +1 -0
  549. package/dist/manifest-builder-g1FLviel.mjs +196 -0
  550. package/dist/manifest-builder-g1FLviel.mjs.map +1 -0
  551. package/dist/manifest-schema-DNb4XmTS.mjs +497 -0
  552. package/dist/manifest-schema-DNb4XmTS.mjs.map +1 -0
  553. package/dist/marketplace-CqbgeIa7.mjs +257 -0
  554. package/dist/marketplace-CqbgeIa7.mjs.map +1 -0
  555. package/dist/media/image-endpoint.mjs +1 -1
  556. package/dist/media/index.d.mts +1 -1
  557. package/dist/media/index.mjs +3 -3
  558. package/dist/media/local-runtime.d.mts +14 -13
  559. package/dist/media/local-runtime.d.mts.map +1 -1
  560. package/dist/media/local-runtime.mjs +14 -14
  561. package/dist/media-BR4_t-Wd.mjs +416 -0
  562. package/dist/media-BR4_t-Wd.mjs.map +1 -0
  563. package/dist/media-CikS-q6E.mjs +294 -0
  564. package/dist/media-CikS-q6E.mjs.map +1 -0
  565. package/dist/media-DepNLhPq.mjs +383 -0
  566. package/dist/media-DepNLhPq.mjs.map +1 -0
  567. package/dist/media-allowlist-BMBLqyWh.mjs +45 -0
  568. package/dist/media-allowlist-BMBLqyWh.mjs.map +1 -0
  569. package/dist/media-folders-CI0Wydfo.mjs +210 -0
  570. package/dist/media-folders-CI0Wydfo.mjs.map +1 -0
  571. package/dist/media-url-BQgKvpQ5.mjs +43 -0
  572. package/dist/media-url-BQgKvpQ5.mjs.map +1 -0
  573. package/dist/media-usage-X1_20MY-.mjs +282 -0
  574. package/dist/media-usage-X1_20MY-.mjs.map +1 -0
  575. package/dist/media-usage-activation-bWusy3M2.mjs +78 -0
  576. package/dist/media-usage-activation-bWusy3M2.mjs.map +1 -0
  577. package/dist/media-usage-work-B2RaoJIa.mjs +151 -0
  578. package/dist/media-usage-work-B2RaoJIa.mjs.map +1 -0
  579. package/dist/media-usage-work-BCK2J-v_.mjs +1036 -0
  580. package/dist/media-usage-work-BCK2J-v_.mjs.map +1 -0
  581. package/dist/menus-B0Qqv_cS.mjs +837 -0
  582. package/dist/menus-B0Qqv_cS.mjs.map +1 -0
  583. package/dist/menus-oypxT1pI.mjs +3802 -0
  584. package/dist/menus-oypxT1pI.mjs.map +1 -0
  585. package/dist/menus-uEAxWAm1.mjs +92 -0
  586. package/dist/menus-uEAxWAm1.mjs.map +1 -0
  587. package/dist/migrations/index.d.mts +1 -1
  588. package/dist/migrations/index.mjs +4 -4
  589. package/dist/mime-D1We9jUx.mjs +81 -0
  590. package/dist/mime-D1We9jUx.mjs.map +1 -0
  591. package/dist/mode-C-D3qICy.mjs +23 -0
  592. package/dist/mode-C-D3qICy.mjs.map +1 -0
  593. package/dist/node-sqlite-compat-CrKzRr0J.mjs +63 -0
  594. package/dist/node-sqlite-compat-CrKzRr0J.mjs.map +1 -0
  595. package/dist/normalize-Cx-bNwhP.mjs +220 -0
  596. package/dist/normalize-Cx-bNwhP.mjs.map +1 -0
  597. package/dist/oauth-authorization-CPLgBrdo.mjs +287 -0
  598. package/dist/oauth-authorization-CPLgBrdo.mjs.map +1 -0
  599. package/dist/oauth-clients-BT0Pg-MO.mjs +266 -0
  600. package/dist/oauth-clients-BT0Pg-MO.mjs.map +1 -0
  601. package/dist/oauth-state-store-BndCfRum.mjs +50 -0
  602. package/dist/oauth-state-store-BndCfRum.mjs.map +1 -0
  603. package/dist/oauth-user-lookup-BDgF6IVG.mjs +26 -0
  604. package/dist/oauth-user-lookup-BDgF6IVG.mjs.map +1 -0
  605. package/dist/object-cache/memory.d.mts +1 -1
  606. package/dist/object-cache-DmKr09La.mjs +603 -0
  607. package/dist/object-cache-DmKr09La.mjs.map +1 -0
  608. package/dist/options-BUUgroHg.d.mts +81 -0
  609. package/dist/options-BUUgroHg.d.mts.map +1 -0
  610. package/dist/ownership-MiyA7qKO.mjs +12 -0
  611. package/dist/ownership-MiyA7qKO.mjs.map +1 -0
  612. package/dist/page/index.d.mts +2 -2
  613. package/dist/page/index.mjs +13 -13
  614. package/dist/parse-B_b6gZxG.mjs +81 -0
  615. package/dist/parse-B_b6gZxG.mjs.map +1 -0
  616. package/dist/parse-Dndx1QmN.d.mts +176 -0
  617. package/dist/parse-Dndx1QmN.d.mts.map +1 -0
  618. package/dist/passkey-config-D2Lua5__.mjs +46 -0
  619. package/dist/passkey-config-D2Lua5__.mjs.map +1 -0
  620. package/dist/paths-biDzFTY2.mjs +77 -0
  621. package/dist/paths-biDzFTY2.mjs.map +1 -0
  622. package/dist/placeholder-CSKu5OkD.d.mts +314 -0
  623. package/dist/placeholder-CSKu5OkD.d.mts.map +1 -0
  624. package/dist/plan-CCoqxNoU.mjs +135 -0
  625. package/dist/plan-CCoqxNoU.mjs.map +1 -0
  626. package/dist/plugin-test-runtime.d.mts +16 -14
  627. package/dist/plugin-test-runtime.d.mts.map +1 -1
  628. package/dist/plugin-test-runtime.mjs +114 -115
  629. package/dist/plugin-tool-name-DDUgN_0p.mjs +27 -0
  630. package/dist/plugin-tool-name-DDUgN_0p.mjs.map +1 -0
  631. package/dist/plugin-types.d.mts +1 -1
  632. package/dist/plugin-utils.d.mts +12 -11
  633. package/dist/plugin-utils.d.mts.map +1 -1
  634. package/dist/plugins/adapt-sandbox-entry.d.mts +12 -11
  635. package/dist/plugins/adapt-sandbox-entry.d.mts.map +1 -1
  636. package/dist/plugins/adapt-sandbox-entry.mjs +4 -4
  637. package/dist/plugins/host.d.mts +5 -5
  638. package/dist/plugins/host.mjs +50 -51
  639. package/dist/plugins-COJ2L49n.mjs +261 -0
  640. package/dist/plugins-COJ2L49n.mjs.map +1 -0
  641. package/dist/policy-BPugqmeV.mjs +53 -0
  642. package/dist/policy-BPugqmeV.mjs.map +1 -0
  643. package/dist/portable-text-BH4zgkSm.mjs +311 -0
  644. package/dist/portable-text-BH4zgkSm.mjs.map +1 -0
  645. package/dist/preview-DLexxwp3.mjs +107 -0
  646. package/dist/preview-DLexxwp3.mjs.map +1 -0
  647. package/dist/protocol-PoAfD_9W.d.mts +65 -0
  648. package/dist/protocol-PoAfD_9W.d.mts.map +1 -0
  649. package/dist/public-plugin-api-routes-CMljrTby.mjs +316 -0
  650. package/dist/public-plugin-api-routes-CMljrTby.mjs.map +1 -0
  651. package/dist/public-submission-ayqoyee4.mjs +251 -0
  652. package/dist/public-submission-ayqoyee4.mjs.map +1 -0
  653. package/dist/public-url-Bt98vysr.mjs +101 -0
  654. package/dist/public-url-Bt98vysr.mjs.map +1 -0
  655. package/dist/query-D62NntCZ.mjs +1146 -0
  656. package/dist/query-D62NntCZ.mjs.map +1 -0
  657. package/dist/query-LmPY2y0C.mjs +41 -0
  658. package/dist/query-LmPY2y0C.mjs.map +1 -0
  659. package/dist/range-CYfeXgGK.mjs +51 -0
  660. package/dist/range-CYfeXgGK.mjs.map +1 -0
  661. package/dist/rate-limit-C04Llsoc.mjs +127 -0
  662. package/dist/rate-limit-C04Llsoc.mjs.map +1 -0
  663. package/dist/receipt-BUsQCOeM.mjs +43 -0
  664. package/dist/receipt-BUsQCOeM.mjs.map +1 -0
  665. package/dist/redirect-CQAV7mCo.mjs +19 -0
  666. package/dist/redirect-CQAV7mCo.mjs.map +1 -0
  667. package/dist/redirect-DjLdw427.mjs +423 -0
  668. package/dist/redirect-DjLdw427.mjs.map +1 -0
  669. package/dist/redirect-paths-DOaVBp6E.mjs +36 -0
  670. package/dist/redirect-paths-DOaVBp6E.mjs.map +1 -0
  671. package/dist/redirects-Cpq1catN.mjs +446 -0
  672. package/dist/redirects-Cpq1catN.mjs.map +1 -0
  673. package/dist/redirects-CyvvZrCJ.mjs +148 -0
  674. package/dist/redirects-CyvvZrCJ.mjs.map +1 -0
  675. package/dist/registry/testing.mjs +3 -3
  676. package/dist/registry-B0-O575m.mjs +8374 -0
  677. package/dist/registry-B0-O575m.mjs.map +1 -0
  678. package/dist/relations-WIOojTL4.mjs +789 -0
  679. package/dist/relations-WIOojTL4.mjs.map +1 -0
  680. package/dist/request-context.d.mts +2 -2
  681. package/dist/request-meta-bwZ_NsvU.mjs +141 -0
  682. package/dist/request-meta-bwZ_NsvU.mjs.map +1 -0
  683. package/dist/resolve-BNnm8EkB.mjs +102 -0
  684. package/dist/resolve-BNnm8EkB.mjs.map +1 -0
  685. package/dist/route-cache-QSOyDEw0.mjs +20 -0
  686. package/dist/route-cache-QSOyDEw0.mjs.map +1 -0
  687. package/dist/route-wire-Ca_HWCZ5.mjs +197 -0
  688. package/dist/route-wire-Ca_HWCZ5.mjs.map +1 -0
  689. package/dist/routes-avqgc-8r.mjs +272 -0
  690. package/dist/routes-avqgc-8r.mjs.map +1 -0
  691. package/dist/runner-Bkkfk4O8.mjs +6669 -0
  692. package/dist/runner-Bkkfk4O8.mjs.map +1 -0
  693. package/dist/runner-Dfgp6-S_.d.mts +73 -0
  694. package/dist/runner-Dfgp6-S_.d.mts.map +1 -0
  695. package/dist/runtime.d.mts +13 -12
  696. package/dist/runtime.d.mts.map +1 -1
  697. package/dist/runtime.mjs +4 -3
  698. package/dist/runtime.mjs.map +1 -1
  699. package/dist/schema/project-env-types.mjs +42 -43
  700. package/dist/schema/project-env-types.mjs.map +1 -1
  701. package/dist/schema-B-3rntlX.mjs +815 -0
  702. package/dist/schema-B-3rntlX.mjs.map +1 -0
  703. package/dist/schema-BqBlUZtb.mjs +13 -0
  704. package/dist/schema-BqBlUZtb.mjs.map +1 -0
  705. package/dist/scopes-DNaY7Ey0.mjs +34 -0
  706. package/dist/scopes-DNaY7Ey0.mjs.map +1 -0
  707. package/dist/search-BPWTnpnD.mjs +450 -0
  708. package/dist/search-BPWTnpnD.mjs.map +1 -0
  709. package/dist/secrets-Dswzrz3k.mjs +369 -0
  710. package/dist/secrets-Dswzrz3k.mjs.map +1 -0
  711. package/dist/sections-rSao6rBG.mjs +346 -0
  712. package/dist/sections-rSao6rBG.mjs.map +1 -0
  713. package/dist/seed/index.d.mts +2 -2
  714. package/dist/seed/index.mjs +40 -41
  715. package/dist/seo/index.d.mts +3 -3
  716. package/dist/seo/index.mjs +27 -27
  717. package/dist/seo-B_H_pqOd.mjs +133 -0
  718. package/dist/seo-B_H_pqOd.mjs.map +1 -0
  719. package/dist/seo-ClB-dw9w.mjs +188 -0
  720. package/dist/seo-ClB-dw9w.mjs.map +1 -0
  721. package/dist/service-DpiUQVpp.mjs +150 -0
  722. package/dist/service-DpiUQVpp.mjs.map +1 -0
  723. package/dist/session-user-DiE4JKPP.mjs +61 -0
  724. package/dist/session-user-DiE4JKPP.mjs.map +1 -0
  725. package/dist/settings--XlUdUaI.mjs +66 -0
  726. package/dist/settings--XlUdUaI.mjs.map +1 -0
  727. package/dist/settings-D932YP2-.mjs +519 -0
  728. package/dist/settings-D932YP2-.mjs.map +1 -0
  729. package/dist/settings-Dd1uivmQ.mjs +73 -0
  730. package/dist/settings-Dd1uivmQ.mjs.map +1 -0
  731. package/dist/setup-complete-qsJYWutC.mjs +65 -0
  732. package/dist/setup-complete-qsJYWutC.mjs.map +1 -0
  733. package/dist/setup-nonce-CBFgUFXw.mjs +25 -0
  734. package/dist/setup-nonce-CBFgUFXw.mjs.map +1 -0
  735. package/dist/site-domain-oRGS_JfA.mjs +131 -0
  736. package/dist/site-domain-oRGS_JfA.mjs.map +1 -0
  737. package/dist/site-settings-DRHfX7bq.mjs +50 -0
  738. package/dist/site-settings-DRHfX7bq.mjs.map +1 -0
  739. package/dist/site-url-MB685I5X.mjs +45 -0
  740. package/dist/site-url-MB685I5X.mjs.map +1 -0
  741. package/dist/sitemap-name-B8QP8wud.mjs +26 -0
  742. package/dist/sitemap-name-B8QP8wud.mjs.map +1 -0
  743. package/dist/slug-aVnUV4SL.mjs +16 -0
  744. package/dist/slug-aVnUV4SL.mjs.map +1 -0
  745. package/dist/snapshot-BjaXDZQ5.mjs +414 -0
  746. package/dist/snapshot-BjaXDZQ5.mjs.map +1 -0
  747. package/dist/ssrf-BcYjyM4M.mjs +406 -0
  748. package/dist/ssrf-BcYjyM4M.mjs.map +1 -0
  749. package/dist/stage-CZQnXM_G.mjs +662 -0
  750. package/dist/stage-CZQnXM_G.mjs.map +1 -0
  751. package/dist/staged-ByBmPFtX.mjs +686 -0
  752. package/dist/staged-ByBmPFtX.mjs.map +1 -0
  753. package/dist/state-CFbGZziM.mjs +178 -0
  754. package/dist/state-CFbGZziM.mjs.map +1 -0
  755. package/dist/status-BFNdxzKc.mjs +30 -0
  756. package/dist/status-BFNdxzKc.mjs.map +1 -0
  757. package/dist/storage/local.d.mts +1 -1
  758. package/dist/storage/local.mjs +2 -2
  759. package/dist/storage/s3.d.mts +1 -1
  760. package/dist/storage/s3.mjs +1 -1
  761. package/dist/storage-query-BFp06Y0s.d.mts +1627 -0
  762. package/dist/storage-query-BFp06Y0s.d.mts.map +1 -0
  763. package/dist/tar-DFjExb9X.mjs +449 -0
  764. package/dist/tar-DFjExb9X.mjs.map +1 -0
  765. package/dist/target-CWZs2-o6.mjs +27 -0
  766. package/dist/target-CWZs2-o6.mjs.map +1 -0
  767. package/dist/taxonomies-5SR76j11.mjs +937 -0
  768. package/dist/taxonomies-5SR76j11.mjs.map +1 -0
  769. package/dist/taxonomies-B__VmCKQ.mjs +703 -0
  770. package/dist/taxonomies-B__VmCKQ.mjs.map +1 -0
  771. package/dist/taxonomy-CMI5fczd.mjs +563 -0
  772. package/dist/taxonomy-CMI5fczd.mjs.map +1 -0
  773. package/dist/tokens-BnhSnGwJ.mjs +171 -0
  774. package/dist/tokens-BnhSnGwJ.mjs.map +1 -0
  775. package/dist/transfer-BbKfufJ4.mjs +166 -0
  776. package/dist/transfer-BbKfufJ4.mjs.map +1 -0
  777. package/dist/transfer-DTGblAj2.mjs +8910 -0
  778. package/dist/transfer-DTGblAj2.mjs.map +1 -0
  779. package/dist/transfer-download-D9LQEDX0.mjs +33 -0
  780. package/dist/transfer-download-D9LQEDX0.mjs.map +1 -0
  781. package/dist/transformations-Bx4lYY0Y.mjs +196 -0
  782. package/dist/transformations-Bx4lYY0Y.mjs.map +1 -0
  783. package/dist/transport-Dzpn5b3i.mjs +137 -0
  784. package/dist/transport-Dzpn5b3i.mjs.map +1 -0
  785. package/dist/trusted-proxy-BU3Nx9g1.mjs +51 -0
  786. package/dist/trusted-proxy-BU3Nx9g1.mjs.map +1 -0
  787. package/dist/turnstile-Cs2wfkJG.mjs +58 -0
  788. package/dist/turnstile-Cs2wfkJG.mjs.map +1 -0
  789. package/dist/types-BAsCk5KU.d.mts +87 -0
  790. package/dist/types-BAsCk5KU.d.mts.map +1 -0
  791. package/dist/types-BuvSwT9Y.d.mts +375 -0
  792. package/dist/types-BuvSwT9Y.d.mts.map +1 -0
  793. package/dist/types-C4KT3Md2.d.mts +293 -0
  794. package/dist/types-C4KT3Md2.d.mts.map +1 -0
  795. package/dist/types-CVXHwIBB.d.mts +125 -0
  796. package/dist/types-CVXHwIBB.d.mts.map +1 -0
  797. package/dist/types-C_asjp1J.mjs.map +1 -1
  798. package/dist/types-CgfFGfO5.mjs +16 -0
  799. package/dist/types-CgfFGfO5.mjs.map +1 -0
  800. package/dist/types-Cj0_yZkn.mjs +18 -0
  801. package/dist/types-Cj0_yZkn.mjs.map +1 -0
  802. package/dist/types-CjftrmZR.d.mts +1741 -0
  803. package/dist/types-CjftrmZR.d.mts.map +1 -0
  804. package/dist/types-DKwRUA-x.d.mts +916 -0
  805. package/dist/types-DKwRUA-x.d.mts.map +1 -0
  806. package/dist/types-DwhEvIVb.mjs.map +1 -1
  807. package/dist/types-GwAyS5SH.d.mts +227 -0
  808. package/dist/types-GwAyS5SH.d.mts.map +1 -0
  809. package/dist/types-qHVygneX.mjs +77 -0
  810. package/dist/types-qHVygneX.mjs.map +1 -0
  811. package/dist/types-sUHaH7lC.mjs +37 -0
  812. package/dist/types-sUHaH7lC.mjs.map +1 -0
  813. package/dist/types-uU2YNYSt.d.mts +209 -0
  814. package/dist/types-uU2YNYSt.d.mts.map +1 -0
  815. package/dist/update-check-ABBJgg6M.mjs +161 -0
  816. package/dist/update-check-ABBJgg6M.mjs.map +1 -0
  817. package/dist/upload-attempts-DPFC4COv.mjs +32 -0
  818. package/dist/upload-attempts-DPFC4COv.mjs.map +1 -0
  819. package/dist/url-pattern-QATUE_rv.mjs +41 -0
  820. package/dist/url-pattern-QATUE_rv.mjs.map +1 -0
  821. package/dist/user-By8SzQxS.mjs +171 -0
  822. package/dist/user-By8SzQxS.mjs.map +1 -0
  823. package/dist/utils-D5uOi6WS.mjs +450 -0
  824. package/dist/utils-D5uOi6WS.mjs.map +1 -0
  825. package/dist/utils-Szp4iBQB.d.mts +376 -0
  826. package/dist/utils-Szp4iBQB.d.mts.map +1 -0
  827. package/dist/validate-DDvxy6qG.d.mts +468 -0
  828. package/dist/validate-DDvxy6qG.d.mts.map +1 -0
  829. package/dist/validate-Dz-TIOFB.mjs +524 -0
  830. package/dist/validate-Dz-TIOFB.mjs.map +1 -0
  831. package/dist/validation-Fc9ZSUS_.mjs +221 -0
  832. package/dist/validation-Fc9ZSUS_.mjs.map +1 -0
  833. package/dist/version-BZj18Q7G.mjs +9 -0
  834. package/dist/version-BZj18Q7G.mjs.map +1 -0
  835. package/dist/version-Bu6Nlbb5.mjs +7 -0
  836. package/dist/version-Bu6Nlbb5.mjs.map +1 -0
  837. package/dist/version-DqB7LIO7.mjs +49 -0
  838. package/dist/version-DqB7LIO7.mjs.map +1 -0
  839. package/dist/video-DytCnw3L.mjs +54 -0
  840. package/dist/video-DytCnw3L.mjs.map +1 -0
  841. package/dist/virtual-modules-DO954n7P.mjs +515 -0
  842. package/dist/virtual-modules-DO954n7P.mjs.map +1 -0
  843. package/dist/widgets-BUx_Mf2q.mjs +134 -0
  844. package/dist/widgets-BUx_Mf2q.mjs.map +1 -0
  845. package/dist/wxr-taxonomies-DbJtWrWM.mjs +454 -0
  846. package/dist/wxr-taxonomies-DbJtWrWM.mjs.map +1 -0
  847. package/dist/zod-generator--nlM0930.mjs +425 -0
  848. package/dist/zod-generator--nlM0930.mjs.map +1 -0
  849. package/package.json +5 -5
  850. package/src/api/handlers/content.ts +49 -18
  851. package/src/api/handlers/device-flow.ts +1 -3
  852. package/src/api/handlers/menus.ts +3 -3
  853. package/src/api/handlers/oauth-authorization.ts +1 -3
  854. package/src/astro/integration/admin-nav.ts +52 -0
  855. package/src/astro/integration/index.ts +7 -0
  856. package/src/astro/integration/runtime.ts +14 -0
  857. package/src/astro/integration/shims/use-sync-external-store-with-selector.js +2 -0
  858. package/src/astro/integration/shims/use-sync-external-store.js +4 -1
  859. package/src/astro/middleware/auth.ts +9 -2
  860. package/src/astro/routes/api/import/wordpress/analyze.ts +5 -29
  861. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +3 -3
  862. package/src/astro/routes/api/media/file/[...key].ts +18 -4
  863. package/src/astro/routes/api/oauth/token.ts +5 -1
  864. package/src/astro/routes/api/widget-areas/[name]/reorder.ts +7 -1
  865. package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +3 -1
  866. package/src/astro/routes/api/widget-areas/[name]/widgets.ts +2 -1
  867. package/src/astro/routes/api/widget-areas/[name].ts +2 -1
  868. package/src/astro/routes/api/widget-areas/index.ts +2 -1
  869. package/src/astro/types.ts +4 -3
  870. package/src/auth/api-tokens.ts +3 -0
  871. package/src/cleanup.ts +44 -0
  872. package/src/components/inline-bubble-menu.tsx +109 -95
  873. package/src/components/inline-image.tsx +54 -48
  874. package/src/database/dialect-helpers.ts +10 -3
  875. package/src/database/repositories/byline.ts +22 -14
  876. package/src/database/repositories/content.ts +17 -4
  877. package/src/database/repositories/media.ts +17 -0
  878. package/src/database/repositories/menu.ts +163 -132
  879. package/src/database/repositories/types.ts +3 -3
  880. package/src/database/types.ts +1 -1
  881. package/src/emdash-runtime.ts +23 -7
  882. package/src/import/utils.ts +15 -2
  883. package/src/index.ts +1 -0
  884. package/src/loader.ts +106 -95
  885. package/src/media/content-disposition.ts +56 -0
  886. package/src/media/normalize.ts +2 -0
  887. package/src/media/usage/content-fields.ts +2 -1
  888. package/src/menus/index.ts +137 -25
  889. package/src/object-cache/index.ts +22 -0
  890. package/src/plugin-test-runtime.ts +1 -0
  891. package/src/query.ts +44 -40
  892. package/src/schema/types.ts +7 -6
  893. package/src/search/fts-manager.ts +5 -3
  894. package/src/seed/apply.ts +52 -44
  895. package/src/seed/types.ts +3 -3
  896. package/src/taxonomies/index.ts +22 -51
  897. package/src/transfer/import/advance.ts +12 -1
  898. package/src/transfer/import/scaffold.ts +7 -1
  899. package/src/transfer/import/stages.ts +53 -2
  900. package/src/utils/revalidating-cache.ts +85 -0
  901. package/src/visual-editing/toolbar.ts +7 -2
  902. package/src/widgets/index.ts +27 -13
  903. package/dist/action-token-B1ds4laA.mjs +0 -26
  904. package/dist/action-token-B1ds4laA.mjs.map +0 -1
  905. package/dist/activation-sGF9br3X.mjs +0 -387
  906. package/dist/activation-sGF9br3X.mjs.map +0 -1
  907. package/dist/adapters-BOMSX9PU.d.mts +0 -173
  908. package/dist/adapters-BOMSX9PU.d.mts.map +0 -1
  909. package/dist/after-PcEvMY_6.mjs +0 -96
  910. package/dist/after-PcEvMY_6.mjs.map +0 -1
  911. package/dist/allowed-origins-CovsTkm3.mjs +0 -116
  912. package/dist/allowed-origins-CovsTkm3.mjs.map +0 -1
  913. package/dist/api-C_LxFnOm.mjs +0 -5077
  914. package/dist/api-C_LxFnOm.mjs.map +0 -1
  915. package/dist/api-tokens-C7l0GUAF.mjs +0 -3
  916. package/dist/api-tokens-DQ9Ee-vP.mjs +0 -173
  917. package/dist/api-tokens-DQ9Ee-vP.mjs.map +0 -1
  918. package/dist/apply-CLjfxvyH.mjs +0 -1758
  919. package/dist/apply-CLjfxvyH.mjs.map +0 -1
  920. package/dist/approvals-ocK89i4H.mjs +0 -460
  921. package/dist/approvals-ocK89i4H.mjs.map +0 -1
  922. package/dist/artifact-fetch-CgvvpoWQ.mjs +0 -659
  923. package/dist/artifact-fetch-CgvvpoWQ.mjs.map +0 -1
  924. package/dist/artifacts-DwOYYBQm.mjs +0 -323
  925. package/dist/artifacts-DwOYYBQm.mjs.map +0 -1
  926. package/dist/authoritative-records-LPtrIGOY.mjs +0 -5183
  927. package/dist/authoritative-records-LPtrIGOY.mjs.map +0 -1
  928. package/dist/authorize-CoDsRRp5.mjs +0 -74
  929. package/dist/authorize-CoDsRRp5.mjs.map +0 -1
  930. package/dist/backup-2Wj-hTCN.mjs +0 -246
  931. package/dist/backup-2Wj-hTCN.mjs.map +0 -1
  932. package/dist/block-types-C3gJEe7l.mjs +0 -132
  933. package/dist/block-types-C3gJEe7l.mjs.map +0 -1
  934. package/dist/block-values-CgbMtSGU.mjs +0 -215
  935. package/dist/block-values-CgbMtSGU.mjs.map +0 -1
  936. package/dist/byline-CzGZC2Zs.mjs +0 -922
  937. package/dist/byline-CzGZC2Zs.mjs.map +0 -1
  938. package/dist/byline-fields-B1qHvRps.mjs +0 -280
  939. package/dist/byline-fields-B1qHvRps.mjs.map +0 -1
  940. package/dist/byline-fields-vYd_4Q1e.mjs +0 -123
  941. package/dist/byline-fields-vYd_4Q1e.mjs.map +0 -1
  942. package/dist/bylines-BF555iIz.mjs +0 -150
  943. package/dist/bylines-BF555iIz.mjs.map +0 -1
  944. package/dist/bylines-DJx6IWWi.mjs +0 -234
  945. package/dist/bylines-DJx6IWWi.mjs.map +0 -1
  946. package/dist/cache-BWzswWB-.mjs +0 -151
  947. package/dist/cache-BWzswWB-.mjs.map +0 -1
  948. package/dist/canonical-DjF_z6GI.mjs +0 -174
  949. package/dist/canonical-DjF_z6GI.mjs.map +0 -1
  950. package/dist/capture-triggers-D7g3fOZj.mjs +0 -362
  951. package/dist/capture-triggers-D7g3fOZj.mjs.map +0 -1
  952. package/dist/challenge-store-Cfjdvw86.mjs +0 -51
  953. package/dist/challenge-store-Cfjdvw86.mjs.map +0 -1
  954. package/dist/checksum-BF4acJwn.mjs +0 -162
  955. package/dist/checksum-BF4acJwn.mjs.map +0 -1
  956. package/dist/chrome-tags-BDs29G3g.mjs +0 -24
  957. package/dist/chrome-tags-BDs29G3g.mjs.map +0 -1
  958. package/dist/chunks-CYBOL-zn.mjs +0 -25
  959. package/dist/chunks-CYBOL-zn.mjs.map +0 -1
  960. package/dist/collection-slugs-cache-B2J5aESO.mjs +0 -91
  961. package/dist/collection-slugs-cache-B2J5aESO.mjs.map +0 -1
  962. package/dist/comment-DV7dybcs.mjs +0 -335
  963. package/dist/comment-DV7dybcs.mjs.map +0 -1
  964. package/dist/comment-reaction-CWwqiT6x.mjs +0 -85
  965. package/dist/comment-reaction-CWwqiT6x.mjs.map +0 -1
  966. package/dist/comments-DVjWJm8X.mjs +0 -99
  967. package/dist/comments-DVjWJm8X.mjs.map +0 -1
  968. package/dist/comments-Q-ILHCEI.mjs +0 -195
  969. package/dist/comments-Q-ILHCEI.mjs.map +0 -1
  970. package/dist/components-DnOmvvgg.mjs +0 -112
  971. package/dist/components-DnOmvvgg.mjs.map +0 -1
  972. package/dist/config-9IzA83_U.d.mts +0 -6811
  973. package/dist/config-9IzA83_U.d.mts.map +0 -1
  974. package/dist/config-BdQzFtmR.mjs +0 -228
  975. package/dist/config-BdQzFtmR.mjs.map +0 -1
  976. package/dist/config-Cs2RBkJ6.d.mts +0 -41
  977. package/dist/config-Cs2RBkJ6.d.mts.map +0 -1
  978. package/dist/connection-CiXgZyCY.mjs +0 -36
  979. package/dist/connection-CiXgZyCY.mjs.map +0 -1
  980. package/dist/content-Dt0Os_WQ.mjs +0 -2109
  981. package/dist/content-Dt0Os_WQ.mjs.map +0 -1
  982. package/dist/content-list-query-BK26u9Ly.d.mts +0 -26
  983. package/dist/content-list-query-BK26u9Ly.d.mts.map +0 -1
  984. package/dist/content-policy-BLDbNJOb.mjs +0 -46
  985. package/dist/content-policy-BLDbNJOb.mjs.map +0 -1
  986. package/dist/content-repair-CjwbLy4m.mjs +0 -442
  987. package/dist/content-repair-CjwbLy4m.mjs.map +0 -1
  988. package/dist/context-ErV7UdQY.mjs +0 -2089
  989. package/dist/context-ErV7UdQY.mjs.map +0 -1
  990. package/dist/credits-BRyjafiF.mjs +0 -110
  991. package/dist/credits-BRyjafiF.mjs.map +0 -1
  992. package/dist/cron-Bm5xa7tv.mjs +0 -306
  993. package/dist/cron-Bm5xa7tv.mjs.map +0 -1
  994. package/dist/dashboard-DVxQ5XiI.mjs +0 -168
  995. package/dist/dashboard-DVxQ5XiI.mjs.map +0 -1
  996. package/dist/default-B9Tf2n94.mjs +0 -81
  997. package/dist/default-B9Tf2n94.mjs.map +0 -1
  998. package/dist/deferred-tasks-CpPEqsga.d.mts +0 -9
  999. package/dist/deferred-tasks-CpPEqsga.d.mts.map +0 -1
  1000. package/dist/dev-typegen-ZeWYV8Jp.mjs +0 -29
  1001. package/dist/dev-typegen-ZeWYV8Jp.mjs.map +0 -1
  1002. package/dist/device-flow-BbYNZ9Xi.mjs +0 -521
  1003. package/dist/device-flow-BbYNZ9Xi.mjs.map +0 -1
  1004. package/dist/dialect-helpers-7_IqPdh9.mjs +0 -307
  1005. package/dist/dialect-helpers-7_IqPdh9.mjs.map +0 -1
  1006. package/dist/digest-DlBa7kJl.mjs +0 -194
  1007. package/dist/digest-DlBa7kJl.mjs.map +0 -1
  1008. package/dist/direct-executor-5T8gkhvA.mjs +0 -117
  1009. package/dist/direct-executor-5T8gkhvA.mjs.map +0 -1
  1010. package/dist/dist-DY0aOmAP.mjs +0 -810
  1011. package/dist/dist-DY0aOmAP.mjs.map +0 -1
  1012. package/dist/email-console-v3OM8It-.mjs +0 -50
  1013. package/dist/email-console-v3OM8It-.mjs.map +0 -1
  1014. package/dist/email-locale-CoZo-oZx.mjs +0 -25
  1015. package/dist/email-locale-CoZo-oZx.mjs.map +0 -1
  1016. package/dist/emdash-runtime-DwezbIqQ.mjs +0 -4392
  1017. package/dist/emdash-runtime-DwezbIqQ.mjs.map +0 -1
  1018. package/dist/enrich-C3XIJi0O.mjs +0 -194
  1019. package/dist/enrich-C3XIJi0O.mjs.map +0 -1
  1020. package/dist/entry-lock-CY7XpdSw.d.mts +0 -4568
  1021. package/dist/entry-lock-CY7XpdSw.d.mts.map +0 -1
  1022. package/dist/entry-lock-DDuWaAiP.mjs +0 -1211
  1023. package/dist/entry-lock-DDuWaAiP.mjs.map +0 -1
  1024. package/dist/entry-lock-D_Og9Gy3.mjs +0 -163
  1025. package/dist/entry-lock-D_Og9Gy3.mjs.map +0 -1
  1026. package/dist/entry-locks-Cp8_BcQQ.mjs +0 -167
  1027. package/dist/entry-locks-Cp8_BcQQ.mjs.map +0 -1
  1028. package/dist/env-types-Br8uywYA.mjs +0 -38
  1029. package/dist/env-types-Br8uywYA.mjs.map +0 -1
  1030. package/dist/error-CT2SsX5S.mjs +0 -90
  1031. package/dist/error-CT2SsX5S.mjs.map +0 -1
  1032. package/dist/errors-BMaCpLeS.mjs +0 -479
  1033. package/dist/errors-BMaCpLeS.mjs.map +0 -1
  1034. package/dist/errors-DlJwot7q.mjs +0 -120
  1035. package/dist/errors-DlJwot7q.mjs.map +0 -1
  1036. package/dist/escape-BfbDyuQ-.mjs +0 -9
  1037. package/dist/escape-BfbDyuQ-.mjs.map +0 -1
  1038. package/dist/fence-BOD3SxZG.mjs +0 -162
  1039. package/dist/fence-BOD3SxZG.mjs.map +0 -1
  1040. package/dist/field-defs-cache-C7sR7ZeU.mjs +0 -77
  1041. package/dist/field-defs-cache-C7sR7ZeU.mjs.map +0 -1
  1042. package/dist/field-map-C_rDXfdJ.mjs +0 -84
  1043. package/dist/field-map-C_rDXfdJ.mjs.map +0 -1
  1044. package/dist/fts-manager-BzFo0xx6.mjs +0 -483
  1045. package/dist/fts-manager-BzFo0xx6.mjs.map +0 -1
  1046. package/dist/gc-B_c3DPpi.mjs +0 -75
  1047. package/dist/gc-B_c3DPpi.mjs.map +0 -1
  1048. package/dist/hash-A-o2ZX8O.mjs +0 -37
  1049. package/dist/hash-A-o2ZX8O.mjs.map +0 -1
  1050. package/dist/hreflang-BpUK9Lcu.mjs +0 -105
  1051. package/dist/hreflang-BpUK9Lcu.mjs.map +0 -1
  1052. package/dist/hreflang-D07R-RbI.d.mts +0 -50
  1053. package/dist/hreflang-D07R-RbI.d.mts.map +0 -1
  1054. package/dist/http-route-dispatch-C2Ep2Uf6.mjs +0 -342
  1055. package/dist/http-route-dispatch-C2Ep2Uf6.mjs.map +0 -1
  1056. package/dist/identity-BivQ8wkV.mjs +0 -35
  1057. package/dist/identity-BivQ8wkV.mjs.map +0 -1
  1058. package/dist/import-B4UvHNJz.mjs +0 -2126
  1059. package/dist/import-B4UvHNJz.mjs.map +0 -1
  1060. package/dist/index-C37Ty40w.d.mts +0 -623
  1061. package/dist/index-C37Ty40w.d.mts.map +0 -1
  1062. package/dist/install-finalization-BbYaB4wj.mjs +0 -58
  1063. package/dist/install-finalization-BbYaB4wj.mjs.map +0 -1
  1064. package/dist/json-recordset-BjYIWFkV.mjs +0 -12
  1065. package/dist/json-recordset-BjYIWFkV.mjs.map +0 -1
  1066. package/dist/json-schema-Cde7le0s.mjs +0 -15
  1067. package/dist/json-schema-Cde7le0s.mjs.map +0 -1
  1068. package/dist/keys-CusTXpw-.mjs +0 -61
  1069. package/dist/keys-CusTXpw-.mjs.map +0 -1
  1070. package/dist/kinds-DogmNB6n.mjs +0 -974
  1071. package/dist/kinds-DogmNB6n.mjs.map +0 -1
  1072. package/dist/lifecycle-BLCoCz4T.mjs +0 -25
  1073. package/dist/lifecycle-BLCoCz4T.mjs.map +0 -1
  1074. package/dist/load-Dds3KhXr.mjs +0 -28
  1075. package/dist/load-Dds3KhXr.mjs.map +0 -1
  1076. package/dist/loader-D4w4XE7q.mjs +0 -1420
  1077. package/dist/loader-D4w4XE7q.mjs.map +0 -1
  1078. package/dist/loops-IYgzQdQu.mjs +0 -205
  1079. package/dist/loops-IYgzQdQu.mjs.map +0 -1
  1080. package/dist/manifest-builder-CGF5kujD.mjs +0 -196
  1081. package/dist/manifest-builder-CGF5kujD.mjs.map +0 -1
  1082. package/dist/manifest-schema-B0BxPSjB.mjs +0 -497
  1083. package/dist/manifest-schema-B0BxPSjB.mjs.map +0 -1
  1084. package/dist/marketplace-DNvEGLqU.mjs +0 -257
  1085. package/dist/marketplace-DNvEGLqU.mjs.map +0 -1
  1086. package/dist/media-BL9MRrSG.mjs +0 -294
  1087. package/dist/media-BL9MRrSG.mjs.map +0 -1
  1088. package/dist/media-B_x5B9EA.mjs +0 -373
  1089. package/dist/media-B_x5B9EA.mjs.map +0 -1
  1090. package/dist/media-allowlist-CpmqBbIQ.mjs +0 -45
  1091. package/dist/media-allowlist-CpmqBbIQ.mjs.map +0 -1
  1092. package/dist/media-folders-CNs_A_B-.mjs +0 -210
  1093. package/dist/media-folders-CNs_A_B-.mjs.map +0 -1
  1094. package/dist/media-qTTHVkls.mjs +0 -416
  1095. package/dist/media-qTTHVkls.mjs.map +0 -1
  1096. package/dist/media-url-GJboA1fl.mjs +0 -43
  1097. package/dist/media-url-GJboA1fl.mjs.map +0 -1
  1098. package/dist/media-usage-ClWgrX0d.mjs +0 -282
  1099. package/dist/media-usage-ClWgrX0d.mjs.map +0 -1
  1100. package/dist/media-usage-activation-B8Fjtq0h.mjs +0 -78
  1101. package/dist/media-usage-activation-B8Fjtq0h.mjs.map +0 -1
  1102. package/dist/media-usage-work-L8-Au4j-.mjs +0 -1036
  1103. package/dist/media-usage-work-L8-Au4j-.mjs.map +0 -1
  1104. package/dist/media-usage-work-LXgze5j9.mjs +0 -151
  1105. package/dist/media-usage-work-LXgze5j9.mjs.map +0 -1
  1106. package/dist/menus-BAxcbsbv.mjs +0 -818
  1107. package/dist/menus-BAxcbsbv.mjs.map +0 -1
  1108. package/dist/menus-BI6oBXco.mjs +0 -92
  1109. package/dist/menus-BI6oBXco.mjs.map +0 -1
  1110. package/dist/menus-fvGFd4m6.mjs +0 -3725
  1111. package/dist/menus-fvGFd4m6.mjs.map +0 -1
  1112. package/dist/mime-DwhtRyUt.mjs +0 -81
  1113. package/dist/mime-DwhtRyUt.mjs.map +0 -1
  1114. package/dist/mode-DIDSUwuN.mjs +0 -23
  1115. package/dist/mode-DIDSUwuN.mjs.map +0 -1
  1116. package/dist/node-sqlite-compat-Ddr_mlR9.mjs +0 -63
  1117. package/dist/node-sqlite-compat-Ddr_mlR9.mjs.map +0 -1
  1118. package/dist/normalize-Ip_hFAm8.mjs +0 -216
  1119. package/dist/normalize-Ip_hFAm8.mjs.map +0 -1
  1120. package/dist/oauth-authorization-CcMgeT8R.mjs +0 -274
  1121. package/dist/oauth-authorization-CcMgeT8R.mjs.map +0 -1
  1122. package/dist/oauth-clients-C_osi0PU.mjs +0 -266
  1123. package/dist/oauth-clients-C_osi0PU.mjs.map +0 -1
  1124. package/dist/oauth-state-store-DGLP-6CK.mjs +0 -50
  1125. package/dist/oauth-state-store-DGLP-6CK.mjs.map +0 -1
  1126. package/dist/oauth-user-lookup-z77Ee0Hm.mjs +0 -26
  1127. package/dist/oauth-user-lookup-z77Ee0Hm.mjs.map +0 -1
  1128. package/dist/object-cache-EjasjtoQ.mjs +0 -586
  1129. package/dist/object-cache-EjasjtoQ.mjs.map +0 -1
  1130. package/dist/options-CmUpkyKW.d.mts +0 -81
  1131. package/dist/options-CmUpkyKW.d.mts.map +0 -1
  1132. package/dist/ownership-DCk5NutQ.mjs +0 -12
  1133. package/dist/ownership-DCk5NutQ.mjs.map +0 -1
  1134. package/dist/parse-2W-E2f7w.mjs +0 -81
  1135. package/dist/parse-2W-E2f7w.mjs.map +0 -1
  1136. package/dist/parse-6pN8Xqg5.d.mts +0 -176
  1137. package/dist/parse-6pN8Xqg5.d.mts.map +0 -1
  1138. package/dist/passkey-config-DTTZB6EI.mjs +0 -46
  1139. package/dist/passkey-config-DTTZB6EI.mjs.map +0 -1
  1140. package/dist/paths-CQA62503.mjs +0 -77
  1141. package/dist/paths-CQA62503.mjs.map +0 -1
  1142. package/dist/placeholder-BlfXkucE.d.mts +0 -313
  1143. package/dist/placeholder-BlfXkucE.d.mts.map +0 -1
  1144. package/dist/plan-B95eiwnF.mjs +0 -135
  1145. package/dist/plan-B95eiwnF.mjs.map +0 -1
  1146. package/dist/plugin-tool-name-BDA7m4Xa.mjs +0 -27
  1147. package/dist/plugin-tool-name-BDA7m4Xa.mjs.map +0 -1
  1148. package/dist/plugins-BhxLJ008.mjs +0 -261
  1149. package/dist/plugins-BhxLJ008.mjs.map +0 -1
  1150. package/dist/policy-DOJ2sPqB.mjs +0 -53
  1151. package/dist/policy-DOJ2sPqB.mjs.map +0 -1
  1152. package/dist/portable-text-RCMpCj47.mjs +0 -311
  1153. package/dist/portable-text-RCMpCj47.mjs.map +0 -1
  1154. package/dist/preview-DFwL5APO.mjs +0 -107
  1155. package/dist/preview-DFwL5APO.mjs.map +0 -1
  1156. package/dist/protocol-B-ztxp_y.d.mts +0 -65
  1157. package/dist/protocol-B-ztxp_y.d.mts.map +0 -1
  1158. package/dist/public-plugin-api-routes-ik4fPZMv.mjs +0 -316
  1159. package/dist/public-plugin-api-routes-ik4fPZMv.mjs.map +0 -1
  1160. package/dist/public-submission-C5JZIykp.mjs +0 -251
  1161. package/dist/public-submission-C5JZIykp.mjs.map +0 -1
  1162. package/dist/public-url-CQwzRljH.mjs +0 -101
  1163. package/dist/public-url-CQwzRljH.mjs.map +0 -1
  1164. package/dist/query-DuwyFr5Z.mjs +0 -41
  1165. package/dist/query-DuwyFr5Z.mjs.map +0 -1
  1166. package/dist/query-eR_Nz70M.mjs +0 -1157
  1167. package/dist/query-eR_Nz70M.mjs.map +0 -1
  1168. package/dist/range-BQWPjWgQ.mjs +0 -51
  1169. package/dist/range-BQWPjWgQ.mjs.map +0 -1
  1170. package/dist/rate-limit-mPKeQ3sm.mjs +0 -127
  1171. package/dist/rate-limit-mPKeQ3sm.mjs.map +0 -1
  1172. package/dist/receipt-CmUpyuW5.mjs +0 -43
  1173. package/dist/receipt-CmUpyuW5.mjs.map +0 -1
  1174. package/dist/redirect-BtiMkehU.mjs +0 -19
  1175. package/dist/redirect-BtiMkehU.mjs.map +0 -1
  1176. package/dist/redirect-DcmNMvOs.mjs +0 -423
  1177. package/dist/redirect-DcmNMvOs.mjs.map +0 -1
  1178. package/dist/redirect-paths-K5i3xYfR.mjs +0 -36
  1179. package/dist/redirect-paths-K5i3xYfR.mjs.map +0 -1
  1180. package/dist/redirects-BA_TvtuH.mjs +0 -148
  1181. package/dist/redirects-BA_TvtuH.mjs.map +0 -1
  1182. package/dist/redirects-BIrRvgn4.mjs +0 -446
  1183. package/dist/redirects-BIrRvgn4.mjs.map +0 -1
  1184. package/dist/registry-DymfZkAN.mjs +0 -8374
  1185. package/dist/registry-DymfZkAN.mjs.map +0 -1
  1186. package/dist/relations-DrEs3Sc1.mjs +0 -789
  1187. package/dist/relations-DrEs3Sc1.mjs.map +0 -1
  1188. package/dist/request-meta-o8RIf9pa.mjs +0 -141
  1189. package/dist/request-meta-o8RIf9pa.mjs.map +0 -1
  1190. package/dist/resolve-CVy9xgy_.mjs +0 -102
  1191. package/dist/resolve-CVy9xgy_.mjs.map +0 -1
  1192. package/dist/route-cache-DAG5dPhh.mjs +0 -20
  1193. package/dist/route-cache-DAG5dPhh.mjs.map +0 -1
  1194. package/dist/route-wire-Xbsu8Vih.mjs +0 -197
  1195. package/dist/route-wire-Xbsu8Vih.mjs.map +0 -1
  1196. package/dist/routes-YQkSOsws.mjs +0 -272
  1197. package/dist/routes-YQkSOsws.mjs.map +0 -1
  1198. package/dist/runner-CLorw5vo.mjs +0 -6669
  1199. package/dist/runner-CLorw5vo.mjs.map +0 -1
  1200. package/dist/runner-g1A9P-wD.d.mts +0 -73
  1201. package/dist/runner-g1A9P-wD.d.mts.map +0 -1
  1202. package/dist/schema-Bss8qImF.mjs +0 -13
  1203. package/dist/schema-Bss8qImF.mjs.map +0 -1
  1204. package/dist/schema-C036pqEw.mjs +0 -815
  1205. package/dist/schema-C036pqEw.mjs.map +0 -1
  1206. package/dist/scopes-C_SoYl9x.mjs +0 -34
  1207. package/dist/scopes-C_SoYl9x.mjs.map +0 -1
  1208. package/dist/search-uNqCgePJ.mjs +0 -450
  1209. package/dist/search-uNqCgePJ.mjs.map +0 -1
  1210. package/dist/secrets-Cc_O3Kp-.mjs +0 -369
  1211. package/dist/secrets-Cc_O3Kp-.mjs.map +0 -1
  1212. package/dist/sections-BLusMa96.mjs +0 -346
  1213. package/dist/sections-BLusMa96.mjs.map +0 -1
  1214. package/dist/seo-BodxIpws.mjs +0 -188
  1215. package/dist/seo-BodxIpws.mjs.map +0 -1
  1216. package/dist/seo-DaMYIQY8.mjs +0 -133
  1217. package/dist/seo-DaMYIQY8.mjs.map +0 -1
  1218. package/dist/service-BuM1BRsA.mjs +0 -150
  1219. package/dist/service-BuM1BRsA.mjs.map +0 -1
  1220. package/dist/session-user-2DpQDMKw.mjs +0 -61
  1221. package/dist/session-user-2DpQDMKw.mjs.map +0 -1
  1222. package/dist/settings-B3ZmPF_8.mjs +0 -73
  1223. package/dist/settings-B3ZmPF_8.mjs.map +0 -1
  1224. package/dist/settings-P5hwPX6_.mjs +0 -66
  1225. package/dist/settings-P5hwPX6_.mjs.map +0 -1
  1226. package/dist/settings-yIqoN-Ok.mjs +0 -519
  1227. package/dist/settings-yIqoN-Ok.mjs.map +0 -1
  1228. package/dist/setup-complete-eu6MUQnt.mjs +0 -65
  1229. package/dist/setup-complete-eu6MUQnt.mjs.map +0 -1
  1230. package/dist/setup-nonce-CyPOapqY.mjs +0 -25
  1231. package/dist/setup-nonce-CyPOapqY.mjs.map +0 -1
  1232. package/dist/site-domain-8lEJl_0U.mjs +0 -131
  1233. package/dist/site-domain-8lEJl_0U.mjs.map +0 -1
  1234. package/dist/site-settings-uPkW0e6o.mjs +0 -50
  1235. package/dist/site-settings-uPkW0e6o.mjs.map +0 -1
  1236. package/dist/site-url-25SGVXwL.mjs +0 -45
  1237. package/dist/site-url-25SGVXwL.mjs.map +0 -1
  1238. package/dist/sitemap-name-DTK7CYnY.mjs +0 -26
  1239. package/dist/sitemap-name-DTK7CYnY.mjs.map +0 -1
  1240. package/dist/slug-BEDl2IJY.mjs +0 -16
  1241. package/dist/slug-BEDl2IJY.mjs.map +0 -1
  1242. package/dist/snapshot-CvkIBRLY.mjs +0 -414
  1243. package/dist/snapshot-CvkIBRLY.mjs.map +0 -1
  1244. package/dist/ssrf-mcCKMH6B.mjs +0 -406
  1245. package/dist/ssrf-mcCKMH6B.mjs.map +0 -1
  1246. package/dist/stage-BQfGzGOy.mjs +0 -662
  1247. package/dist/stage-BQfGzGOy.mjs.map +0 -1
  1248. package/dist/staged-B5vQGeSf.mjs +0 -686
  1249. package/dist/staged-B5vQGeSf.mjs.map +0 -1
  1250. package/dist/state-dO6t6OxV.mjs +0 -178
  1251. package/dist/state-dO6t6OxV.mjs.map +0 -1
  1252. package/dist/status-DSURZwKS.mjs +0 -30
  1253. package/dist/status-DSURZwKS.mjs.map +0 -1
  1254. package/dist/storage-query-Cy0SZ8iG.d.mts +0 -1619
  1255. package/dist/storage-query-Cy0SZ8iG.d.mts.map +0 -1
  1256. package/dist/tar-DWzcUZ_Q.mjs +0 -449
  1257. package/dist/tar-DWzcUZ_Q.mjs.map +0 -1
  1258. package/dist/target-C9htUbrT.mjs +0 -27
  1259. package/dist/target-C9htUbrT.mjs.map +0 -1
  1260. package/dist/taxonomies-By2aGvq2.mjs +0 -729
  1261. package/dist/taxonomies-By2aGvq2.mjs.map +0 -1
  1262. package/dist/taxonomies-CVRd_jz0.mjs +0 -937
  1263. package/dist/taxonomies-CVRd_jz0.mjs.map +0 -1
  1264. package/dist/taxonomy-BG_xu2Qf.mjs +0 -563
  1265. package/dist/taxonomy-BG_xu2Qf.mjs.map +0 -1
  1266. package/dist/tokens-U5vzgSrM.mjs +0 -171
  1267. package/dist/tokens-U5vzgSrM.mjs.map +0 -1
  1268. package/dist/transfer-DA0OSfaT.mjs +0 -8873
  1269. package/dist/transfer-DA0OSfaT.mjs.map +0 -1
  1270. package/dist/transfer-Pyf3d7ka.mjs +0 -166
  1271. package/dist/transfer-Pyf3d7ka.mjs.map +0 -1
  1272. package/dist/transfer-download-cX7SuWEy.mjs +0 -33
  1273. package/dist/transfer-download-cX7SuWEy.mjs.map +0 -1
  1274. package/dist/transformations-DczubD4j.mjs +0 -196
  1275. package/dist/transformations-DczubD4j.mjs.map +0 -1
  1276. package/dist/transport-DtIrjEFO.mjs +0 -137
  1277. package/dist/transport-DtIrjEFO.mjs.map +0 -1
  1278. package/dist/trusted-proxy-CDRd5Kmw.mjs +0 -51
  1279. package/dist/trusted-proxy-CDRd5Kmw.mjs.map +0 -1
  1280. package/dist/turnstile-Ct5YuFNY.mjs +0 -58
  1281. package/dist/turnstile-Ct5YuFNY.mjs.map +0 -1
  1282. package/dist/types-Bgujop4S.d.mts +0 -374
  1283. package/dist/types-Bgujop4S.d.mts.map +0 -1
  1284. package/dist/types-BirHUEXt.mjs +0 -18
  1285. package/dist/types-BirHUEXt.mjs.map +0 -1
  1286. package/dist/types-BqJgTL_y.d.mts +0 -293
  1287. package/dist/types-BqJgTL_y.d.mts.map +0 -1
  1288. package/dist/types-C-lrOt9T.d.mts +0 -87
  1289. package/dist/types-C-lrOt9T.d.mts.map +0 -1
  1290. package/dist/types-CCEHAhOv.d.mts +0 -916
  1291. package/dist/types-CCEHAhOv.d.mts.map +0 -1
  1292. package/dist/types-CLVwYRBr.d.mts +0 -227
  1293. package/dist/types-CLVwYRBr.d.mts.map +0 -1
  1294. package/dist/types-DVbTb4Hk.mjs +0 -77
  1295. package/dist/types-DVbTb4Hk.mjs.map +0 -1
  1296. package/dist/types-Ddku19Zw.d.mts +0 -209
  1297. package/dist/types-Ddku19Zw.d.mts.map +0 -1
  1298. package/dist/types-FIiGQ3PE.mjs +0 -16
  1299. package/dist/types-FIiGQ3PE.mjs.map +0 -1
  1300. package/dist/types-OauzCOY0.mjs +0 -37
  1301. package/dist/types-OauzCOY0.mjs.map +0 -1
  1302. package/dist/types-mQGTpP-4.d.mts +0 -1741
  1303. package/dist/types-mQGTpP-4.d.mts.map +0 -1
  1304. package/dist/types-nbjz3Mgm.d.mts +0 -125
  1305. package/dist/types-nbjz3Mgm.d.mts.map +0 -1
  1306. package/dist/update-check-hW32-0pf.mjs +0 -161
  1307. package/dist/update-check-hW32-0pf.mjs.map +0 -1
  1308. package/dist/upload-attempts-Bpik1TLF.mjs +0 -32
  1309. package/dist/upload-attempts-Bpik1TLF.mjs.map +0 -1
  1310. package/dist/url-pattern-CJeCyNij.mjs +0 -41
  1311. package/dist/url-pattern-CJeCyNij.mjs.map +0 -1
  1312. package/dist/user-nQInBZbE.mjs +0 -171
  1313. package/dist/user-nQInBZbE.mjs.map +0 -1
  1314. package/dist/utils-govudc_U.mjs +0 -442
  1315. package/dist/utils-govudc_U.mjs.map +0 -1
  1316. package/dist/validate-BxLvcDYh.mjs +0 -524
  1317. package/dist/validate-BxLvcDYh.mjs.map +0 -1
  1318. package/dist/validate-mnoVfASU.d.mts +0 -468
  1319. package/dist/validate-mnoVfASU.d.mts.map +0 -1
  1320. package/dist/validation-DQDEvh87.mjs +0 -221
  1321. package/dist/validation-DQDEvh87.mjs.map +0 -1
  1322. package/dist/version-BOFfLiVT.mjs +0 -49
  1323. package/dist/version-BOFfLiVT.mjs.map +0 -1
  1324. package/dist/version-Dcvx_C9g.mjs +0 -7
  1325. package/dist/version-Dcvx_C9g.mjs.map +0 -1
  1326. package/dist/version-DzTJ3gD7.mjs +0 -9
  1327. package/dist/version-DzTJ3gD7.mjs.map +0 -1
  1328. package/dist/video-BX7AI5nJ.mjs +0 -54
  1329. package/dist/video-BX7AI5nJ.mjs.map +0 -1
  1330. package/dist/virtual-modules-CU29aip9.mjs +0 -515
  1331. package/dist/virtual-modules-CU29aip9.mjs.map +0 -1
  1332. package/dist/widgets-HIeFmZxt.mjs +0 -121
  1333. package/dist/widgets-HIeFmZxt.mjs.map +0 -1
  1334. package/dist/wxr-taxonomies-DyOGhl8W.mjs +0 -454
  1335. package/dist/wxr-taxonomies-DyOGhl8W.mjs.map +0 -1
  1336. package/dist/zod-generator-VxCPVDpo.mjs +0 -425
  1337. package/dist/zod-generator-VxCPVDpo.mjs.map +0 -1
  1338. /package/dist/{ssrf-BBXcxG-f.mjs → ssrf-DM0E-D_8.mjs} +0 -0
@@ -0,0 +1,3802 @@
1
+ import { t as validateIdentifier } from "./validate-DANX1-Qi.mjs";
2
+ import { a as getLocaleChainRank, o as getLocaleRank } from "./config-Cs_AwWXI.mjs";
3
+ import { getRequestContext } from "./request-context.mjs";
4
+ import { t as OptionsRepository } from "./options-DhrI7eMv.mjs";
5
+ import { n as localeMatches } from "./query-BFHjCzSh.mjs";
6
+ import { _ as isObjectCacheActive, a as contentCacheNamespaces, n as cachedQuery, r as cachedQueryWithEpochs, t as CacheNamespace } from "./object-cache-DmKr09La.mjs";
7
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-DiW8VMwz.mjs";
8
+ import { r as requestCached } from "./request-cache-5z2WzWmh.mjs";
9
+ import { i as sanitizeHref } from "./url-DTfGDJhI.mjs";
10
+ import { t as CommentRepository } from "./comment-DB74Zpa4.mjs";
11
+ import { C as toBylineInfo, t as PluginContextFactory } from "./context-CzjejcsE.mjs";
12
+ import { a as resolveLocalizedContentRoutePath, i as resolveLocaleChain, r as resolveLocale } from "./resolve-DdNXBJSr.mjs";
13
+ import { n as inspectContentPolicyDecision } from "./content-policy-BmE0MPZY.mjs";
14
+ import { t as menuTag } from "./chrome-tags-BIKBMZYO.mjs";
15
+ import { u as getDb } from "./loader-DhnedqY4.mjs";
16
+ import { n as videoBlockFields, r as videoNodeAttrs, t as isPortableTextVideoBlock } from "./video-DytCnw3L.mjs";
17
+ import { a as normalizePluginCapabilities, o as warnDeprecatedPluginCapabilities } from "./types-sUHaH7lC.mjs";
18
+ import { a as sanitizeGalleryImages, i as resolveImageMedia } from "./apply-DVnupNeS.mjs";
19
+ import { r as setCronTasksEnabled } from "./cron-D7obTIfk.mjs";
20
+ import { t as PluginRouteRegistry } from "./routes-avqgc-8r.mjs";
21
+ import { t as CommentReactionRepository } from "./comment-reaction-BScxIWUn.mjs";
22
+ import { sql } from "kysely";
23
+ import { AsyncLocalStorage } from "node:async_hooks";
24
+ import { z } from "astro/zod";
25
+ import { PLUGIN_CAPABILITIES, isJsonPostRouteContract } from "@emdash-cms/plugin-types";
26
+ import { htmlBlockFields } from "@emdash-cms/admin/html-block";
27
+ import { UnsafePortableTextTableError, portableTextTableToProseMirror, proseMirrorTableToPortableText } from "@emdash-cms/admin/portable-text-table";
28
+ import { Extension, Mark, Node } from "@tiptap/core";
29
+
30
+ //#region src/config/errors.ts
31
+ /** A configuration failure whose message is safe to return from the API. */
32
+ var EmDashConfigurationError = class extends Error {
33
+ constructor(message, code, cause) {
34
+ super(message);
35
+ this.code = code;
36
+ this.cause = cause;
37
+ this.name = "EmDashConfigurationError";
38
+ }
39
+ };
40
+
41
+ //#endregion
42
+ //#region src/fields/image.ts
43
+ const mediaSchema = z.object({
44
+ id: z.string(),
45
+ src: z.string().optional(),
46
+ alt: z.string().optional(),
47
+ caption: z.string().optional(),
48
+ width: z.number().optional(),
49
+ height: z.number().optional(),
50
+ filename: z.string().optional(),
51
+ mimeType: z.string().optional(),
52
+ blurhash: z.string().optional(),
53
+ dominantColor: z.string().optional(),
54
+ focalX: z.number().optional(),
55
+ focalY: z.number().optional(),
56
+ provider: z.string().optional(),
57
+ previewUrl: z.string().optional(),
58
+ meta: z.record(z.string(), z.unknown()).optional()
59
+ });
60
+ const imageSchema = mediaSchema.extend({ darkVariant: mediaSchema.optional() });
61
+ function image(options = {}) {
62
+ const validation = options.allowedTypes && options.allowedTypes.length > 0 ? { allowedMimeTypes: [...options.allowedTypes] } : void 0;
63
+ return {
64
+ type: "image",
65
+ columnType: "TEXT",
66
+ schema: options.required === false ? imageSchema.optional() : imageSchema,
67
+ options,
68
+ ui: { widget: "image" },
69
+ validation
70
+ };
71
+ }
72
+
73
+ //#endregion
74
+ //#region src/fields/file.ts
75
+ function file(options = {}) {
76
+ const fileObjSchema = z.object({
77
+ id: z.string(),
78
+ url: z.string().optional(),
79
+ src: z.string().optional(),
80
+ filename: z.string().optional(),
81
+ mimeType: z.string().optional(),
82
+ size: z.number().optional(),
83
+ provider: z.string().optional(),
84
+ meta: z.record(z.string(), z.unknown()).optional()
85
+ });
86
+ return {
87
+ type: "file",
88
+ columnType: "TEXT",
89
+ schema: options.required ? fileObjSchema : fileObjSchema.optional(),
90
+ options,
91
+ ui: {
92
+ widget: "file",
93
+ helpText: options.helpText,
94
+ maxSize: options.maxSize
95
+ },
96
+ validation: options.allowedTypes && options.allowedTypes.length > 0 ? { allowedMimeTypes: [...options.allowedTypes] } : void 0
97
+ };
98
+ }
99
+
100
+ //#endregion
101
+ //#region src/fields/reference.ts
102
+ /**
103
+ * Reference field
104
+ * References another content item by ID
105
+ */
106
+ function reference(collection, options) {
107
+ const schema = z.string();
108
+ return {
109
+ type: "reference",
110
+ columnType: "TEXT",
111
+ schema: options?.required === false ? schema.optional() : schema,
112
+ options: {
113
+ ...options,
114
+ collection
115
+ },
116
+ ui: { widget: "reference" }
117
+ };
118
+ }
119
+
120
+ //#endregion
121
+ //#region src/fields/portable-text.ts
122
+ /**
123
+ * Portable Text block schema
124
+ */
125
+ const portableTextBlockSchema = z.object({
126
+ _type: z.string(),
127
+ _key: z.string()
128
+ }).loose();
129
+ /**
130
+ * Portable Text field
131
+ * Stores structured content in Portable Text format
132
+ */
133
+ function portableText(options) {
134
+ const schema = z.array(portableTextBlockSchema);
135
+ return {
136
+ type: "portableText",
137
+ columnType: "JSON",
138
+ schema: options?.required === false ? schema.optional() : schema,
139
+ options,
140
+ ui: { widget: "portableText" }
141
+ };
142
+ }
143
+
144
+ //#endregion
145
+ //#region src/content/converters/mark-safety.ts
146
+ const SUPPORTED_PORTABLE_TEXT_DECORATORS = new Set([
147
+ "strong",
148
+ "em",
149
+ "underline",
150
+ "strike-through",
151
+ "subscript",
152
+ "superscript",
153
+ "code"
154
+ ]);
155
+ const SUPPORTED_PROSEMIRROR_MARKS = new Set([
156
+ "bold",
157
+ "strong",
158
+ "italic",
159
+ "em",
160
+ "underline",
161
+ "strike",
162
+ "strikethrough",
163
+ "subscript",
164
+ "superscript",
165
+ "code",
166
+ "link",
167
+ "emdashPortableTextSpan"
168
+ ]);
169
+ function isRecord$2(value) {
170
+ return typeof value === "object" && value !== null && !Array.isArray(value);
171
+ }
172
+ function collectPortableTextMarks(value, inheritedMarkDefs, unsupported) {
173
+ if (Array.isArray(value)) {
174
+ for (const item of value) collectPortableTextMarks(item, inheritedMarkDefs, unsupported);
175
+ return;
176
+ }
177
+ if (!isRecord$2(value)) return;
178
+ let markDefs = inheritedMarkDefs;
179
+ if (Array.isArray(value.markDefs)) {
180
+ const localMarkDefs = new Map(inheritedMarkDefs);
181
+ for (const markDef of value.markDefs) if (isRecord$2(markDef) && typeof markDef._key === "string") localMarkDefs.set(markDef._key, markDef);
182
+ markDefs = localMarkDefs;
183
+ }
184
+ if (value._type === "span" && Array.isArray(value.marks)) for (const mark of value.marks) {
185
+ if (typeof mark !== "string" || SUPPORTED_PORTABLE_TEXT_DECORATORS.has(mark)) continue;
186
+ const markDef = markDefs.get(mark);
187
+ if (markDef?._type === "link") continue;
188
+ unsupported.add(typeof markDef?._type === "string" ? markDef._type : mark);
189
+ }
190
+ for (const [key, child] of Object.entries(value)) if (key !== "markDefs") collectPortableTextMarks(child, markDefs, unsupported);
191
+ }
192
+ function collectProseMirrorMarks(node, unsupported) {
193
+ for (const mark of node.marks ?? []) if (!SUPPORTED_PROSEMIRROR_MARKS.has(mark.type)) unsupported.add(mark.type);
194
+ for (const child of node.content ?? []) collectProseMirrorMarks(child, unsupported);
195
+ }
196
+ var UnsupportedPortableTextMarksError = class extends Error {
197
+ marks;
198
+ constructor(marks) {
199
+ const sortedMarks = [...new Set(marks)].toSorted();
200
+ super(`Unsupported Portable Text marks: ${sortedMarks.join(", ")}`);
201
+ this.name = "UnsupportedPortableTextMarksError";
202
+ this.marks = sortedMarks;
203
+ }
204
+ };
205
+ function findUnsupportedPortableTextMarks(blocks) {
206
+ const unsupported = /* @__PURE__ */ new Set();
207
+ for (const block of blocks) if (block._type === "block" || block._type === "table") collectPortableTextMarks(block, /* @__PURE__ */ new Map(), unsupported);
208
+ return [...unsupported].toSorted();
209
+ }
210
+ function assertPortableTextMarksSupported(blocks) {
211
+ const unsupported = findUnsupportedPortableTextMarks(blocks);
212
+ if (unsupported.length > 0) throw new UnsupportedPortableTextMarksError(unsupported);
213
+ }
214
+ function assertProseMirrorMarksSupported(document) {
215
+ const unsupported = /* @__PURE__ */ new Set();
216
+ for (const node of document.content) collectProseMirrorMarks(node, unsupported);
217
+ if (unsupported.size > 0) throw new UnsupportedPortableTextMarksError(unsupported);
218
+ }
219
+
220
+ //#endregion
221
+ //#region src/content/converters/numbered-list.ts
222
+ const MAX_ORDERED_LIST_START = 2147483647;
223
+ function normalizeListId(value) {
224
+ if (typeof value !== "string") return void 0;
225
+ const normalized = value.trim();
226
+ return normalized.length > 0 && normalized.length <= 128 ? normalized : void 0;
227
+ }
228
+ function normalizeListStart(value) {
229
+ return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= MAX_ORDERED_LIST_START ? value : void 0;
230
+ }
231
+ function deriveLegacyListId(seed) {
232
+ const readable = `legacy:${seed}`;
233
+ if (readable.length <= 128) return readable;
234
+ let hash = 2166136261;
235
+ for (let i = 0; i < seed.length; i++) {
236
+ hash ^= seed.charCodeAt(i);
237
+ hash = Math.imul(hash, 16777619);
238
+ }
239
+ return `legacy:${seed.slice(0, 96)}:${(hash >>> 0).toString(36)}:${seed.length.toString(36)}`;
240
+ }
241
+ function readOrderedListMetadata(attrs, fallbackId) {
242
+ return {
243
+ listId: normalizeListId(attrs?.listId) ?? deriveLegacyListId(fallbackId),
244
+ listStart: normalizeListStart(attrs?.listStart) ?? normalizeListStart(attrs?.start) ?? 1
245
+ };
246
+ }
247
+ function collectProseMirrorOrderedLists(doc) {
248
+ const lists = [];
249
+ const visit = (node, path, depth, context) => {
250
+ if (node.type === "orderedList") lists.push({
251
+ node,
252
+ path,
253
+ depth,
254
+ context
255
+ });
256
+ for (const [index, child] of (node.content ?? []).entries()) {
257
+ const childPath = `${path}:${index}`;
258
+ visit(child, childPath, depth + 1, child.type === "listItem" ? `listItem:${childPath}` : context);
259
+ }
260
+ };
261
+ for (const [index, node] of doc.content.entries()) visit(node, `root:${index}`, 0, "root");
262
+ return lists;
263
+ }
264
+ function cloneProseMirrorNode(node) {
265
+ return {
266
+ ...node,
267
+ attrs: node.attrs ? { ...node.attrs } : void 0,
268
+ content: node.content?.map(cloneProseMirrorNode),
269
+ marks: node.marks?.map((mark) => ({
270
+ ...mark,
271
+ attrs: mark.attrs ? { ...mark.attrs } : void 0
272
+ }))
273
+ };
274
+ }
275
+ function createRepairId(sourceId, scope, attempt) {
276
+ const base = deriveLegacyListId(`repair:${sourceId}:${scope}`);
277
+ const suffix = `:${attempt.toString(36)}`;
278
+ return `${base.slice(0, 128 - suffix.length)}${suffix}`;
279
+ }
280
+ function normalizeProseMirrorOrderedListJson(doc) {
281
+ const normalized = {
282
+ ...doc,
283
+ content: doc.content.map(cloneProseMirrorNode)
284
+ };
285
+ const canonicalBySourceScope = /* @__PURE__ */ new Map();
286
+ const assignedCanonicalIds = /* @__PURE__ */ new Set();
287
+ const lists = collectProseMirrorOrderedLists(normalized).map((list) => {
288
+ const sourceId = normalizeListId(list.node.attrs?.listId) ?? deriveLegacyListId(`pm-json:${list.path}:${list.depth}:${list.context}`);
289
+ const scope = JSON.stringify([list.depth, list.context]);
290
+ const sourceScope = JSON.stringify([sourceId, scope]);
291
+ let listId = canonicalBySourceScope.get(sourceScope);
292
+ if (!listId) {
293
+ if (!assignedCanonicalIds.has(sourceId)) listId = sourceId;
294
+ else {
295
+ let attempt = 0;
296
+ do
297
+ listId = createRepairId(sourceId, scope, attempt++);
298
+ while (assignedCanonicalIds.has(listId));
299
+ }
300
+ canonicalBySourceScope.set(sourceScope, listId);
301
+ assignedCanonicalIds.add(listId);
302
+ }
303
+ return {
304
+ ...list,
305
+ listId,
306
+ scopeKey: JSON.stringify([
307
+ listId,
308
+ list.depth,
309
+ list.context
310
+ ])
311
+ };
312
+ });
313
+ const bases = /* @__PURE__ */ new Map();
314
+ for (const list of lists) {
315
+ const listStart = normalizeListStart(list.node.attrs?.listStart);
316
+ if (listStart !== void 0 && !bases.has(list.scopeKey)) bases.set(list.scopeKey, listStart);
317
+ }
318
+ for (const list of lists) if (!bases.has(list.scopeKey)) bases.set(list.scopeKey, normalizeListStart(list.node.attrs?.start) ?? 1);
319
+ const counts = /* @__PURE__ */ new Map();
320
+ for (const list of lists) {
321
+ const listStart = bases.get(list.scopeKey);
322
+ const count = counts.get(list.scopeKey) ?? 0;
323
+ const start = normalizeListStart(listStart + count) ?? 1;
324
+ const directItemCount = list.node.content?.filter((node) => node.type === "listItem").length ?? 0;
325
+ counts.set(list.scopeKey, count + directItemCount);
326
+ list.node.attrs = {
327
+ ...list.node.attrs,
328
+ listId: list.listId,
329
+ listStart,
330
+ start
331
+ };
332
+ }
333
+ return normalized;
334
+ }
335
+
336
+ //#endregion
337
+ //#region src/content/converters/portable-text-identity.ts
338
+ const PORTABLE_TEXT_BLOCK_NODE = "emdashPortableTextBlock";
339
+ const PORTABLE_TEXT_BLOCK_ATTR = "emdashPortableTextBlock";
340
+ const PORTABLE_TEXT_KEY_ATTR = "emdashPortableTextKey";
341
+ const PORTABLE_TEXT_SPAN_MARK = "emdashPortableTextSpan";
342
+ function isRecord$1(value) {
343
+ return typeof value === "object" && value !== null && !Array.isArray(value);
344
+ }
345
+ function attrsWithPortableTextKey(attrs, key) {
346
+ return {
347
+ ...attrs,
348
+ [PORTABLE_TEXT_KEY_ATTR]: key
349
+ };
350
+ }
351
+ function portableTextKeyFromAttrs(attrs) {
352
+ const key = attrs?.[PORTABLE_TEXT_KEY_ATTR];
353
+ return typeof key === "string" && key ? key : void 0;
354
+ }
355
+ function portableTextSpanKeyFromMarks(marks) {
356
+ for (const mark of marks ?? []) {
357
+ if (!isRecord$1(mark) || mark.type !== PORTABLE_TEXT_SPAN_MARK || !isRecord$1(mark.attrs)) continue;
358
+ const key = mark.attrs.key;
359
+ if (typeof key === "string" && key) return key;
360
+ }
361
+ }
362
+ function portableTextMarkDefsFromMarks(marks) {
363
+ const identity = (marks ?? []).find((mark) => isRecord$1(mark) && mark.type === PORTABLE_TEXT_SPAN_MARK && isRecord$1(mark.attrs));
364
+ if (!isRecord$1(identity) || !isRecord$1(identity.attrs) || !Array.isArray(identity.attrs.markDefs)) return [];
365
+ return identity.attrs.markDefs.filter((markDef) => isRecord$1(markDef) && typeof markDef._type === "string" && typeof markDef._key === "string");
366
+ }
367
+ function portableTextBlockFromAttrs(attrs) {
368
+ const block = attrs?.[PORTABLE_TEXT_BLOCK_ATTR];
369
+ if (!isRecord$1(block) || typeof block._type !== "string" || typeof block._key !== "string") return;
370
+ return {
371
+ ...block,
372
+ _type: block._type,
373
+ _key: block._key
374
+ };
375
+ }
376
+ const PortableTextIdentityExtension = Extension.create({
377
+ name: "emdashPortableTextIdentity",
378
+ addGlobalAttributes() {
379
+ const hiddenAttribute = {
380
+ default: null,
381
+ rendered: false
382
+ };
383
+ return [{
384
+ types: [
385
+ "paragraph",
386
+ "heading",
387
+ "blockquote",
388
+ "codeBlock",
389
+ "htmlBlock",
390
+ "iframeBlock",
391
+ "image",
392
+ "videoBlock",
393
+ "horizontalRule",
394
+ "gallery",
395
+ PORTABLE_TEXT_BLOCK_NODE
396
+ ],
397
+ attributes: { [PORTABLE_TEXT_KEY_ATTR]: hiddenAttribute }
398
+ }];
399
+ }
400
+ });
401
+ const PortableTextSpanIdentity = Mark.create({
402
+ name: PORTABLE_TEXT_SPAN_MARK,
403
+ inclusive: false,
404
+ spanning: false,
405
+ addAttributes() {
406
+ return {
407
+ key: {
408
+ default: null,
409
+ rendered: false
410
+ },
411
+ markDefs: {
412
+ default: [],
413
+ rendered: false
414
+ }
415
+ };
416
+ },
417
+ parseHTML() {
418
+ return [];
419
+ },
420
+ renderHTML() {
421
+ return ["span", 0];
422
+ }
423
+ });
424
+ const PortableTextOpaqueBlock = Node.create({
425
+ name: PORTABLE_TEXT_BLOCK_NODE,
426
+ group: "block",
427
+ atom: true,
428
+ selectable: true,
429
+ draggable: true,
430
+ addAttributes() {
431
+ return { [PORTABLE_TEXT_BLOCK_ATTR]: {
432
+ default: null,
433
+ rendered: false
434
+ } };
435
+ },
436
+ parseHTML() {
437
+ return [{ tag: "div[data-emdash-portable-text-block]" }];
438
+ },
439
+ renderHTML({ node }) {
440
+ const blockType = portableTextBlockFromAttrs(node.attrs)?._type ?? "unknown";
441
+ return [
442
+ "div",
443
+ {
444
+ "data-emdash-portable-text-block": blockType,
445
+ contenteditable: "false"
446
+ },
447
+ `[Unknown block type: ${blockType}]`
448
+ ];
449
+ }
450
+ });
451
+ const portableTextIdentityExtensions = [
452
+ PortableTextIdentityExtension,
453
+ PortableTextSpanIdentity,
454
+ PortableTextOpaqueBlock
455
+ ];
456
+
457
+ //#endregion
458
+ //#region src/content/converters/prosemirror-to-portable-text.ts
459
+ /**
460
+ * ProseMirror to Portable Text Converter
461
+ *
462
+ * Converts TipTap's ProseMirror JSON format to Portable Text for storage.
463
+ */
464
+ /**
465
+ * Generate a unique key for Portable Text blocks
466
+ */
467
+ function generateKey$1() {
468
+ return Math.random().toString(36).substring(2, 11);
469
+ }
470
+ /**
471
+ * Convert ProseMirror document to Portable Text
472
+ */
473
+ function prosemirrorToPortableText(doc) {
474
+ if (!doc || doc.type !== "doc" || !doc.content) return [];
475
+ assertProseMirrorMarksSupported(doc);
476
+ const blocks = [];
477
+ const usedBlockKeys = /* @__PURE__ */ new Set();
478
+ for (const [i, node] of doc.content.entries()) {
479
+ if (i === doc.content.length - 1 && isUnkeyedEmptyParagraph(node)) continue;
480
+ const converted = convertNode(node, `root:${i}`);
481
+ for (const block of converted ? Array.isArray(converted) ? converted : [converted] : []) {
482
+ let key = block._key;
483
+ if (usedBlockKeys.has(key)) do
484
+ key = generateKey$1();
485
+ while (usedBlockKeys.has(key));
486
+ usedBlockKeys.add(key);
487
+ blocks.push(key === block._key ? block : {
488
+ ...block,
489
+ _key: key
490
+ });
491
+ }
492
+ }
493
+ return blocks;
494
+ }
495
+ function isUnkeyedEmptyParagraph(node) {
496
+ return node.type === "paragraph" && (node.content?.length ?? 0) === 0 && portableTextKeyFromAttrs(node.attrs) === void 0;
497
+ }
498
+ /**
499
+ * Convert a single ProseMirror node to Portable Text block(s)
500
+ */
501
+ function convertNode(node, path) {
502
+ switch (node.type) {
503
+ case PORTABLE_TEXT_BLOCK_NODE: return portableTextBlockFromAttrs(node.attrs) ?? null;
504
+ case "paragraph": return convertParagraph(node);
505
+ case "heading": return convertHeading(node);
506
+ case "bulletList": return convertList$1(node, "bullet", path);
507
+ case "orderedList": return convertList$1(node, "number", path);
508
+ case "blockquote": return convertBlockquote(node);
509
+ case "codeBlock": return convertCodeBlock$1(node);
510
+ case "htmlBlock": return convertHtmlBlock(node);
511
+ case "iframeBlock": return convertIframeBlock(node);
512
+ case "image": return convertImage$1(node);
513
+ case "videoBlock": return convertVideo(node);
514
+ case "gallery": return convertGallery(node);
515
+ case "table": {
516
+ const result = proseMirrorTableToPortableText(node, {
517
+ path,
518
+ createKey: generateKey$1,
519
+ inlineToSpans: (content) => {
520
+ const { children, markDefs } = convertInlineContent(content, true);
521
+ return {
522
+ content: children,
523
+ markDefs
524
+ };
525
+ }
526
+ });
527
+ if (!result.ok) throw new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);
528
+ return result.table;
529
+ }
530
+ case "horizontalRule": return {
531
+ _type: "break",
532
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
533
+ style: "lineBreak"
534
+ };
535
+ default: return {
536
+ _type: node.type,
537
+ _key: generateKey$1(),
538
+ ...node.attrs,
539
+ _pmContent: node.content
540
+ };
541
+ }
542
+ }
543
+ /**
544
+ * Convert paragraph to Portable Text block
545
+ */
546
+ function convertParagraph(node) {
547
+ const { children, markDefs } = convertInlineContent(node.content || []);
548
+ if (children.length === 0) return null;
549
+ const ta = node.attrs?.textAlign;
550
+ const textAlign = ta === "center" || ta === "right" || ta === "justify" ? ta : void 0;
551
+ return {
552
+ _type: "block",
553
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
554
+ style: "normal",
555
+ children,
556
+ ...markDefs.length > 0 ? { markDefs } : {},
557
+ ...textAlign ? { textAlign } : {}
558
+ };
559
+ }
560
+ /** Map heading level number to Portable Text style */
561
+ function headingLevelToStyle(level) {
562
+ switch (level) {
563
+ case 1: return "h1";
564
+ case 2: return "h2";
565
+ case 3: return "h3";
566
+ case 4: return "h4";
567
+ case 5: return "h5";
568
+ case 6: return "h6";
569
+ default: return "h1";
570
+ }
571
+ }
572
+ /**
573
+ * Convert heading to Portable Text block
574
+ */
575
+ function convertHeading(node) {
576
+ const { children, markDefs } = convertInlineContent(node.content || []);
577
+ const style = headingLevelToStyle(typeof node.attrs?.level === "number" ? node.attrs.level : 1);
578
+ if (children.length === 0) return null;
579
+ const ta = node.attrs?.textAlign;
580
+ const textAlign = ta === "center" || ta === "right" || ta === "justify" ? ta : void 0;
581
+ return {
582
+ _type: "block",
583
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
584
+ style,
585
+ children,
586
+ markDefs: markDefs.length > 0 ? markDefs : void 0,
587
+ ...textAlign ? { textAlign } : {}
588
+ };
589
+ }
590
+ /**
591
+ * Convert list to Portable Text blocks
592
+ */
593
+ function convertList$1(node, listItem, path) {
594
+ const blocks = [];
595
+ const metadata = listItem === "number" ? readOrderedListMetadata(node.attrs, path) : void 0;
596
+ for (const [i, item] of (node.content ?? []).entries()) if (item.type === "listItem") {
597
+ const itemBlocks = convertListItem$1(item, listItem, 1, `${path}:${i}`, metadata);
598
+ blocks.push(...itemBlocks);
599
+ }
600
+ return blocks;
601
+ }
602
+ /**
603
+ * Convert list item to Portable Text blocks
604
+ */
605
+ function convertListItem$1(item, listItem, level, path, metadata) {
606
+ const blocks = [];
607
+ for (const [i, child] of (item.content ?? []).entries()) if (child.type === "paragraph") {
608
+ const { children, markDefs } = convertInlineContent(child.content || []);
609
+ if (children.length > 0) blocks.push({
610
+ _type: "block",
611
+ _key: portableTextKeyFromAttrs(child.attrs) ?? generateKey$1(),
612
+ style: "normal",
613
+ listItem,
614
+ level,
615
+ ...metadata,
616
+ children,
617
+ markDefs: markDefs.length > 0 ? markDefs : void 0
618
+ });
619
+ } else if (child.type === "bulletList") blocks.push(...convertListItemNested(child, "bullet", level + 1, `${path}:${i}`));
620
+ else if (child.type === "orderedList") blocks.push(...convertListItemNested(child, "number", level + 1, `${path}:${i}`));
621
+ return blocks;
622
+ }
623
+ /**
624
+ * Convert nested list
625
+ */
626
+ function convertListItemNested(node, listItem, level, path) {
627
+ const blocks = [];
628
+ const metadata = listItem === "number" ? readOrderedListMetadata(node.attrs, path) : void 0;
629
+ for (const [i, item] of (node.content ?? []).entries()) if (item.type === "listItem") blocks.push(...convertListItem$1(item, listItem, level, `${path}:${i}`, metadata));
630
+ return blocks;
631
+ }
632
+ /**
633
+ * Convert blockquote to Portable Text blocks
634
+ */
635
+ function convertBlockquote(node) {
636
+ const blocks = [];
637
+ for (const child of node.content || []) if (child.type === "paragraph") {
638
+ const { children, markDefs } = convertInlineContent(child.content || []);
639
+ if (children.length > 0) blocks.push({
640
+ _type: "block",
641
+ _key: portableTextKeyFromAttrs(child.attrs) ?? portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
642
+ style: "blockquote",
643
+ children,
644
+ markDefs: markDefs.length > 0 ? markDefs : void 0
645
+ });
646
+ }
647
+ return blocks.length === 1 ? blocks[0] : blocks.length > 0 ? blocks : null;
648
+ }
649
+ /**
650
+ * Convert code block to Portable Text
651
+ */
652
+ function convertCodeBlock$1(node) {
653
+ const code = node.content?.map((n) => n.text || "").join("") || "";
654
+ const language = typeof node.attrs?.language === "string" ? node.attrs.language : void 0;
655
+ return {
656
+ _type: "code",
657
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
658
+ code,
659
+ language: language || void 0
660
+ };
661
+ }
662
+ /**
663
+ * Convert HTML block to Portable Text
664
+ */
665
+ function convertHtmlBlock(node) {
666
+ return {
667
+ _type: "htmlBlock",
668
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
669
+ ...htmlBlockFields(node.attrs ?? {})
670
+ };
671
+ }
672
+ /**
673
+ * Convert iframe block to Portable Text, writing optional fields only when set
674
+ */
675
+ function convertIframeBlock(node) {
676
+ const { src, title, width, height, allow, allowFullscreen } = node.attrs ?? {};
677
+ const block = {
678
+ _type: "iframe",
679
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
680
+ src: typeof src === "string" ? src : ""
681
+ };
682
+ if (typeof title === "string" && title) block.title = title;
683
+ if (isFrameDimension$1(width)) block.width = width;
684
+ if (isFrameDimension$1(height)) block.height = height;
685
+ if (typeof allow === "string" && allow) block.allow = allow;
686
+ if (allowFullscreen === true) block.allowFullscreen = true;
687
+ return block;
688
+ }
689
+ /**
690
+ * Convert video block to Portable Text
691
+ */
692
+ function convertVideo(node) {
693
+ return {
694
+ _type: "video",
695
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
696
+ ...videoBlockFields(node.attrs ?? {})
697
+ };
698
+ }
699
+ function isFrameDimension$1(value) {
700
+ return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 1e4;
701
+ }
702
+ function imageDimension$1(value) {
703
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
704
+ }
705
+ /**
706
+ * Convert image to Portable Text
707
+ */
708
+ function convertImage$1(node) {
709
+ const attrs = node.attrs;
710
+ const provider = typeof attrs?.provider === "string" ? attrs.provider : void 0;
711
+ const mediaId = typeof attrs?.mediaId === "string" ? attrs.mediaId : void 0;
712
+ const src = typeof attrs?.src === "string" ? attrs.src : "";
713
+ const alt = typeof attrs?.alt === "string" ? attrs.alt : void 0;
714
+ const title = typeof attrs?.title === "string" ? attrs.title : void 0;
715
+ const caption = attrs && Object.hasOwn(attrs, "caption") ? typeof attrs.caption === "string" ? attrs.caption : void 0 : title;
716
+ const width = imageDimension$1(attrs?.width);
717
+ const height = imageDimension$1(attrs?.height);
718
+ const displayWidth = imageDimension$1(attrs?.displayWidth);
719
+ const displayHeight = imageDimension$1(attrs?.displayHeight);
720
+ const alignment = attrs?.alignment;
721
+ let link;
722
+ const rawLink = attrs?.link;
723
+ if (rawLink && typeof rawLink === "object") {
724
+ const linkObj = rawLink;
725
+ const href = typeof linkObj.href === "string" ? linkObj.href.trim() : "";
726
+ if (href) {
727
+ link = { href };
728
+ if (linkObj.blank === true) link.blank = true;
729
+ }
730
+ }
731
+ return {
732
+ _type: "image",
733
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
734
+ asset: {
735
+ _ref: mediaId || src || "",
736
+ url: src || "",
737
+ provider: provider && provider !== "local" ? provider : void 0
738
+ },
739
+ alt: alt || void 0,
740
+ caption: caption || (title ? "" : void 0),
741
+ title: title || void 0,
742
+ width: width || void 0,
743
+ height: height || void 0,
744
+ displayWidth: displayWidth || void 0,
745
+ displayHeight: displayHeight || void 0,
746
+ alignment: alignment === "left" || alignment === "center" || alignment === "right" || alignment === "wide" || alignment === "full" ? alignment : void 0,
747
+ link
748
+ };
749
+ }
750
+ /**
751
+ * Convert gallery node to Portable Text
752
+ */
753
+ function convertGallery(node) {
754
+ const columns = node.attrs?.columns;
755
+ return {
756
+ _type: "gallery",
757
+ _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
758
+ images: sanitizeGalleryImages(node.attrs?.images, generateKey$1),
759
+ ...typeof columns === "number" ? { columns } : {}
760
+ };
761
+ }
762
+ /**
763
+ * Convert inline content (text nodes with marks) to Portable Text spans
764
+ */
765
+ function convertInlineContent(nodes, preserveHardBreakBoundary = false) {
766
+ const children = [];
767
+ const markDefs = [];
768
+ const markDefMap = /* @__PURE__ */ new Map();
769
+ const usedSpanKeys = /* @__PURE__ */ new Set();
770
+ const claimSpanKey = (preferred) => {
771
+ if (preferred && !usedSpanKeys.has(preferred)) {
772
+ usedSpanKeys.add(preferred);
773
+ return preferred;
774
+ }
775
+ let key;
776
+ do
777
+ key = generateKey$1();
778
+ while (usedSpanKeys.has(key));
779
+ usedSpanKeys.add(key);
780
+ return key;
781
+ };
782
+ for (const node of nodes) if (node.type === "text" && node.text) {
783
+ const marks = [];
784
+ const originalMarkDefs = portableTextMarkDefsFromMarks(node.marks);
785
+ for (const mark of node.marks || []) {
786
+ const markType = convertMark(mark, markDefs, markDefMap, originalMarkDefs);
787
+ if (markType) marks.push(markType);
788
+ }
789
+ const preferredKey = portableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs);
790
+ const normalizedMarks = marks.length > 0 ? marks : void 0;
791
+ const previous = children.at(-1);
792
+ if (preferredKey && previous?._key === preferredKey && JSON.stringify(previous.marks) === JSON.stringify(normalizedMarks)) {
793
+ previous.text += node.text;
794
+ continue;
795
+ }
796
+ children.push({
797
+ _type: "span",
798
+ _key: claimSpanKey(preferredKey),
799
+ text: node.text,
800
+ marks: normalizedMarks
801
+ });
802
+ } else if (node.type === "hardBreak") if (children.length > 0 && !preserveHardBreakBoundary) {
803
+ const lastChild = children.at(-1);
804
+ lastChild.text += "\n";
805
+ } else children.push({
806
+ _type: "span",
807
+ _key: claimSpanKey(portableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs)),
808
+ text: "\n"
809
+ });
810
+ if (children.length === 0) children.push({
811
+ _type: "span",
812
+ _key: claimSpanKey(),
813
+ text: ""
814
+ });
815
+ return {
816
+ children,
817
+ markDefs
818
+ };
819
+ }
820
+ /**
821
+ * Convert a ProseMirror mark to Portable Text mark
822
+ */
823
+ function convertMark(mark, markDefs, markDefMap, originalMarkDefs) {
824
+ switch (mark.type) {
825
+ case "bold":
826
+ case "strong": return "strong";
827
+ case "italic":
828
+ case "em": return "em";
829
+ case "underline": return "underline";
830
+ case "strike":
831
+ case "strikethrough": return "strike-through";
832
+ case "subscript": return "subscript";
833
+ case "superscript": return "superscript";
834
+ case "code": return "code";
835
+ case PORTABLE_TEXT_SPAN_MARK: return null;
836
+ case "link": {
837
+ const href = (typeof mark.attrs?.href === "string" ? mark.attrs.href : "") || "";
838
+ const blank = mark.attrs?.target === "_blank";
839
+ const originalMarkDef = originalMarkDefs.find((markDef) => markDef._type === "link");
840
+ const mapKey = originalMarkDef ? `key:${originalMarkDef._key}` : `value:${JSON.stringify([href, blank])}`;
841
+ if (markDefMap.has(mapKey)) return markDefMap.get(mapKey);
842
+ const key = originalMarkDef?._key || generateKey$1();
843
+ markDefs.push({
844
+ ...originalMarkDef,
845
+ _type: "link",
846
+ _key: key,
847
+ href,
848
+ ...originalMarkDef ? blank || Object.hasOwn(originalMarkDef, "blank") ? { blank } : {} : { blank }
849
+ });
850
+ markDefMap.set(mapKey, key);
851
+ return key;
852
+ }
853
+ default: throw new UnsupportedPortableTextMarksError([mark.type]);
854
+ }
855
+ }
856
+
857
+ //#endregion
858
+ //#region src/content/converters/image-link.ts
859
+ function normalizeImageLink(raw) {
860
+ if (typeof raw === "string") {
861
+ const href = raw.trim();
862
+ return href ? { href } : null;
863
+ }
864
+ if (typeof raw !== "object" || raw === null) return null;
865
+ const { href, blank } = raw;
866
+ if (typeof href !== "string") return null;
867
+ const trimmed = href.trim();
868
+ if (!trimmed) return null;
869
+ return blank === true ? {
870
+ href: trimmed,
871
+ blank: true
872
+ } : { href: trimmed };
873
+ }
874
+
875
+ //#endregion
876
+ //#region src/content/converters/portable-text-to-prosemirror.ts
877
+ /**
878
+ * Portable Text to ProseMirror Converter
879
+ *
880
+ * Converts Portable Text to TipTap's ProseMirror JSON format for editing.
881
+ */
882
+ function generateKey() {
883
+ return Math.random().toString(36).substring(2, 11);
884
+ }
885
+ /** Convert Portable Text to a ProseMirror document. */
886
+ function portableTextToProsemirror(blocks, options = {}) {
887
+ if (!blocks || blocks.length === 0) return {
888
+ type: "doc",
889
+ content: [{ type: "paragraph" }]
890
+ };
891
+ assertPortableTextMarksSupported(blocks);
892
+ const preserveIdentity = options.preserveIdentity === true;
893
+ const content = [];
894
+ let i = 0;
895
+ while (i < blocks.length) {
896
+ const block = blocks[i];
897
+ if (isTextBlock(block) && block.listItem) {
898
+ const listBlocks = [];
899
+ const listType = block.listItem;
900
+ const runStart = i;
901
+ const rootId = listType === "number" ? normalizeListId(block.listId) : void 0;
902
+ while (i < blocks.length) {
903
+ const current = blocks[i];
904
+ if (!isTextBlock(current) || !current.listItem) break;
905
+ const level = current.level || 1;
906
+ const currentId = current.listItem === "number" ? normalizeListId(current.listId) : void 0;
907
+ const sameRootIdentity = listType !== "number" || level > 1 || (rootId ? currentId === rootId : currentId === void 0);
908
+ if (level > 1 || current.listItem === listType && sameRootIdentity) {
909
+ listBlocks.push(current);
910
+ i++;
911
+ } else break;
912
+ }
913
+ content.push(convertList(listBlocks, listType, `root:${runStart}`, preserveIdentity));
914
+ } else if (isTextBlock(block) && block.style === "blockquote") {
915
+ const quoteBlocks = [];
916
+ while (i < blocks.length) {
917
+ const current = blocks[i];
918
+ if (!isTextBlock(current) || current.style !== "blockquote" || current.listItem !== void 0) break;
919
+ quoteBlocks.push(current);
920
+ i++;
921
+ }
922
+ content.push({
923
+ type: "blockquote",
924
+ content: quoteBlocks.map((quoteBlock) => {
925
+ const paragraph = convertSpans(quoteBlock.children, quoteBlock.markDefs || [], preserveIdentity);
926
+ return {
927
+ type: "paragraph",
928
+ attrs: identityAttrs(void 0, quoteBlock._key, preserveIdentity),
929
+ content: paragraph.length > 0 ? paragraph : void 0
930
+ };
931
+ })
932
+ });
933
+ } else {
934
+ const converted = convertBlock(block, `root:${i}`, preserveIdentity);
935
+ if (converted) content.push(converted);
936
+ i++;
937
+ }
938
+ }
939
+ return normalizeProseMirrorOrderedListJson({
940
+ type: "doc",
941
+ content: content.length > 0 ? content : [{ type: "paragraph" }]
942
+ });
943
+ }
944
+ function identityAttrs(attrs, key, preserveIdentity) {
945
+ return preserveIdentity ? attrsWithPortableTextKey(attrs, key) : attrs;
946
+ }
947
+ function getListMetadata(item, fallbackSeed) {
948
+ const listId = normalizeListId(item.listId) ?? deriveLegacyListId(fallbackSeed);
949
+ const listStart = normalizeListStart(item.listStart);
950
+ return {
951
+ listId,
952
+ ...listStart === void 0 ? {} : { listStart }
953
+ };
954
+ }
955
+ function belongsToNestedGroup(item, minLevel, parentListType, anchorType, anchorId) {
956
+ if ((item.level || 2) > minLevel) return true;
957
+ if ((item.listItem || parentListType) !== anchorType) return false;
958
+ if (anchorType !== "number") return true;
959
+ const itemId = normalizeListId(item.listId);
960
+ return anchorId ? itemId === anchorId : itemId === void 0;
961
+ }
962
+ /**
963
+ * Type guard for text blocks
964
+ */
965
+ function isTextBlock(block) {
966
+ return block._type === "block";
967
+ }
968
+ /**
969
+ * Type guard for image blocks.
970
+ * Checks both `_type` and that `asset` is a valid object — image blocks
971
+ * without an `asset` wrapper (e.g. `{ _type: "image", url: "..." }`) are
972
+ * malformed and should not be cast to `PortableTextImageBlock`.
973
+ */
974
+ function isImageBlock(block) {
975
+ return block._type === "image" && "asset" in block && typeof block.asset === "object" && block.asset !== null;
976
+ }
977
+ /**
978
+ * Type guard for gallery blocks that carry a usable `images` array.
979
+ * Galleries without one are handled separately in `convertBlock`.
980
+ */
981
+ function isGalleryBlock(block) {
982
+ return block._type === "gallery" && "images" in block && Array.isArray(block.images);
983
+ }
984
+ const isString = (value) => typeof value === "string";
985
+ const isFrameDimension = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 1e4;
986
+ const IFRAME_BLOCK_FIELDS = new Map([
987
+ ["_type", () => true],
988
+ ["_key", () => true],
989
+ ["src", isString],
990
+ ["title", isString],
991
+ ["width", isFrameDimension],
992
+ ["height", isFrameDimension],
993
+ ["allow", isString],
994
+ ["allowFullscreen", (value) => typeof value === "boolean"]
995
+ ]);
996
+ /**
997
+ * An `iframe` block with other fields, or with values of other types, belongs
998
+ * to a plugin and stays a generic block.
999
+ */
1000
+ function isIframeBlock(block) {
1001
+ return block._type === "iframe" && typeof block.src === "string" && Object.entries(block).every(([key, value]) => value === void 0 || (IFRAME_BLOCK_FIELDS.get(key)?.(value) ?? false));
1002
+ }
1003
+ /**
1004
+ * Type guard for code blocks
1005
+ */
1006
+ function isCodeBlock(block) {
1007
+ return block._type === "code";
1008
+ }
1009
+ /**
1010
+ * Convert a single Portable Text block to ProseMirror node
1011
+ */
1012
+ function convertBlock(block, path, preserveIdentity) {
1013
+ if (isTextBlock(block)) return convertTextBlock(block, preserveIdentity);
1014
+ if (isImageBlock(block)) return convertImage(block, preserveIdentity);
1015
+ if (block._type === "image") return convertMalformedImage(block, preserveIdentity);
1016
+ if (isGalleryBlock(block)) return {
1017
+ type: "gallery",
1018
+ attrs: identityAttrs({
1019
+ images: sanitizeGalleryImages(block.images),
1020
+ columns: typeof block.columns === "number" ? block.columns : void 0
1021
+ }, block._key, preserveIdentity)
1022
+ };
1023
+ if (isCodeBlock(block)) return convertCodeBlock(block, preserveIdentity);
1024
+ if (block._type === "htmlBlock") return {
1025
+ type: "htmlBlock",
1026
+ attrs: identityAttrs({ ...htmlBlockFields(block) }, block._key, preserveIdentity)
1027
+ };
1028
+ if (isIframeBlock(block)) {
1029
+ const { _type, _key, ...attrs } = block;
1030
+ return {
1031
+ type: "iframeBlock",
1032
+ attrs: identityAttrs(attrs, _key, preserveIdentity)
1033
+ };
1034
+ }
1035
+ if (isPortableTextVideoBlock(block)) return {
1036
+ type: "videoBlock",
1037
+ attrs: identityAttrs(videoNodeAttrs(block), block._key, preserveIdentity)
1038
+ };
1039
+ if (block._type === "break") return {
1040
+ type: "horizontalRule",
1041
+ attrs: identityAttrs(void 0, block._key, preserveIdentity)
1042
+ };
1043
+ if (block._type === "gallery") {
1044
+ if (preserveIdentity) return {
1045
+ type: PORTABLE_TEXT_BLOCK_NODE,
1046
+ attrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block }
1047
+ };
1048
+ return {
1049
+ type: "paragraph",
1050
+ content: [{
1051
+ type: "text",
1052
+ text: `[Unknown block type: ${block._type}]`,
1053
+ marks: [{ type: "code" }]
1054
+ }]
1055
+ };
1056
+ }
1057
+ if (preserveIdentity) return {
1058
+ type: PORTABLE_TEXT_BLOCK_NODE,
1059
+ attrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block }
1060
+ };
1061
+ if (block._type === "table") {
1062
+ const result = portableTextTableToProseMirror(block, {
1063
+ path,
1064
+ createKey: generateKey,
1065
+ spansToInline: (content, markDefs) => convertSpans(content, markDefs, preserveIdentity)
1066
+ });
1067
+ if (!result.ok) throw new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);
1068
+ return result.node;
1069
+ }
1070
+ return {
1071
+ type: "paragraph",
1072
+ content: [{
1073
+ type: "text",
1074
+ text: `[Unknown block type: ${block._type}]`,
1075
+ marks: [{ type: "code" }]
1076
+ }]
1077
+ };
1078
+ }
1079
+ /**
1080
+ * Convert text block to ProseMirror paragraph or heading
1081
+ */
1082
+ function convertTextBlock(block, preserveIdentity) {
1083
+ const { style = "normal", children, markDefs = [] } = block;
1084
+ const content = convertSpans(children, markDefs, preserveIdentity);
1085
+ switch (style) {
1086
+ case "h1":
1087
+ case "h2":
1088
+ case "h3":
1089
+ case "h4":
1090
+ case "h5":
1091
+ case "h6": return {
1092
+ type: "heading",
1093
+ attrs: identityAttrs({
1094
+ level: parseInt(style.substring(1), 10),
1095
+ ...block.textAlign ? { textAlign: block.textAlign } : {}
1096
+ }, block._key, preserveIdentity),
1097
+ content: content.length > 0 ? content : void 0
1098
+ };
1099
+ case "blockquote": return {
1100
+ type: "blockquote",
1101
+ attrs: identityAttrs(void 0, block._key, preserveIdentity),
1102
+ content: [{
1103
+ type: "paragraph",
1104
+ content: content.length > 0 ? content : void 0
1105
+ }]
1106
+ };
1107
+ default: return {
1108
+ type: "paragraph",
1109
+ attrs: identityAttrs(block.textAlign ? { textAlign: block.textAlign } : void 0, block._key, preserveIdentity),
1110
+ content: content.length > 0 ? content : void 0
1111
+ };
1112
+ }
1113
+ }
1114
+ /**
1115
+ * Convert list items to ProseMirror list
1116
+ */
1117
+ function convertList(items, listType, context, preserveIdentity) {
1118
+ const rootItems = [];
1119
+ let i = 0;
1120
+ while (i < items.length) {
1121
+ const item = items[i];
1122
+ if ((item.level || 1) === 1) {
1123
+ const nestedItems = [];
1124
+ i++;
1125
+ while (i < items.length && (items[i].level || 1) > 1) {
1126
+ nestedItems.push(items[i]);
1127
+ i++;
1128
+ }
1129
+ rootItems.push(convertListItem(item, nestedItems, listType, `${context}:${rootItems.length}`, preserveIdentity));
1130
+ } else {
1131
+ rootItems.push(convertListItem(item, [], listType, `${context}:${rootItems.length}`, preserveIdentity));
1132
+ i++;
1133
+ }
1134
+ }
1135
+ const metadata = listType === "number" ? getListMetadata(items[0], `${context}:${items[0]._key}`) : void 0;
1136
+ return {
1137
+ type: listType === "bullet" ? "bulletList" : "orderedList",
1138
+ attrs: metadata ? {
1139
+ ...metadata,
1140
+ start: metadata.listStart ?? 1
1141
+ } : void 0,
1142
+ content: rootItems
1143
+ };
1144
+ }
1145
+ /**
1146
+ * Convert a single list item to ProseMirror
1147
+ */
1148
+ function convertListItem(item, nestedItems, parentListType, context, preserveIdentity) {
1149
+ const content = [];
1150
+ const spans = convertSpans(item.children, item.markDefs || [], preserveIdentity);
1151
+ content.push({
1152
+ type: "paragraph",
1153
+ attrs: identityAttrs(void 0, item._key, preserveIdentity),
1154
+ content: spans.length > 0 ? spans : void 0
1155
+ });
1156
+ if (nestedItems.length > 0) {
1157
+ let minLevel = Infinity;
1158
+ for (const ni of nestedItems) {
1159
+ const level = ni.level || 2;
1160
+ if (level < minLevel) minLevel = level;
1161
+ }
1162
+ let j = 0;
1163
+ while (j < nestedItems.length) {
1164
+ const anchorType = nestedItems[j].listItem || parentListType;
1165
+ const anchorId = anchorType === "number" ? normalizeListId(nestedItems[j].listId) : void 0;
1166
+ const nestedGroup = [];
1167
+ do {
1168
+ nestedGroup.push(nestedItems[j]);
1169
+ j++;
1170
+ } while (j < nestedItems.length && belongsToNestedGroup(nestedItems[j], minLevel, parentListType, anchorType, anchorId));
1171
+ if (nestedGroup.length > 0) {
1172
+ const adjustedGroup = nestedGroup.map((ni) => ({
1173
+ ...ni,
1174
+ level: (ni.level || 2) - 1
1175
+ }));
1176
+ content.push(convertList(adjustedGroup, anchorType, `${context}:nested:${j - nestedGroup.length}`, preserveIdentity));
1177
+ }
1178
+ }
1179
+ }
1180
+ return {
1181
+ type: "listItem",
1182
+ content
1183
+ };
1184
+ }
1185
+ /**
1186
+ * Convert Portable Text spans to ProseMirror text nodes
1187
+ */
1188
+ function convertSpans(spans, markDefs, preserveIdentity) {
1189
+ const nodes = [];
1190
+ const markDefsMap = new Map(markDefs.map((md) => [md._key, md]));
1191
+ for (const span of spans) {
1192
+ if (span._type !== "span") continue;
1193
+ const referencedMarkDefs = markDefs.filter((markDef) => span.marks?.includes(markDef._key));
1194
+ const parts = span.text.split("\n");
1195
+ for (let i = 0; i < parts.length; i++) {
1196
+ const text = parts[i];
1197
+ if (text.length > 0) {
1198
+ const marks = convertMarks(span.marks || [], markDefsMap);
1199
+ if (preserveIdentity) marks.push({
1200
+ type: PORTABLE_TEXT_SPAN_MARK,
1201
+ attrs: {
1202
+ key: span._key,
1203
+ markDefs: referencedMarkDefs
1204
+ }
1205
+ });
1206
+ const node = {
1207
+ type: "text",
1208
+ text
1209
+ };
1210
+ if (marks.length > 0) node.marks = marks;
1211
+ nodes.push(node);
1212
+ }
1213
+ if (i < parts.length - 1) nodes.push(preserveIdentity ? {
1214
+ type: "hardBreak",
1215
+ marks: [{
1216
+ type: PORTABLE_TEXT_SPAN_MARK,
1217
+ attrs: {
1218
+ key: span._key,
1219
+ markDefs: referencedMarkDefs
1220
+ }
1221
+ }]
1222
+ } : { type: "hardBreak" });
1223
+ }
1224
+ }
1225
+ return nodes;
1226
+ }
1227
+ /**
1228
+ * Convert Portable Text marks to ProseMirror marks
1229
+ */
1230
+ function convertMarks(marks, markDefs) {
1231
+ const pmMarks = [];
1232
+ for (const mark of marks) switch (mark) {
1233
+ case "strong":
1234
+ pmMarks.push({ type: "bold" });
1235
+ break;
1236
+ case "em":
1237
+ pmMarks.push({ type: "italic" });
1238
+ break;
1239
+ case "underline":
1240
+ pmMarks.push({ type: "underline" });
1241
+ break;
1242
+ case "strike-through":
1243
+ pmMarks.push({ type: "strike" });
1244
+ break;
1245
+ case "subscript":
1246
+ pmMarks.push({ type: "subscript" });
1247
+ break;
1248
+ case "superscript":
1249
+ pmMarks.push({ type: "superscript" });
1250
+ break;
1251
+ case "code":
1252
+ pmMarks.push({ type: "code" });
1253
+ break;
1254
+ default: {
1255
+ const markDef = markDefs.get(mark);
1256
+ if (markDef?._type === "link") pmMarks.push({
1257
+ type: "link",
1258
+ attrs: {
1259
+ href: markDef.href,
1260
+ target: markDef.blank ? "_blank" : null
1261
+ }
1262
+ });
1263
+ else throw new UnsupportedPortableTextMarksError([typeof markDef?._type === "string" ? markDef._type : mark]);
1264
+ break;
1265
+ }
1266
+ }
1267
+ return pmMarks;
1268
+ }
1269
+ function imageAlignment(value) {
1270
+ return value === "left" || value === "center" || value === "right" || value === "wide" || value === "full" ? value : void 0;
1271
+ }
1272
+ function imageDimension(value) {
1273
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
1274
+ }
1275
+ /**
1276
+ * Convert image block to ProseMirror
1277
+ */
1278
+ function convertImage(block, preserveIdentity) {
1279
+ const { asset, alt, width, height } = resolveImageMedia(block);
1280
+ return {
1281
+ type: "image",
1282
+ attrs: identityAttrs({
1283
+ src: asset.url || asset._ref,
1284
+ alt: alt || "",
1285
+ title: block.title || "",
1286
+ caption: Object.hasOwn(block, "caption") ? block.caption || "" : block.title || "",
1287
+ mediaId: asset._ref,
1288
+ provider: asset.provider,
1289
+ width: imageDimension(width),
1290
+ height: imageDimension(height),
1291
+ displayWidth: imageDimension(block.displayWidth),
1292
+ displayHeight: imageDimension(block.displayHeight),
1293
+ alignment: imageAlignment(block.alignment),
1294
+ link: normalizeImageLink(block.link)
1295
+ }, block._key, preserveIdentity)
1296
+ };
1297
+ }
1298
+ /**
1299
+ * Convert a malformed image block (missing `asset` wrapper) to ProseMirror.
1300
+ * Handles blocks like `{ _type: "image", url: "...", alt: "..." }` that may
1301
+ * originate from migrations or third-party imports.
1302
+ */
1303
+ function convertMalformedImage(block, preserveIdentity) {
1304
+ const url = "url" in block && typeof block.url === "string" ? block.url : "";
1305
+ const alt = "alt" in block && typeof block.alt === "string" ? block.alt : "";
1306
+ const title = "title" in block && typeof block.title === "string" ? block.title : "";
1307
+ const rawCaption = "caption" in block ? block.caption : void 0;
1308
+ return {
1309
+ type: "image",
1310
+ attrs: identityAttrs({
1311
+ src: url,
1312
+ alt,
1313
+ title,
1314
+ caption: Object.hasOwn(block, "caption") ? typeof rawCaption === "string" ? rawCaption : "" : title,
1315
+ mediaId: void 0,
1316
+ provider: void 0,
1317
+ width: imageDimension("width" in block ? block.width : void 0),
1318
+ height: imageDimension("height" in block ? block.height : void 0),
1319
+ displayWidth: imageDimension("displayWidth" in block ? block.displayWidth : void 0),
1320
+ displayHeight: imageDimension("displayHeight" in block ? block.displayHeight : void 0),
1321
+ alignment: imageAlignment("alignment" in block ? block.alignment : void 0)
1322
+ }, block._key, preserveIdentity)
1323
+ };
1324
+ }
1325
+ /**
1326
+ * Convert code block to ProseMirror
1327
+ */
1328
+ function convertCodeBlock(block, preserveIdentity) {
1329
+ return {
1330
+ type: "codeBlock",
1331
+ attrs: identityAttrs({ language: block.language || null }, block._key, preserveIdentity),
1332
+ content: block.code ? [{
1333
+ type: "text",
1334
+ text: block.code
1335
+ }] : void 0
1336
+ };
1337
+ }
1338
+
1339
+ //#endregion
1340
+ //#region src/plugins/define-plugin.ts
1341
+ /**
1342
+ * definePlugin() Helper
1343
+ *
1344
+ * Native plugin authoring entry. Returns a fully-resolved
1345
+ * `ResolvedPlugin` ready for the host integration to mount.
1346
+ *
1347
+ * Sandboxed plugins do NOT use this function. They default-export
1348
+ * a bare `{ hooks?, routes? }` object with a `satisfies SandboxedPlugin`
1349
+ * annotation from `emdash/plugin`. See the `emdash` changeset for the
1350
+ * authoring shape.
1351
+ */
1352
+ const MCP_TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
1353
+ /**
1354
+ * Define a native EmDash plugin.
1355
+ *
1356
+ * Native plugins ship as regular npm modules, get installed via
1357
+ * `pnpm add` + an `astro.config.mjs` edit, and run in the host
1358
+ * process. They have full access to the runtime — capabilities are
1359
+ * still enforced by `PluginContextFactory`, but there is no isolation
1360
+ * boundary.
1361
+ *
1362
+ * @example
1363
+ * ```typescript
1364
+ * import { definePlugin } from "emdash";
1365
+ *
1366
+ * export default definePlugin({
1367
+ * id: "my-plugin",
1368
+ * version: "1.0.0",
1369
+ * capabilities: ["content:read"],
1370
+ * hooks: {
1371
+ * "content:beforeSave": async (event, ctx) => {
1372
+ * ctx.log.info("Saving content", { collection: event.collection });
1373
+ * return event.content;
1374
+ * }
1375
+ * },
1376
+ * routes: {
1377
+ * "sync": {
1378
+ * handler: async (ctx) => {
1379
+ * return { status: "ok" };
1380
+ * }
1381
+ * }
1382
+ * }
1383
+ * });
1384
+ * ```
1385
+ *
1386
+ * Sandboxed-format plugins do not use `definePlugin`. They
1387
+ * default-export a bare `{ hooks?, routes? }` object with a
1388
+ * `satisfies SandboxedPlugin` annotation from `emdash/plugin`. Calling
1389
+ * `definePlugin` with an object that has no `id` throws at runtime
1390
+ * (the type system already rejects it at compile time — this check is
1391
+ * for callers that bypass typechecking). Passing a plugin descriptor
1392
+ * (an object with an `entrypoint`) also throws.
1393
+ */
1394
+ function definePlugin(definition) {
1395
+ if (typeof definition.id !== "string" || definition.id.length === 0) throw new Error(`definePlugin() requires \`id\` (got ${typeof definition.id}). For native plugins, make sure your definition has both \`id\` and \`version\`. For sandboxed plugins, drop \`definePlugin()\` entirely and \`export default { hooks, routes } satisfies SandboxedPlugin\` from "emdash/plugin" — identity comes from \`emdash-plugin.jsonc\`.`);
1396
+ if ("entrypoint" in definition) throw new Error(`definePlugin() received a plugin descriptor for "${definition.id}" (it has an \`entrypoint\`). Pass the descriptor directly to the \`plugins\` array of the emdash() integration instead of wrapping it in definePlugin().`);
1397
+ return defineNativePlugin(definition);
1398
+ }
1399
+ function definePluginRoute(route) {
1400
+ return route;
1401
+ }
1402
+ /**
1403
+ * Internal: define a native-format plugin with full validation and normalization.
1404
+ */
1405
+ function defineNativePlugin(definition) {
1406
+ const SIMPLE_ID = /^[a-z0-9-]+$/;
1407
+ const SCOPED_ID = /^@[a-z0-9-]+\/[a-z0-9-]+$/;
1408
+ const SEMVER_PATTERN = /^\d+\.\d+\.\d+/;
1409
+ const { id, version, capabilities = [], allowedHosts = [], hooks = {}, routes = {}, mcp = { tools: {} }, admin = {} } = definition;
1410
+ const storage = definition.storage ?? {};
1411
+ if (!SIMPLE_ID.test(id) && !SCOPED_ID.test(id)) throw new Error(`Invalid plugin id "${id}". Must be lowercase alphanumeric with dashes (e.g., "my-plugin" or "@scope/my-plugin").`);
1412
+ if (!SEMVER_PATTERN.test(version)) throw new Error(`Invalid plugin version "${version}". Must be semver format (e.g., "1.0.0").`);
1413
+ for (const [name, tool] of Object.entries(mcp.tools)) {
1414
+ if (!MCP_TOOL_NAME_PATTERN.test(name)) throw new Error(`Invalid MCP tool name "${name}" in plugin "${id}".`);
1415
+ const route = routes[tool.route];
1416
+ if (!route) throw new Error(`MCP tool "${name}" references unknown route "${tool.route}".`);
1417
+ if (route.public) throw new Error(`MCP tool "${name}" cannot reference a public route.`);
1418
+ if (route.response === "raw") throw new Error(`MCP tool "${name}" cannot reference a raw response route.`);
1419
+ if (!isJsonPostRouteContract(route)) throw new Error(`MCP tool "${name}" must reference a POST-compatible JSON route.`);
1420
+ if (!route.permission) throw new Error(`MCP route "${tool.route}" must declare a permission.`);
1421
+ }
1422
+ for (const [kind, extensions] of [["editor panel", admin.editorPanels], ["editor action", admin.editorActions]]) for (const extension of extensions ?? []) {
1423
+ const route = routes[extension.route];
1424
+ if (!route) throw new Error(`Plugin ${kind} "${extension.id}" references unknown route "${extension.route}".`);
1425
+ if (route.public) throw new Error(`Plugin ${kind} "${extension.id}" must reference a private route.`);
1426
+ if (!isJsonPostRouteContract(route)) throw new Error(`Plugin ${kind} "${extension.id}" must reference a route that accepts POST JSON requests and returns JSON.`);
1427
+ }
1428
+ if ((admin.pages?.length ?? 0) > 0 || (admin.widgets?.length ?? 0) > 0) {
1429
+ const adminRoute = routes.admin;
1430
+ if (adminRoute && (adminRoute.public === true || !isJsonPostRouteContract(adminRoute))) throw new Error("Block Kit admin route must accept POST JSON requests and return JSON.");
1431
+ }
1432
+ const validCapabilities = new Set(PLUGIN_CAPABILITIES);
1433
+ for (const cap of capabilities) if (!validCapabilities.has(cap)) throw new Error(`Invalid capability "${cap}" in plugin "${id}".`);
1434
+ warnDeprecatedPluginCapabilities(id, capabilities);
1435
+ return {
1436
+ id,
1437
+ version,
1438
+ capabilities: normalizePluginCapabilities(capabilities),
1439
+ allowedHosts,
1440
+ storage,
1441
+ hooks: resolveHooks(hooks, id),
1442
+ routes,
1443
+ mcp,
1444
+ admin
1445
+ };
1446
+ }
1447
+ /**
1448
+ * Resolve hooks to normalized format with defaults.
1449
+ *
1450
+ * PluginHooks and ResolvedPluginHooks share the same keys — each input value is
1451
+ * `HookConfig<H> | H` and the output is `ResolvedHook<H>`. TS can't narrow
1452
+ * the handler type through a dynamic key, so we assert at the loop boundary.
1453
+ */
1454
+ function resolveHooks(hooks, pluginId) {
1455
+ const resolved = {};
1456
+ for (const key of Object.keys(hooks)) {
1457
+ const hook = hooks[key];
1458
+ if (hook) resolved[key] = resolveHook(hook, pluginId);
1459
+ }
1460
+ return resolved;
1461
+ }
1462
+ /**
1463
+ * Check if a hook value is a config object (has a `handler` property)
1464
+ */
1465
+ function isHookConfig(hook) {
1466
+ return typeof hook === "object" && hook !== null && "handler" in hook;
1467
+ }
1468
+ /**
1469
+ * Resolve a single hook to normalized format
1470
+ */
1471
+ function resolveHook(hook, pluginId) {
1472
+ if (isHookConfig(hook)) {
1473
+ if (hook.exclusive !== void 0 && typeof hook.exclusive !== "boolean") throw new Error(`Invalid "exclusive" value in hook config for plugin "${pluginId}". Must be boolean.`);
1474
+ return {
1475
+ priority: hook.priority ?? 100,
1476
+ timeout: hook.timeout ?? 5e3,
1477
+ dependencies: hook.dependencies ?? [],
1478
+ errorPolicy: hook.errorPolicy ?? "abort",
1479
+ exclusive: hook.exclusive ?? false,
1480
+ handler: hook.handler,
1481
+ pluginId
1482
+ };
1483
+ }
1484
+ return {
1485
+ priority: 100,
1486
+ timeout: 5e3,
1487
+ dependencies: [],
1488
+ errorPolicy: "abort",
1489
+ exclusive: false,
1490
+ handler: hook,
1491
+ pluginId
1492
+ };
1493
+ }
1494
+
1495
+ //#endregion
1496
+ //#region src/plugins/hooks.ts
1497
+ /**
1498
+ * Plugin Hooks System v2
1499
+ *
1500
+ * Uses the unified PluginContext for all hooks.
1501
+ * Manages lifecycle hooks with:
1502
+ * - Deterministic ordering via priority + dependencies
1503
+ * - Timeout enforcement
1504
+ * - Error isolation
1505
+ * - Observability
1506
+ *
1507
+ */
1508
+ const CONTENT_SAVE_HOOK_CONTEXT_KEY = Symbol.for("emdash:content-save-hook-context");
1509
+ const contentSaveHookContext = globalThis[CONTENT_SAVE_HOOK_CONTEXT_KEY] ?? new AsyncLocalStorage();
1510
+ globalThis[CONTENT_SAVE_HOOK_CONTEXT_KEY] = contentSaveHookContext;
1511
+ function getActiveContentSaveHookName() {
1512
+ return contentSaveHookContext.getStore();
1513
+ }
1514
+ function assignSaveHookDetails(event, details) {
1515
+ if (details.locale !== void 0) event.locale = details.locale;
1516
+ if (details.translationOf !== void 0) event.translationOf = details.translationOf;
1517
+ }
1518
+ /**
1519
+ * Hook pipeline for executing hooks in order
1520
+ */
1521
+ var HookPipeline = class HookPipeline {
1522
+ hooks = /* @__PURE__ */ new Map();
1523
+ pluginMap = /* @__PURE__ */ new Map();
1524
+ contextFactory = null;
1525
+ /** Stored so setContextFactory can merge incrementally. */
1526
+ contextFactoryOptions = {};
1527
+ /** Hook names where at least one handler declared exclusive: true */
1528
+ exclusiveHookNames = /* @__PURE__ */ new Set();
1529
+ /**
1530
+ * Selected provider plugin ID for each exclusive hook.
1531
+ * Set by the PluginManager after resolution.
1532
+ */
1533
+ exclusiveSelections = /* @__PURE__ */ new Map();
1534
+ constructor(plugins, factoryOptions) {
1535
+ if (factoryOptions) {
1536
+ this.contextFactory = new PluginContextFactory(factoryOptions);
1537
+ this.contextFactoryOptions = { ...factoryOptions };
1538
+ }
1539
+ for (const plugin of plugins) this.pluginMap.set(plugin.id, plugin);
1540
+ this.registerPlugins(plugins);
1541
+ }
1542
+ /**
1543
+ * Set or update the context factory options.
1544
+ *
1545
+ * When called on a pipeline that already has a factory, the new options
1546
+ * are merged on top of the existing ones so that callers don't need to
1547
+ * repeat every field (e.g. adding `cronReschedule` without losing
1548
+ * `storage` / `getUploadUrl`).
1549
+ */
1550
+ setContextFactory(options) {
1551
+ const merged = {
1552
+ ...this.contextFactoryOptions,
1553
+ ...options
1554
+ };
1555
+ this.contextFactory = new PluginContextFactory(merged);
1556
+ this.contextFactoryOptions = merged;
1557
+ }
1558
+ /**
1559
+ * Get context for a plugin
1560
+ */
1561
+ getContext(pluginId) {
1562
+ const plugin = this.pluginMap.get(pluginId);
1563
+ if (!plugin) throw new Error(`Plugin "${pluginId}" not found`);
1564
+ if (!this.contextFactory) throw new Error("Context factory not initialized - call setContextFactory first");
1565
+ return this.contextFactory.createContext(plugin);
1566
+ }
1567
+ /**
1568
+ * Get typed hooks for a specific hook name.
1569
+ * The internal map stores ResolvedHook<unknown>, but we know each name
1570
+ * maps to a specific handler type via HookHandlerMap.
1571
+ *
1572
+ * Exclusive hooks that have a selected provider are filtered out — they
1573
+ * should only run via invokeExclusiveHook(), not in the regular pipeline.
1574
+ */
1575
+ getTypedHooks(name) {
1576
+ const all = this.hooks.get(name) ?? [];
1577
+ if (this.exclusiveSelections.has(name)) return all.filter((h) => !h.exclusive);
1578
+ return all;
1579
+ }
1580
+ /**
1581
+ * Register all hooks from plugins.
1582
+ *
1583
+ * Registers each hook name individually to preserve type safety. The
1584
+ * internal map stores ResolvedHook<unknown> since it's keyed by string,
1585
+ * but getTypedHooks() restores the correct handler type on retrieval.
1586
+ */
1587
+ registerPlugins(plugins) {
1588
+ for (const plugin of plugins) {
1589
+ this.registerPluginHook(plugin, "plugin:install");
1590
+ this.registerPluginHook(plugin, "plugin:activate");
1591
+ this.registerPluginHook(plugin, "plugin:deactivate");
1592
+ this.registerPluginHook(plugin, "plugin:uninstall");
1593
+ this.registerPluginHook(plugin, "content:beforeSave");
1594
+ this.registerPluginHook(plugin, "content:afterSave");
1595
+ this.registerPluginHook(plugin, "content:beforeDelete");
1596
+ this.registerPluginHook(plugin, "content:afterDelete");
1597
+ this.registerPluginHook(plugin, "content:beforePublish");
1598
+ this.registerPluginHook(plugin, "content:beforeSchedule");
1599
+ this.registerPluginHook(plugin, "content:beforeUnpublish");
1600
+ this.registerPluginHook(plugin, "content:afterPublish");
1601
+ this.registerPluginHook(plugin, "content:afterUnpublish");
1602
+ this.registerPluginHook(plugin, "content:afterRestore");
1603
+ this.registerPluginHook(plugin, "content:afterSchedule");
1604
+ this.registerPluginHook(plugin, "content:afterUnschedule");
1605
+ this.registerPluginHook(plugin, "media:beforeUpload");
1606
+ this.registerPluginHook(plugin, "media:afterUpload");
1607
+ this.registerPluginHook(plugin, "cron");
1608
+ this.registerPluginHook(plugin, "email:beforeSend");
1609
+ this.registerPluginHook(plugin, "email:deliver");
1610
+ this.registerPluginHook(plugin, "email:afterSend");
1611
+ this.registerPluginHook(plugin, "comment:beforeCreate");
1612
+ this.registerPluginHook(plugin, "comment:moderate");
1613
+ this.registerPluginHook(plugin, "comment:afterCreate");
1614
+ this.registerPluginHook(plugin, "comment:afterModerate");
1615
+ this.registerPluginHook(plugin, "byline:afterSave");
1616
+ this.registerPluginHook(plugin, "byline:afterDelete");
1617
+ this.registerPluginHook(plugin, "page:metadata");
1618
+ this.registerPluginHook(plugin, "page:fragments");
1619
+ }
1620
+ for (const [hookName, hooks] of this.hooks) this.hooks.set(hookName, this.sortHooks(hooks));
1621
+ }
1622
+ /**
1623
+ * Maps hook names to the capability required to register them.
1624
+ *
1625
+ * Hooks not listed here have no capability requirement (e.g. lifecycle
1626
+ * hooks, cron). Any plugin declaring a listed hook without the required
1627
+ * capability will have that hook silently skipped at registration time.
1628
+ */
1629
+ static HOOK_REQUIRED_CAPABILITY = new Map([
1630
+ ["email:beforeSend", "hooks.email-events:register"],
1631
+ ["email:afterSend", "hooks.email-events:register"],
1632
+ ["email:deliver", "hooks.email-transport:register"],
1633
+ ["content:beforeSave", "content:write"],
1634
+ ["content:afterSave", "content:read"],
1635
+ ["content:beforeDelete", "content:read"],
1636
+ ["content:afterDelete", "content:read"],
1637
+ ["content:beforePublish", "hooks.content-policy:register"],
1638
+ ["content:beforeSchedule", "hooks.content-policy:register"],
1639
+ ["content:beforeUnpublish", "hooks.content-policy:register"],
1640
+ ["content:afterPublish", "content:read"],
1641
+ ["content:afterUnpublish", "content:read"],
1642
+ ["content:afterRestore", "content:read"],
1643
+ ["content:afterSchedule", "content:read"],
1644
+ ["content:afterUnschedule", "content:read"],
1645
+ ["media:beforeUpload", "media:write"],
1646
+ ["media:afterUpload", "media:read"],
1647
+ ["comment:beforeCreate", "users:read"],
1648
+ ["comment:moderate", "users:read"],
1649
+ ["comment:afterCreate", "users:read"],
1650
+ ["comment:afterModerate", "users:read"],
1651
+ ["byline:afterSave", "bylines:read"],
1652
+ ["byline:afterDelete", "bylines:read"],
1653
+ ["page:fragments", "hooks.page-fragments:register"]
1654
+ ]);
1655
+ /**
1656
+ * Register a single plugin's hook by name
1657
+ */
1658
+ registerPluginHook(plugin, name) {
1659
+ const hook = plugin.hooks[name];
1660
+ if (!hook) return;
1661
+ const requiredCapability = HookPipeline.HOOK_REQUIRED_CAPABILITY.get(name);
1662
+ if (requiredCapability && !plugin.capabilities.includes(requiredCapability)) {
1663
+ console.warn(`[hooks] Plugin "${plugin.id}" declares ${name} hook without ${requiredCapability} capability — skipping`);
1664
+ return;
1665
+ }
1666
+ if (hook.exclusive) this.exclusiveHookNames.add(name);
1667
+ this.registerHook(name, hook);
1668
+ }
1669
+ /**
1670
+ * Register a single hook
1671
+ */
1672
+ registerHook(name, hook) {
1673
+ const existing = this.hooks.get(name) || [];
1674
+ existing.push(hook);
1675
+ this.hooks.set(name, existing);
1676
+ }
1677
+ /**
1678
+ * Sort hooks by priority and dependencies
1679
+ */
1680
+ sortHooks(hooks) {
1681
+ const sorted = [];
1682
+ const remaining = [...hooks];
1683
+ while (remaining.length > 0) {
1684
+ const ready = remaining.filter((hook) => hook.dependencies.every((dep) => sorted.some((s) => s.pluginId === dep)));
1685
+ if (ready.length === 0) {
1686
+ const pluginIds = remaining.map((h) => h.pluginId).join(", ");
1687
+ console.warn(`[hooks] Hook dependency cycle or missing dependency detected among plugins: ${pluginIds}. Falling back to priority order.`);
1688
+ remaining.sort((a, b) => a.priority - b.priority);
1689
+ sorted.push(...remaining);
1690
+ break;
1691
+ }
1692
+ ready.sort((a, b) => a.priority - b.priority);
1693
+ const next = ready[0];
1694
+ sorted.push(next);
1695
+ remaining.splice(remaining.indexOf(next), 1);
1696
+ }
1697
+ return sorted;
1698
+ }
1699
+ /**
1700
+ * Execute a hook with timeout
1701
+ */
1702
+ async executeWithTimeout(fn, timeout) {
1703
+ let timer;
1704
+ const timeoutPromise = new Promise((_, reject) => timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Hook timeout after ${timeout}ms`)), timeout));
1705
+ try {
1706
+ return await Promise.race([fn(), timeoutPromise]);
1707
+ } finally {
1708
+ clearTimeout(timer);
1709
+ }
1710
+ }
1711
+ /**
1712
+ * Run plugin:install hooks
1713
+ */
1714
+ async runPluginInstall(pluginId) {
1715
+ return this.runLifecycleHook("plugin:install", pluginId);
1716
+ }
1717
+ /**
1718
+ * Run plugin:activate hooks
1719
+ */
1720
+ async runPluginActivate(pluginId) {
1721
+ return this.runLifecycleHook("plugin:activate", pluginId);
1722
+ }
1723
+ /**
1724
+ * Run plugin:deactivate hooks
1725
+ */
1726
+ async runPluginDeactivate(pluginId) {
1727
+ return this.runLifecycleHook("plugin:deactivate", pluginId);
1728
+ }
1729
+ /**
1730
+ * Run plugin:uninstall hooks
1731
+ */
1732
+ async runPluginUninstall(pluginId, deleteData) {
1733
+ const hooks = this.getTypedHooks("plugin:uninstall");
1734
+ const results = [];
1735
+ const hook = hooks.find((h) => h.pluginId === pluginId);
1736
+ if (!hook) return results;
1737
+ const { handler } = hook;
1738
+ const event = { deleteData };
1739
+ const ctx = this.getContext(pluginId);
1740
+ const start = Date.now();
1741
+ try {
1742
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1743
+ results.push({
1744
+ success: true,
1745
+ pluginId: hook.pluginId,
1746
+ duration: Date.now() - start
1747
+ });
1748
+ } catch (error) {
1749
+ results.push({
1750
+ success: false,
1751
+ error: error instanceof Error ? error : new Error(String(error)),
1752
+ pluginId: hook.pluginId,
1753
+ duration: Date.now() - start
1754
+ });
1755
+ }
1756
+ return results;
1757
+ }
1758
+ async runLifecycleHook(hookName, pluginId) {
1759
+ const hooks = this.getTypedHooks(hookName);
1760
+ const results = [];
1761
+ const hook = hooks.find((h) => h.pluginId === pluginId);
1762
+ if (!hook) return results;
1763
+ const { handler } = hook;
1764
+ const event = {};
1765
+ const ctx = this.getContext(pluginId);
1766
+ const start = Date.now();
1767
+ try {
1768
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1769
+ results.push({
1770
+ success: true,
1771
+ pluginId: hook.pluginId,
1772
+ duration: Date.now() - start
1773
+ });
1774
+ } catch (error) {
1775
+ results.push({
1776
+ success: false,
1777
+ error: error instanceof Error ? error : new Error(String(error)),
1778
+ pluginId: hook.pluginId,
1779
+ duration: Date.now() - start
1780
+ });
1781
+ }
1782
+ return results;
1783
+ }
1784
+ /**
1785
+ * Run content:beforeSave hooks
1786
+ * Returns modified content from the pipeline. `id` is the existing item's
1787
+ * ID when updating. `actor` is the authenticated user that triggered the
1788
+ * save, when one is available.
1789
+ */
1790
+ async runContentBeforeSave(content, collection, isNew, id, actor, details = {}) {
1791
+ const hooks = this.getTypedHooks("content:beforeSave");
1792
+ const results = [];
1793
+ let currentContent = content;
1794
+ for (const hook of hooks) {
1795
+ const { handler } = hook;
1796
+ const event = {
1797
+ content: currentContent,
1798
+ collection,
1799
+ isNew
1800
+ };
1801
+ if (id !== void 0) event.id = id;
1802
+ if (actor !== void 0) event.actor = { ...actor };
1803
+ assignSaveHookDetails(event, details);
1804
+ const ctx = this.getContext(hook.pluginId);
1805
+ const start = Date.now();
1806
+ try {
1807
+ const result = await contentSaveHookContext.run("content:beforeSave", () => this.executeWithTimeout(() => handler(event, ctx), hook.timeout));
1808
+ if (result !== void 0) currentContent = result;
1809
+ results.push({
1810
+ success: true,
1811
+ value: currentContent,
1812
+ pluginId: hook.pluginId,
1813
+ duration: Date.now() - start
1814
+ });
1815
+ } catch (error) {
1816
+ results.push({
1817
+ success: false,
1818
+ error: error instanceof Error ? error : new Error(String(error)),
1819
+ pluginId: hook.pluginId,
1820
+ duration: Date.now() - start
1821
+ });
1822
+ if (hook.errorPolicy === "abort") throw error;
1823
+ }
1824
+ }
1825
+ return {
1826
+ content: currentContent,
1827
+ results
1828
+ };
1829
+ }
1830
+ /**
1831
+ * Run content:afterSave hooks
1832
+ */
1833
+ async runContentAfterSave(content, collection, isNew, actor, excludePluginId, details = {}) {
1834
+ const hooks = this.getTypedHooks("content:afterSave");
1835
+ const results = [];
1836
+ for (const hook of hooks) {
1837
+ if (hook.pluginId === excludePluginId) continue;
1838
+ const { handler } = hook;
1839
+ const event = {
1840
+ content,
1841
+ collection,
1842
+ isNew
1843
+ };
1844
+ if (actor !== void 0) event.actor = { ...actor };
1845
+ assignSaveHookDetails(event, details);
1846
+ const ctx = this.getContext(hook.pluginId);
1847
+ const start = Date.now();
1848
+ try {
1849
+ await contentSaveHookContext.run("content:afterSave", () => this.executeWithTimeout(() => handler(event, ctx), hook.timeout));
1850
+ results.push({
1851
+ success: true,
1852
+ pluginId: hook.pluginId,
1853
+ duration: Date.now() - start
1854
+ });
1855
+ } catch (error) {
1856
+ results.push({
1857
+ success: false,
1858
+ error: error instanceof Error ? error : new Error(String(error)),
1859
+ pluginId: hook.pluginId,
1860
+ duration: Date.now() - start
1861
+ });
1862
+ if (hook.errorPolicy === "abort") throw error;
1863
+ }
1864
+ }
1865
+ return results;
1866
+ }
1867
+ /**
1868
+ * Run content:beforeDelete hooks
1869
+ * Returns whether deletion is allowed
1870
+ */
1871
+ async runContentBeforeDelete(id, collection) {
1872
+ const hooks = this.getTypedHooks("content:beforeDelete");
1873
+ const results = [];
1874
+ let allowed = true;
1875
+ for (const hook of hooks) {
1876
+ const { handler } = hook;
1877
+ const event = {
1878
+ id,
1879
+ collection,
1880
+ permanent: false
1881
+ };
1882
+ const ctx = this.getContext(hook.pluginId);
1883
+ const start = Date.now();
1884
+ try {
1885
+ const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1886
+ if (result === false) allowed = false;
1887
+ results.push({
1888
+ success: true,
1889
+ value: result !== false,
1890
+ pluginId: hook.pluginId,
1891
+ duration: Date.now() - start
1892
+ });
1893
+ } catch (error) {
1894
+ results.push({
1895
+ success: false,
1896
+ error: error instanceof Error ? error : new Error(String(error)),
1897
+ pluginId: hook.pluginId,
1898
+ duration: Date.now() - start
1899
+ });
1900
+ if (hook.errorPolicy === "abort") throw error;
1901
+ }
1902
+ }
1903
+ return {
1904
+ allowed,
1905
+ results
1906
+ };
1907
+ }
1908
+ /**
1909
+ * Run content:afterDelete hooks
1910
+ */
1911
+ async runContentAfterDelete(id, collection, permanent) {
1912
+ const hooks = this.getTypedHooks("content:afterDelete");
1913
+ const results = [];
1914
+ for (const hook of hooks) {
1915
+ const { handler } = hook;
1916
+ const event = {
1917
+ id,
1918
+ collection,
1919
+ permanent
1920
+ };
1921
+ const ctx = this.getContext(hook.pluginId);
1922
+ const start = Date.now();
1923
+ try {
1924
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1925
+ results.push({
1926
+ success: true,
1927
+ pluginId: hook.pluginId,
1928
+ duration: Date.now() - start
1929
+ });
1930
+ } catch (error) {
1931
+ results.push({
1932
+ success: false,
1933
+ error: error instanceof Error ? error : new Error(String(error)),
1934
+ pluginId: hook.pluginId,
1935
+ duration: Date.now() - start
1936
+ });
1937
+ if (hook.errorPolicy === "abort") throw error;
1938
+ }
1939
+ }
1940
+ return results;
1941
+ }
1942
+ async runContentPolicy(name, event) {
1943
+ if (name === "content:beforeSchedule") {
1944
+ if (!("scheduledAt" in event)) throw new Error("content:beforeSchedule requires scheduledAt");
1945
+ return this.runContentPolicyHooks(name, this.getTypedHooks(name), event);
1946
+ }
1947
+ return this.runContentPolicyHooks(name, this.getTypedHooks(name), event);
1948
+ }
1949
+ async runContentPolicyHooks(name, hooks, event) {
1950
+ const results = [];
1951
+ for (const hook of hooks) {
1952
+ const ctx = this.getContext(hook.pluginId);
1953
+ const start = Date.now();
1954
+ try {
1955
+ const decision = inspectContentPolicyDecision(await this.executeWithTimeout(() => hook.handler(event, ctx), hook.timeout));
1956
+ if (decision.kind === "invalid") throw new Error(`Plugin "${hook.pluginId}" returned an invalid ${name} decision`);
1957
+ results.push({
1958
+ success: true,
1959
+ pluginId: hook.pluginId,
1960
+ duration: Date.now() - start
1961
+ });
1962
+ if (decision.kind === "cancel") return {
1963
+ cancellation: {
1964
+ pluginId: hook.pluginId,
1965
+ reason: decision.reason
1966
+ },
1967
+ results
1968
+ };
1969
+ } catch (error) {
1970
+ results.push({
1971
+ success: false,
1972
+ error: error instanceof Error ? error : new Error(String(error)),
1973
+ pluginId: hook.pluginId,
1974
+ duration: Date.now() - start
1975
+ });
1976
+ if (hook.errorPolicy === "abort") throw error;
1977
+ console.error(`[content-policy] Plugin "${hook.pluginId}" failed ${name}; continuing by policy`);
1978
+ }
1979
+ }
1980
+ return { results };
1981
+ }
1982
+ /**
1983
+ * Run content state-change hooks that all share the same event shape.
1984
+ */
1985
+ async runContentStateChangeHook(name, content, collection) {
1986
+ const hooks = this.getTypedHooks(name);
1987
+ const results = [];
1988
+ for (const hook of hooks) {
1989
+ const { handler } = hook;
1990
+ const event = {
1991
+ content,
1992
+ collection
1993
+ };
1994
+ const ctx = this.getContext(hook.pluginId);
1995
+ const start = Date.now();
1996
+ try {
1997
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1998
+ results.push({
1999
+ success: true,
2000
+ pluginId: hook.pluginId,
2001
+ duration: Date.now() - start
2002
+ });
2003
+ } catch (error) {
2004
+ results.push({
2005
+ success: false,
2006
+ error: error instanceof Error ? error : new Error(String(error)),
2007
+ pluginId: hook.pluginId,
2008
+ duration: Date.now() - start
2009
+ });
2010
+ if (hook.errorPolicy === "abort") throw error;
2011
+ }
2012
+ }
2013
+ return results;
2014
+ }
2015
+ /**
2016
+ * Run content:afterPublish hooks (fire-and-forget).
2017
+ */
2018
+ async runContentAfterPublish(content, collection) {
2019
+ return this.runContentStateChangeHook("content:afterPublish", content, collection);
2020
+ }
2021
+ /**
2022
+ * Run content:afterUnpublish hooks (fire-and-forget).
2023
+ */
2024
+ async runContentAfterUnpublish(content, collection) {
2025
+ return this.runContentStateChangeHook("content:afterUnpublish", content, collection);
2026
+ }
2027
+ /**
2028
+ * Run content:afterRestore hooks (fire-and-forget).
2029
+ */
2030
+ async runContentAfterRestore(content, collection) {
2031
+ return this.runContentStateChangeHook("content:afterRestore", content, collection);
2032
+ }
2033
+ /**
2034
+ * Run content:afterSchedule hooks (fire-and-forget).
2035
+ */
2036
+ async runContentAfterSchedule(content, collection) {
2037
+ return this.runContentStateChangeHook("content:afterSchedule", content, collection);
2038
+ }
2039
+ /**
2040
+ * Run content:afterUnschedule hooks (fire-and-forget).
2041
+ */
2042
+ async runContentAfterUnschedule(content, collection) {
2043
+ return this.runContentStateChangeHook("content:afterUnschedule", content, collection);
2044
+ }
2045
+ /**
2046
+ * Run media:beforeUpload hooks
2047
+ */
2048
+ async runMediaBeforeUpload(file) {
2049
+ const hooks = this.getTypedHooks("media:beforeUpload");
2050
+ const results = [];
2051
+ let currentFile = file;
2052
+ for (const hook of hooks) {
2053
+ const { handler } = hook;
2054
+ const event = { file: currentFile };
2055
+ const ctx = this.getContext(hook.pluginId);
2056
+ const start = Date.now();
2057
+ try {
2058
+ const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2059
+ if (result !== void 0) currentFile = result;
2060
+ results.push({
2061
+ success: true,
2062
+ value: currentFile,
2063
+ pluginId: hook.pluginId,
2064
+ duration: Date.now() - start
2065
+ });
2066
+ } catch (error) {
2067
+ results.push({
2068
+ success: false,
2069
+ error: error instanceof Error ? error : new Error(String(error)),
2070
+ pluginId: hook.pluginId,
2071
+ duration: Date.now() - start
2072
+ });
2073
+ if (hook.errorPolicy === "abort") throw error;
2074
+ }
2075
+ }
2076
+ return {
2077
+ file: currentFile,
2078
+ results
2079
+ };
2080
+ }
2081
+ /**
2082
+ * Run media:afterUpload hooks
2083
+ */
2084
+ async runMediaAfterUpload(media) {
2085
+ const hooks = this.getTypedHooks("media:afterUpload");
2086
+ const results = [];
2087
+ for (const hook of hooks) {
2088
+ const { handler } = hook;
2089
+ const event = { media };
2090
+ const ctx = this.getContext(hook.pluginId);
2091
+ const start = Date.now();
2092
+ try {
2093
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2094
+ results.push({
2095
+ success: true,
2096
+ pluginId: hook.pluginId,
2097
+ duration: Date.now() - start
2098
+ });
2099
+ } catch (error) {
2100
+ results.push({
2101
+ success: false,
2102
+ error: error instanceof Error ? error : new Error(String(error)),
2103
+ pluginId: hook.pluginId,
2104
+ duration: Date.now() - start
2105
+ });
2106
+ if (hook.errorPolicy === "abort") throw error;
2107
+ }
2108
+ }
2109
+ return results;
2110
+ }
2111
+ /**
2112
+ * Invoke the cron hook for a specific plugin.
2113
+ *
2114
+ * Unlike other hooks which broadcast to all plugins, the cron hook is
2115
+ * dispatched only to the target plugin — the one that owns the task.
2116
+ */
2117
+ async invokeCronHook(pluginId, event) {
2118
+ const hook = this.getTypedHooks("cron").find((h) => h.pluginId === pluginId);
2119
+ if (!hook) return {
2120
+ success: false,
2121
+ error: /* @__PURE__ */ new Error(`Plugin "${pluginId}" has no cron hook registered`),
2122
+ pluginId,
2123
+ duration: 0
2124
+ };
2125
+ const { handler } = hook;
2126
+ const ctx = this.getContext(pluginId);
2127
+ const start = Date.now();
2128
+ try {
2129
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2130
+ return {
2131
+ success: true,
2132
+ pluginId,
2133
+ duration: Date.now() - start
2134
+ };
2135
+ } catch (error) {
2136
+ return {
2137
+ success: false,
2138
+ error: error instanceof Error ? error : new Error(String(error)),
2139
+ pluginId,
2140
+ duration: Date.now() - start
2141
+ };
2142
+ }
2143
+ }
2144
+ /**
2145
+ * Run email:beforeSend hooks (middleware pipeline).
2146
+ *
2147
+ * Each handler receives the message and returns a modified message or
2148
+ * `false` to cancel delivery. The pipeline chains message transformations —
2149
+ * each handler receives the output of the previous one.
2150
+ */
2151
+ async runEmailBeforeSend(message, source) {
2152
+ const hooks = this.getTypedHooks("email:beforeSend");
2153
+ const results = [];
2154
+ let currentMessage = message;
2155
+ for (const hook of hooks) {
2156
+ const { handler } = hook;
2157
+ const event = {
2158
+ message: { ...currentMessage },
2159
+ source
2160
+ };
2161
+ const ctx = this.getContext(hook.pluginId);
2162
+ const start = Date.now();
2163
+ try {
2164
+ const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2165
+ if (result === false) {
2166
+ results.push({
2167
+ success: true,
2168
+ value: false,
2169
+ pluginId: hook.pluginId,
2170
+ duration: Date.now() - start
2171
+ });
2172
+ return {
2173
+ message: false,
2174
+ results
2175
+ };
2176
+ }
2177
+ if (result && typeof result === "object") currentMessage = result;
2178
+ results.push({
2179
+ success: true,
2180
+ value: currentMessage,
2181
+ pluginId: hook.pluginId,
2182
+ duration: Date.now() - start
2183
+ });
2184
+ } catch (error) {
2185
+ results.push({
2186
+ success: false,
2187
+ error: error instanceof Error ? error : new Error(String(error)),
2188
+ pluginId: hook.pluginId,
2189
+ duration: Date.now() - start
2190
+ });
2191
+ if (hook.errorPolicy === "abort") throw error;
2192
+ }
2193
+ }
2194
+ return {
2195
+ message: currentMessage,
2196
+ results
2197
+ };
2198
+ }
2199
+ /**
2200
+ * Run email:afterSend hooks (fire-and-forget).
2201
+ *
2202
+ * Errors are logged but don't propagate — they don't affect the caller.
2203
+ */
2204
+ async runEmailAfterSend(message, source) {
2205
+ const hooks = this.getTypedHooks("email:afterSend");
2206
+ const results = [];
2207
+ for (const hook of hooks) {
2208
+ const { handler } = hook;
2209
+ const event = {
2210
+ message,
2211
+ source
2212
+ };
2213
+ const ctx = this.getContext(hook.pluginId);
2214
+ const start = Date.now();
2215
+ try {
2216
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2217
+ results.push({
2218
+ success: true,
2219
+ pluginId: hook.pluginId,
2220
+ duration: Date.now() - start
2221
+ });
2222
+ } catch (error) {
2223
+ console.error(`[email:afterSend] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2224
+ results.push({
2225
+ success: false,
2226
+ error: error instanceof Error ? error : new Error(String(error)),
2227
+ pluginId: hook.pluginId,
2228
+ duration: Date.now() - start
2229
+ });
2230
+ }
2231
+ }
2232
+ return results;
2233
+ }
2234
+ /**
2235
+ * Run comment:beforeCreate hooks (middleware pipeline).
2236
+ *
2237
+ * Each handler receives the event and returns a modified event or
2238
+ * `false` to reject the comment. The pipeline chains transformations —
2239
+ * each handler receives the output of the previous one.
2240
+ */
2241
+ async runCommentBeforeCreate(event) {
2242
+ const hooks = this.getTypedHooks("comment:beforeCreate");
2243
+ let currentEvent = event;
2244
+ for (const hook of hooks) {
2245
+ const { handler } = hook;
2246
+ const ctx = this.getContext(hook.pluginId);
2247
+ const start = Date.now();
2248
+ try {
2249
+ const result = await this.executeWithTimeout(() => handler({ ...currentEvent }, ctx), hook.timeout);
2250
+ if (result === false) return false;
2251
+ if (result && typeof result === "object") currentEvent = result;
2252
+ } catch (error) {
2253
+ console.error(`[comment:beforeCreate] Plugin "${hook.pluginId}" error (${Date.now() - start}ms):`, error instanceof Error ? error.message : error);
2254
+ if (hook.errorPolicy === "abort") throw error;
2255
+ }
2256
+ }
2257
+ return currentEvent;
2258
+ }
2259
+ /**
2260
+ * Run comment:afterCreate hooks (fire-and-forget).
2261
+ *
2262
+ * Errors are logged but don't propagate — they don't affect the caller.
2263
+ */
2264
+ async runCommentAfterCreate(event) {
2265
+ const hooks = this.getTypedHooks("comment:afterCreate");
2266
+ for (const hook of hooks) {
2267
+ const { handler } = hook;
2268
+ const ctx = this.getContext(hook.pluginId);
2269
+ try {
2270
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2271
+ } catch (error) {
2272
+ console.error(`[comment:afterCreate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2273
+ }
2274
+ }
2275
+ }
2276
+ /**
2277
+ * Run comment:afterModerate hooks (fire-and-forget).
2278
+ *
2279
+ * Errors are logged but don't propagate — they don't affect the caller.
2280
+ */
2281
+ async runCommentAfterModerate(event) {
2282
+ const hooks = this.getTypedHooks("comment:afterModerate");
2283
+ for (const hook of hooks) {
2284
+ const { handler } = hook;
2285
+ const ctx = this.getContext(hook.pluginId);
2286
+ try {
2287
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2288
+ } catch (error) {
2289
+ console.error(`[comment:afterModerate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2290
+ }
2291
+ }
2292
+ }
2293
+ /** Run byline:afterSave hooks. Errors are logged and never propagate. */
2294
+ async runBylineAfterSave(byline, isNew) {
2295
+ const event = {
2296
+ byline: toBylineInfo(byline),
2297
+ isNew
2298
+ };
2299
+ for (const hook of this.getTypedHooks("byline:afterSave")) await this.runLoggedHook("byline:afterSave", hook, (ctx) => hook.handler(event, ctx));
2300
+ }
2301
+ /** Run byline:afterDelete hooks. Errors are logged and never propagate. */
2302
+ async runBylineAfterDelete(byline) {
2303
+ const event = { byline: toBylineInfo(byline) };
2304
+ for (const hook of this.getTypedHooks("byline:afterDelete")) await this.runLoggedHook("byline:afterDelete", hook, (ctx) => hook.handler(event, ctx));
2305
+ }
2306
+ async runLoggedHook(name, hook, run) {
2307
+ try {
2308
+ await this.executeWithTimeout(() => run(this.getContext(hook.pluginId)), hook.timeout);
2309
+ } catch (error) {
2310
+ console.error(`[${name}] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2311
+ }
2312
+ }
2313
+ /**
2314
+ * Run page:metadata hooks. Each handler returns contributions that are
2315
+ * merged by the metadata collector. Errors are logged but don't propagate.
2316
+ */
2317
+ async runPageMetadata(event) {
2318
+ const hooks = this.getTypedHooks("page:metadata");
2319
+ const results = [];
2320
+ for (const hook of hooks) {
2321
+ const { handler } = hook;
2322
+ const ctx = this.getContext(hook.pluginId);
2323
+ try {
2324
+ const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2325
+ if (result != null) {
2326
+ const contributions = Array.isArray(result) ? result : [result];
2327
+ results.push({
2328
+ pluginId: hook.pluginId,
2329
+ contributions
2330
+ });
2331
+ }
2332
+ } catch (error) {
2333
+ console.error(`[page:metadata] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2334
+ }
2335
+ }
2336
+ return results;
2337
+ }
2338
+ /**
2339
+ * Run page:fragments hooks. Only trusted plugins should be registered
2340
+ * for this hook. Errors are logged but don't propagate.
2341
+ */
2342
+ async runPageFragments(event) {
2343
+ const hooks = this.getTypedHooks("page:fragments");
2344
+ const results = [];
2345
+ for (const hook of hooks) {
2346
+ const { handler } = hook;
2347
+ const ctx = this.getContext(hook.pluginId);
2348
+ try {
2349
+ const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2350
+ if (result != null) {
2351
+ const contributions = Array.isArray(result) ? result : [result];
2352
+ results.push({
2353
+ pluginId: hook.pluginId,
2354
+ contributions
2355
+ });
2356
+ }
2357
+ } catch (error) {
2358
+ console.error(`[page:fragments] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2359
+ }
2360
+ }
2361
+ return results;
2362
+ }
2363
+ /**
2364
+ * Check if any hooks are registered for a given name
2365
+ */
2366
+ hasHooks(name) {
2367
+ const hooks = this.hooks.get(name);
2368
+ return hooks !== void 0 && hooks.length > 0;
2369
+ }
2370
+ /**
2371
+ * Get hook count for debugging
2372
+ */
2373
+ getHookCount(name) {
2374
+ return this.hooks.get(name)?.length || 0;
2375
+ }
2376
+ /**
2377
+ * Get all registered hook names
2378
+ */
2379
+ getRegisteredHooks() {
2380
+ return [...this.hooks.keys()];
2381
+ }
2382
+ /**
2383
+ * Returns hook names where at least one handler declared exclusive: true
2384
+ */
2385
+ getRegisteredExclusiveHooks() {
2386
+ return [...this.exclusiveHookNames];
2387
+ }
2388
+ /**
2389
+ * Check if a hook is exclusive
2390
+ */
2391
+ isExclusiveHook(name) {
2392
+ return this.exclusiveHookNames.has(name);
2393
+ }
2394
+ /**
2395
+ * Set the selected provider for an exclusive hook.
2396
+ * Called by PluginManager after resolution.
2397
+ */
2398
+ setExclusiveSelection(hookName, pluginId) {
2399
+ this.exclusiveSelections.set(hookName, pluginId);
2400
+ }
2401
+ /**
2402
+ * Clear the selected provider for an exclusive hook.
2403
+ */
2404
+ clearExclusiveSelection(hookName) {
2405
+ this.exclusiveSelections.delete(hookName);
2406
+ }
2407
+ /**
2408
+ * Get the selected provider for an exclusive hook (if any).
2409
+ */
2410
+ getExclusiveSelection(hookName) {
2411
+ return this.exclusiveSelections.get(hookName);
2412
+ }
2413
+ /**
2414
+ * Get all plugins that registered a handler for a given exclusive hook.
2415
+ */
2416
+ getExclusiveHookProviders(hookName) {
2417
+ return (this.hooks.get(hookName) ?? []).filter((h) => h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2418
+ }
2419
+ /**
2420
+ * Get all plugins that registered a non-exclusive handler for a given
2421
+ * hook (e.g. `email:beforeSend`, `email:afterSend`), preserving priority
2422
+ * order. Partitions with `getExclusiveHookProviders()`, which returns
2423
+ * plugins whose registration is marked `exclusive: true`.
2424
+ */
2425
+ getHookProviders(hookName) {
2426
+ return (this.hooks.get(hookName) ?? []).filter((h) => !h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2427
+ }
2428
+ /**
2429
+ * Invoke an exclusive hook — dispatch only to the selected provider.
2430
+ * Returns null if no provider is selected or if the selected hook
2431
+ * is not found in the pipeline.
2432
+ *
2433
+ * This is a generic dispatch used by the email pipeline and other
2434
+ * exclusive hook consumers. The handler type is unknown — callers
2435
+ * must know the expected signature.
2436
+ *
2437
+ * Errors are isolated: a failing handler returns an error result
2438
+ * instead of propagating the exception to the caller.
2439
+ */
2440
+ async invokeExclusiveHook(hookName, event) {
2441
+ const selectedPluginId = this.exclusiveSelections.get(hookName);
2442
+ if (!selectedPluginId) return null;
2443
+ const hook = (this.hooks.get(hookName) ?? []).find((h) => h.pluginId === selectedPluginId && h.exclusive);
2444
+ if (!hook) return null;
2445
+ const start = Date.now();
2446
+ try {
2447
+ const ctx = this.getContext(selectedPluginId);
2448
+ const handler = hook.handler;
2449
+ return {
2450
+ result: await this.executeWithTimeout(() => handler(event, ctx), hook.timeout),
2451
+ pluginId: selectedPluginId,
2452
+ duration: Date.now() - start
2453
+ };
2454
+ } catch (error) {
2455
+ return {
2456
+ result: void 0,
2457
+ pluginId: selectedPluginId,
2458
+ error: error instanceof Error ? error : new Error(String(error)),
2459
+ duration: Date.now() - start
2460
+ };
2461
+ }
2462
+ }
2463
+ };
2464
+ /**
2465
+ * Create a hook pipeline from plugins
2466
+ */
2467
+ function createHookPipeline(plugins, factoryOptions) {
2468
+ return new HookPipeline(plugins, factoryOptions);
2469
+ }
2470
+ /** Options table key prefix for exclusive hook selections */
2471
+ const EXCLUSIVE_HOOK_KEY_PREFIX$1 = "emdash:exclusive_hook:";
2472
+ /**
2473
+ * Resolve exclusive hook selections.
2474
+ *
2475
+ * Shared algorithm used by both PluginManager and EmDashRuntime:
2476
+ * 1. If a DB selection exists and that plugin is active → keep it.
2477
+ * 2. If DB selection is stale (plugin inactive/gone) → clear it.
2478
+ * 3. If no selection and only one active provider → auto-select it. Fallback
2479
+ * providers are not counted when another provider is active, so a single
2480
+ * plugin provider is selected over a built-in fallback. A fallback
2481
+ * selection is kept in memory only.
2482
+ * 4. If preferred hints match an active provider → first match wins.
2483
+ * 5. If multiple providers and no hint → leave unselected (admin must choose).
2484
+ */
2485
+ async function resolveExclusiveHooks(opts) {
2486
+ const { pipeline, isActive, getOption, getOptions, setOption, deleteOption, preferredHints, fallbackProviders } = opts;
2487
+ const exclusiveHookNames = pipeline.getRegisteredExclusiveHooks();
2488
+ if (exclusiveHookNames.length === 0) return;
2489
+ let batchedSelections;
2490
+ if (getOptions) try {
2491
+ batchedSelections = await getOptions(exclusiveHookNames.map((hookName) => `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`));
2492
+ } catch {
2493
+ return;
2494
+ }
2495
+ for (const hookName of exclusiveHookNames) {
2496
+ const providers = pipeline.getExclusiveHookProviders(hookName);
2497
+ const activeProviderIds = new Set(providers.map((p) => p.pluginId).filter((id) => isActive(id)));
2498
+ const key = `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`;
2499
+ let currentSelection = null;
2500
+ if (batchedSelections) currentSelection = batchedSelections.get(key) ?? null;
2501
+ else try {
2502
+ currentSelection = await getOption(key);
2503
+ } catch {
2504
+ continue;
2505
+ }
2506
+ if (currentSelection && activeProviderIds.has(currentSelection)) {
2507
+ pipeline.setExclusiveSelection(hookName, currentSelection);
2508
+ continue;
2509
+ }
2510
+ if (currentSelection) try {
2511
+ await deleteOption(key);
2512
+ } catch {}
2513
+ const candidates = activeProviderIds.size > 1 && fallbackProviders ? [...activeProviderIds].filter((id) => !fallbackProviders.has(id)) : [...activeProviderIds];
2514
+ if (candidates.length === 1) {
2515
+ const [onlyProvider] = candidates;
2516
+ if (!fallbackProviders?.has(onlyProvider)) try {
2517
+ await setOption(key, onlyProvider);
2518
+ } catch {}
2519
+ pipeline.setExclusiveSelection(hookName, onlyProvider);
2520
+ continue;
2521
+ }
2522
+ if (preferredHints) {
2523
+ let found = false;
2524
+ for (const [pluginId, hooks] of preferredHints) if (hooks.includes(hookName) && activeProviderIds.has(pluginId)) {
2525
+ try {
2526
+ await setOption(key, pluginId);
2527
+ } catch {}
2528
+ pipeline.setExclusiveSelection(hookName, pluginId);
2529
+ found = true;
2530
+ break;
2531
+ }
2532
+ if (found) continue;
2533
+ }
2534
+ pipeline.clearExclusiveSelection(hookName);
2535
+ }
2536
+ }
2537
+
2538
+ //#endregion
2539
+ //#region src/plugins/save-rejection.ts
2540
+ /**
2541
+ * Thrown by a `content:beforeSave` hook to reject a save with a message
2542
+ * that is safe to show to the editor. The runtime converts it into a
2543
+ * structured `SAVE_REJECTED` API error; any other exception thrown by the
2544
+ * hook cancels the save with a generic error that hides the exception
2545
+ * message.
2546
+ */
2547
+ var ContentSaveRejectedError = class extends Error {
2548
+ name = "ContentSaveRejectedError";
2549
+ };
2550
+ /**
2551
+ * Matches by name as well as by prototype: bundlers can duplicate this
2552
+ * module across SSR chunks, and an `instanceof` against the wrong copy of
2553
+ * the class would misreport a rejection as a plugin crash.
2554
+ */
2555
+ function isContentSaveRejection(error) {
2556
+ if (error instanceof ContentSaveRejectedError) return true;
2557
+ return error instanceof Error && error.name === "ContentSaveRejectedError";
2558
+ }
2559
+
2560
+ //#endregion
2561
+ //#region src/plugins/email.ts
2562
+ /**
2563
+ * Email Pipeline
2564
+ *
2565
+ * Orchestrates the three-stage email pipeline:
2566
+ * 1. email:beforeSend hooks (middleware — transform, validate, cancel)
2567
+ * 2. email:deliver hook (exclusive — exactly one provider delivers)
2568
+ * 3. email:afterSend hooks (logging, analytics, fire-and-forget)
2569
+ *
2570
+ * Security features:
2571
+ * - Recursion guard prevents re-entrant sends (e.g. plugin calling ctx.email.send from a hook)
2572
+ * - System emails (source="system") bypass email:beforeSend and email:afterSend hooks entirely
2573
+ * to protect auth tokens from exfiltration by plugin hooks
2574
+ *
2575
+ */
2576
+ /** Hook name for the exclusive email delivery hook */
2577
+ const EMAIL_DELIVER_HOOK = "email:deliver";
2578
+ /** Source value used for auth emails (magic links, invites, password resets) */
2579
+ const SYSTEM_SOURCE = "system";
2580
+ /**
2581
+ * Error thrown when ctx.email.send() is called but no provider is configured.
2582
+ */
2583
+ var EmailNotConfiguredError = class extends Error {
2584
+ constructor() {
2585
+ super("No email provider is configured. Install and activate an email provider plugin, then select it in Settings > Email.");
2586
+ this.name = "EmailNotConfiguredError";
2587
+ }
2588
+ };
2589
+ /**
2590
+ * Error thrown when a recursive email send is detected.
2591
+ */
2592
+ var EmailRecursionError = class extends Error {
2593
+ constructor() {
2594
+ super("Recursive email send detected. A plugin hook attempted to send an email from within the email pipeline, which would cause infinite recursion.");
2595
+ this.name = "EmailRecursionError";
2596
+ }
2597
+ };
2598
+ /**
2599
+ * Recursion guard using AsyncLocalStorage.
2600
+ *
2601
+ * EmailPipeline is a singleton (worker-lifetime cached via EmDashRuntime).
2602
+ * Instance state like `sendDepth` would false-positive under concurrent
2603
+ * requests because two unrelated sends would increment the same counter.
2604
+ * ALS scopes the guard to the current async execution context, so concurrent
2605
+ * requests each get their own independent recursion tracking.
2606
+ */
2607
+ const emailSendALS = new AsyncLocalStorage();
2608
+ /**
2609
+ * EmailPipeline orchestrates email delivery through the plugin hook system.
2610
+ *
2611
+ * The pipeline runs in three stages:
2612
+ * 1. email:beforeSend — middleware hooks that can transform or cancel messages
2613
+ * 2. email:deliver — exclusive hook dispatching to the selected provider
2614
+ * 3. email:afterSend — fire-and-forget hooks for logging/analytics
2615
+ */
2616
+ var EmailPipeline = class {
2617
+ pipeline;
2618
+ constructor(pipeline) {
2619
+ this.pipeline = pipeline;
2620
+ }
2621
+ /**
2622
+ * Replace the underlying hook pipeline.
2623
+ *
2624
+ * Called by the runtime when rebuilding the hook pipeline after a
2625
+ * plugin is enabled or disabled, so the email pipeline dispatches
2626
+ * to the current set of active hooks.
2627
+ */
2628
+ setPipeline(pipeline) {
2629
+ this.pipeline = pipeline;
2630
+ }
2631
+ /**
2632
+ * Send an email through the full pipeline.
2633
+ *
2634
+ * @param message - The email to send
2635
+ * @param source - Where the email originated ("system" for auth, plugin ID for plugins)
2636
+ * @throws EmailNotConfiguredError if no provider is selected
2637
+ * @throws EmailRecursionError if called re-entrantly from within a hook
2638
+ * @throws Error if the provider handler throws
2639
+ */
2640
+ async send(message, source) {
2641
+ const store = emailSendALS.getStore();
2642
+ if (store && store.depth > 0) throw new EmailRecursionError();
2643
+ const run = () => this.sendInner(message, source);
2644
+ if (store) {
2645
+ store.depth++;
2646
+ try {
2647
+ await run();
2648
+ } finally {
2649
+ store.depth--;
2650
+ }
2651
+ } else await emailSendALS.run({ depth: 1 }, run);
2652
+ }
2653
+ /**
2654
+ * Inner send implementation, separated from the recursion guard.
2655
+ */
2656
+ async sendInner(message, source) {
2657
+ if (!message || typeof message !== "object") throw new Error("Invalid email message: message must be an object");
2658
+ if (!message.to || typeof message.to !== "string") throw new Error("Invalid email message: 'to' is required and must be a string");
2659
+ if (message.cc !== void 0 && (!Array.isArray(message.cc) || message.cc.some((address) => typeof address !== "string"))) throw new Error("Invalid email message: 'cc' must be an array of strings");
2660
+ if (message.replyTo !== void 0 && typeof message.replyTo !== "string") throw new Error("Invalid email message: 'replyTo' must be a string");
2661
+ if (!message.subject || typeof message.subject !== "string") throw new Error("Invalid email message: 'subject' is required and must be a string");
2662
+ if (!message.text || typeof message.text !== "string") throw new Error("Invalid email message: 'text' is required and must be a string");
2663
+ const isSystemEmail = source === SYSTEM_SOURCE;
2664
+ let finalMessage;
2665
+ if (isSystemEmail) finalMessage = message;
2666
+ else {
2667
+ const beforeResult = await this.pipeline.runEmailBeforeSend(message, source);
2668
+ if (beforeResult.message === false) {
2669
+ const cancelledBy = beforeResult.results.find((r) => r.value === false)?.pluginId ?? "unknown";
2670
+ console.info(`[email] Email to "${message.to}" cancelled by plugin "${cancelledBy}"`);
2671
+ return;
2672
+ }
2673
+ finalMessage = beforeResult.message;
2674
+ }
2675
+ const deliverEvent = {
2676
+ message: finalMessage,
2677
+ source
2678
+ };
2679
+ const deliverResult = await this.pipeline.invokeExclusiveHook(EMAIL_DELIVER_HOOK, deliverEvent);
2680
+ if (!deliverResult) throw new EmailNotConfiguredError();
2681
+ if (deliverResult.error) {
2682
+ console.error(`[email:deliver] Provider "${deliverResult.pluginId}" failed to send email to "${finalMessage.to}":`, deliverResult.error);
2683
+ throw deliverResult.error;
2684
+ }
2685
+ if (!isSystemEmail) this.pipeline.runEmailAfterSend(finalMessage, source).catch((err) => console.error("[email] afterSend pipeline error:", err instanceof Error ? err.message : err));
2686
+ }
2687
+ /**
2688
+ * Check if an email provider is configured and available.
2689
+ *
2690
+ * Returns true if an email:deliver provider is selected in the exclusive
2691
+ * hook system. Plugins and auth code use this to decide whether to show
2692
+ * "send invite" vs "copy invite link" UI.
2693
+ */
2694
+ isAvailable() {
2695
+ return this.pipeline.getExclusiveSelection(EMAIL_DELIVER_HOOK) !== void 0;
2696
+ }
2697
+ };
2698
+
2699
+ //#endregion
2700
+ //#region src/plugins/manager.ts
2701
+ /** Options table key prefix for exclusive hook DB reads via PluginManager */
2702
+ const EXCLUSIVE_HOOK_KEY_PREFIX = "emdash:exclusive_hook:";
2703
+ /**
2704
+ * Plugin Manager v2
2705
+ *
2706
+ * Manages the full lifecycle of plugins and coordinates hooks/routes.
2707
+ */
2708
+ var PluginManager = class {
2709
+ plugins = /* @__PURE__ */ new Map();
2710
+ hookPipeline = null;
2711
+ routeRegistry = null;
2712
+ factoryOptions;
2713
+ initialized = false;
2714
+ constructor(options) {
2715
+ this.options = options;
2716
+ this.factoryOptions = {
2717
+ db: options.db,
2718
+ storage: options.storage,
2719
+ getUploadUrl: options.getUploadUrl,
2720
+ trustedProxyHeaders: options.trustedProxyHeaders
2721
+ };
2722
+ }
2723
+ /**
2724
+ * Set the email pipeline used when creating plugin contexts.
2725
+ * Reinitializes routes/hooks if already initialized so ctx.email is available immediately.
2726
+ */
2727
+ setEmailPipeline(pipeline) {
2728
+ this.factoryOptions.emailPipeline = pipeline;
2729
+ if (this.initialized) this.reinitialize();
2730
+ }
2731
+ /**
2732
+ * Register a plugin definition
2733
+ * This resolves the definition and adds it to the manager, but doesn't install it
2734
+ */
2735
+ register(definition) {
2736
+ const resolved = definePlugin(definition);
2737
+ if (this.plugins.has(resolved.id)) throw new Error(`Plugin "${resolved.id}" is already registered`);
2738
+ this.plugins.set(resolved.id, {
2739
+ plugin: resolved,
2740
+ state: "registered"
2741
+ });
2742
+ this.initialized = false;
2743
+ return resolved;
2744
+ }
2745
+ /**
2746
+ * Register multiple plugins
2747
+ */
2748
+ registerAll(definitions) {
2749
+ for (const def of definitions) this.register(def);
2750
+ }
2751
+ /**
2752
+ * Unregister a plugin
2753
+ * Plugin must be inactive or just registered
2754
+ */
2755
+ unregister(pluginId) {
2756
+ const entry = this.plugins.get(pluginId);
2757
+ if (!entry) return false;
2758
+ if (entry.state === "active") throw new Error(`Cannot unregister active plugin "${pluginId}". Deactivate it first.`);
2759
+ this.plugins.delete(pluginId);
2760
+ this.initialized = false;
2761
+ return true;
2762
+ }
2763
+ /**
2764
+ * Install a plugin (run install hooks, set up storage)
2765
+ */
2766
+ async install(pluginId) {
2767
+ const entry = this.plugins.get(pluginId);
2768
+ if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2769
+ if (entry.state !== "registered") throw new Error(`Plugin "${pluginId}" is already installed (state: ${entry.state})`);
2770
+ this.ensureInitialized();
2771
+ const results = await this.hookPipeline.runPluginInstall(pluginId);
2772
+ const failed = results.find((r) => !r.success);
2773
+ if (failed) throw new Error(`Plugin install failed: ${failed.error?.message ?? "Unknown error"}`);
2774
+ entry.state = "installed";
2775
+ return results;
2776
+ }
2777
+ /**
2778
+ * Activate a plugin (run activate hooks, enable hooks/routes)
2779
+ */
2780
+ async activate(pluginId) {
2781
+ const entry = this.plugins.get(pluginId);
2782
+ if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2783
+ if (entry.state === "active") return [];
2784
+ if (entry.state === "registered") await this.install(pluginId);
2785
+ this.ensureInitialized();
2786
+ const results = await this.hookPipeline.runPluginActivate(pluginId);
2787
+ const failed = results.find((r) => !r.success);
2788
+ if (failed) throw new Error(`Plugin activation failed: ${failed.error?.message ?? "Unknown error"}`);
2789
+ entry.state = "active";
2790
+ await setCronTasksEnabled(this.options.db, pluginId, true);
2791
+ this.reinitialize();
2792
+ await this.resolveExclusiveHooks();
2793
+ return results;
2794
+ }
2795
+ /**
2796
+ * Deactivate a plugin (run deactivate hooks, disable hooks/routes)
2797
+ */
2798
+ async deactivate(pluginId) {
2799
+ const entry = this.plugins.get(pluginId);
2800
+ if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2801
+ if (entry.state !== "active") return [];
2802
+ this.ensureInitialized();
2803
+ const results = await this.hookPipeline.runPluginDeactivate(pluginId);
2804
+ await setCronTasksEnabled(this.options.db, pluginId, false);
2805
+ entry.state = "inactive";
2806
+ this.reinitialize();
2807
+ await this.resolveExclusiveHooks();
2808
+ return results;
2809
+ }
2810
+ /**
2811
+ * Uninstall a plugin (run uninstall hooks, optionally delete data)
2812
+ */
2813
+ async uninstall(pluginId, deleteData = false) {
2814
+ const entry = this.plugins.get(pluginId);
2815
+ if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2816
+ if (entry.state === "active") await this.deactivate(pluginId);
2817
+ this.ensureInitialized();
2818
+ const results = await this.hookPipeline.runPluginUninstall(pluginId, deleteData);
2819
+ await this.deleteCronTasks(pluginId);
2820
+ this.plugins.delete(pluginId);
2821
+ this.initialized = false;
2822
+ await this.resolveExclusiveHooks();
2823
+ return results;
2824
+ }
2825
+ /**
2826
+ * Run content:beforeSave hooks across all active plugins
2827
+ */
2828
+ async runContentBeforeSave(content, collection, isNew, id, actor, details) {
2829
+ this.ensureInitialized();
2830
+ return this.hookPipeline.runContentBeforeSave(content, collection, isNew, id, actor, details);
2831
+ }
2832
+ /**
2833
+ * Run content:afterSave hooks across all active plugins
2834
+ */
2835
+ async runContentAfterSave(content, collection, isNew, actor, details) {
2836
+ this.ensureInitialized();
2837
+ return this.hookPipeline.runContentAfterSave(content, collection, isNew, actor, void 0, details);
2838
+ }
2839
+ /**
2840
+ * Run content:beforeDelete hooks across all active plugins
2841
+ */
2842
+ async runContentBeforeDelete(id, collection) {
2843
+ this.ensureInitialized();
2844
+ return this.hookPipeline.runContentBeforeDelete(id, collection);
2845
+ }
2846
+ /**
2847
+ * Run content:afterDelete hooks across all active plugins
2848
+ */
2849
+ async runContentAfterDelete(id, collection, permanent) {
2850
+ this.ensureInitialized();
2851
+ return this.hookPipeline.runContentAfterDelete(id, collection, permanent);
2852
+ }
2853
+ /**
2854
+ * Run content:afterPublish hooks across all active plugins
2855
+ */
2856
+ async runContentAfterPublish(content, collection) {
2857
+ this.ensureInitialized();
2858
+ return this.hookPipeline.runContentAfterPublish(content, collection);
2859
+ }
2860
+ /**
2861
+ * Run content:afterUnpublish hooks across all active plugins
2862
+ */
2863
+ async runContentAfterUnpublish(content, collection) {
2864
+ this.ensureInitialized();
2865
+ return this.hookPipeline.runContentAfterUnpublish(content, collection);
2866
+ }
2867
+ /**
2868
+ * Run content:afterRestore hooks across all active plugins
2869
+ */
2870
+ async runContentAfterRestore(content, collection) {
2871
+ this.ensureInitialized();
2872
+ return this.hookPipeline.runContentAfterRestore(content, collection);
2873
+ }
2874
+ /**
2875
+ * Run content:afterSchedule hooks across all active plugins
2876
+ */
2877
+ async runContentAfterSchedule(content, collection) {
2878
+ this.ensureInitialized();
2879
+ return this.hookPipeline.runContentAfterSchedule(content, collection);
2880
+ }
2881
+ /**
2882
+ * Run content:afterUnschedule hooks across all active plugins
2883
+ */
2884
+ async runContentAfterUnschedule(content, collection) {
2885
+ this.ensureInitialized();
2886
+ return this.hookPipeline.runContentAfterUnschedule(content, collection);
2887
+ }
2888
+ /**
2889
+ * Run media:beforeUpload hooks across all active plugins
2890
+ */
2891
+ async runMediaBeforeUpload(file) {
2892
+ this.ensureInitialized();
2893
+ return this.hookPipeline.runMediaBeforeUpload(file);
2894
+ }
2895
+ /**
2896
+ * Run media:afterUpload hooks across all active plugins
2897
+ */
2898
+ async runMediaAfterUpload(media) {
2899
+ this.ensureInitialized();
2900
+ return this.hookPipeline.runMediaAfterUpload(media);
2901
+ }
2902
+ /**
2903
+ * Invoke the cron hook for a specific plugin (per-plugin dispatch).
2904
+ * Used as the InvokeCronHookFn callback for CronExecutor.
2905
+ */
2906
+ async invokeCronHook(pluginId, event) {
2907
+ this.ensureInitialized();
2908
+ const result = await this.hookPipeline.invokeCronHook(pluginId, event);
2909
+ if (!result.success && result.error) throw result.error;
2910
+ }
2911
+ /**
2912
+ * Invoke a plugin route
2913
+ */
2914
+ async invokeRoute(pluginId, routeName, options) {
2915
+ this.ensureInitialized();
2916
+ return this.routeRegistry.invoke(pluginId, routeName, options);
2917
+ }
2918
+ /**
2919
+ * Get all routes for a plugin
2920
+ */
2921
+ getPluginRoutes(pluginId) {
2922
+ this.ensureInitialized();
2923
+ return this.routeRegistry.getRoutes(pluginId);
2924
+ }
2925
+ /**
2926
+ * Get a plugin by ID
2927
+ */
2928
+ getPlugin(pluginId) {
2929
+ return this.plugins.get(pluginId)?.plugin;
2930
+ }
2931
+ /**
2932
+ * Get plugin state
2933
+ */
2934
+ getPluginState(pluginId) {
2935
+ return this.plugins.get(pluginId)?.state;
2936
+ }
2937
+ /**
2938
+ * Get all registered plugins
2939
+ */
2940
+ getAllPlugins() {
2941
+ return Array.from(this.plugins.values(), (entry) => ({
2942
+ plugin: entry.plugin,
2943
+ state: entry.state
2944
+ }));
2945
+ }
2946
+ /**
2947
+ * Get all active plugins
2948
+ */
2949
+ getActivePlugins() {
2950
+ return [...this.plugins.values()].filter((entry) => entry.state === "active").map((entry) => entry.plugin);
2951
+ }
2952
+ /**
2953
+ * Check if a plugin exists
2954
+ */
2955
+ hasPlugin(pluginId) {
2956
+ return this.plugins.has(pluginId);
2957
+ }
2958
+ /**
2959
+ * Check if a plugin is active
2960
+ */
2961
+ isActive(pluginId) {
2962
+ return this.plugins.get(pluginId)?.state === "active";
2963
+ }
2964
+ /**
2965
+ * Get all plugins that registered a handler for an exclusive hook.
2966
+ */
2967
+ getExclusiveHookProviders(hookName) {
2968
+ this.ensureInitialized();
2969
+ return this.hookPipeline.getExclusiveHookProviders(hookName).map((p) => {
2970
+ const plugin = this.plugins.get(p.pluginId);
2971
+ return {
2972
+ pluginId: p.pluginId,
2973
+ pluginName: plugin?.plugin.id ?? p.pluginId
2974
+ };
2975
+ });
2976
+ }
2977
+ /**
2978
+ * Read the selected provider for an exclusive hook from the options table.
2979
+ */
2980
+ async getExclusiveHookSelection(hookName) {
2981
+ return new OptionsRepository(this.options.db).get(`${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`);
2982
+ }
2983
+ /**
2984
+ * Set the selected provider for an exclusive hook in the options table.
2985
+ * Pass null to clear the selection.
2986
+ */
2987
+ async setExclusiveHookSelection(hookName, pluginId) {
2988
+ const optionsRepo = new OptionsRepository(this.options.db);
2989
+ const key = `${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`;
2990
+ if (pluginId === null) {
2991
+ await optionsRepo.delete(key);
2992
+ this.hookPipeline?.clearExclusiveSelection(hookName);
2993
+ return;
2994
+ }
2995
+ const entry = this.plugins.get(pluginId);
2996
+ if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2997
+ if (entry.state !== "active") throw new Error(`Plugin "${pluginId}" is not active`);
2998
+ await optionsRepo.set(key, pluginId);
2999
+ this.hookPipeline?.setExclusiveSelection(hookName, pluginId);
3000
+ }
3001
+ /**
3002
+ * Resolution algorithm for exclusive hooks.
3003
+ *
3004
+ * Delegates to the shared resolveExclusiveHooks() function.
3005
+ * See hooks.ts for the full algorithm description.
3006
+ */
3007
+ async resolveExclusiveHooks(preferredHints) {
3008
+ this.ensureInitialized();
3009
+ const optionsRepo = new OptionsRepository(this.options.db);
3010
+ await resolveExclusiveHooks({
3011
+ pipeline: this.hookPipeline,
3012
+ isActive: (pluginId) => this.isActive(pluginId),
3013
+ getOption: (key) => optionsRepo.get(key),
3014
+ getOptions: (keys) => optionsRepo.getMany(keys),
3015
+ setOption: (key, value) => optionsRepo.set(key, value),
3016
+ deleteOption: async (key) => {
3017
+ await optionsRepo.delete(key);
3018
+ },
3019
+ preferredHints
3020
+ });
3021
+ }
3022
+ /**
3023
+ * Get all exclusive hooks with their providers and current selections.
3024
+ * Used by the admin API.
3025
+ */
3026
+ async getExclusiveHooksInfo() {
3027
+ this.ensureInitialized();
3028
+ const exclusiveHookNames = this.hookPipeline.getRegisteredExclusiveHooks();
3029
+ const result = [];
3030
+ for (const hookName of exclusiveHookNames) {
3031
+ const providers = this.hookPipeline.getExclusiveHookProviders(hookName);
3032
+ const selection = await this.getExclusiveHookSelection(hookName);
3033
+ result.push({
3034
+ hookName,
3035
+ providers,
3036
+ selectedPluginId: selection
3037
+ });
3038
+ }
3039
+ return result;
3040
+ }
3041
+ /**
3042
+ * Initialize or reinitialize the hook pipeline and route registry
3043
+ */
3044
+ ensureInitialized() {
3045
+ if (this.initialized) return;
3046
+ const activePlugins = this.getActivePlugins();
3047
+ this.hookPipeline = new HookPipeline(activePlugins, this.factoryOptions);
3048
+ this.routeRegistry = new PluginRouteRegistry(this.factoryOptions);
3049
+ for (const plugin of activePlugins) this.routeRegistry.register(plugin);
3050
+ this.initialized = true;
3051
+ }
3052
+ /**
3053
+ * Force reinitialization (useful after plugin state changes)
3054
+ */
3055
+ reinitialize() {
3056
+ this.initialized = false;
3057
+ this.ensureInitialized();
3058
+ }
3059
+ /**
3060
+ * Delete all cron tasks for a plugin.
3061
+ * Used during uninstall.
3062
+ */
3063
+ async deleteCronTasks(pluginId) {
3064
+ try {
3065
+ await sql`
3066
+ DELETE FROM _emdash_cron_tasks
3067
+ WHERE plugin_id = ${pluginId}
3068
+ `.execute(this.options.db);
3069
+ } catch {}
3070
+ }
3071
+ };
3072
+ /**
3073
+ * Create a plugin manager
3074
+ */
3075
+ function createPluginManager(options) {
3076
+ return new PluginManager(options);
3077
+ }
3078
+
3079
+ //#endregion
3080
+ //#region src/plugins/scheduler/node.ts
3081
+ /** Minimum polling interval (ms) — prevents tight loops if next_run_at is in the past */
3082
+ const MIN_INTERVAL_MS = 1e3;
3083
+ /**
3084
+ * Maximum polling interval (ms). Each wake runs the maintenance pass — stale
3085
+ * lock recovery *and* the scheduled-publishing sweep + system cleanup. The cap
3086
+ * is the worst-case latency for scheduled content when no plugin cron task is
3087
+ * due sooner (`getNextDueTime()` only knows about cron tasks, not content
3088
+ * `scheduled_at`). Held at 60s so Node publish latency matches the Cloudflare
3089
+ * Cron Trigger cadence (`* * * * *`) rather than lagging up to five minutes.
3090
+ */
3091
+ const MAX_INTERVAL_MS = 60 * 1e3;
3092
+ var NodeCronScheduler = class {
3093
+ timer = null;
3094
+ running = false;
3095
+ systemCleanup = null;
3096
+ constructor(executor) {
3097
+ this.executor = executor;
3098
+ }
3099
+ setSystemCleanup(fn) {
3100
+ this.systemCleanup = fn;
3101
+ }
3102
+ start() {
3103
+ this.running = true;
3104
+ this.arm();
3105
+ }
3106
+ stop() {
3107
+ this.running = false;
3108
+ if (this.timer) {
3109
+ clearTimeout(this.timer);
3110
+ this.timer = null;
3111
+ }
3112
+ }
3113
+ reschedule() {
3114
+ if (!this.running) return;
3115
+ if (this.timer) {
3116
+ clearTimeout(this.timer);
3117
+ this.timer = null;
3118
+ }
3119
+ this.arm();
3120
+ }
3121
+ arm() {
3122
+ if (!this.running) return;
3123
+ this.executor.getNextDueTime().then((nextDue) => {
3124
+ if (!this.running) return void 0;
3125
+ let delayMs;
3126
+ if (nextDue) {
3127
+ const dueAt = new Date(nextDue).getTime();
3128
+ delayMs = Math.max(dueAt - Date.now(), MIN_INTERVAL_MS);
3129
+ delayMs = Math.min(delayMs, MAX_INTERVAL_MS);
3130
+ } else delayMs = MAX_INTERVAL_MS;
3131
+ this.timer = setTimeout(() => {
3132
+ if (!this.running) return;
3133
+ this.executeTick();
3134
+ }, delayMs);
3135
+ if (this.timer && typeof this.timer === "object" && "unref" in this.timer) this.timer.unref();
3136
+ }).catch((error) => {
3137
+ console.error("[cron:node] Failed to get next due time:", error);
3138
+ if (this.running) {
3139
+ this.timer = setTimeout(() => this.arm(), MAX_INTERVAL_MS);
3140
+ if (this.timer && typeof this.timer === "object" && "unref" in this.timer) this.timer.unref();
3141
+ }
3142
+ });
3143
+ }
3144
+ executeTick() {
3145
+ if (!this.running) return;
3146
+ const tasks = [this.executor.tick(), this.executor.recoverStaleLocks()];
3147
+ if (this.systemCleanup) tasks.push(this.systemCleanup());
3148
+ Promise.allSettled(tasks).then((results) => {
3149
+ for (const r of results) if (r.status === "rejected") console.error("[cron:node] Tick task failed:", r.reason);
3150
+ }).finally(() => {
3151
+ if (this.running) this.arm();
3152
+ });
3153
+ }
3154
+ };
3155
+
3156
+ //#endregion
3157
+ //#region src/plugins/sandbox/noop.ts
3158
+ /**
3159
+ * Error thrown when attempting to use sandboxing on an unsupported platform.
3160
+ */
3161
+ var SandboxNotAvailableError = class extends Error {
3162
+ constructor() {
3163
+ super("Plugin sandboxing is not available. Configure a sandbox runner: use @emdash-cms/cloudflare/sandbox on Cloudflare, or @emdash-cms/sandbox-workerd/sandbox on Node.js (requires workerd). Without sandboxing, use trusted plugins (from config) instead.");
3164
+ this.name = "SandboxNotAvailableError";
3165
+ }
3166
+ };
3167
+ /**
3168
+ * No-op sandbox runner for platforms without isolation support.
3169
+ *
3170
+ * - `isAvailable()` returns false
3171
+ * - `load()` throws SandboxNotAvailableError
3172
+ * - `terminateAll()` is a no-op
3173
+ *
3174
+ * This is the default runner when no platform adapter is configured.
3175
+ */
3176
+ var NoopSandboxRunner = class {
3177
+ /**
3178
+ * Always returns false - sandboxing is not available.
3179
+ */
3180
+ isAvailable() {
3181
+ return false;
3182
+ }
3183
+ /**
3184
+ * Always returns false - no sandbox runtime to be healthy.
3185
+ */
3186
+ isHealthy() {
3187
+ return false;
3188
+ }
3189
+ /**
3190
+ * Always throws - can't load sandboxed plugins without isolation.
3191
+ */
3192
+ async load(_manifest, _code) {
3193
+ throw new SandboxNotAvailableError();
3194
+ }
3195
+ /**
3196
+ * No-op - sandboxing not available, email callback is irrelevant.
3197
+ */
3198
+ setEmailSend() {}
3199
+ /**
3200
+ * No-op - nothing to terminate.
3201
+ */
3202
+ async terminateAll() {}
3203
+ };
3204
+ /**
3205
+ * Create a no-op sandbox runner.
3206
+ * This is used as the default when no platform adapter is configured.
3207
+ */
3208
+ function createNoopSandboxRunner(_options) {
3209
+ return new NoopSandboxRunner();
3210
+ }
3211
+
3212
+ //#endregion
3213
+ //#region src/plugins/sandbox/hook-result.ts
3214
+ /** Current wire-format version for sandbox hook result envelopes. */
3215
+ const SANDBOX_HOOK_RESULT_VERSION = 1;
3216
+ /** Maximum editor-facing rejection reason accepted from a sandboxed plugin. */
3217
+ const MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH = 500;
3218
+ function isRecord(value) {
3219
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3220
+ }
3221
+ /** Validate and normalize an untrusted value returned across the sandbox boundary. */
3222
+ function inspectSandboxHookResult(value) {
3223
+ if (!isRecord(value) || !Object.hasOwn(value, "__emdashSandboxHookResult")) return { kind: "value" };
3224
+ if (value.__emdashSandboxHookResult !== true || value.version !== SANDBOX_HOOK_RESULT_VERSION || !isRecord(value.error) || value.error.code !== "SAVE_REJECTED" || typeof value.error.reason !== "string") return { kind: "malformed" };
3225
+ const reason = value.error.reason.trim();
3226
+ if (reason.length === 0 || reason.length > MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH) return { kind: "malformed" };
3227
+ return {
3228
+ kind: "error",
3229
+ error: {
3230
+ code: "SAVE_REJECTED",
3231
+ reason
3232
+ }
3233
+ };
3234
+ }
3235
+
3236
+ //#endregion
3237
+ //#region src/comments/ranking.ts
3238
+ /**
3239
+ * Comment ranking utilities (Tier 1 of the best-in-class comments RFC).
3240
+ *
3241
+ * Wilson score lower-bound (95% confidence) — the same primitive Reddit uses
3242
+ * for its "Best" comment sort. Ranks by the statistical lower bound of the
3243
+ * positive-reaction proportion rather than the raw count, so a comment with a
3244
+ * couple of reactions can't outrank a heavily-reacted one until it earns
3245
+ * confidence, and a late-but-popular comment still rises (submission time is
3246
+ * irrelevant).
3247
+ *
3248
+ * Positive-only reactions (the recommended default) degrade gracefully: with
3249
+ * `down = 0` the score still increases monotonically with `up` while penalising
3250
+ * low-sample comments — wilson(1,0) ≈ 0.21, wilson(10,0) ≈ 0.73,
3251
+ * wilson(200,0) ≈ 0.98.
3252
+ */
3253
+ /** z for a 95% two-sided confidence interval. */
3254
+ const DEFAULT_Z = 1.96;
3255
+ /** Reactions that count against a comment when both signals are in use. */
3256
+ const NEGATIVE_REACTIONS = new Set(["dislike", "down"]);
3257
+ /**
3258
+ * Wilson score lower bound of the positive proportion.
3259
+ *
3260
+ * @param up count of positive reactions
3261
+ * @param down count of negative reactions
3262
+ * @returns a score in [0, 1]; 0 when there are no reactions
3263
+ */
3264
+ function wilsonLowerBound(up, down, z = DEFAULT_Z) {
3265
+ const n = up + down;
3266
+ if (n <= 0) return 0;
3267
+ const phat = up / n;
3268
+ const z2 = z * z;
3269
+ const denom = 1 + z2 / n;
3270
+ return (phat + z2 / (2 * n) - z * Math.sqrt((phat * (1 - phat) + z2 / (4 * n)) / n)) / denom;
3271
+ }
3272
+ /**
3273
+ * Reduce a per-reaction count map to a single rank score via the Wilson
3274
+ * lower bound. Any reaction not in {@link NEGATIVE_REACTIONS} is treated as
3275
+ * positive, so the positive-only default (just `like`) works without special
3276
+ * casing.
3277
+ */
3278
+ function reactionScore(counts) {
3279
+ let up = 0;
3280
+ let down = 0;
3281
+ for (const [reaction, count] of Object.entries(counts)) if (NEGATIVE_REACTIONS.has(reaction)) down += count;
3282
+ else up += count;
3283
+ return wilsonLowerBound(up, down);
3284
+ }
3285
+
3286
+ //#endregion
3287
+ //#region src/comments/query.ts
3288
+ /**
3289
+ * Get approved comments for a content item.
3290
+ *
3291
+ * @example
3292
+ * ```ts
3293
+ * import { getComments } from "emdash";
3294
+ *
3295
+ * const { items, total } = await getComments({
3296
+ * collection: "posts",
3297
+ * contentId: post.id,
3298
+ * threaded: true,
3299
+ * });
3300
+ * ```
3301
+ */
3302
+ async function getComments(options) {
3303
+ const sort = options.sort ?? "oldest";
3304
+ const withReactions = options.reactions || sort === "best";
3305
+ const threaded = options.threaded ? "t" : "f";
3306
+ return cachedQuery({
3307
+ namespace: CacheNamespace.COMMENTS,
3308
+ key: `comments:${options.collection}:${options.contentId}:${threaded}:${withReactions ? "r" : "n"}:${sort}`,
3309
+ load: async () => {
3310
+ return getCommentsWithDb(await getDb(), options);
3311
+ }
3312
+ });
3313
+ }
3314
+ /**
3315
+ * Get approved comments with an explicit db handle.
3316
+ *
3317
+ * @internal Use `getComments()` in templates. This variant is for routes
3318
+ * that already have a database handle.
3319
+ */
3320
+ async function getCommentsWithDb(db, options) {
3321
+ const repo = new CommentRepository(db);
3322
+ const result = await repo.findByContent(options.collection, options.contentId, {
3323
+ status: "approved",
3324
+ limit: 500
3325
+ });
3326
+ const total = result.nextCursor === void 0 ? result.items.length : await repo.countByContent(options.collection, options.contentId, "approved");
3327
+ const items = options.threaded ? CommentRepository.assembleThreads(result.items).map((c) => CommentRepository.toPublicComment(c)) : result.items.map((c) => CommentRepository.toPublicComment(c));
3328
+ if (options.reactions || options.sort === "best") {
3329
+ await attachReactions(db, items);
3330
+ if (options.sort === "best") sortByBest(items);
3331
+ }
3332
+ return {
3333
+ items,
3334
+ total
3335
+ };
3336
+ }
3337
+ /**
3338
+ * Attach aggregate reaction counts to a list of public comments (and their
3339
+ * replies), in a single batched query.
3340
+ */
3341
+ async function attachReactions(db, items) {
3342
+ const ids = [];
3343
+ for (const comment of items) {
3344
+ ids.push(comment.id);
3345
+ if (comment.replies) for (const reply of comment.replies) ids.push(reply.id);
3346
+ }
3347
+ if (ids.length === 0) return;
3348
+ const counts = await new CommentReactionRepository(db).countsForComments(ids);
3349
+ const assign = (comment) => {
3350
+ const reactions = counts.get(comment.id);
3351
+ if (reactions) comment.reactions = reactions;
3352
+ };
3353
+ for (const comment of items) {
3354
+ assign(comment);
3355
+ comment.replies?.forEach(assign);
3356
+ }
3357
+ }
3358
+ /**
3359
+ * Sort top-level comments by Wilson-scored reactions (descending), tie-broken
3360
+ * by oldest-first to keep ordering stable.
3361
+ */
3362
+ function sortByBest(items) {
3363
+ items.sort((a, b) => {
3364
+ const scoreDelta = reactionScore(b.reactions ?? {}) - reactionScore(a.reactions ?? {});
3365
+ if (scoreDelta !== 0) return scoreDelta;
3366
+ if (a.createdAt < b.createdAt) return -1;
3367
+ if (a.createdAt > b.createdAt) return 1;
3368
+ return 0;
3369
+ });
3370
+ }
3371
+ /**
3372
+ * Get the count of approved comments for a content item.
3373
+ *
3374
+ * @example
3375
+ * ```ts
3376
+ * import { getCommentCount } from "emdash";
3377
+ *
3378
+ * const count = await getCommentCount("posts", post.id);
3379
+ * ```
3380
+ */
3381
+ async function getCommentCount(collection, contentId) {
3382
+ return getCommentCountWithDb(await getDb(), collection, contentId);
3383
+ }
3384
+ /**
3385
+ * Get comment count with an explicit db handle.
3386
+ *
3387
+ * @internal Use `getCommentCount()` in templates.
3388
+ */
3389
+ async function getCommentCountWithDb(db, collection, contentId) {
3390
+ return new CommentRepository(db).countByContent(collection, contentId, "approved");
3391
+ }
3392
+
3393
+ //#endregion
3394
+ //#region src/menus/index.ts
3395
+ /** Per isolate: the namespaces each resolved menu was last cached under. */
3396
+ const LAST_RESOLVED_NAMESPACES_KEY = Symbol.for("emdash:menu-resolved-namespaces");
3397
+ const lastResolvedNamespaces = globalThis[LAST_RESOLVED_NAMESPACES_KEY] ?? (() => {
3398
+ const map = /* @__PURE__ */ new Map();
3399
+ globalThis[LAST_RESOLVED_NAMESPACES_KEY] = map;
3400
+ return map;
3401
+ })();
3402
+ /**
3403
+ * Get a menu by name with resolved URLs.
3404
+ *
3405
+ * @example
3406
+ * ```ts
3407
+ * const menu = await getMenu("primary");
3408
+ * const menuEs = await getMenu("primary", { locale: "es" });
3409
+ * ```
3410
+ */
3411
+ async function getMenu(name, options = {}) {
3412
+ const locale = resolveLocale(options.locale);
3413
+ const trailingSlash = options.trailingSlash ?? await getHostTrailingSlash();
3414
+ const key = `${name}:${locale ?? "*"}:${trailingSlash}`;
3415
+ return requestCached(`menu:${key}`, async () => {
3416
+ if (!await isObjectCacheActive()) return getMenuWithDb(name, await getDb(), {
3417
+ locale,
3418
+ trailingSlash
3419
+ });
3420
+ const readRows = async () => {
3421
+ let epoch;
3422
+ return {
3423
+ rows: await cachedQueryWithEpochs({
3424
+ namespace: CacheNamespace.MENUS,
3425
+ key: `rows:${name}:${locale ?? "*"}`,
3426
+ load: async () => loadMenuRows(name, await getDb(), locale),
3427
+ onEpochs: ([menus]) => {
3428
+ epoch = menus;
3429
+ }
3430
+ }),
3431
+ epoch
3432
+ };
3433
+ };
3434
+ const remembered = lastResolvedNamespaces.get(key);
3435
+ const earlyRead = remembered ? void 0 : await readRows();
3436
+ const namespaces = remembered ?? (earlyRead?.rows && resolvedMenuNamespaces(earlyRead.rows.items));
3437
+ if (!namespaces) return null;
3438
+ let resolvedEpoch;
3439
+ let loaded;
3440
+ const menu = await cachedQueryWithEpochs({
3441
+ namespace: namespaces,
3442
+ key,
3443
+ onEpochs: ([menus]) => {
3444
+ resolvedEpoch = menus;
3445
+ },
3446
+ load: async () => {
3447
+ const { rows } = earlyRead && earlyRead.epoch === resolvedEpoch ? earlyRead : await readRows();
3448
+ if (!rows) return null;
3449
+ loaded = resolvedMenuNamespaces(rows.items);
3450
+ return resolveMenu(rows, await getDb(), trailingSlash);
3451
+ },
3452
+ cacheable: (value) => value !== null && sameNamespaces(loaded, namespaces)
3453
+ });
3454
+ if (menu) lastResolvedNamespaces.set(key, loaded ?? namespaces);
3455
+ else lastResolvedNamespaces.delete(key);
3456
+ return menu;
3457
+ });
3458
+ }
3459
+ /**
3460
+ * Object-cache namespaces for a resolved menu: the menu epoch plus the content
3461
+ * epoch of every collection its items link to, and the taxonomy epoch when it
3462
+ * links to terms. Which links resolve depends on those rows, so publishing,
3463
+ * unpublishing, or trashing a linked entry invalidates the cached menu.
3464
+ */
3465
+ function resolvedMenuNamespaces(items) {
3466
+ const namespaces = [CacheNamespace.MENUS];
3467
+ for (const collection of collectContentReferences(items).keys()) namespaces.push(...contentCacheNamespaces(collection));
3468
+ if (items.some((item) => item.type === "taxonomy" && item.reference_id)) namespaces.push(CacheNamespace.TAXONOMIES);
3469
+ return namespaces;
3470
+ }
3471
+ function sameNamespaces(a, b) {
3472
+ return a !== void 0 && a.length === b.length && a.every((namespace, i) => namespace === b[i]);
3473
+ }
3474
+ async function getHostTrailingSlash() {
3475
+ try {
3476
+ return (await import("virtual:emdash/config")).default?.trailingSlash ?? "ignore";
3477
+ } catch {
3478
+ return "ignore";
3479
+ }
3480
+ }
3481
+ /**
3482
+ * Get menu by name with resolved URLs (with explicit db). Internal helper for
3483
+ * admin routes that already have a database handle.
3484
+ */
3485
+ async function getMenuWithDb(name, db, options = {}) {
3486
+ const rows = await loadMenuRows(name, db, options.locale);
3487
+ return rows && resolveMenu(rows, db, options.trailingSlash);
3488
+ }
3489
+ async function loadMenuRows(name, db, requestedLocale) {
3490
+ const chain = resolveLocaleChain(requestedLocale);
3491
+ let query = db.selectFrom("_emdash_menus as m").leftJoin("_emdash_menu_items as i", "i.menu_id", "m.id").selectAll("i").select([
3492
+ "m.id as m_id",
3493
+ "m.name as m_name",
3494
+ "m.label as m_label",
3495
+ "m.locale as m_locale",
3496
+ "m.translation_group as m_translation_group"
3497
+ ]).where("m.name", "=", name).orderBy("i.sort_order", "asc");
3498
+ if (chain.length > 0) query = query.where((eb) => eb.or(chain.map((locale) => localeMatches("m.locale", locale))));
3499
+ const rows = await query.execute();
3500
+ const menuRow = rows.toSorted((a, b) => {
3501
+ if (chain.length === 0) return a.m_locale.localeCompare(b.m_locale) || a.m_id.localeCompare(b.m_id);
3502
+ return getLocaleChainRank(a.m_locale, chain) - getLocaleChainRank(b.m_locale, chain) || a.m_id.localeCompare(b.m_id);
3503
+ })[0];
3504
+ if (!menuRow) return null;
3505
+ const menuId = menuRow.m_id;
3506
+ const itemRows = rows.filter((row) => row.m_id === menuId && row.id !== null);
3507
+ return {
3508
+ menu: {
3509
+ id: menuRow.m_id,
3510
+ name: menuRow.m_name,
3511
+ label: menuRow.m_label,
3512
+ locale: menuRow.m_locale,
3513
+ translationGroup: menuRow.m_translation_group
3514
+ },
3515
+ items: itemRows
3516
+ };
3517
+ }
3518
+ async function resolveMenu(rows, db, trailingSlash) {
3519
+ return {
3520
+ ...rows.menu,
3521
+ items: await buildMenuTree(rows.items, db, rows.menu.locale, trailingSlash)
3522
+ };
3523
+ }
3524
+ /**
3525
+ * Get all menus (without items, locale-filtered — for admin list / site nav
3526
+ * summaries). When no locale is configured, returns menus across all locales.
3527
+ */
3528
+ async function getMenus(options = {}) {
3529
+ return getMenusWithDb(await getDb(), options);
3530
+ }
3531
+ /**
3532
+ * Get all menus (with explicit db)
3533
+ *
3534
+ * @internal Use `getMenus()` in templates. This variant is for admin routes
3535
+ * that already have a database handle.
3536
+ */
3537
+ async function getMenusWithDb(db, options = {}) {
3538
+ const locale = resolveLocale(options.locale);
3539
+ let query = db.selectFrom("_emdash_menus").select([
3540
+ "id",
3541
+ "name",
3542
+ "label",
3543
+ "locale"
3544
+ ]).orderBy("name", "asc");
3545
+ if (locale !== void 0) query = query.where(localeMatches("locale", locale));
3546
+ return query.execute();
3547
+ }
3548
+ /**
3549
+ * Get a menu by name with a Workers edge-cache hint.
3550
+ *
3551
+ * Use the returned `cacheHint` with `Astro.cache.set()` so pages that render
3552
+ * this menu can be purged automatically when the menu is edited.
3553
+ */
3554
+ async function getMenuWithCacheHint(name, options = {}) {
3555
+ return {
3556
+ data: await getMenu(name, options),
3557
+ cacheHint: { tags: [menuTag(name)] }
3558
+ };
3559
+ }
3560
+ /**
3561
+ * Build a hierarchical menu tree from a flat list of items. Items are
3562
+ * resolved against the given `locale` so references land on the right
3563
+ * per-locale content rows.
3564
+ */
3565
+ async function buildMenuTree(items, db, locale, trailingSlash) {
3566
+ const contentReferences = collectContentReferences(items);
3567
+ const taxonomyReferences = new Set(items.flatMap((item) => item.type === "taxonomy" && item.reference_id ? [item.reference_id] : []));
3568
+ const [urlPatterns, contentLookup, taxonomyLookup] = await Promise.all([
3569
+ contentReferences.size > 0 ? getCollectionUrlPatterns(db, new Set(contentReferences.keys())) : /* @__PURE__ */ new Map(),
3570
+ resolveContentReferences(db, contentReferences, locale),
3571
+ resolveTaxonomyReferences(db, taxonomyReferences, locale)
3572
+ ]);
3573
+ const validItems = (await Promise.all(items.map((item) => resolveMenuItem(item, urlPatterns, contentLookup, taxonomyLookup, locale, trailingSlash)))).filter((item) => item !== null);
3574
+ const itemMap = /* @__PURE__ */ new Map();
3575
+ const rootItems = [];
3576
+ const itemIds = new Set(items.map((item) => item.id));
3577
+ for (const item of validItems) itemMap.set(item.id, {
3578
+ ...item,
3579
+ children: []
3580
+ });
3581
+ for (const item of items) {
3582
+ const menuItem = itemMap.get(item.id);
3583
+ if (!menuItem) continue;
3584
+ if (item.parent_id && itemIds.has(item.parent_id)) itemMap.get(item.parent_id)?.children.push(menuItem);
3585
+ else rootItems.push(menuItem);
3586
+ }
3587
+ return rootItems;
3588
+ }
3589
+ function collectContentReferences(items) {
3590
+ const references = /* @__PURE__ */ new Map();
3591
+ for (const item of items) {
3592
+ const reference = getContentReference(item);
3593
+ if (!reference) continue;
3594
+ let ids = references.get(reference.collection);
3595
+ if (!ids) {
3596
+ ids = /* @__PURE__ */ new Set();
3597
+ references.set(reference.collection, ids);
3598
+ }
3599
+ ids.add(reference.id);
3600
+ }
3601
+ return references;
3602
+ }
3603
+ function getContentReference(item) {
3604
+ if (item.type === "page" || item.type === "post") {
3605
+ if (!item.reference_id) return null;
3606
+ return {
3607
+ collection: item.reference_collection || `${item.type}s`,
3608
+ id: item.reference_id
3609
+ };
3610
+ }
3611
+ if (item.type === "collection") {
3612
+ if (!item.reference_collection || !item.reference_id) return null;
3613
+ return {
3614
+ collection: item.reference_collection,
3615
+ id: item.reference_id
3616
+ };
3617
+ }
3618
+ if (item.type !== "custom" && item.type !== "taxonomy" && item.reference_collection && item.reference_id) return {
3619
+ collection: item.reference_collection,
3620
+ id: item.reference_id
3621
+ };
3622
+ return null;
3623
+ }
3624
+ /**
3625
+ * Look up the `url_pattern` for a set of collection slugs, request-cached so
3626
+ * a page rendering several menus (header, footer, ...) only pays for the
3627
+ * lookup once per distinct slug set. Callers must treat the returned map as
3628
+ * read-only — it is shared across cache hits within the request.
3629
+ */
3630
+ function getCollectionUrlPatterns(db, collectionSlugs) {
3631
+ return requestCached(`menu-collection-patterns:${[...collectionSlugs].toSorted().join(",")}`, async () => {
3632
+ const rows = await db.selectFrom("_emdash_collections").select(["slug", "url_pattern"]).where("slug", "in", [...collectionSlugs]).execute();
3633
+ const urlPatterns = /* @__PURE__ */ new Map();
3634
+ for (const row of rows) urlPatterns.set(row.slug, row.url_pattern);
3635
+ return urlPatterns;
3636
+ });
3637
+ }
3638
+ /**
3639
+ * Resolve a single menu item's URL. `reference_id` is a translation_group
3640
+ * (migration 036 remapped all existing references); we look it up against
3641
+ * the per-locale ec_* row or per-locale taxonomy row.
3642
+ */
3643
+ async function resolveMenuItem(item, urlPatterns, contentLookup, taxonomyLookup, locale, trailingSlash) {
3644
+ let url;
3645
+ switch (item.type) {
3646
+ case "custom":
3647
+ url = item.custom_url || "#";
3648
+ break;
3649
+ case "page":
3650
+ case "post":
3651
+ url = await resolveContentUrl(item.reference_collection || `${item.type}s`, item.reference_id, urlPatterns, contentLookup, locale, trailingSlash);
3652
+ if (url === null) return null;
3653
+ break;
3654
+ case "taxonomy":
3655
+ url = resolveTaxonomyUrl(item.reference_id, taxonomyLookup);
3656
+ if (url === null) return null;
3657
+ break;
3658
+ case "collection":
3659
+ if (!item.reference_collection) return null;
3660
+ if (item.reference_id) {
3661
+ url = await resolveContentUrl(item.reference_collection, item.reference_id, urlPatterns, contentLookup, locale, trailingSlash);
3662
+ if (url === null) return null;
3663
+ } else url = `/${item.reference_collection}/`;
3664
+ break;
3665
+ default: if (item.reference_collection && item.reference_id) {
3666
+ url = await resolveContentUrl(item.reference_collection, item.reference_id, urlPatterns, contentLookup, locale, trailingSlash);
3667
+ if (url === null) return null;
3668
+ } else url = "#";
3669
+ }
3670
+ return {
3671
+ id: item.id,
3672
+ label: item.label,
3673
+ url: sanitizeHref(url),
3674
+ target: item.target || void 0,
3675
+ titleAttr: item.title_attr || void 0,
3676
+ cssClasses: item.css_classes || void 0,
3677
+ children: []
3678
+ };
3679
+ }
3680
+ async function resolveContentReferences(db, references, locale) {
3681
+ const editMode = getRequestContext()?.editMode === true;
3682
+ const isVisible = (row) => row.deleted_at === null && (editMode || row.status === "published");
3683
+ const entries = await Promise.all(Array.from(references, async ([collection, referenceGroups]) => {
3684
+ const lookup = /* @__PURE__ */ new Map();
3685
+ const localized = /* @__PURE__ */ new Map();
3686
+ const found = /* @__PURE__ */ new Set();
3687
+ try {
3688
+ validateIdentifier(collection, "menu item collection");
3689
+ for (const batch of chunks([...referenceGroups], SQL_BATCH_SIZE)) {
3690
+ const result = await sql`
3691
+ SELECT id, slug, published_at, locale, translation_group, status, deleted_at
3692
+ FROM ${sql.ref(`ec_${collection}`)}
3693
+ WHERE translation_group IN (${sql.join(batch)})
3694
+ `.execute(db);
3695
+ for (const row of result.rows) {
3696
+ found.add(row.translation_group);
3697
+ if (!isVisible(row)) continue;
3698
+ if (shouldPreferLocalizedRow(row, localized.get(row.translation_group), locale)) localized.set(row.translation_group, row);
3699
+ }
3700
+ }
3701
+ for (const [referenceGroup, row] of localized) lookup.set(referenceGroup, {
3702
+ id: row.id,
3703
+ slug: row.slug,
3704
+ publishedAt: row.published_at
3705
+ });
3706
+ const unresolved = [...referenceGroups].filter((id) => !found.has(id));
3707
+ for (const batch of chunks(unresolved, SQL_BATCH_SIZE)) {
3708
+ const result = await sql`
3709
+ SELECT id, slug, published_at, status, deleted_at FROM ${sql.ref(`ec_${collection}`)}
3710
+ WHERE id IN (${sql.join(batch)})
3711
+ `.execute(db);
3712
+ for (const row of result.rows) {
3713
+ if (!isVisible(row)) continue;
3714
+ lookup.set(row.id, {
3715
+ id: row.id,
3716
+ slug: row.slug,
3717
+ publishedAt: row.published_at
3718
+ });
3719
+ }
3720
+ }
3721
+ } catch (error) {
3722
+ console.error(`Failed to resolve content URLs for ${collection}:`, error);
3723
+ }
3724
+ return [collection, lookup];
3725
+ }));
3726
+ return new Map(entries);
3727
+ }
3728
+ function shouldPreferLocalizedRow(candidate, existing, locale) {
3729
+ if (!existing) return true;
3730
+ const candidateRank = getLocaleRank(candidate.locale, locale);
3731
+ const existingRank = getLocaleRank(existing.locale, locale);
3732
+ return candidateRank < existingRank || candidateRank === existingRank && (candidate.locale < existing.locale || candidate.locale === existing.locale && candidate.id < existing.id);
3733
+ }
3734
+ /**
3735
+ * Resolve the URL for a content reference. `referenceGroup` is the content
3736
+ * row's translation_group; we look up the row in the requested locale
3737
+ * (falling back to the source if no translation exists so the menu link is
3738
+ * still clickable).
3739
+ */
3740
+ async function resolveContentUrl(collection, referenceGroup, urlPatterns, contentLookup, locale, trailingSlash) {
3741
+ if (!referenceGroup) return null;
3742
+ const row = contentLookup.get(collection)?.get(referenceGroup);
3743
+ if (!row) return null;
3744
+ return resolveLocalizedContentRoutePath({
3745
+ pattern: urlPatterns.get(collection) ?? null,
3746
+ collection,
3747
+ slug: row.slug,
3748
+ id: row.id,
3749
+ date: row.publishedAt,
3750
+ locale,
3751
+ trailingSlash
3752
+ });
3753
+ }
3754
+ async function resolveTaxonomyReferences(db, referenceGroups, locale) {
3755
+ const lookup = /* @__PURE__ */ new Map();
3756
+ const localized = /* @__PURE__ */ new Map();
3757
+ try {
3758
+ for (const batch of chunks([...referenceGroups], SQL_BATCH_SIZE)) {
3759
+ const rows = await db.selectFrom("taxonomies").select([
3760
+ "id",
3761
+ "name",
3762
+ "slug",
3763
+ "locale",
3764
+ "translation_group"
3765
+ ]).where("translation_group", "in", batch).$narrowType().execute();
3766
+ for (const row of rows) if (shouldPreferLocalizedRow(row, localized.get(row.translation_group), locale)) localized.set(row.translation_group, row);
3767
+ }
3768
+ for (const [referenceGroup, row] of localized) lookup.set(referenceGroup, {
3769
+ name: row.name,
3770
+ slug: row.slug
3771
+ });
3772
+ const unresolved = [...referenceGroups].filter((id) => !lookup.has(id));
3773
+ for (const batch of chunks(unresolved, SQL_BATCH_SIZE)) {
3774
+ const rows = await db.selectFrom("taxonomies").select([
3775
+ "id",
3776
+ "name",
3777
+ "slug"
3778
+ ]).where("id", "in", batch).execute();
3779
+ for (const row of rows) lookup.set(row.id, {
3780
+ name: row.name,
3781
+ slug: row.slug
3782
+ });
3783
+ }
3784
+ } catch (error) {
3785
+ console.error("Failed to resolve taxonomy URLs:", error);
3786
+ }
3787
+ return lookup;
3788
+ }
3789
+ /**
3790
+ * Resolve URL for a taxonomy term reference. `referenceGroup` is the term's
3791
+ * translation_group; we pick the row in the active locale (or fall back).
3792
+ */
3793
+ function resolveTaxonomyUrl(referenceGroup, taxonomyLookup) {
3794
+ if (!referenceGroup) return null;
3795
+ const taxonomy = taxonomyLookup.get(referenceGroup);
3796
+ if (!taxonomy) return null;
3797
+ return `/${taxonomy.name}/${taxonomy.slug}`;
3798
+ }
3799
+
3800
+ //#endregion
3801
+ export { file as A, definePlugin as C, portableTextIdentityExtensions as D, prosemirrorToPortableText as E, EmDashConfigurationError as M, portableText as O, resolveExclusiveHooks as S, portableTextToProsemirror as T, isContentSaveRejection as _, getComments as a, createHookPipeline as b, inspectSandboxHookResult as c, createNoopSandboxRunner as d, NodeCronScheduler as f, ContentSaveRejectedError as g, EmailPipeline as h, getCommentCount as i, image as j, reference as k, NoopSandboxRunner as l, createPluginManager as m, getMenuWithCacheHint as n, MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH as o, PluginManager as p, getMenus as r, SANDBOX_HOOK_RESULT_VERSION as s, getMenu as t, SandboxNotAvailableError as u, EXCLUSIVE_HOOK_KEY_PREFIX$1 as v, definePluginRoute as w, getActiveContentSaveHookName as x, HookPipeline as y };
3802
+ //# sourceMappingURL=menus-oypxT1pI.mjs.map