emdash 1.5.0 → 1.6.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 (1618) hide show
  1. package/dist/action-token-DyXQ5VhB.mjs +26 -0
  2. package/dist/action-token-DyXQ5VhB.mjs.map +1 -0
  3. package/dist/activation-BRmrunZ3.mjs +387 -0
  4. package/dist/activation-BRmrunZ3.mjs.map +1 -0
  5. package/dist/adapters-CMuwJgdX.d.mts +173 -0
  6. package/dist/adapters-CMuwJgdX.d.mts.map +1 -0
  7. package/dist/after-B8cG5P6f.mjs +53 -0
  8. package/dist/after-B8cG5P6f.mjs.map +1 -0
  9. package/dist/allowed-origins-CUNAP6hl.mjs +116 -0
  10. package/dist/allowed-origins-CUNAP6hl.mjs.map +1 -0
  11. package/dist/api/route-utils.d.mts +4 -4
  12. package/dist/api/route-utils.mjs +6 -5
  13. package/dist/api/route-utils.mjs.map +1 -1
  14. package/dist/api/schemas/index.d.mts +2 -2
  15. package/dist/api/schemas/index.mjs +7 -7
  16. package/dist/api-tokens-BIwfh_Ke.mjs +173 -0
  17. package/dist/api-tokens-BIwfh_Ke.mjs.map +1 -0
  18. package/dist/apply-CmE9k57Q.mjs +1774 -0
  19. package/dist/apply-CmE9k57Q.mjs.map +1 -0
  20. package/dist/approvals-DbCK12-7.mjs +460 -0
  21. package/dist/approvals-DbCK12-7.mjs.map +1 -0
  22. package/dist/artifact-fetch-DXHP2vKC.mjs +659 -0
  23. package/dist/artifact-fetch-DXHP2vKC.mjs.map +1 -0
  24. package/dist/artifacts-a_0bb4Ks.mjs +323 -0
  25. package/dist/artifacts-a_0bb4Ks.mjs.map +1 -0
  26. package/dist/astro/image-endpoint.d.mts.map +1 -1
  27. package/dist/astro/image-endpoint.mjs +12 -4
  28. package/dist/astro/image-endpoint.mjs.map +1 -1
  29. package/dist/astro/index.d.mts +17 -17
  30. package/dist/astro/index.d.mts.map +1 -1
  31. package/dist/astro/index.mjs +28 -12
  32. package/dist/astro/index.mjs.map +1 -1
  33. package/dist/astro/middleware/auth.d.mts +17 -15
  34. package/dist/astro/middleware/auth.d.mts.map +1 -1
  35. package/dist/astro/middleware/auth.mjs +31 -20
  36. package/dist/astro/middleware/auth.mjs.map +1 -1
  37. package/dist/astro/middleware/media-usage-write-fence.mjs +2 -2
  38. package/dist/astro/middleware/redirect.d.mts +2 -1
  39. package/dist/astro/middleware/redirect.d.mts.map +1 -1
  40. package/dist/astro/middleware/redirect.mjs +29 -19
  41. package/dist/astro/middleware/redirect.mjs.map +1 -1
  42. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  43. package/dist/astro/middleware/request-context.mjs +6 -5
  44. package/dist/astro/middleware/request-context.mjs.map +1 -1
  45. package/dist/astro/middleware.d.mts +19 -21
  46. package/dist/astro/middleware.d.mts.map +1 -1
  47. package/dist/astro/middleware.mjs +179 -129
  48. package/dist/astro/middleware.mjs.map +1 -1
  49. package/dist/astro/routes/PluginRegistry.d.mts +2 -3
  50. package/dist/astro/routes/PluginRegistry.d.mts.map +1 -1
  51. package/dist/astro/routes/PluginRegistry.mjs +1 -1
  52. package/dist/astro/routes/PluginRegistry.mjs.map +1 -1
  53. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +3 -3
  54. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +3 -3
  55. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +2 -2
  56. package/dist/astro/routes/api/admin/api-tokens/index.mjs +3 -3
  57. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -5
  58. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs.map +1 -1
  59. package/dist/astro/routes/api/admin/byline-fields/_slug_.d.mts.map +1 -1
  60. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +8 -11
  61. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs.map +1 -1
  62. package/dist/astro/routes/api/admin/byline-fields/index.d.mts.map +1 -1
  63. package/dist/astro/routes/api/admin/byline-fields/index.mjs +7 -9
  64. package/dist/astro/routes/api/admin/byline-fields/index.mjs.map +1 -1
  65. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +6 -7
  66. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs.map +1 -1
  67. package/dist/astro/routes/api/admin/bylines/_id_/index.d.mts.map +1 -1
  68. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +9 -10
  69. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  70. package/dist/astro/routes/api/admin/bylines/_id_/translations.d.mts.map +1 -1
  71. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +10 -12
  72. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  73. package/dist/astro/routes/api/admin/bylines/index.mjs +8 -8
  74. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +8 -8
  75. package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
  76. package/dist/astro/routes/api/admin/comments/_id_.d.mts.map +1 -1
  77. package/dist/astro/routes/api/admin/comments/_id_.mjs +7 -8
  78. package/dist/astro/routes/api/admin/comments/_id_.mjs.map +1 -1
  79. package/dist/astro/routes/api/admin/comments/bulk.mjs +9 -9
  80. package/dist/astro/routes/api/admin/comments/bulk.mjs.map +1 -1
  81. package/dist/astro/routes/api/admin/comments/counts.mjs +5 -5
  82. package/dist/astro/routes/api/admin/comments/counts.mjs.map +1 -1
  83. package/dist/astro/routes/api/admin/comments/index.mjs +7 -7
  84. package/dist/astro/routes/api/admin/comments/index.mjs.map +1 -1
  85. package/dist/astro/routes/api/admin/core-update.mjs +6 -6
  86. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +3 -3
  87. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +2 -2
  88. package/dist/astro/routes/api/admin/media-usage/activation.d.mts.map +1 -1
  89. package/dist/astro/routes/api/admin/media-usage/activation.mjs +8 -10
  90. package/dist/astro/routes/api/admin/media-usage/activation.mjs.map +1 -1
  91. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +7 -8
  92. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs.map +1 -1
  93. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +7 -8
  94. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs.map +1 -1
  95. package/dist/astro/routes/api/admin/media-usage/progress.d.mts.map +1 -1
  96. package/dist/astro/routes/api/admin/media-usage/progress.mjs +6 -8
  97. package/dist/astro/routes/api/admin/media-usage/progress.mjs.map +1 -1
  98. package/dist/astro/routes/api/admin/media-usage/repair.mjs +6 -7
  99. package/dist/astro/routes/api/admin/media-usage/repair.mjs.map +1 -1
  100. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +7 -8
  101. package/dist/astro/routes/api/admin/media-usage/work/index.mjs.map +1 -1
  102. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +7 -8
  103. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs.map +1 -1
  104. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +3 -3
  105. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +3 -3
  106. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +4 -4
  107. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +4 -4
  108. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +3 -3
  109. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +4 -4
  110. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +4 -4
  111. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +5 -5
  112. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +9 -8
  113. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  114. package/dist/astro/routes/api/admin/plugins/index.mjs +3 -3
  115. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +3 -3
  116. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +3 -3
  117. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +8 -7
  118. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  119. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +3 -3
  120. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +7 -7
  121. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +14 -13
  122. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  123. package/dist/astro/routes/api/admin/plugins/registry/artifact.d.mts.map +1 -1
  124. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +6 -6
  125. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  126. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +10 -10
  127. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs +4 -4
  128. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +8 -8
  129. package/dist/astro/routes/api/admin/plugins/updates.mjs +7 -7
  130. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +2 -2
  131. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +3 -3
  132. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +3 -3
  133. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +3 -3
  134. package/dist/astro/routes/api/admin/transfer/_...path_.mjs +1 -1
  135. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs +7 -8
  136. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs.map +1 -1
  137. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs +7 -8
  138. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs.map +1 -1
  139. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs +9 -10
  140. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs.map +1 -1
  141. package/dist/astro/routes/api/admin/transfer/capabilities.mjs +9 -10
  142. package/dist/astro/routes/api/admin/transfer/capabilities.mjs.map +1 -1
  143. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs +8 -9
  144. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs.map +1 -1
  145. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs +9 -10
  146. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs.map +1 -1
  147. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs +9 -10
  148. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs.map +1 -1
  149. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs +8 -9
  150. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs.map +1 -1
  151. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs +9 -10
  152. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs.map +1 -1
  153. package/dist/astro/routes/api/admin/transfer/exports/index.d.mts.map +1 -1
  154. package/dist/astro/routes/api/admin/transfer/exports/index.mjs +11 -13
  155. package/dist/astro/routes/api/admin/transfer/exports/index.mjs.map +1 -1
  156. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs +8 -9
  157. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs.map +1 -1
  158. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs +8 -9
  159. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs.map +1 -1
  160. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs +10 -11
  161. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs.map +1 -1
  162. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs +8 -9
  163. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs.map +1 -1
  164. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs +11 -12
  165. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs.map +1 -1
  166. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs +9 -10
  167. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs.map +1 -1
  168. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs +8 -9
  169. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs.map +1 -1
  170. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs +10 -11
  171. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs.map +1 -1
  172. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs +8 -9
  173. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs.map +1 -1
  174. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs +8 -9
  175. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs.map +1 -1
  176. package/dist/astro/routes/api/admin/transfer/imports/index.d.mts.map +1 -1
  177. package/dist/astro/routes/api/admin/transfer/imports/index.mjs +13 -15
  178. package/dist/astro/routes/api/admin/transfer/imports/index.mjs.map +1 -1
  179. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +2 -2
  180. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
  181. package/dist/astro/routes/api/admin/users/_id_/index.mjs +4 -4
  182. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +4 -4
  183. package/dist/astro/routes/api/admin/users/index.mjs +3 -3
  184. package/dist/astro/routes/api/auth/dev-bypass.mjs +2 -2
  185. package/dist/astro/routes/api/auth/handover.mjs +3 -3
  186. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
  187. package/dist/astro/routes/api/auth/invite/complete.d.mts.map +1 -1
  188. package/dist/astro/routes/api/auth/invite/complete.mjs +10 -9
  189. package/dist/astro/routes/api/auth/invite/complete.mjs.map +1 -1
  190. package/dist/astro/routes/api/auth/invite/index.mjs +6 -6
  191. package/dist/astro/routes/api/auth/invite/register-options.mjs +6 -6
  192. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  193. package/dist/astro/routes/api/auth/magic-link/send.mjs +8 -8
  194. package/dist/astro/routes/api/auth/magic-link/verify.d.mts.map +1 -1
  195. package/dist/astro/routes/api/auth/magic-link/verify.mjs +7 -6
  196. package/dist/astro/routes/api/auth/magic-link/verify.mjs.map +1 -1
  197. package/dist/astro/routes/api/auth/me.mjs +4 -4
  198. package/dist/astro/routes/api/auth/mode.mjs +1 -1
  199. package/dist/astro/routes/api/auth/oauth/_provider_/callback.d.mts.map +1 -1
  200. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +6 -5
  201. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs.map +1 -1
  202. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  203. package/dist/astro/routes/api/auth/passkey/_id_.mjs +3 -3
  204. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  205. package/dist/astro/routes/api/auth/passkey/options.mjs +9 -9
  206. package/dist/astro/routes/api/auth/passkey/register/options.mjs +6 -6
  207. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +7 -7
  208. package/dist/astro/routes/api/auth/passkey/verify.d.mts.map +1 -1
  209. package/dist/astro/routes/api/auth/passkey/verify.mjs +10 -9
  210. package/dist/astro/routes/api/auth/passkey/verify.mjs.map +1 -1
  211. package/dist/astro/routes/api/auth/signup/complete.d.mts.map +1 -1
  212. package/dist/astro/routes/api/auth/signup/complete.mjs +10 -9
  213. package/dist/astro/routes/api/auth/signup/complete.mjs.map +1 -1
  214. package/dist/astro/routes/api/auth/signup/register-options.d.mts +8 -0
  215. package/dist/astro/routes/api/auth/signup/register-options.d.mts.map +1 -0
  216. package/dist/astro/routes/api/auth/signup/register-options.mjs +44 -0
  217. package/dist/astro/routes/api/auth/signup/register-options.mjs.map +1 -0
  218. package/dist/astro/routes/api/auth/signup/request.mjs +7 -7
  219. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
  220. package/dist/astro/routes/api/calendar.mjs +4 -4
  221. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.d.mts.map +1 -1
  222. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +6 -7
  223. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
  224. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.d.mts.map +1 -1
  225. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +11 -12
  226. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs.map +1 -1
  227. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  228. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +9 -10
  229. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
  230. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +6 -7
  231. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs.map +1 -1
  232. package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts.map +1 -1
  233. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +15 -15
  234. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs.map +1 -1
  235. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +2 -2
  236. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +2 -2
  237. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +8 -8
  238. package/dist/astro/routes/api/content/_collection_/_id_/publish.d.mts.map +1 -1
  239. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +9 -10
  240. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  241. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +6 -7
  242. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  243. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +6 -7
  244. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  245. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +3 -3
  246. package/dist/astro/routes/api/content/_collection_/_id_/revisions/editors.mjs +2 -2
  247. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +6 -6
  248. package/dist/astro/routes/api/content/_collection_/_id_/room.mjs +4 -4
  249. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +6 -6
  250. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.d.mts.map +1 -1
  251. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +16 -19
  252. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  253. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  254. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +9 -10
  255. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
  256. package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
  257. package/dist/astro/routes/api/content/_collection_/_id_.mjs +19 -19
  258. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  259. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  260. package/dist/astro/routes/api/content/_collection_/index.mjs +5 -5
  261. package/dist/astro/routes/api/content/_collection_/trash.mjs +4 -4
  262. package/dist/astro/routes/api/dashboard.mjs +6 -6
  263. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  264. package/dist/astro/routes/api/dev/scheduled-tasks.mjs +4 -3
  265. package/dist/astro/routes/api/dev/scheduled-tasks.mjs.map +1 -1
  266. package/dist/astro/routes/api/health.mjs +3 -3
  267. package/dist/astro/routes/api/import/probe.d.mts +4 -4
  268. package/dist/astro/routes/api/import/probe.mjs +6 -6
  269. package/dist/astro/routes/api/import/wordpress/analyze.d.mts +3 -3
  270. package/dist/astro/routes/api/import/wordpress/analyze.mjs +3 -3
  271. package/dist/astro/routes/api/import/wordpress/execute.d.mts +16 -16
  272. package/dist/astro/routes/api/import/wordpress/execute.mjs +7 -7
  273. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  274. package/dist/astro/routes/api/import/wordpress/media.d.mts +15 -15
  275. package/dist/astro/routes/api/import/wordpress/media.d.mts.map +1 -1
  276. package/dist/astro/routes/api/import/wordpress/media.mjs +9 -8
  277. package/dist/astro/routes/api/import/wordpress/media.mjs.map +1 -1
  278. package/dist/astro/routes/api/import/wordpress/prepare.mjs +7 -7
  279. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +16 -16
  280. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +6 -6
  281. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  282. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +6 -6
  283. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +16 -16
  284. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +13 -13
  285. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  286. package/dist/astro/routes/api/manifest.mjs +4 -4
  287. package/dist/astro/routes/api/mcp.mjs +84 -77
  288. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  289. package/dist/astro/routes/api/media/_id_/confirm.mjs +7 -7
  290. package/dist/astro/routes/api/media/_id_/replace.d.mts.map +1 -1
  291. package/dist/astro/routes/api/media/_id_/replace.mjs +8 -6
  292. package/dist/astro/routes/api/media/_id_/replace.mjs.map +1 -1
  293. package/dist/astro/routes/api/media/_id_/upload.mjs +5 -5
  294. package/dist/astro/routes/api/media/_id_/usage.mjs +6 -6
  295. package/dist/astro/routes/api/media/_id_.d.mts.map +1 -1
  296. package/dist/astro/routes/api/media/_id_.mjs +11 -8
  297. package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
  298. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +3 -3
  299. package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
  300. package/dist/astro/routes/api/media/file/_...key_.mjs +7 -5
  301. package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
  302. package/dist/astro/routes/api/media/folders/_id_.mjs +5 -5
  303. package/dist/astro/routes/api/media/folders/index.mjs +5 -5
  304. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.d.mts.map +1 -1
  305. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +10 -4
  306. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs.map +1 -1
  307. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  308. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  309. package/dist/astro/routes/api/media/upload-url.mjs +7 -7
  310. package/dist/astro/routes/api/media.mjs +9 -9
  311. package/dist/astro/routes/api/menus/_name_/items/_id_.d.mts.map +1 -1
  312. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +8 -6
  313. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  314. package/dist/astro/routes/api/menus/_name_/items.mjs +7 -6
  315. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  316. package/dist/astro/routes/api/menus/_name_/reorder.mjs +7 -6
  317. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  318. package/dist/astro/routes/api/menus/_name_/translations.d.mts.map +1 -1
  319. package/dist/astro/routes/api/menus/_name_/translations.mjs +7 -9
  320. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  321. package/dist/astro/routes/api/menus/_name_.d.mts.map +1 -1
  322. package/dist/astro/routes/api/menus/_name_.mjs +9 -6
  323. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  324. package/dist/astro/routes/api/menus/index.d.mts.map +1 -1
  325. package/dist/astro/routes/api/menus/index.mjs +8 -6
  326. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  327. package/dist/astro/routes/api/oauth/authorize.mjs +3 -3
  328. package/dist/astro/routes/api/oauth/device/authorize.mjs +3 -3
  329. package/dist/astro/routes/api/oauth/device/code.mjs +6 -6
  330. package/dist/astro/routes/api/oauth/device/token.mjs +5 -5
  331. package/dist/astro/routes/api/oauth/register.mjs +4 -4
  332. package/dist/astro/routes/api/oauth/token/refresh.mjs +3 -3
  333. package/dist/astro/routes/api/oauth/token/revoke.mjs +3 -3
  334. package/dist/astro/routes/api/oauth/token.mjs +4 -4
  335. package/dist/astro/routes/api/openapi.json.mjs +9 -9
  336. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  337. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +2 -2
  338. package/dist/astro/routes/api/redirects/404s/index.d.mts.map +1 -1
  339. package/dist/astro/routes/api/redirects/404s/index.mjs +8 -11
  340. package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
  341. package/dist/astro/routes/api/redirects/404s/summary.mjs +6 -7
  342. package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
  343. package/dist/astro/routes/api/redirects/_id_.d.mts.map +1 -1
  344. package/dist/astro/routes/api/redirects/_id_.mjs +9 -12
  345. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  346. package/dist/astro/routes/api/redirects/index.d.mts.map +1 -1
  347. package/dist/astro/routes/api/redirects/index.mjs +8 -10
  348. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  349. package/dist/astro/routes/api/relations/_id_/index.d.mts.map +1 -1
  350. package/dist/astro/routes/api/relations/_id_/index.mjs +8 -11
  351. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  352. package/dist/astro/routes/api/relations/index.d.mts.map +1 -1
  353. package/dist/astro/routes/api/relations/index.mjs +7 -9
  354. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  355. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  356. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +6 -6
  357. package/dist/astro/routes/api/schema/block-types/_slug_/index.d.mts.map +1 -1
  358. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs +7 -9
  359. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs.map +1 -1
  360. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs +6 -7
  361. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs.map +1 -1
  362. package/dist/astro/routes/api/schema/block-types/index.d.mts.map +1 -1
  363. package/dist/astro/routes/api/schema/block-types/index.mjs +7 -9
  364. package/dist/astro/routes/api/schema/block-types/index.mjs.map +1 -1
  365. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.d.mts.map +1 -1
  366. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +8 -11
  367. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  368. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.d.mts.map +1 -1
  369. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +7 -9
  370. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  371. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +6 -7
  372. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  373. package/dist/astro/routes/api/schema/collections/_slug_/index.d.mts.map +1 -1
  374. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +8 -11
  375. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  376. package/dist/astro/routes/api/schema/collections/index.d.mts.map +1 -1
  377. package/dist/astro/routes/api/schema/collections/index.mjs +7 -9
  378. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  379. package/dist/astro/routes/api/schema/collections/reorder.mjs +6 -7
  380. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  381. package/dist/astro/routes/api/schema/index.mjs +4 -5
  382. package/dist/astro/routes/api/schema/index.mjs.map +1 -1
  383. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +6 -7
  384. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  385. package/dist/astro/routes/api/schema/orphans/index.mjs +4 -5
  386. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  387. package/dist/astro/routes/api/search/enable.d.mts.map +1 -1
  388. package/dist/astro/routes/api/search/enable.mjs +8 -5
  389. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  390. package/dist/astro/routes/api/search/index.d.mts.map +1 -1
  391. package/dist/astro/routes/api/search/index.mjs +7 -4
  392. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  393. package/dist/astro/routes/api/search/rebuild.d.mts.map +1 -1
  394. package/dist/astro/routes/api/search/rebuild.mjs +8 -5
  395. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  396. package/dist/astro/routes/api/search/stats.d.mts.map +1 -1
  397. package/dist/astro/routes/api/search/stats.mjs +6 -3
  398. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  399. package/dist/astro/routes/api/search/suggest.d.mts.map +1 -1
  400. package/dist/astro/routes/api/search/suggest.mjs +7 -4
  401. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  402. package/dist/astro/routes/api/sections/_slug_.d.mts.map +1 -1
  403. package/dist/astro/routes/api/sections/_slug_.mjs +8 -11
  404. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  405. package/dist/astro/routes/api/sections/index.d.mts.map +1 -1
  406. package/dist/astro/routes/api/sections/index.mjs +7 -9
  407. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  408. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +4 -4
  409. package/dist/astro/routes/api/settings/backups/archives/index.mjs +3 -3
  410. package/dist/astro/routes/api/settings/backups/export.mjs +4 -4
  411. package/dist/astro/routes/api/settings/backups/index.mjs +5 -5
  412. package/dist/astro/routes/api/settings/domain-notify.mjs +6 -6
  413. package/dist/astro/routes/api/settings/domain.mjs +6 -6
  414. package/dist/astro/routes/api/settings/email.mjs +5 -5
  415. package/dist/astro/routes/api/settings.mjs +5 -5
  416. package/dist/astro/routes/api/setup/admin-verify.d.mts.map +1 -1
  417. package/dist/astro/routes/api/setup/admin-verify.mjs +12 -11
  418. package/dist/astro/routes/api/setup/admin-verify.mjs.map +1 -1
  419. package/dist/astro/routes/api/setup/admin.mjs +7 -7
  420. package/dist/astro/routes/api/setup/dev-bypass.mjs +8 -8
  421. package/dist/astro/routes/api/setup/dev-reset.mjs +1 -1
  422. package/dist/astro/routes/api/setup/index.mjs +8 -8
  423. package/dist/astro/routes/api/setup/status.mjs +2 -2
  424. package/dist/astro/routes/api/site/domain-proof.mjs +2 -2
  425. package/dist/astro/routes/api/snapshot.mjs +6 -6
  426. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +6 -7
  427. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
  428. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.d.mts.map +1 -1
  429. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +7 -9
  430. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  431. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.d.mts.map +1 -1
  432. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +9 -12
  433. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  434. package/dist/astro/routes/api/taxonomies/_name_/terms/index.d.mts.map +1 -1
  435. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +7 -9
  436. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  437. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +6 -7
  438. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -1
  439. package/dist/astro/routes/api/taxonomies/_name_.d.mts.map +1 -1
  440. package/dist/astro/routes/api/taxonomies/_name_.mjs +9 -12
  441. package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -1
  442. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs +12 -13
  443. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs.map +1 -1
  444. package/dist/astro/routes/api/taxonomies/index.d.mts.map +1 -1
  445. package/dist/astro/routes/api/taxonomies/index.mjs +8 -10
  446. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  447. package/dist/astro/routes/api/themes/preview.mjs +4 -4
  448. package/dist/astro/routes/api/typegen.mjs +3 -3
  449. package/dist/astro/routes/api/visual-editing/action-token.mjs +3 -3
  450. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +3 -3
  451. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +1 -1
  452. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  453. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +1 -1
  454. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +1 -1
  455. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +6 -5
  456. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  457. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.d.mts.map +1 -1
  458. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +8 -6
  459. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  460. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +7 -6
  461. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  462. package/dist/astro/routes/api/widget-areas/_name_.d.mts.map +1 -1
  463. package/dist/astro/routes/api/widget-areas/_name_.mjs +6 -4
  464. package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
  465. package/dist/astro/routes/api/widget-areas/index.d.mts.map +1 -1
  466. package/dist/astro/routes/api/widget-areas/index.mjs +8 -6
  467. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  468. package/dist/astro/routes/api/widget-components.mjs +2 -2
  469. package/dist/astro/routes/robots.txt.mjs +2 -2
  470. package/dist/astro/routes/sitemap-_collection_.xml.mjs +5 -5
  471. package/dist/astro/routes/sitemap.xml.mjs +3 -3
  472. package/dist/astro/types.d.mts +82 -69
  473. package/dist/astro/types.d.mts.map +1 -1
  474. package/dist/auth/providers/github.d.mts +1 -1
  475. package/dist/auth/providers/google.d.mts +1 -1
  476. package/dist/auth/providers/microsoft.d.mts +1 -1
  477. package/dist/authoritative-records-DFHFmreO.mjs +5183 -0
  478. package/dist/authoritative-records-DFHFmreO.mjs.map +1 -0
  479. package/dist/authorize-6a0h5NN5.mjs +74 -0
  480. package/dist/authorize-6a0h5NN5.mjs.map +1 -0
  481. package/dist/backup-GBRxixs1.mjs +246 -0
  482. package/dist/backup-GBRxixs1.mjs.map +1 -0
  483. package/dist/block-types-BeLZ85Sw.mjs +132 -0
  484. package/dist/block-types-BeLZ85Sw.mjs.map +1 -0
  485. package/dist/block-values-BRJZHvF4.mjs +215 -0
  486. package/dist/block-values-BRJZHvF4.mjs.map +1 -0
  487. package/dist/byline-BufjxQyd.mjs +930 -0
  488. package/dist/byline-BufjxQyd.mjs.map +1 -0
  489. package/dist/byline-fields-Bw7z2opJ.mjs +123 -0
  490. package/dist/byline-fields-Bw7z2opJ.mjs.map +1 -0
  491. package/dist/byline-registry-edmv55U7.mjs +406 -0
  492. package/dist/byline-registry-edmv55U7.mjs.map +1 -0
  493. package/dist/bylines-C8ZT6iWw.mjs +234 -0
  494. package/dist/bylines-C8ZT6iWw.mjs.map +1 -0
  495. package/dist/bylines-a01JW9yq.mjs +150 -0
  496. package/dist/bylines-a01JW9yq.mjs.map +1 -0
  497. package/dist/cache-LOb3NthC.mjs +151 -0
  498. package/dist/cache-LOb3NthC.mjs.map +1 -0
  499. package/dist/canonical-CUkatNPc.mjs +174 -0
  500. package/dist/canonical-CUkatNPc.mjs.map +1 -0
  501. package/dist/capture-triggers-BK2pp_kZ.mjs +362 -0
  502. package/dist/capture-triggers-BK2pp_kZ.mjs.map +1 -0
  503. package/dist/checksum-C8lkApUe.mjs +162 -0
  504. package/dist/checksum-C8lkApUe.mjs.map +1 -0
  505. package/dist/chunks-CvgCLYip.mjs +25 -0
  506. package/dist/chunks-CvgCLYip.mjs.map +1 -0
  507. package/dist/cli/index.mjs +24 -24
  508. package/dist/client/cf-access.d.mts +1 -1
  509. package/dist/client/index.d.mts +63 -63
  510. package/dist/client/index.d.mts.map +1 -1
  511. package/dist/client/index.mjs +6 -4
  512. package/dist/client/index.mjs.map +1 -1
  513. package/dist/collection-slugs-cache-CLR_8fY5.mjs +91 -0
  514. package/dist/collection-slugs-cache-CLR_8fY5.mjs.map +1 -0
  515. package/dist/comment-C163Gl_4.mjs +335 -0
  516. package/dist/comment-C163Gl_4.mjs.map +1 -0
  517. package/dist/comment-reaction-1Df3G-ij.mjs +85 -0
  518. package/dist/comment-reaction-1Df3G-ij.mjs.map +1 -0
  519. package/dist/comments-BFyw2y-m.mjs +99 -0
  520. package/dist/comments-BFyw2y-m.mjs.map +1 -0
  521. package/dist/comments-D73Sy_2U.mjs +195 -0
  522. package/dist/comments-D73Sy_2U.mjs.map +1 -0
  523. package/dist/components-DjV1sxUL.mjs +112 -0
  524. package/dist/components-DjV1sxUL.mjs.map +1 -0
  525. package/dist/config-B27hvMjf.d.mts +7274 -0
  526. package/dist/config-B27hvMjf.d.mts.map +1 -0
  527. package/dist/config-DLzKVQBA.d.mts +41 -0
  528. package/dist/config-DLzKVQBA.d.mts.map +1 -0
  529. package/dist/config-DeluGa9H.mjs +228 -0
  530. package/dist/config-DeluGa9H.mjs.map +1 -0
  531. package/dist/connection-D6aKSo2Y.mjs +36 -0
  532. package/dist/connection-D6aKSo2Y.mjs.map +1 -0
  533. package/dist/content-2gjSbGP3.mjs +2295 -0
  534. package/dist/content-2gjSbGP3.mjs.map +1 -0
  535. package/dist/content-list-query-B9SlIDbL.d.mts +26 -0
  536. package/dist/content-list-query-B9SlIDbL.d.mts.map +1 -0
  537. package/dist/content-repair-Dizo4qiY.mjs +443 -0
  538. package/dist/content-repair-Dizo4qiY.mjs.map +1 -0
  539. package/dist/content-save-BKDTKmkx.mjs +202 -0
  540. package/dist/content-save-BKDTKmkx.mjs.map +1 -0
  541. package/dist/context-DCQrjN95.mjs +2242 -0
  542. package/dist/context-DCQrjN95.mjs.map +1 -0
  543. package/dist/credits-Bxp4F72g.mjs +110 -0
  544. package/dist/credits-Bxp4F72g.mjs.map +1 -0
  545. package/dist/cron-DEV8oz3R.mjs +310 -0
  546. package/dist/cron-DEV8oz3R.mjs.map +1 -0
  547. package/dist/db/index.d.mts +3 -3
  548. package/dist/db/index.mjs +1 -1
  549. package/dist/db/libsql-migrations.d.mts +1 -1
  550. package/dist/db/libsql-migrations.mjs +2 -2
  551. package/dist/db/libsql.d.mts +1 -1
  552. package/dist/db/postgres-migrations.d.mts +1 -1
  553. package/dist/db/postgres-migrations.mjs +2 -2
  554. package/dist/db/postgres.d.mts +1 -1
  555. package/dist/db/sqlite-migrations.d.mts +1 -1
  556. package/dist/db/sqlite-migrations.mjs +2 -2
  557. package/dist/db/sqlite.d.mts +1 -1
  558. package/dist/db/sqlite.mjs +1 -1
  559. package/dist/default-DKs7zP7m.mjs +81 -0
  560. package/dist/default-DKs7zP7m.mjs.map +1 -0
  561. package/dist/deferred-tasks-B5LQWb5F.d.mts +10 -0
  562. package/dist/deferred-tasks-B5LQWb5F.d.mts.map +1 -0
  563. package/dist/device-flow-D6kyi3jX.mjs +519 -0
  564. package/dist/device-flow-D6kyi3jX.mjs.map +1 -0
  565. package/dist/dialect-helpers-DRe1Y08G.mjs +355 -0
  566. package/dist/dialect-helpers-DRe1Y08G.mjs.map +1 -0
  567. package/dist/digest-DSsUd9oL.mjs +194 -0
  568. package/dist/digest-DSsUd9oL.mjs.map +1 -0
  569. package/dist/direct-executor-DAcU8MTG.mjs +117 -0
  570. package/dist/direct-executor-DAcU8MTG.mjs.map +1 -0
  571. package/dist/email-console-CBZpj1VI.mjs +50 -0
  572. package/dist/email-console-CBZpj1VI.mjs.map +1 -0
  573. package/dist/email-locale-CGjBa23b.mjs +25 -0
  574. package/dist/email-locale-CGjBa23b.mjs.map +1 -0
  575. package/dist/email-smtp-CE6nESRL.mjs +643 -0
  576. package/dist/email-smtp-CE6nESRL.mjs.map +1 -0
  577. package/dist/emdash-runtime-CF6KAut9.mjs +5576 -0
  578. package/dist/emdash-runtime-CF6KAut9.mjs.map +1 -0
  579. package/dist/enrich-C4vKniyi.mjs +203 -0
  580. package/dist/enrich-C4vKniyi.mjs.map +1 -0
  581. package/dist/entry-lock-DJgDNfMf.mjs +1230 -0
  582. package/dist/entry-lock-DJgDNfMf.mjs.map +1 -0
  583. package/dist/entry-lock-GKD0lJI5.mjs +207 -0
  584. package/dist/entry-lock-GKD0lJI5.mjs.map +1 -0
  585. package/dist/entry-locks-B58Q9LZh.mjs +173 -0
  586. package/dist/entry-locks-B58Q9LZh.mjs.map +1 -0
  587. package/dist/env-types-EL7WTMzr.mjs +38 -0
  588. package/dist/env-types-EL7WTMzr.mjs.map +1 -0
  589. package/dist/error-0Y0dFPxm.mjs +82 -0
  590. package/dist/error-0Y0dFPxm.mjs.map +1 -0
  591. package/dist/errors-OTWh4SC_.mjs +502 -0
  592. package/dist/errors-OTWh4SC_.mjs.map +1 -0
  593. package/dist/errors-u5rZhbVQ.mjs +120 -0
  594. package/dist/errors-u5rZhbVQ.mjs.map +1 -0
  595. package/dist/fence-CkdbSoZX.mjs +162 -0
  596. package/dist/fence-CkdbSoZX.mjs.map +1 -0
  597. package/dist/field-defs-cache-BW0Y9Wrp.mjs +79 -0
  598. package/dist/field-defs-cache-BW0Y9Wrp.mjs.map +1 -0
  599. package/dist/field-map-Bhqs6zUK.mjs +84 -0
  600. package/dist/field-map-Bhqs6zUK.mjs.map +1 -0
  601. package/dist/fts-manager-m8GPxogO.mjs +532 -0
  602. package/dist/fts-manager-m8GPxogO.mjs.map +1 -0
  603. package/dist/gc-CEhfEMLY.mjs +62 -0
  604. package/dist/gc-CEhfEMLY.mjs.map +1 -0
  605. package/dist/hook-result-CG0uHAT5.d.mts +31 -0
  606. package/dist/hook-result-CG0uHAT5.d.mts.map +1 -0
  607. package/dist/hook-result-mOyk-VCt.mjs +3855 -0
  608. package/dist/hook-result-mOyk-VCt.mjs.map +1 -0
  609. package/dist/hreflang-B1E64c5R.d.mts +51 -0
  610. package/dist/hreflang-B1E64c5R.d.mts.map +1 -0
  611. package/dist/hreflang-DaMRoUor.mjs +105 -0
  612. package/dist/hreflang-DaMRoUor.mjs.map +1 -0
  613. package/dist/http-route-dispatch-Y8bwyixm.mjs +348 -0
  614. package/dist/http-route-dispatch-Y8bwyixm.mjs.map +1 -0
  615. package/dist/identity-cqdOzgy9.mjs +35 -0
  616. package/dist/identity-cqdOzgy9.mjs.map +1 -0
  617. package/dist/index-CzbH8FX2.d.mts +261 -0
  618. package/dist/index-CzbH8FX2.d.mts.map +1 -0
  619. package/dist/index.d.mts +25 -25
  620. package/dist/index.mjs +60 -53
  621. package/dist/index.mjs.map +1 -1
  622. package/dist/install-finalization-B02IcpqW.mjs +58 -0
  623. package/dist/install-finalization-B02IcpqW.mjs.map +1 -0
  624. package/dist/json-recordset-2VNAgija.mjs +12 -0
  625. package/dist/json-recordset-2VNAgija.mjs.map +1 -0
  626. package/dist/json-schema-CnImQ4DF.mjs +15 -0
  627. package/dist/json-schema-CnImQ4DF.mjs.map +1 -0
  628. package/dist/keys-B5WUGmYK.mjs +61 -0
  629. package/dist/keys-B5WUGmYK.mjs.map +1 -0
  630. package/dist/kinds-DyAmbNrx.mjs +974 -0
  631. package/dist/kinds-DyAmbNrx.mjs.map +1 -0
  632. package/dist/lifecycle-1Nl01SeB.mjs +53 -0
  633. package/dist/lifecycle-1Nl01SeB.mjs.map +1 -0
  634. package/dist/limits-BuiMu9zx.mjs +44 -0
  635. package/dist/limits-BuiMu9zx.mjs.map +1 -0
  636. package/dist/load-CEt0TQ4_.mjs +36 -0
  637. package/dist/load-CEt0TQ4_.mjs.map +1 -0
  638. package/dist/loader-DF6J1Fpd.mjs +1537 -0
  639. package/dist/loader-DF6J1Fpd.mjs.map +1 -0
  640. package/dist/loops-3DdrfQ6y.mjs +217 -0
  641. package/dist/loops-3DdrfQ6y.mjs.map +1 -0
  642. package/dist/manifest-builder-Dcfqd9Aw.mjs +196 -0
  643. package/dist/manifest-builder-Dcfqd9Aw.mjs.map +1 -0
  644. package/dist/manifest-schema-Pi_JP_Wi.mjs +497 -0
  645. package/dist/manifest-schema-Pi_JP_Wi.mjs.map +1 -0
  646. package/dist/marketplace-BsMC_Z7o.mjs +257 -0
  647. package/dist/marketplace-BsMC_Z7o.mjs.map +1 -0
  648. package/dist/marketplace-D9fChLav.mjs +965 -0
  649. package/dist/marketplace-D9fChLav.mjs.map +1 -0
  650. package/dist/media/image-endpoint.d.mts +33 -1
  651. package/dist/media/image-endpoint.d.mts.map +1 -1
  652. package/dist/media/image-endpoint.mjs +77 -1
  653. package/dist/media/image-endpoint.mjs.map +1 -1
  654. package/dist/media/index.d.mts +1 -1
  655. package/dist/media/index.mjs +1 -1
  656. package/dist/media/local-runtime.d.mts +17 -17
  657. package/dist/media/local-runtime.mjs +3 -3
  658. package/dist/media--P-IEycF.mjs +2813 -0
  659. package/dist/media--P-IEycF.mjs.map +1 -0
  660. package/dist/media-CTA82rU1.mjs +295 -0
  661. package/dist/media-CTA82rU1.mjs.map +1 -0
  662. package/dist/media-Cq_oKN_Y.mjs +425 -0
  663. package/dist/media-Cq_oKN_Y.mjs.map +1 -0
  664. package/dist/media-DRDkfiDv.d.mts +203 -0
  665. package/dist/media-DRDkfiDv.d.mts.map +1 -0
  666. package/dist/media-allowlist-C_kSleFj.mjs +103 -0
  667. package/dist/media-allowlist-C_kSleFj.mjs.map +1 -0
  668. package/dist/media-folders-Lc9Ks8az.mjs +205 -0
  669. package/dist/media-folders-Lc9Ks8az.mjs.map +1 -0
  670. package/dist/media-url-BEvOId4Z.mjs +43 -0
  671. package/dist/media-url-BEvOId4Z.mjs.map +1 -0
  672. package/dist/media-usage-D6LjfdGn.mjs +282 -0
  673. package/dist/media-usage-D6LjfdGn.mjs.map +1 -0
  674. package/dist/media-usage-activation-i6tqb6cn.mjs +78 -0
  675. package/dist/media-usage-activation-i6tqb6cn.mjs.map +1 -0
  676. package/dist/media-usage-work-C5HHgfEU.mjs +1036 -0
  677. package/dist/media-usage-work-C5HHgfEU.mjs.map +1 -0
  678. package/dist/media-usage-work-CxqS_Ny9.mjs +151 -0
  679. package/dist/media-usage-work-CxqS_Ny9.mjs.map +1 -0
  680. package/dist/menu-CvWToneO.mjs +420 -0
  681. package/dist/menu-CvWToneO.mjs.map +1 -0
  682. package/dist/menus-BzjHvAM4.mjs +434 -0
  683. package/dist/menus-BzjHvAM4.mjs.map +1 -0
  684. package/dist/menus-CnEw5nz8.mjs +92 -0
  685. package/dist/menus-CnEw5nz8.mjs.map +1 -0
  686. package/dist/menus-DoVbs2sn.mjs +433 -0
  687. package/dist/menus-DoVbs2sn.mjs.map +1 -0
  688. package/dist/migrations/index.d.mts +1 -1
  689. package/dist/migrations/index.mjs +2 -2
  690. package/dist/mime-C_YV5Mjm.mjs +90 -0
  691. package/dist/mime-C_YV5Mjm.mjs.map +1 -0
  692. package/dist/node-sqlite-compat-DHFDZMe2.mjs +68 -0
  693. package/dist/node-sqlite-compat-DHFDZMe2.mjs.map +1 -0
  694. package/dist/oauth-authorization-CvT-8KtG.mjs +287 -0
  695. package/dist/oauth-authorization-CvT-8KtG.mjs.map +1 -0
  696. package/dist/oauth-clients-ohsH0FlQ.mjs +266 -0
  697. package/dist/oauth-clients-ohsH0FlQ.mjs.map +1 -0
  698. package/dist/oauth-state-store-V4y2qZwD.mjs +80 -0
  699. package/dist/oauth-state-store-V4y2qZwD.mjs.map +1 -0
  700. package/dist/oauth-user-lookup-D2NTHxcr.mjs +26 -0
  701. package/dist/oauth-user-lookup-D2NTHxcr.mjs.map +1 -0
  702. package/dist/object-cache/memory.d.mts +1 -1
  703. package/dist/object-cache-I4Re7BOR.mjs +807 -0
  704. package/dist/object-cache-I4Re7BOR.mjs.map +1 -0
  705. package/dist/options-CbSYZAwr.d.mts +81 -0
  706. package/dist/options-CbSYZAwr.d.mts.map +1 -0
  707. package/dist/page/index.d.mts +2 -2
  708. package/dist/parse-BTfkfMuL.mjs +82 -0
  709. package/dist/parse-BTfkfMuL.mjs.map +1 -0
  710. package/dist/parse-CBM779p-.d.mts +180 -0
  711. package/dist/parse-CBM779p-.d.mts.map +1 -0
  712. package/dist/parts-i0nNljq-.mjs +68 -0
  713. package/dist/parts-i0nNljq-.mjs.map +1 -0
  714. package/dist/passkey-config-D9iYgt4G.mjs +46 -0
  715. package/dist/passkey-config-D9iYgt4G.mjs.map +1 -0
  716. package/dist/paths-B1TgS0ir.mjs +77 -0
  717. package/dist/paths-B1TgS0ir.mjs.map +1 -0
  718. package/dist/placeholder-PFMxMYTa.d.mts +316 -0
  719. package/dist/placeholder-PFMxMYTa.d.mts.map +1 -0
  720. package/dist/plan-DQoNgF2Y.mjs +135 -0
  721. package/dist/plan-DQoNgF2Y.mjs.map +1 -0
  722. package/dist/plugin-settings-CKffVNYE.mjs +162 -0
  723. package/dist/plugin-settings-CKffVNYE.mjs.map +1 -0
  724. package/dist/plugin-test-runtime.d.mts +23 -22
  725. package/dist/plugin-test-runtime.d.mts.map +1 -1
  726. package/dist/plugin-test-runtime.mjs +9 -8
  727. package/dist/plugin-types.d.mts +2 -2
  728. package/dist/plugin-utils.d.mts +15 -15
  729. package/dist/plugins/adapt-sandbox-entry.d.mts +15 -15
  730. package/dist/plugins/adapt-sandbox-entry.mjs +4 -4
  731. package/dist/plugins/host.d.mts +6 -6
  732. package/dist/plugins/host.mjs +8 -7
  733. package/dist/plugins-DDiWIA_N.mjs +261 -0
  734. package/dist/plugins-DDiWIA_N.mjs.map +1 -0
  735. package/dist/policy-72PGoCgJ.mjs +56 -0
  736. package/dist/policy-72PGoCgJ.mjs.map +1 -0
  737. package/dist/portable-text-D18C1jR6.mjs +457 -0
  738. package/dist/portable-text-D18C1jR6.mjs.map +1 -0
  739. package/dist/protocol-CbSoh3FE.d.mts +65 -0
  740. package/dist/protocol-CbSoh3FE.d.mts.map +1 -0
  741. package/dist/public-plugin-api-routes-Bq55wwHn.mjs +323 -0
  742. package/dist/public-plugin-api-routes-Bq55wwHn.mjs.map +1 -0
  743. package/dist/public-submission-BEcSmcWi.mjs +253 -0
  744. package/dist/public-submission-BEcSmcWi.mjs.map +1 -0
  745. package/dist/public-url-DYZMfvpa.mjs +123 -0
  746. package/dist/public-url-DYZMfvpa.mjs.map +1 -0
  747. package/dist/query-CslUTGOV.mjs +1221 -0
  748. package/dist/query-CslUTGOV.mjs.map +1 -0
  749. package/dist/query-Cv8bjIwl.mjs +41 -0
  750. package/dist/query-Cv8bjIwl.mjs.map +1 -0
  751. package/dist/range-CzdsIs-O.mjs +51 -0
  752. package/dist/range-CzdsIs-O.mjs.map +1 -0
  753. package/dist/rate-limit-iZgsy_oY.mjs +127 -0
  754. package/dist/rate-limit-iZgsy_oY.mjs.map +1 -0
  755. package/dist/receipt-CqxAacXn.mjs +43 -0
  756. package/dist/receipt-CqxAacXn.mjs.map +1 -0
  757. package/dist/redirect-3A3kqsD-.mjs +19 -0
  758. package/dist/redirect-3A3kqsD-.mjs.map +1 -0
  759. package/dist/redirect-DsaFuuQi.mjs +466 -0
  760. package/dist/redirect-DsaFuuQi.mjs.map +1 -0
  761. package/dist/redirect-paths-DgkkN0qJ.mjs +36 -0
  762. package/dist/redirect-paths-DgkkN0qJ.mjs.map +1 -0
  763. package/dist/redirects-DfvdrgF1.mjs +446 -0
  764. package/dist/redirects-DfvdrgF1.mjs.map +1 -0
  765. package/dist/redirects-Yo8YTJMV.mjs +148 -0
  766. package/dist/redirects-Yo8YTJMV.mjs.map +1 -0
  767. package/dist/registry/testing.mjs +2 -2
  768. package/dist/registry-2vAYgqCz.mjs +755 -0
  769. package/dist/registry-2vAYgqCz.mjs.map +1 -0
  770. package/dist/registry-COR9pjyi.mjs +1449 -0
  771. package/dist/registry-COR9pjyi.mjs.map +1 -0
  772. package/dist/registry-CSLrHSx1.mjs +6139 -0
  773. package/dist/registry-CSLrHSx1.mjs.map +1 -0
  774. package/dist/relations-5fVj42fZ.mjs +798 -0
  775. package/dist/relations-5fVj42fZ.mjs.map +1 -0
  776. package/dist/request-context.d.mts +2 -2
  777. package/dist/request-meta-B0TPrDpq.mjs +141 -0
  778. package/dist/request-meta-B0TPrDpq.mjs.map +1 -0
  779. package/dist/resolve--EmZidEz.mjs +92 -0
  780. package/dist/resolve--EmZidEz.mjs.map +1 -0
  781. package/dist/revision-Dk9VI8Vf.mjs +503 -0
  782. package/dist/revision-Dk9VI8Vf.mjs.map +1 -0
  783. package/dist/rooms/index.d.mts +15 -15
  784. package/dist/rooms/index.mjs +3 -3
  785. package/dist/rooms/node/index.d.mts +15 -15
  786. package/dist/rooms/node/index.mjs +6 -6
  787. package/dist/rooms/notifications.d.mts +15 -15
  788. package/dist/rooms/notifications.mjs +2 -2
  789. package/dist/rooms/room.d.mts +15 -15
  790. package/dist/rooms/room.mjs +2 -2
  791. package/dist/rooms/site.d.mts +15 -15
  792. package/dist/rooms/site.mjs +4 -4
  793. package/dist/rooms-AcO0YNUt.mjs +335 -0
  794. package/dist/rooms-AcO0YNUt.mjs.map +1 -0
  795. package/dist/rooms-B2P1xIS_.d.mts +4778 -0
  796. package/dist/rooms-B2P1xIS_.d.mts.map +1 -0
  797. package/dist/rooms-C08U-F8Y.mjs +169 -0
  798. package/dist/rooms-C08U-F8Y.mjs.map +1 -0
  799. package/dist/route-cache-CvTJlNVT.mjs +30 -0
  800. package/dist/route-cache-CvTJlNVT.mjs.map +1 -0
  801. package/dist/route-wire-NAkNES3Z.mjs +197 -0
  802. package/dist/route-wire-NAkNES3Z.mjs.map +1 -0
  803. package/dist/routes-BScyES_G.mjs +272 -0
  804. package/dist/routes-BScyES_G.mjs.map +1 -0
  805. package/dist/runner-C6gBIcTD.d.mts +79 -0
  806. package/dist/runner-C6gBIcTD.d.mts.map +1 -0
  807. package/dist/runner-Nv0yWP-G.mjs +6964 -0
  808. package/dist/runner-Nv0yWP-G.mjs.map +1 -0
  809. package/dist/runtime-holder-DkZ_0f7A.mjs +36 -0
  810. package/dist/runtime-holder-DkZ_0f7A.mjs.map +1 -0
  811. package/dist/runtime.d.mts +16 -16
  812. package/dist/runtime.mjs +1 -1
  813. package/dist/scheduler-health-B5n19775.mjs +31 -0
  814. package/dist/scheduler-health-B5n19775.mjs.map +1 -0
  815. package/dist/schema/project-env-types.mjs +6 -6
  816. package/dist/schema-B7ODIkP4.mjs +13 -0
  817. package/dist/schema-B7ODIkP4.mjs.map +1 -0
  818. package/dist/schema-D04_n_7j.mjs +815 -0
  819. package/dist/schema-D04_n_7j.mjs.map +1 -0
  820. package/dist/scopes-CHc86VzZ.mjs +34 -0
  821. package/dist/scopes-CHc86VzZ.mjs.map +1 -0
  822. package/dist/search-BxBg7Xq1.mjs +503 -0
  823. package/dist/search-BxBg7Xq1.mjs.map +1 -0
  824. package/dist/search-SRLBXKJU.mjs +12 -0
  825. package/dist/search-SRLBXKJU.mjs.map +1 -0
  826. package/dist/secrets-O25WpEe_.mjs +369 -0
  827. package/dist/secrets-O25WpEe_.mjs.map +1 -0
  828. package/dist/sections-BK7soA2U.mjs +222 -0
  829. package/dist/sections-BK7soA2U.mjs.map +1 -0
  830. package/dist/sections-CLejSkAG.mjs +129 -0
  831. package/dist/sections-CLejSkAG.mjs.map +1 -0
  832. package/dist/seed/index.d.mts +2 -2
  833. package/dist/seed/index.mjs +4 -4
  834. package/dist/seo/index.d.mts +3 -3
  835. package/dist/seo/index.mjs +3 -3
  836. package/dist/seo-Ie7B6cud.mjs +194 -0
  837. package/dist/seo-Ie7B6cud.mjs.map +1 -0
  838. package/dist/service-DbKGSUHC.mjs +150 -0
  839. package/dist/service-DbKGSUHC.mjs.map +1 -0
  840. package/dist/session-user-BrCPLyWB.mjs +61 -0
  841. package/dist/session-user-BrCPLyWB.mjs.map +1 -0
  842. package/dist/settings-BApLX_aS.mjs +413 -0
  843. package/dist/settings-BApLX_aS.mjs.map +1 -0
  844. package/dist/settings-Ces2K0VL.mjs +74 -0
  845. package/dist/settings-Ces2K0VL.mjs.map +1 -0
  846. package/dist/settings-DMHIgDyb.mjs +66 -0
  847. package/dist/settings-DMHIgDyb.mjs.map +1 -0
  848. package/dist/settings-DgnWX0GN.mjs +157 -0
  849. package/dist/settings-DgnWX0GN.mjs.map +1 -0
  850. package/dist/setup-complete-DQ1nNEjm.mjs +65 -0
  851. package/dist/setup-complete-DQ1nNEjm.mjs.map +1 -0
  852. package/dist/setup-nonce-5k8BY3W_.mjs +25 -0
  853. package/dist/setup-nonce-5k8BY3W_.mjs.map +1 -0
  854. package/dist/site-domain-B2KvJstd.mjs +131 -0
  855. package/dist/site-domain-B2KvJstd.mjs.map +1 -0
  856. package/dist/site-settings-B7VxSqP6.mjs +50 -0
  857. package/dist/site-settings-B7VxSqP6.mjs.map +1 -0
  858. package/dist/site-title-DHgWlyMw.mjs +14 -0
  859. package/dist/site-title-DHgWlyMw.mjs.map +1 -0
  860. package/dist/site-url-OBYES-gb.mjs +45 -0
  861. package/dist/site-url-OBYES-gb.mjs.map +1 -0
  862. package/dist/sitemap-name-BZXv5sf0.mjs +26 -0
  863. package/dist/sitemap-name-BZXv5sf0.mjs.map +1 -0
  864. package/dist/slug-CFsfrxUp.mjs +16 -0
  865. package/dist/slug-CFsfrxUp.mjs.map +1 -0
  866. package/dist/snapshot-BaIv7afB.mjs +466 -0
  867. package/dist/snapshot-BaIv7afB.mjs.map +1 -0
  868. package/dist/snapshot-VQM7BcdM.mjs +184 -0
  869. package/dist/snapshot-VQM7BcdM.mjs.map +1 -0
  870. package/dist/ssrf-Em0CeaaN.mjs +406 -0
  871. package/dist/ssrf-Em0CeaaN.mjs.map +1 -0
  872. package/dist/stage-Ctas_E7M.mjs +662 -0
  873. package/dist/stage-Ctas_E7M.mjs.map +1 -0
  874. package/dist/staged-C746SkS0.mjs +686 -0
  875. package/dist/staged-C746SkS0.mjs.map +1 -0
  876. package/dist/start-user-session-CdyNie0P.mjs +9 -0
  877. package/dist/start-user-session-CdyNie0P.mjs.map +1 -0
  878. package/dist/state-Cdkt6b1h.mjs +282 -0
  879. package/dist/state-Cdkt6b1h.mjs.map +1 -0
  880. package/dist/storage/local.d.mts +1 -1
  881. package/dist/storage/local.mjs +2 -2
  882. package/dist/storage/s3.d.mts +1 -1
  883. package/dist/storage/s3.mjs +1 -1
  884. package/dist/storage-query-DdKo8oes.d.mts +1614 -0
  885. package/dist/storage-query-DdKo8oes.d.mts.map +1 -0
  886. package/dist/tar-Tbl91sMI.mjs +449 -0
  887. package/dist/tar-Tbl91sMI.mjs.map +1 -0
  888. package/dist/target-Bjxlaj4T.mjs +27 -0
  889. package/dist/target-Bjxlaj4T.mjs.map +1 -0
  890. package/dist/taxonomies-D5bavOHA.mjs +937 -0
  891. package/dist/taxonomies-D5bavOHA.mjs.map +1 -0
  892. package/dist/taxonomies-DApyZAJq.mjs +722 -0
  893. package/dist/taxonomies-DApyZAJq.mjs.map +1 -0
  894. package/dist/taxonomy-D4Fl2smf.mjs +593 -0
  895. package/dist/taxonomy-D4Fl2smf.mjs.map +1 -0
  896. package/dist/tokens-DvEbszXd.mjs +171 -0
  897. package/dist/tokens-DvEbszXd.mjs.map +1 -0
  898. package/dist/transaction-D5Kq7MTL.mjs +44 -0
  899. package/dist/transaction-D5Kq7MTL.mjs.map +1 -0
  900. package/dist/transfer-BwKpOrTV.mjs +8963 -0
  901. package/dist/transfer-BwKpOrTV.mjs.map +1 -0
  902. package/dist/transfer-CafpWTD6.mjs +166 -0
  903. package/dist/transfer-CafpWTD6.mjs.map +1 -0
  904. package/dist/transfer-download-H8beYs2r.mjs +33 -0
  905. package/dist/transfer-download-H8beYs2r.mjs.map +1 -0
  906. package/dist/transformations-DX_dwSfp.mjs +196 -0
  907. package/dist/transformations-DX_dwSfp.mjs.map +1 -0
  908. package/dist/transport-7mI_Nvnn.d.mts +42 -0
  909. package/dist/transport-7mI_Nvnn.d.mts.map +1 -0
  910. package/dist/transport-Cs1Xl7-v.mjs +144 -0
  911. package/dist/transport-Cs1Xl7-v.mjs.map +1 -0
  912. package/dist/trusted-proxy-DaSru7xW.mjs +51 -0
  913. package/dist/trusted-proxy-DaSru7xW.mjs.map +1 -0
  914. package/dist/turnstile-DNR0cwtt.mjs +58 -0
  915. package/dist/turnstile-DNR0cwtt.mjs.map +1 -0
  916. package/dist/types-8q-gxKfV.d.mts +935 -0
  917. package/dist/types-8q-gxKfV.d.mts.map +1 -0
  918. package/dist/types-BBH-w_KS.mjs.map +1 -1
  919. package/dist/types-BE4og6EZ.d.mts +292 -0
  920. package/dist/types-BE4og6EZ.d.mts.map +1 -0
  921. package/dist/types-BbOWBoRk.d.mts +384 -0
  922. package/dist/types-BbOWBoRk.d.mts.map +1 -0
  923. package/dist/types-BmBK2cqf.mjs.map +1 -1
  924. package/dist/types-C3tTVw9y.mjs +37 -0
  925. package/dist/types-C3tTVw9y.mjs.map +1 -0
  926. package/dist/types-CTQEkZcI.mjs +16 -0
  927. package/dist/types-CTQEkZcI.mjs.map +1 -0
  928. package/dist/types-CbfB5YfA.d.mts +209 -0
  929. package/dist/types-CbfB5YfA.d.mts.map +1 -0
  930. package/dist/types-CeknTiV0.d.mts +93 -0
  931. package/dist/types-CeknTiV0.d.mts.map +1 -0
  932. package/dist/types-CpFfDrGH.mjs.map +1 -1
  933. package/dist/types-DHjtQujX.mjs +77 -0
  934. package/dist/types-DHjtQujX.mjs.map +1 -0
  935. package/dist/types-EYyvAjNA.d.mts +125 -0
  936. package/dist/types-EYyvAjNA.d.mts.map +1 -0
  937. package/dist/types-VMZCO8hc.d.mts +366 -0
  938. package/dist/types-VMZCO8hc.d.mts.map +1 -0
  939. package/dist/types-YTpIfKXX.d.mts +1756 -0
  940. package/dist/types-YTpIfKXX.d.mts.map +1 -0
  941. package/dist/types-iSBIMGiz.d.mts +227 -0
  942. package/dist/types-iSBIMGiz.d.mts.map +1 -0
  943. package/dist/upload-attempts-ChkgAfye.mjs +32 -0
  944. package/dist/upload-attempts-ChkgAfye.mjs.map +1 -0
  945. package/dist/url-CBR5ZBBQ.mjs +87 -0
  946. package/dist/url-CBR5ZBBQ.mjs.map +1 -0
  947. package/dist/url-pattern-DViEwhDu.mjs +41 -0
  948. package/dist/url-pattern-DViEwhDu.mjs.map +1 -0
  949. package/dist/urls-BCnpTM3T.mjs +79 -0
  950. package/dist/urls-BCnpTM3T.mjs.map +1 -0
  951. package/dist/user-Cy4kOmtD.mjs +184 -0
  952. package/dist/user-Cy4kOmtD.mjs.map +1 -0
  953. package/dist/utils-0R0olFJs.d.mts +374 -0
  954. package/dist/utils-0R0olFJs.d.mts.map +1 -0
  955. package/dist/utils-DIfKXQ5o.mjs +450 -0
  956. package/dist/utils-DIfKXQ5o.mjs.map +1 -0
  957. package/dist/validate-CYHbSQ-M.d.mts +472 -0
  958. package/dist/validate-CYHbSQ-M.d.mts.map +1 -0
  959. package/dist/validate-DBnEN6hU.mjs +524 -0
  960. package/dist/validate-DBnEN6hU.mjs.map +1 -0
  961. package/dist/validation-Becbh-zl.mjs +204 -0
  962. package/dist/validation-Becbh-zl.mjs.map +1 -0
  963. package/dist/version-BE4RahxC.mjs +7 -0
  964. package/dist/version-BE4RahxC.mjs.map +1 -0
  965. package/dist/version-C3C6o1xi.mjs +9 -0
  966. package/dist/version-C3C6o1xi.mjs.map +1 -0
  967. package/dist/version-PIyVra05.mjs +49 -0
  968. package/dist/version-PIyVra05.mjs.map +1 -0
  969. package/dist/video-Cgw31pIP.mjs +18 -0
  970. package/dist/video-Cgw31pIP.mjs.map +1 -0
  971. package/dist/virtual-modules-DAvm-Tct.mjs +565 -0
  972. package/dist/virtual-modules-DAvm-Tct.mjs.map +1 -0
  973. package/dist/widgets-HYhp_QtR.mjs +134 -0
  974. package/dist/widgets-HYhp_QtR.mjs.map +1 -0
  975. package/dist/wxr-CDtij4U5.mjs +1054 -0
  976. package/dist/wxr-CDtij4U5.mjs.map +1 -0
  977. package/dist/wxr-taxonomies-fliLjgKD.mjs +735 -0
  978. package/dist/wxr-taxonomies-fliLjgKD.mjs.map +1 -0
  979. package/dist/wxr-taxonomies-uZgPVgPe.d.mts +34 -0
  980. package/dist/wxr-taxonomies-uZgPVgPe.d.mts.map +1 -0
  981. package/package.json +11 -10
  982. package/src/after.ts +17 -10
  983. package/src/api/error.ts +0 -13
  984. package/src/api/handlers/manifest.ts +1 -0
  985. package/src/api/handlers/media-allowlist.ts +66 -7
  986. package/src/api/handlers/media-usage.ts +2 -1
  987. package/src/api/handlers/media.ts +4 -2
  988. package/src/api/handlers/seo.ts +19 -7
  989. package/src/api/openapi/document.ts +1 -1
  990. package/src/api/schemas/auth.ts +7 -0
  991. package/src/api/schemas/media-usage.ts +1 -0
  992. package/src/api/schemas/media.ts +13 -3
  993. package/src/api/schemas/schema.ts +14 -0
  994. package/src/api/search.ts +15 -0
  995. package/src/api/types.ts +3 -0
  996. package/src/astro/image-endpoint.ts +30 -4
  997. package/src/astro/integration/dev-scheduler-bridge.ts +1 -2
  998. package/src/astro/integration/index.ts +22 -1
  999. package/src/astro/integration/routes.ts +4 -0
  1000. package/src/astro/integration/virtual-modules.ts +3 -6
  1001. package/src/astro/integration/vite-config.ts +13 -6
  1002. package/src/astro/middleware/auth.ts +18 -11
  1003. package/src/astro/middleware/redirect.ts +41 -23
  1004. package/src/astro/middleware/request-context.ts +4 -2
  1005. package/src/astro/middleware/scoped-db.ts +4 -4
  1006. package/src/astro/middleware.ts +288 -204
  1007. package/src/astro/prefetch.ts +21 -17
  1008. package/src/astro/public-plugin-api-routes.ts +4 -4
  1009. package/src/astro/routes/PluginRegistry.tsx +2 -3
  1010. package/src/astro/routes/api/admin/byline-fields/[slug]/usage.ts +4 -3
  1011. package/src/astro/routes/api/admin/byline-fields/[slug].ts +10 -7
  1012. package/src/astro/routes/api/admin/byline-fields/index.ts +7 -5
  1013. package/src/astro/routes/api/admin/byline-fields/reorder.ts +4 -3
  1014. package/src/astro/routes/api/admin/bylines/[id]/index.ts +4 -3
  1015. package/src/astro/routes/api/admin/bylines/[id]/translations.ts +7 -5
  1016. package/src/astro/routes/api/admin/comments/[id]/status.ts +4 -3
  1017. package/src/astro/routes/api/admin/comments/[id].ts +7 -5
  1018. package/src/astro/routes/api/admin/comments/bulk.ts +4 -3
  1019. package/src/astro/routes/api/admin/comments/counts.ts +4 -3
  1020. package/src/astro/routes/api/admin/comments/index.ts +4 -3
  1021. package/src/astro/routes/api/admin/media-usage/activation.ts +7 -5
  1022. package/src/astro/routes/api/admin/media-usage/collection-deletions/index.ts +4 -3
  1023. package/src/astro/routes/api/admin/media-usage/collection-deletions/retry.ts +4 -3
  1024. package/src/astro/routes/api/admin/media-usage/progress.ts +7 -5
  1025. package/src/astro/routes/api/admin/media-usage/repair.ts +4 -3
  1026. package/src/astro/routes/api/admin/media-usage/work/index.ts +4 -3
  1027. package/src/astro/routes/api/admin/media-usage/work/retry.ts +4 -3
  1028. package/src/astro/routes/api/admin/plugins/registry/artifact.ts +7 -4
  1029. package/src/astro/routes/api/admin/transfer/approvals/[id]/approve.ts +4 -3
  1030. package/src/astro/routes/api/admin/transfer/approvals/[id]/deny.ts +4 -3
  1031. package/src/astro/routes/api/admin/transfer/approvals/index.ts +4 -3
  1032. package/src/astro/routes/api/admin/transfer/capabilities.ts +4 -3
  1033. package/src/astro/routes/api/admin/transfer/exports/[id]/advance.ts +4 -3
  1034. package/src/astro/routes/api/admin/transfer/exports/[id]/archive.ts +4 -3
  1035. package/src/astro/routes/api/admin/transfer/exports/[id]/files/[...path].ts +4 -3
  1036. package/src/astro/routes/api/admin/transfer/exports/[id]/index.ts +4 -3
  1037. package/src/astro/routes/api/admin/transfer/exports/[id]/manifest.ts +4 -3
  1038. package/src/astro/routes/api/admin/transfer/exports/index.ts +7 -5
  1039. package/src/astro/routes/api/admin/transfer/imports/[id]/abandon.ts +4 -3
  1040. package/src/astro/routes/api/admin/transfer/imports/[id]/advance.ts +4 -3
  1041. package/src/astro/routes/api/admin/transfer/imports/[id]/analyze.ts +4 -3
  1042. package/src/astro/routes/api/admin/transfer/imports/[id]/cancel.ts +4 -3
  1043. package/src/astro/routes/api/admin/transfer/imports/[id]/execute.ts +4 -3
  1044. package/src/astro/routes/api/admin/transfer/imports/[id]/files/[...path].ts +4 -3
  1045. package/src/astro/routes/api/admin/transfer/imports/[id]/index.ts +4 -3
  1046. package/src/astro/routes/api/admin/transfer/imports/[id]/missing.ts +4 -3
  1047. package/src/astro/routes/api/admin/transfer/imports/[id]/plan.ts +4 -3
  1048. package/src/astro/routes/api/admin/transfer/imports/[id]/receipt.ts +4 -3
  1049. package/src/astro/routes/api/admin/transfer/imports/index.ts +7 -5
  1050. package/src/astro/routes/api/auth/invite/complete.ts +2 -1
  1051. package/src/astro/routes/api/auth/magic-link/verify.ts +2 -1
  1052. package/src/astro/routes/api/auth/oauth/[provider]/callback.ts +2 -1
  1053. package/src/astro/routes/api/auth/passkey/verify.ts +2 -1
  1054. package/src/astro/routes/api/auth/signup/complete.ts +2 -1
  1055. package/src/astro/routes/api/auth/signup/register-options.ts +69 -0
  1056. package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +7 -5
  1057. package/src/astro/routes/api/comments/[collection]/[contentId]/reactions.ts +7 -5
  1058. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +3 -13
  1059. package/src/astro/routes/api/content/[collection]/[id]/duplicate.ts +3 -13
  1060. package/src/astro/routes/api/content/[collection]/[id]/lock.ts +19 -19
  1061. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +3 -12
  1062. package/src/astro/routes/api/content/[collection]/[id]/references/[relation]/children.ts +4 -3
  1063. package/src/astro/routes/api/content/[collection]/[id]/references/[relation]/parents.ts +4 -3
  1064. package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +11 -19
  1065. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +3 -12
  1066. package/src/astro/routes/api/content/[collection]/[id].ts +12 -34
  1067. package/src/astro/routes/api/import/wordpress/execute.ts +1 -4
  1068. package/src/astro/routes/api/import/wordpress/media.ts +3 -2
  1069. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +1 -4
  1070. package/src/astro/routes/api/media/[id]/replace.ts +11 -2
  1071. package/src/astro/routes/api/media/[id].ts +16 -3
  1072. package/src/astro/routes/api/media/file/[...key].ts +11 -0
  1073. package/src/astro/routes/api/media/providers/[providerId]/[itemId].ts +18 -2
  1074. package/src/astro/routes/api/menus/[name]/items/[id].ts +6 -0
  1075. package/src/astro/routes/api/menus/[name]/items.ts +4 -1
  1076. package/src/astro/routes/api/menus/[name]/reorder.ts +4 -1
  1077. package/src/astro/routes/api/menus/[name]/translations.ts +7 -5
  1078. package/src/astro/routes/api/menus/[name].ts +10 -1
  1079. package/src/astro/routes/api/menus/index.ts +7 -1
  1080. package/src/astro/routes/api/redirects/404s/index.ts +10 -7
  1081. package/src/astro/routes/api/redirects/404s/summary.ts +4 -3
  1082. package/src/astro/routes/api/redirects/[id].ts +10 -7
  1083. package/src/astro/routes/api/redirects/index.ts +7 -5
  1084. package/src/astro/routes/api/relations/[id]/index.ts +10 -7
  1085. package/src/astro/routes/api/relations/index.ts +7 -5
  1086. package/src/astro/routes/api/schema/block-types/[slug]/index.ts +7 -5
  1087. package/src/astro/routes/api/schema/block-types/[slug]/versions/[version]/activate.ts +4 -3
  1088. package/src/astro/routes/api/schema/block-types/index.ts +7 -5
  1089. package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +10 -7
  1090. package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +7 -5
  1091. package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +4 -3
  1092. package/src/astro/routes/api/schema/collections/[slug]/index.ts +10 -7
  1093. package/src/astro/routes/api/schema/collections/index.ts +7 -5
  1094. package/src/astro/routes/api/schema/collections/reorder.ts +4 -3
  1095. package/src/astro/routes/api/schema/index.ts +4 -3
  1096. package/src/astro/routes/api/schema/orphans/[slug].ts +4 -3
  1097. package/src/astro/routes/api/schema/orphans/index.ts +4 -3
  1098. package/src/astro/routes/api/search/enable.ts +4 -0
  1099. package/src/astro/routes/api/search/index.ts +5 -3
  1100. package/src/astro/routes/api/search/rebuild.ts +4 -0
  1101. package/src/astro/routes/api/search/stats.ts +4 -0
  1102. package/src/astro/routes/api/search/suggest.ts +4 -0
  1103. package/src/astro/routes/api/sections/[slug].ts +10 -7
  1104. package/src/astro/routes/api/sections/index.ts +7 -5
  1105. package/src/astro/routes/api/setup/admin-verify.ts +2 -1
  1106. package/src/astro/routes/api/taxonomies/[name]/reorder.ts +4 -3
  1107. package/src/astro/routes/api/taxonomies/[name]/terms/[slug]/translations.ts +7 -5
  1108. package/src/astro/routes/api/taxonomies/[name]/terms/[slug].ts +10 -7
  1109. package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +7 -5
  1110. package/src/astro/routes/api/taxonomies/[name]/translations.ts +4 -3
  1111. package/src/astro/routes/api/taxonomies/[name].ts +10 -7
  1112. package/src/astro/routes/api/taxonomies/bulk-tag.ts +4 -3
  1113. package/src/astro/routes/api/taxonomies/index.ts +7 -5
  1114. package/src/astro/routes/api/widget-areas/[name]/reorder.ts +3 -0
  1115. package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +6 -0
  1116. package/src/astro/routes/api/widget-areas/[name]/widgets.ts +3 -0
  1117. package/src/astro/routes/api/widget-areas/[name].ts +6 -0
  1118. package/src/astro/routes/api/widget-areas/index.ts +6 -0
  1119. package/src/astro/session-user.ts +8 -4
  1120. package/src/astro/types.ts +77 -53
  1121. package/src/auth/start-user-session.ts +16 -0
  1122. package/src/cleanup.ts +24 -5
  1123. package/src/client/index.ts +5 -3
  1124. package/src/client/portable-text.ts +9 -1
  1125. package/src/comments/public-submission.ts +1 -1
  1126. package/src/components/Code.astro +6 -1
  1127. package/src/components/Comments.astro +17 -6
  1128. package/src/components/InlinePortableTextEditor.tsx +9 -1
  1129. package/src/database/dialect-helpers.ts +18 -3
  1130. package/src/database/migrations/098_user_last_login.ts +13 -0
  1131. package/src/database/migrations/runner.ts +2 -0
  1132. package/src/database/repositories/content.ts +37 -0
  1133. package/src/database/repositories/media-folders.ts +2 -6
  1134. package/src/database/repositories/media.ts +16 -7
  1135. package/src/database/repositories/revision.ts +2 -2
  1136. package/src/database/repositories/seo.ts +34 -10
  1137. package/src/database/repositories/types.ts +2 -2
  1138. package/src/database/repositories/user.ts +2 -2
  1139. package/src/database/types.ts +1 -0
  1140. package/src/db/node-sqlite-compat.ts +13 -0
  1141. package/src/emdash-runtime.ts +775 -308
  1142. package/src/mcp/server.ts +27 -34
  1143. package/src/media/image-endpoint.ts +84 -0
  1144. package/src/media/url.ts +16 -3
  1145. package/src/media/usage/content-fields.ts +7 -5
  1146. package/src/media/usage/content-lock.ts +71 -0
  1147. package/src/media/usage/content-refresh.ts +3 -72
  1148. package/src/media/usage/content-snapshots.ts +26 -0
  1149. package/src/media/usage/extractor.ts +132 -32
  1150. package/src/media/usage/types.ts +3 -1
  1151. package/src/object-cache/index.ts +16 -12
  1152. package/src/plugins/context.ts +22 -1
  1153. package/src/plugins/http-route-dispatch.ts +16 -8
  1154. package/src/plugins/lifecycle.ts +16 -4
  1155. package/src/plugins/sandbox/proxy.ts +2 -2
  1156. package/src/plugins/scheduler/node.ts +17 -11
  1157. package/src/plugins/state.ts +236 -78
  1158. package/src/query.ts +36 -5
  1159. package/src/scheduled-publish.ts +54 -6
  1160. package/src/schema/block-type-contract.ts +35 -4
  1161. package/src/schema/block-type-registry.ts +1 -1
  1162. package/src/schema/types.ts +3 -0
  1163. package/src/search/fts-manager.ts +79 -19
  1164. package/src/search/query.ts +212 -101
  1165. package/src/search/types.ts +6 -1
  1166. package/src/virtual-modules.d.ts +3 -10
  1167. package/dist/action-token-CKphU6ur.mjs +0 -26
  1168. package/dist/action-token-CKphU6ur.mjs.map +0 -1
  1169. package/dist/activation-X5iMalte.mjs +0 -387
  1170. package/dist/activation-X5iMalte.mjs.map +0 -1
  1171. package/dist/adapters-DFsc9XjW.d.mts +0 -173
  1172. package/dist/adapters-DFsc9XjW.d.mts.map +0 -1
  1173. package/dist/after-B3AvMfBQ.mjs +0 -50
  1174. package/dist/after-B3AvMfBQ.mjs.map +0 -1
  1175. package/dist/allowed-origins-BFDNF-05.mjs +0 -116
  1176. package/dist/allowed-origins-BFDNF-05.mjs.map +0 -1
  1177. package/dist/api-tokens-D27OQ0oQ.mjs +0 -173
  1178. package/dist/api-tokens-D27OQ0oQ.mjs.map +0 -1
  1179. package/dist/apply-Culv7QJl.mjs +0 -1774
  1180. package/dist/apply-Culv7QJl.mjs.map +0 -1
  1181. package/dist/approvals-oLE5G5jw.mjs +0 -460
  1182. package/dist/approvals-oLE5G5jw.mjs.map +0 -1
  1183. package/dist/artifact-fetch-ByK_1pck.mjs +0 -659
  1184. package/dist/artifact-fetch-ByK_1pck.mjs.map +0 -1
  1185. package/dist/artifacts-BXKMIV2F.mjs +0 -323
  1186. package/dist/artifacts-BXKMIV2F.mjs.map +0 -1
  1187. package/dist/authoritative-records-Cd5BVXRs.mjs +0 -5183
  1188. package/dist/authoritative-records-Cd5BVXRs.mjs.map +0 -1
  1189. package/dist/authorize-B-4ogCQG.mjs +0 -74
  1190. package/dist/authorize-B-4ogCQG.mjs.map +0 -1
  1191. package/dist/backup-BQhg3MEK.mjs +0 -246
  1192. package/dist/backup-BQhg3MEK.mjs.map +0 -1
  1193. package/dist/block-types-BTzqdEZV.mjs +0 -132
  1194. package/dist/block-types-BTzqdEZV.mjs.map +0 -1
  1195. package/dist/block-values-DzZIh7WN.mjs +0 -215
  1196. package/dist/block-values-DzZIh7WN.mjs.map +0 -1
  1197. package/dist/byline--sweE_MZ.mjs +0 -930
  1198. package/dist/byline--sweE_MZ.mjs.map +0 -1
  1199. package/dist/byline-fields-Czdq4Yad.mjs +0 -123
  1200. package/dist/byline-fields-Czdq4Yad.mjs.map +0 -1
  1201. package/dist/byline-registry-Cr7kjrxM.mjs +0 -406
  1202. package/dist/byline-registry-Cr7kjrxM.mjs.map +0 -1
  1203. package/dist/bylines-DnuH3H8z.mjs +0 -234
  1204. package/dist/bylines-DnuH3H8z.mjs.map +0 -1
  1205. package/dist/bylines-txlwgzIK.mjs +0 -150
  1206. package/dist/bylines-txlwgzIK.mjs.map +0 -1
  1207. package/dist/cache-BjnpmIpb.mjs +0 -151
  1208. package/dist/cache-BjnpmIpb.mjs.map +0 -1
  1209. package/dist/canonical-Cb-rJGRU.mjs +0 -174
  1210. package/dist/canonical-Cb-rJGRU.mjs.map +0 -1
  1211. package/dist/capture-triggers-BZmIEdX2.mjs +0 -362
  1212. package/dist/capture-triggers-BZmIEdX2.mjs.map +0 -1
  1213. package/dist/checksum-CH9TyM-N.mjs +0 -162
  1214. package/dist/checksum-CH9TyM-N.mjs.map +0 -1
  1215. package/dist/chunks-DRnEstVb.mjs +0 -25
  1216. package/dist/chunks-DRnEstVb.mjs.map +0 -1
  1217. package/dist/collection-slugs-cache-CYMrqHZ6.mjs +0 -91
  1218. package/dist/collection-slugs-cache-CYMrqHZ6.mjs.map +0 -1
  1219. package/dist/comment-BGeXmJ8F.mjs +0 -335
  1220. package/dist/comment-BGeXmJ8F.mjs.map +0 -1
  1221. package/dist/comment-reaction-ty-JEDYR.mjs +0 -85
  1222. package/dist/comment-reaction-ty-JEDYR.mjs.map +0 -1
  1223. package/dist/comments-ByrrLvZL.mjs +0 -99
  1224. package/dist/comments-ByrrLvZL.mjs.map +0 -1
  1225. package/dist/comments-DqhARoef.mjs +0 -195
  1226. package/dist/comments-DqhARoef.mjs.map +0 -1
  1227. package/dist/components-u2HE5Mu9.mjs +0 -112
  1228. package/dist/components-u2HE5Mu9.mjs.map +0 -1
  1229. package/dist/config-B4F2ttAZ.d.mts +0 -7230
  1230. package/dist/config-B4F2ttAZ.d.mts.map +0 -1
  1231. package/dist/config-BnrtMvHW.mjs +0 -228
  1232. package/dist/config-BnrtMvHW.mjs.map +0 -1
  1233. package/dist/config-DEse9gaE.d.mts +0 -41
  1234. package/dist/config-DEse9gaE.d.mts.map +0 -1
  1235. package/dist/connection-BaIVuaDX.mjs +0 -36
  1236. package/dist/connection-BaIVuaDX.mjs.map +0 -1
  1237. package/dist/content-Dxztag5t.mjs +0 -2270
  1238. package/dist/content-Dxztag5t.mjs.map +0 -1
  1239. package/dist/content-list-query-yYbBU-dB.d.mts +0 -26
  1240. package/dist/content-list-query-yYbBU-dB.d.mts.map +0 -1
  1241. package/dist/content-repair-2PdahlgZ.mjs +0 -443
  1242. package/dist/content-repair-2PdahlgZ.mjs.map +0 -1
  1243. package/dist/content-save-KMll0S7E.mjs +0 -202
  1244. package/dist/content-save-KMll0S7E.mjs.map +0 -1
  1245. package/dist/context-C3OZjexd.mjs +0 -2225
  1246. package/dist/context-C3OZjexd.mjs.map +0 -1
  1247. package/dist/credits-C8uXoWfN.mjs +0 -110
  1248. package/dist/credits-C8uXoWfN.mjs.map +0 -1
  1249. package/dist/cron-CrjBjDuy.mjs +0 -310
  1250. package/dist/cron-CrjBjDuy.mjs.map +0 -1
  1251. package/dist/default-DPoN3H5H.mjs +0 -81
  1252. package/dist/default-DPoN3H5H.mjs.map +0 -1
  1253. package/dist/deferred-tasks-uSx5qCFn.d.mts +0 -10
  1254. package/dist/deferred-tasks-uSx5qCFn.d.mts.map +0 -1
  1255. package/dist/device-flow-hT8lKWXq.mjs +0 -519
  1256. package/dist/device-flow-hT8lKWXq.mjs.map +0 -1
  1257. package/dist/dialect-helpers-DqUMP9fJ.mjs +0 -350
  1258. package/dist/dialect-helpers-DqUMP9fJ.mjs.map +0 -1
  1259. package/dist/digest-xYRiuW_E.mjs +0 -194
  1260. package/dist/digest-xYRiuW_E.mjs.map +0 -1
  1261. package/dist/direct-executor-CZ2SH1bq.mjs +0 -117
  1262. package/dist/direct-executor-CZ2SH1bq.mjs.map +0 -1
  1263. package/dist/email-console-CochjAlh.mjs +0 -50
  1264. package/dist/email-console-CochjAlh.mjs.map +0 -1
  1265. package/dist/email-locale-BoxaIPG8.mjs +0 -25
  1266. package/dist/email-locale-BoxaIPG8.mjs.map +0 -1
  1267. package/dist/email-smtp-BnHR_Ccx.mjs +0 -643
  1268. package/dist/email-smtp-BnHR_Ccx.mjs.map +0 -1
  1269. package/dist/emdash-runtime-CXsdCQnM.mjs +0 -5262
  1270. package/dist/emdash-runtime-CXsdCQnM.mjs.map +0 -1
  1271. package/dist/enrich-BReo_COC.mjs +0 -203
  1272. package/dist/enrich-BReo_COC.mjs.map +0 -1
  1273. package/dist/entry-lock-BfnhlRhC.mjs +0 -207
  1274. package/dist/entry-lock-BfnhlRhC.mjs.map +0 -1
  1275. package/dist/entry-lock-DsVhZcJN.mjs +0 -1228
  1276. package/dist/entry-lock-DsVhZcJN.mjs.map +0 -1
  1277. package/dist/entry-locks-D_kjygT1.mjs +0 -173
  1278. package/dist/entry-locks-D_kjygT1.mjs.map +0 -1
  1279. package/dist/env-types-CXI9uaMU.mjs +0 -38
  1280. package/dist/env-types-CXI9uaMU.mjs.map +0 -1
  1281. package/dist/error-DcDNU7hZ.mjs +0 -92
  1282. package/dist/error-DcDNU7hZ.mjs.map +0 -1
  1283. package/dist/errors-CJ6711al.mjs +0 -120
  1284. package/dist/errors-CJ6711al.mjs.map +0 -1
  1285. package/dist/errors-CwYHYcWF.mjs +0 -502
  1286. package/dist/errors-CwYHYcWF.mjs.map +0 -1
  1287. package/dist/fence-C3MLClBo.mjs +0 -162
  1288. package/dist/fence-C3MLClBo.mjs.map +0 -1
  1289. package/dist/field-defs-cache-Cpk0eFsQ.mjs +0 -79
  1290. package/dist/field-defs-cache-Cpk0eFsQ.mjs.map +0 -1
  1291. package/dist/field-map-6o9hPcRl.mjs +0 -84
  1292. package/dist/field-map-6o9hPcRl.mjs.map +0 -1
  1293. package/dist/fts-manager-B3iLXCGz.mjs +0 -500
  1294. package/dist/fts-manager-B3iLXCGz.mjs.map +0 -1
  1295. package/dist/gc-D24C-KP7.mjs +0 -62
  1296. package/dist/gc-D24C-KP7.mjs.map +0 -1
  1297. package/dist/hook-result-BU5rI-6M.d.mts +0 -31
  1298. package/dist/hook-result-BU5rI-6M.d.mts.map +0 -1
  1299. package/dist/hook-result-CO4E3zDv.mjs +0 -3854
  1300. package/dist/hook-result-CO4E3zDv.mjs.map +0 -1
  1301. package/dist/hreflang-Bzvlo9Ci.mjs +0 -105
  1302. package/dist/hreflang-Bzvlo9Ci.mjs.map +0 -1
  1303. package/dist/hreflang-Ds0WbBOu.d.mts +0 -51
  1304. package/dist/hreflang-Ds0WbBOu.d.mts.map +0 -1
  1305. package/dist/http-route-dispatch-BsjkWBZF.mjs +0 -348
  1306. package/dist/http-route-dispatch-BsjkWBZF.mjs.map +0 -1
  1307. package/dist/identity-CahxkBZC.mjs +0 -35
  1308. package/dist/identity-CahxkBZC.mjs.map +0 -1
  1309. package/dist/index-BauU0yTw.d.mts +0 -261
  1310. package/dist/index-BauU0yTw.d.mts.map +0 -1
  1311. package/dist/install-finalization-CIl610wT.mjs +0 -58
  1312. package/dist/install-finalization-CIl610wT.mjs.map +0 -1
  1313. package/dist/json-recordset-CrS6ZqMk.mjs +0 -12
  1314. package/dist/json-recordset-CrS6ZqMk.mjs.map +0 -1
  1315. package/dist/json-schema-CBcJlGcY.mjs +0 -15
  1316. package/dist/json-schema-CBcJlGcY.mjs.map +0 -1
  1317. package/dist/keys-DJ62Wt5b.mjs +0 -61
  1318. package/dist/keys-DJ62Wt5b.mjs.map +0 -1
  1319. package/dist/kinds-D7_f3Qu3.mjs +0 -974
  1320. package/dist/kinds-D7_f3Qu3.mjs.map +0 -1
  1321. package/dist/lifecycle-DPCkpFHV.mjs +0 -49
  1322. package/dist/lifecycle-DPCkpFHV.mjs.map +0 -1
  1323. package/dist/limits-Bv6mXNM-.mjs +0 -44
  1324. package/dist/limits-Bv6mXNM-.mjs.map +0 -1
  1325. package/dist/load-r9P0fsRH.mjs +0 -36
  1326. package/dist/load-r9P0fsRH.mjs.map +0 -1
  1327. package/dist/loader-CSEfTKzr.mjs +0 -1537
  1328. package/dist/loader-CSEfTKzr.mjs.map +0 -1
  1329. package/dist/loops-BxzrcxPO.mjs +0 -217
  1330. package/dist/loops-BxzrcxPO.mjs.map +0 -1
  1331. package/dist/manifest-builder-BLWqITXR.mjs +0 -196
  1332. package/dist/manifest-builder-BLWqITXR.mjs.map +0 -1
  1333. package/dist/manifest-schema-BRpk5V7x.mjs +0 -497
  1334. package/dist/manifest-schema-BRpk5V7x.mjs.map +0 -1
  1335. package/dist/marketplace-5YFgYPVr.mjs +0 -257
  1336. package/dist/marketplace-5YFgYPVr.mjs.map +0 -1
  1337. package/dist/marketplace-zPVE4UY5.mjs +0 -965
  1338. package/dist/marketplace-zPVE4UY5.mjs.map +0 -1
  1339. package/dist/media-C5fg1Xte.d.mts +0 -203
  1340. package/dist/media-C5fg1Xte.d.mts.map +0 -1
  1341. package/dist/media-CPETKjop.mjs +0 -424
  1342. package/dist/media-CPETKjop.mjs.map +0 -1
  1343. package/dist/media-Cid3xIHk.mjs +0 -294
  1344. package/dist/media-Cid3xIHk.mjs.map +0 -1
  1345. package/dist/media-DJaAAYI2.mjs +0 -2805
  1346. package/dist/media-DJaAAYI2.mjs.map +0 -1
  1347. package/dist/media-allowlist-B7JwNf-U.mjs +0 -75
  1348. package/dist/media-allowlist-B7JwNf-U.mjs.map +0 -1
  1349. package/dist/media-folders-BI7B7XUM.mjs +0 -210
  1350. package/dist/media-folders-BI7B7XUM.mjs.map +0 -1
  1351. package/dist/media-url-xWuPVfqO.mjs +0 -43
  1352. package/dist/media-url-xWuPVfqO.mjs.map +0 -1
  1353. package/dist/media-usage-SwtWPxy4.mjs +0 -282
  1354. package/dist/media-usage-SwtWPxy4.mjs.map +0 -1
  1355. package/dist/media-usage-activation-BTa1H4wE.mjs +0 -78
  1356. package/dist/media-usage-activation-BTa1H4wE.mjs.map +0 -1
  1357. package/dist/media-usage-work-BxHWfbKq.mjs +0 -1036
  1358. package/dist/media-usage-work-BxHWfbKq.mjs.map +0 -1
  1359. package/dist/media-usage-work-DYenZS8y.mjs +0 -151
  1360. package/dist/media-usage-work-DYenZS8y.mjs.map +0 -1
  1361. package/dist/menu-FtSf33fF.mjs +0 -420
  1362. package/dist/menu-FtSf33fF.mjs.map +0 -1
  1363. package/dist/menus--MSfZ5Eu.mjs +0 -433
  1364. package/dist/menus--MSfZ5Eu.mjs.map +0 -1
  1365. package/dist/menus-C8h6Jtpu.mjs +0 -92
  1366. package/dist/menus-C8h6Jtpu.mjs.map +0 -1
  1367. package/dist/menus-CpFAi_LK.mjs +0 -434
  1368. package/dist/menus-CpFAi_LK.mjs.map +0 -1
  1369. package/dist/mime-Dx6aHTsR.mjs +0 -82
  1370. package/dist/mime-Dx6aHTsR.mjs.map +0 -1
  1371. package/dist/node-sqlite-compat-DvYkqx7Q.mjs +0 -63
  1372. package/dist/node-sqlite-compat-DvYkqx7Q.mjs.map +0 -1
  1373. package/dist/oauth-authorization-CBxtOboy.mjs +0 -287
  1374. package/dist/oauth-authorization-CBxtOboy.mjs.map +0 -1
  1375. package/dist/oauth-clients-HLGHmHqI.mjs +0 -266
  1376. package/dist/oauth-clients-HLGHmHqI.mjs.map +0 -1
  1377. package/dist/oauth-state-store-B4YAveSb.mjs +0 -80
  1378. package/dist/oauth-state-store-B4YAveSb.mjs.map +0 -1
  1379. package/dist/oauth-user-lookup-CTYMaKlq.mjs +0 -26
  1380. package/dist/oauth-user-lookup-CTYMaKlq.mjs.map +0 -1
  1381. package/dist/object-cache-DeATK4vw.mjs +0 -805
  1382. package/dist/object-cache-DeATK4vw.mjs.map +0 -1
  1383. package/dist/options-BJZMHnpx.d.mts +0 -81
  1384. package/dist/options-BJZMHnpx.d.mts.map +0 -1
  1385. package/dist/parse-B1E5cdyD.mjs +0 -82
  1386. package/dist/parse-B1E5cdyD.mjs.map +0 -1
  1387. package/dist/parse-Clt6wmpy.d.mts +0 -178
  1388. package/dist/parse-Clt6wmpy.d.mts.map +0 -1
  1389. package/dist/parts-CMwESQ6e.mjs +0 -68
  1390. package/dist/parts-CMwESQ6e.mjs.map +0 -1
  1391. package/dist/passkey-config-DiVZI-cx.mjs +0 -46
  1392. package/dist/passkey-config-DiVZI-cx.mjs.map +0 -1
  1393. package/dist/paths-NrYImb_h.mjs +0 -77
  1394. package/dist/paths-NrYImb_h.mjs.map +0 -1
  1395. package/dist/placeholder-B0vI-EQ9.d.mts +0 -316
  1396. package/dist/placeholder-B0vI-EQ9.d.mts.map +0 -1
  1397. package/dist/plan-CSb3BdFS.mjs +0 -135
  1398. package/dist/plan-CSb3BdFS.mjs.map +0 -1
  1399. package/dist/plugin-settings-HdYYRFi3.mjs +0 -162
  1400. package/dist/plugin-settings-HdYYRFi3.mjs.map +0 -1
  1401. package/dist/plugins-Bc70Xs37.mjs +0 -261
  1402. package/dist/plugins-Bc70Xs37.mjs.map +0 -1
  1403. package/dist/policy-C-ngDrxa.mjs +0 -56
  1404. package/dist/policy-C-ngDrxa.mjs.map +0 -1
  1405. package/dist/portable-text-T17rOqF7.mjs +0 -454
  1406. package/dist/portable-text-T17rOqF7.mjs.map +0 -1
  1407. package/dist/protocol-CmSX4cXv.d.mts +0 -65
  1408. package/dist/protocol-CmSX4cXv.d.mts.map +0 -1
  1409. package/dist/public-plugin-api-routes-_xsWTlwE.mjs +0 -316
  1410. package/dist/public-plugin-api-routes-_xsWTlwE.mjs.map +0 -1
  1411. package/dist/public-submission-ui3pFYtq.mjs +0 -253
  1412. package/dist/public-submission-ui3pFYtq.mjs.map +0 -1
  1413. package/dist/public-url-DMRZPAiW.mjs +0 -123
  1414. package/dist/public-url-DMRZPAiW.mjs.map +0 -1
  1415. package/dist/query-C1K9PzUc.mjs +0 -41
  1416. package/dist/query-C1K9PzUc.mjs.map +0 -1
  1417. package/dist/query-DdmHrvie.mjs +0 -1201
  1418. package/dist/query-DdmHrvie.mjs.map +0 -1
  1419. package/dist/range-BaF0521t.mjs +0 -51
  1420. package/dist/range-BaF0521t.mjs.map +0 -1
  1421. package/dist/rate-limit-6MngP0_m.mjs +0 -127
  1422. package/dist/rate-limit-6MngP0_m.mjs.map +0 -1
  1423. package/dist/receipt-BFm5eaN7.mjs +0 -43
  1424. package/dist/receipt-BFm5eaN7.mjs.map +0 -1
  1425. package/dist/redirect-ChcHI1KC.mjs +0 -466
  1426. package/dist/redirect-ChcHI1KC.mjs.map +0 -1
  1427. package/dist/redirect-EpidEf_5.mjs +0 -19
  1428. package/dist/redirect-EpidEf_5.mjs.map +0 -1
  1429. package/dist/redirect-paths-B9cXh9Wv.mjs +0 -36
  1430. package/dist/redirect-paths-B9cXh9Wv.mjs.map +0 -1
  1431. package/dist/redirects-D3zHoxhn.mjs +0 -446
  1432. package/dist/redirects-D3zHoxhn.mjs.map +0 -1
  1433. package/dist/redirects-dFPJ0HrD.mjs +0 -148
  1434. package/dist/redirects-dFPJ0HrD.mjs.map +0 -1
  1435. package/dist/registry-CDzYrAFY.mjs +0 -6074
  1436. package/dist/registry-CDzYrAFY.mjs.map +0 -1
  1437. package/dist/registry-Cf9vkVxW.mjs +0 -1449
  1438. package/dist/registry-Cf9vkVxW.mjs.map +0 -1
  1439. package/dist/registry-mZi_lxtT.mjs +0 -755
  1440. package/dist/registry-mZi_lxtT.mjs.map +0 -1
  1441. package/dist/relations-Eyop_U4o.mjs +0 -798
  1442. package/dist/relations-Eyop_U4o.mjs.map +0 -1
  1443. package/dist/request-meta-DsSkOdO0.mjs +0 -141
  1444. package/dist/request-meta-DsSkOdO0.mjs.map +0 -1
  1445. package/dist/resolve-s7ANHtFx.mjs +0 -92
  1446. package/dist/resolve-s7ANHtFx.mjs.map +0 -1
  1447. package/dist/revision-D7EedSdU.mjs +0 -503
  1448. package/dist/revision-D7EedSdU.mjs.map +0 -1
  1449. package/dist/rooms-CSNLTJsG.mjs +0 -331
  1450. package/dist/rooms-CSNLTJsG.mjs.map +0 -1
  1451. package/dist/rooms-CVsLla78.mjs +0 -169
  1452. package/dist/rooms-CVsLla78.mjs.map +0 -1
  1453. package/dist/rooms-CyXG83RZ.d.mts +0 -4653
  1454. package/dist/rooms-CyXG83RZ.d.mts.map +0 -1
  1455. package/dist/route-cache-CBpXPq-N.mjs +0 -30
  1456. package/dist/route-cache-CBpXPq-N.mjs.map +0 -1
  1457. package/dist/route-wire-DKSTaEz_.mjs +0 -197
  1458. package/dist/route-wire-DKSTaEz_.mjs.map +0 -1
  1459. package/dist/routes-QcHRiebw.mjs +0 -272
  1460. package/dist/routes-QcHRiebw.mjs.map +0 -1
  1461. package/dist/runner-4BfB04Rg.mjs +0 -6950
  1462. package/dist/runner-4BfB04Rg.mjs.map +0 -1
  1463. package/dist/runner-CAHS_KER.d.mts +0 -79
  1464. package/dist/runner-CAHS_KER.d.mts.map +0 -1
  1465. package/dist/runtime-holder-0g6pqbzx.mjs +0 -36
  1466. package/dist/runtime-holder-0g6pqbzx.mjs.map +0 -1
  1467. package/dist/scheduler-health-C5HEg2Yl.mjs +0 -31
  1468. package/dist/scheduler-health-C5HEg2Yl.mjs.map +0 -1
  1469. package/dist/schema-DS7ooMmp.mjs +0 -13
  1470. package/dist/schema-DS7ooMmp.mjs.map +0 -1
  1471. package/dist/schema-Mjtj7n1t.mjs +0 -815
  1472. package/dist/schema-Mjtj7n1t.mjs.map +0 -1
  1473. package/dist/scopes-BaR6WUyq.mjs +0 -34
  1474. package/dist/scopes-BaR6WUyq.mjs.map +0 -1
  1475. package/dist/search-B9RFgr0N.mjs +0 -450
  1476. package/dist/search-B9RFgr0N.mjs.map +0 -1
  1477. package/dist/secrets-C4UrjPiG.mjs +0 -369
  1478. package/dist/secrets-C4UrjPiG.mjs.map +0 -1
  1479. package/dist/sections-Bfa0oF8Q.mjs +0 -129
  1480. package/dist/sections-Bfa0oF8Q.mjs.map +0 -1
  1481. package/dist/sections-Bn2C6we7.mjs +0 -222
  1482. package/dist/sections-Bn2C6we7.mjs.map +0 -1
  1483. package/dist/seo-DPW6k5_-.mjs +0 -188
  1484. package/dist/seo-DPW6k5_-.mjs.map +0 -1
  1485. package/dist/service-B4mHMku9.mjs +0 -150
  1486. package/dist/service-B4mHMku9.mjs.map +0 -1
  1487. package/dist/session-user-CF2jNfj7.mjs +0 -61
  1488. package/dist/session-user-CF2jNfj7.mjs.map +0 -1
  1489. package/dist/settings-4r88LLIM.mjs +0 -66
  1490. package/dist/settings-4r88LLIM.mjs.map +0 -1
  1491. package/dist/settings-BB2xxz3Y.mjs +0 -74
  1492. package/dist/settings-BB2xxz3Y.mjs.map +0 -1
  1493. package/dist/settings-BTkGl-bX.mjs +0 -413
  1494. package/dist/settings-BTkGl-bX.mjs.map +0 -1
  1495. package/dist/settings-y8Jx8b7g.mjs +0 -157
  1496. package/dist/settings-y8Jx8b7g.mjs.map +0 -1
  1497. package/dist/setup-complete-BGRiC59t.mjs +0 -65
  1498. package/dist/setup-complete-BGRiC59t.mjs.map +0 -1
  1499. package/dist/setup-nonce-D43FsOgZ.mjs +0 -25
  1500. package/dist/setup-nonce-D43FsOgZ.mjs.map +0 -1
  1501. package/dist/site-domain-CFX7g6ik.mjs +0 -131
  1502. package/dist/site-domain-CFX7g6ik.mjs.map +0 -1
  1503. package/dist/site-settings-C0D9fv7e.mjs +0 -50
  1504. package/dist/site-settings-C0D9fv7e.mjs.map +0 -1
  1505. package/dist/site-title-C0JVN6en.mjs +0 -14
  1506. package/dist/site-title-C0JVN6en.mjs.map +0 -1
  1507. package/dist/site-url-DzVnHJ8j.mjs +0 -45
  1508. package/dist/site-url-DzVnHJ8j.mjs.map +0 -1
  1509. package/dist/sitemap-name-Ja_Cvwx9.mjs +0 -26
  1510. package/dist/sitemap-name-Ja_Cvwx9.mjs.map +0 -1
  1511. package/dist/slug-CO2jtUda.mjs +0 -16
  1512. package/dist/slug-CO2jtUda.mjs.map +0 -1
  1513. package/dist/snapshot-C9OWUtFr.mjs +0 -466
  1514. package/dist/snapshot-C9OWUtFr.mjs.map +0 -1
  1515. package/dist/snapshot-CR5tan8p.mjs +0 -184
  1516. package/dist/snapshot-CR5tan8p.mjs.map +0 -1
  1517. package/dist/ssrf-Lj1KZxYt.mjs +0 -406
  1518. package/dist/ssrf-Lj1KZxYt.mjs.map +0 -1
  1519. package/dist/stage-ChbGIslu.mjs +0 -662
  1520. package/dist/stage-ChbGIslu.mjs.map +0 -1
  1521. package/dist/staged-BN8pRZwX.mjs +0 -686
  1522. package/dist/staged-BN8pRZwX.mjs.map +0 -1
  1523. package/dist/state-DtcE0eN3.mjs +0 -178
  1524. package/dist/state-DtcE0eN3.mjs.map +0 -1
  1525. package/dist/storage-query-BDUX3Cef.d.mts +0 -1608
  1526. package/dist/storage-query-BDUX3Cef.d.mts.map +0 -1
  1527. package/dist/tar-CAvEHFbE.mjs +0 -449
  1528. package/dist/tar-CAvEHFbE.mjs.map +0 -1
  1529. package/dist/target-BM_6fT9m.mjs +0 -27
  1530. package/dist/target-BM_6fT9m.mjs.map +0 -1
  1531. package/dist/taxonomies-BMuFLd53.mjs +0 -722
  1532. package/dist/taxonomies-BMuFLd53.mjs.map +0 -1
  1533. package/dist/taxonomies-ClkYcmcH.mjs +0 -937
  1534. package/dist/taxonomies-ClkYcmcH.mjs.map +0 -1
  1535. package/dist/taxonomy-s1GcBCRo.mjs +0 -593
  1536. package/dist/taxonomy-s1GcBCRo.mjs.map +0 -1
  1537. package/dist/tokens-Cpm6FIKJ.mjs +0 -171
  1538. package/dist/tokens-Cpm6FIKJ.mjs.map +0 -1
  1539. package/dist/transaction-SKrr6u84.mjs +0 -44
  1540. package/dist/transaction-SKrr6u84.mjs.map +0 -1
  1541. package/dist/transfer-B3CsI5MG.mjs +0 -8963
  1542. package/dist/transfer-B3CsI5MG.mjs.map +0 -1
  1543. package/dist/transfer-DqUiK3ca.mjs +0 -166
  1544. package/dist/transfer-DqUiK3ca.mjs.map +0 -1
  1545. package/dist/transfer-download-CWPfhL91.mjs +0 -33
  1546. package/dist/transfer-download-CWPfhL91.mjs.map +0 -1
  1547. package/dist/transformations-ClH4dJeM.mjs +0 -196
  1548. package/dist/transformations-ClH4dJeM.mjs.map +0 -1
  1549. package/dist/transport-C6Ps8ejN.mjs +0 -144
  1550. package/dist/transport-C6Ps8ejN.mjs.map +0 -1
  1551. package/dist/transport-D4hWYmO_.d.mts +0 -42
  1552. package/dist/transport-D4hWYmO_.d.mts.map +0 -1
  1553. package/dist/trusted-proxy-CWX1sqgb.mjs +0 -51
  1554. package/dist/trusted-proxy-CWX1sqgb.mjs.map +0 -1
  1555. package/dist/turnstile-B6zM50Mh.mjs +0 -58
  1556. package/dist/turnstile-B6zM50Mh.mjs.map +0 -1
  1557. package/dist/types-Ba3bWb9D.mjs +0 -37
  1558. package/dist/types-Ba3bWb9D.mjs.map +0 -1
  1559. package/dist/types-C0M6z2A4.mjs +0 -16
  1560. package/dist/types-C0M6z2A4.mjs.map +0 -1
  1561. package/dist/types-CG1dR_Cm.d.mts +0 -934
  1562. package/dist/types-CG1dR_Cm.d.mts.map +0 -1
  1563. package/dist/types-CImd8MBY.d.mts +0 -1756
  1564. package/dist/types-CImd8MBY.d.mts.map +0 -1
  1565. package/dist/types-CML-oGr6.d.mts +0 -293
  1566. package/dist/types-CML-oGr6.d.mts.map +0 -1
  1567. package/dist/types-CZO9f_vJ.d.mts +0 -381
  1568. package/dist/types-CZO9f_vJ.d.mts.map +0 -1
  1569. package/dist/types-DLKviL1s.d.mts +0 -93
  1570. package/dist/types-DLKviL1s.d.mts.map +0 -1
  1571. package/dist/types-Df0R58Wu.mjs +0 -77
  1572. package/dist/types-Df0R58Wu.mjs.map +0 -1
  1573. package/dist/types-DwNwhyWP.d.mts +0 -227
  1574. package/dist/types-DwNwhyWP.d.mts.map +0 -1
  1575. package/dist/types-DwZgl0Zn.d.mts +0 -366
  1576. package/dist/types-DwZgl0Zn.d.mts.map +0 -1
  1577. package/dist/types-Dyb_OuSw.d.mts +0 -125
  1578. package/dist/types-Dyb_OuSw.d.mts.map +0 -1
  1579. package/dist/types-iOnPkHRk.d.mts +0 -209
  1580. package/dist/types-iOnPkHRk.d.mts.map +0 -1
  1581. package/dist/upload-attempts-5Ot7-vsw.mjs +0 -32
  1582. package/dist/upload-attempts-5Ot7-vsw.mjs.map +0 -1
  1583. package/dist/url-ZCjpMO-q.mjs +0 -74
  1584. package/dist/url-ZCjpMO-q.mjs.map +0 -1
  1585. package/dist/url-pattern-BQT-sGmD.mjs +0 -41
  1586. package/dist/url-pattern-BQT-sGmD.mjs.map +0 -1
  1587. package/dist/urls-Cq_hUk4P.mjs +0 -79
  1588. package/dist/urls-Cq_hUk4P.mjs.map +0 -1
  1589. package/dist/user-C4km6fox.mjs +0 -184
  1590. package/dist/user-C4km6fox.mjs.map +0 -1
  1591. package/dist/utils-Cpo0_V09.d.mts +0 -374
  1592. package/dist/utils-Cpo0_V09.d.mts.map +0 -1
  1593. package/dist/utils-DMDmdhU3.mjs +0 -450
  1594. package/dist/utils-DMDmdhU3.mjs.map +0 -1
  1595. package/dist/validate-BNupiQtz.mjs +0 -524
  1596. package/dist/validate-BNupiQtz.mjs.map +0 -1
  1597. package/dist/validate-DBfkJa3O.d.mts +0 -472
  1598. package/dist/validate-DBfkJa3O.d.mts.map +0 -1
  1599. package/dist/validation-W_efZFgP.mjs +0 -204
  1600. package/dist/validation-W_efZFgP.mjs.map +0 -1
  1601. package/dist/version-C61rw8-y.mjs +0 -9
  1602. package/dist/version-C61rw8-y.mjs.map +0 -1
  1603. package/dist/version-DhGLeLRo.mjs +0 -7
  1604. package/dist/version-DhGLeLRo.mjs.map +0 -1
  1605. package/dist/version-eqLBDtcz.mjs +0 -49
  1606. package/dist/version-eqLBDtcz.mjs.map +0 -1
  1607. package/dist/video-My3h7vwE.mjs +0 -18
  1608. package/dist/video-My3h7vwE.mjs.map +0 -1
  1609. package/dist/virtual-modules-BZKqvjRC.mjs +0 -568
  1610. package/dist/virtual-modules-BZKqvjRC.mjs.map +0 -1
  1611. package/dist/widgets-DAdni19y.mjs +0 -134
  1612. package/dist/widgets-DAdni19y.mjs.map +0 -1
  1613. package/dist/wxr-DDPJOgkM.mjs +0 -1054
  1614. package/dist/wxr-DDPJOgkM.mjs.map +0 -1
  1615. package/dist/wxr-taxonomies-B0U2fJgs.mjs +0 -735
  1616. package/dist/wxr-taxonomies-B0U2fJgs.mjs.map +0 -1
  1617. package/dist/wxr-taxonomies-CyP2k4-Q.d.mts +0 -34
  1618. package/dist/wxr-taxonomies-CyP2k4-Q.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["isRecord","generateKey","convertList","convertCodeBlock","convertImage","convertListItem","isFrameDimension","imageDimension","resolveExclusiveHooksShared","ulid"],"sources":["../src/fields/image.ts","../src/fields/file.ts","../src/fields/reference.ts","../src/fields/portable-text.ts","../src/content/converters/mark-safety.ts","../src/content/converters/numbered-list.ts","../src/content/converters/portable-text-identity.ts","../src/content/converters/prosemirror-to-portable-text.ts","../src/content/converters/image-link.ts","../src/content/converters/portable-text-to-prosemirror.ts","../src/plugins/manager.ts","../src/plugins/scheduler/node.ts","../src/plugins/sandbox/noop.ts","../src/import/sections.ts","../src/preview/helpers.ts","../src/comments/ranking.ts","../src/comments/query.ts"],"sourcesContent":["import { z } from \"astro/zod\";\n\nimport type { FieldDefinition, ImageValue } from \"./types.js\";\n\nconst mediaSchema = z.object({\n\tid: z.string(),\n\tsrc: z.string().optional(),\n\talt: z.string().optional(),\n\tcaption: z.string().optional(),\n\twidth: z.number().optional(),\n\theight: z.number().optional(),\n\tfilename: z.string().optional(),\n\tmimeType: z.string().optional(),\n\tblurhash: z.string().optional(),\n\tdominantColor: z.string().optional(),\n\tfocalX: z.number().optional(),\n\tfocalY: z.number().optional(),\n\tprovider: z.string().optional(),\n\tpreviewUrl: z.string().optional(),\n\tmeta: z.record(z.string(), z.unknown()).optional(),\n});\n\nconst imageSchema = mediaSchema.extend({\n\tdarkVariant: mediaSchema.optional(),\n});\n\nexport interface ImageOptions {\n\trequired?: boolean;\n\tmaxSize?: number; // in bytes\n\tallowedTypes?: string[]; // MIME types — exact or prefix\n\t/** Offer editors a second slot for a dark-color-scheme counterpart of the image. */\n\tdarkVariant?: boolean;\n}\n\nexport function image(options: ImageOptions = {}): FieldDefinition<ImageValue | undefined> {\n\tconst validation =\n\t\toptions.allowedTypes && options.allowedTypes.length > 0\n\t\t\t? { allowedMimeTypes: [...options.allowedTypes] }\n\t\t\t: undefined;\n\n\treturn {\n\t\ttype: \"image\",\n\t\tcolumnType: \"TEXT\",\n\t\tschema: options.required === false ? imageSchema.optional() : imageSchema,\n\t\toptions,\n\t\tui: {\n\t\t\twidget: \"image\",\n\t\t},\n\t\tvalidation,\n\t};\n}\n","import { z } from \"astro/zod\";\n\nimport type { FieldDefinition, FieldUIHints, FileValue } from \"./types.js\";\n\nexport interface FileOptions {\n\trequired?: boolean;\n\tmaxSize?: number; // In bytes\n\tallowedTypes?: string[]; // MIME types — exact (image/png) or prefix (image/)\n\thelpText?: string;\n}\n\nexport function file(options: FileOptions = {}): FieldDefinition<FileValue> {\n\tconst fileObjSchema = z.object({\n\t\tid: z.string(),\n\t\turl: z.string().optional(),\n\t\tsrc: z.string().optional(),\n\t\tfilename: z.string().optional(),\n\t\tmimeType: z.string().optional(),\n\t\tsize: z.number().optional(),\n\t\tprovider: z.string().optional(),\n\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t});\n\n\tconst schema: z.ZodType = options.required ? fileObjSchema : fileObjSchema.optional();\n\n\tconst ui: FieldUIHints = {\n\t\twidget: \"file\",\n\t\thelpText: options.helpText,\n\t\tmaxSize: options.maxSize,\n\t};\n\n\tconst validation =\n\t\toptions.allowedTypes && options.allowedTypes.length > 0\n\t\t\t? { allowedMimeTypes: [...options.allowedTypes] }\n\t\t\t: undefined;\n\n\treturn {\n\t\ttype: \"file\",\n\t\tcolumnType: \"TEXT\",\n\t\tschema,\n\t\toptions,\n\t\tui,\n\t\tvalidation,\n\t};\n}\n","import { z } from \"astro/zod\";\n\nimport type { FieldDefinition } from \"./types.js\";\n\n/**\n * Reference field\n * References another content item by ID\n */\nexport function reference(\n\tcollection: string,\n\toptions?: {\n\t\trequired?: boolean;\n\t},\n): FieldDefinition<string | undefined> {\n\tconst schema = z.string();\n\n\treturn {\n\t\ttype: \"reference\",\n\t\tcolumnType: \"TEXT\",\n\t\tschema: options?.required === false ? schema.optional() : schema,\n\t\toptions: {\n\t\t\t...options,\n\t\t\tcollection,\n\t\t},\n\t\tui: {\n\t\t\twidget: \"reference\",\n\t\t},\n\t};\n}\n","import { z } from \"astro/zod\";\n\nimport type { FieldDefinition, PortableTextBlock } from \"./types.js\";\n\n/**\n * Portable Text block schema\n */\nconst portableTextBlockSchema: z.ZodType<PortableTextBlock> = z\n\t.object({\n\t\t_type: z.string(),\n\t\t_key: z.string(),\n\t})\n\t.loose();\n\n/**\n * Portable Text field\n * Stores structured content in Portable Text format\n */\nexport function portableText(options?: {\n\trequired?: boolean;\n}): FieldDefinition<PortableTextBlock[] | undefined> {\n\tconst schema = z.array(portableTextBlockSchema);\n\n\treturn {\n\t\ttype: \"portableText\",\n\t\tcolumnType: \"JSON\",\n\t\tschema: options?.required === false ? schema.optional() : schema,\n\t\toptions,\n\t\tui: {\n\t\t\twidget: \"portableText\",\n\t\t},\n\t};\n}\n","import type { ProseMirrorDocument, ProseMirrorNode } from \"./types.js\";\n\nconst SUPPORTED_PORTABLE_TEXT_DECORATORS = new Set([\n\t\"strong\",\n\t\"em\",\n\t\"underline\",\n\t\"strike-through\",\n\t\"subscript\",\n\t\"superscript\",\n\t\"code\",\n]);\n\nconst SUPPORTED_PROSEMIRROR_MARKS = new Set([\n\t\"bold\",\n\t\"strong\",\n\t\"italic\",\n\t\"em\",\n\t\"underline\",\n\t\"strike\",\n\t\"strikethrough\",\n\t\"subscript\",\n\t\"superscript\",\n\t\"code\",\n\t\"link\",\n\t\"emdashPortableTextSpan\",\n]);\n\ntype UnknownRecord = Record<string, unknown>;\n\nfunction isRecord(value: unknown): value is UnknownRecord {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction collectPortableTextMarks(\n\tvalue: unknown,\n\tinheritedMarkDefs: ReadonlyMap<string, UnknownRecord>,\n\tunsupported: Set<string>,\n): void {\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tcollectPortableTextMarks(item, inheritedMarkDefs, unsupported);\n\t\t}\n\t\treturn;\n\t}\n\tif (!isRecord(value)) return;\n\n\tlet markDefs: ReadonlyMap<string, UnknownRecord> = inheritedMarkDefs;\n\tif (Array.isArray(value.markDefs)) {\n\t\tconst localMarkDefs = new Map(inheritedMarkDefs);\n\t\tfor (const markDef of value.markDefs) {\n\t\t\tif (isRecord(markDef) && typeof markDef._key === \"string\") {\n\t\t\t\tlocalMarkDefs.set(markDef._key, markDef);\n\t\t\t}\n\t\t}\n\t\tmarkDefs = localMarkDefs;\n\t}\n\n\tif (value._type === \"span\" && Array.isArray(value.marks)) {\n\t\tfor (const mark of value.marks) {\n\t\t\tif (typeof mark !== \"string\" || SUPPORTED_PORTABLE_TEXT_DECORATORS.has(mark)) continue;\n\t\t\tconst markDef = markDefs.get(mark);\n\t\t\tif (markDef?._type === \"link\") continue;\n\t\t\tunsupported.add(typeof markDef?._type === \"string\" ? markDef._type : mark);\n\t\t}\n\t}\n\n\tfor (const [key, child] of Object.entries(value)) {\n\t\tif (key !== \"markDefs\") {\n\t\t\tcollectPortableTextMarks(child, markDefs, unsupported);\n\t\t}\n\t}\n}\n\nfunction collectProseMirrorMarks(node: ProseMirrorNode, unsupported: Set<string>): void {\n\tfor (const mark of node.marks ?? []) {\n\t\tif (!SUPPORTED_PROSEMIRROR_MARKS.has(mark.type)) {\n\t\t\tunsupported.add(mark.type);\n\t\t}\n\t}\n\tfor (const child of node.content ?? []) {\n\t\tcollectProseMirrorMarks(child, unsupported);\n\t}\n}\n\nexport class UnsupportedPortableTextMarksError extends Error {\n\treadonly marks: string[];\n\n\tconstructor(marks: Iterable<string>) {\n\t\tconst sortedMarks = [...new Set(marks)].toSorted();\n\t\tsuper(`Unsupported Portable Text marks: ${sortedMarks.join(\", \")}`);\n\t\tthis.name = \"UnsupportedPortableTextMarksError\";\n\t\tthis.marks = sortedMarks;\n\t}\n}\n\nexport function findUnsupportedPortableTextMarks(blocks: readonly { _type: string }[]): string[] {\n\tconst unsupported = new Set<string>();\n\tfor (const block of blocks) {\n\t\tif (block._type === \"block\" || block._type === \"table\") {\n\t\t\tcollectPortableTextMarks(block, new Map(), unsupported);\n\t\t}\n\t}\n\treturn [...unsupported].toSorted();\n}\n\nexport function assertPortableTextMarksSupported(blocks: readonly { _type: string }[]): void {\n\tconst unsupported = findUnsupportedPortableTextMarks(blocks);\n\tif (unsupported.length > 0) {\n\t\tthrow new UnsupportedPortableTextMarksError(unsupported);\n\t}\n}\n\nexport function assertProseMirrorMarksSupported(document: ProseMirrorDocument): void {\n\tconst unsupported = new Set<string>();\n\tfor (const node of document.content) {\n\t\tcollectProseMirrorMarks(node, unsupported);\n\t}\n\tif (unsupported.size > 0) {\n\t\tthrow new UnsupportedPortableTextMarksError(unsupported);\n\t}\n}\n","import type { ProseMirrorDocument, ProseMirrorNode } from \"./types.js\";\n\nexport const MAX_ORDERED_LIST_START = 2_147_483_647;\n\nexport interface OrderedListMetadata {\n\tlistId: string;\n\tlistStart: number;\n}\n\nexport function normalizeListId(value: unknown): string | undefined {\n\tif (typeof value !== \"string\") return undefined;\n\tconst normalized = value.trim();\n\treturn normalized.length > 0 && normalized.length <= 128 ? normalized : undefined;\n}\n\nexport function normalizeListStart(value: unknown): number | undefined {\n\treturn typeof value === \"number\" &&\n\t\tNumber.isInteger(value) &&\n\t\tvalue >= 1 &&\n\t\tvalue <= MAX_ORDERED_LIST_START\n\t\t? value\n\t\t: undefined;\n}\n\nexport function deriveLegacyListId(seed: string): string {\n\tconst readable = `legacy:${seed}`;\n\tif (readable.length <= 128) return readable;\n\tlet hash = 2_166_136_261;\n\tfor (let i = 0; i < seed.length; i++) {\n\t\thash ^= seed.charCodeAt(i);\n\t\thash = Math.imul(hash, 16_777_619);\n\t}\n\treturn `legacy:${seed.slice(0, 96)}:${(hash >>> 0).toString(36)}:${seed.length.toString(36)}`;\n}\n\nexport function readOrderedListMetadata(\n\tattrs: Record<string, unknown> | undefined,\n\tfallbackId: string,\n): OrderedListMetadata {\n\treturn {\n\t\tlistId: normalizeListId(attrs?.listId) ?? deriveLegacyListId(fallbackId),\n\t\tlistStart: normalizeListStart(attrs?.listStart) ?? normalizeListStart(attrs?.start) ?? 1,\n\t};\n}\n\ninterface ProseMirrorListDescriptor {\n\tnode: ProseMirrorNode;\n\tpath: string;\n\tdepth: number;\n\tcontext: string;\n}\n\nfunction collectProseMirrorOrderedLists(doc: ProseMirrorDocument): ProseMirrorListDescriptor[] {\n\tconst lists: ProseMirrorListDescriptor[] = [];\n\tconst visit = (node: ProseMirrorNode, path: string, depth: number, context: string) => {\n\t\tif (node.type === \"orderedList\") lists.push({ node, path, depth, context });\n\t\tfor (const [index, child] of (node.content ?? []).entries()) {\n\t\t\tconst childPath = `${path}:${index}`;\n\t\t\tvisit(\n\t\t\t\tchild,\n\t\t\t\tchildPath,\n\t\t\t\tdepth + 1,\n\t\t\t\tchild.type === \"listItem\" ? `listItem:${childPath}` : context,\n\t\t\t);\n\t\t}\n\t};\n\tfor (const [index, node] of doc.content.entries()) {\n\t\tvisit(node, `root:${index}`, 0, \"root\");\n\t}\n\treturn lists;\n}\n\nfunction cloneProseMirrorNode(node: ProseMirrorNode): ProseMirrorNode {\n\treturn {\n\t\t...node,\n\t\tattrs: node.attrs ? { ...node.attrs } : undefined,\n\t\tcontent: node.content?.map(cloneProseMirrorNode),\n\t\tmarks: node.marks?.map((mark) => ({\n\t\t\t...mark,\n\t\t\tattrs: mark.attrs ? { ...mark.attrs } : undefined,\n\t\t})),\n\t};\n}\n\nfunction createRepairId(sourceId: string, scope: string, attempt: number): string {\n\tconst base = deriveLegacyListId(`repair:${sourceId}:${scope}`);\n\tconst suffix = `:${attempt.toString(36)}`;\n\treturn `${base.slice(0, 128 - suffix.length)}${suffix}`;\n}\n\nexport function normalizeProseMirrorOrderedListJson(doc: ProseMirrorDocument): ProseMirrorDocument {\n\tconst normalized = {\n\t\t...doc,\n\t\tcontent: doc.content.map(cloneProseMirrorNode),\n\t};\n\tconst canonicalBySourceScope = new Map<string, string>();\n\tconst assignedCanonicalIds = new Set<string>();\n\tconst lists = collectProseMirrorOrderedLists(normalized).map((list) => {\n\t\tconst sourceId =\n\t\t\tnormalizeListId(list.node.attrs?.listId) ??\n\t\t\tderiveLegacyListId(`pm-json:${list.path}:${list.depth}:${list.context}`);\n\t\tconst scope = JSON.stringify([list.depth, list.context]);\n\t\tconst sourceScope = JSON.stringify([sourceId, scope]);\n\t\tlet listId = canonicalBySourceScope.get(sourceScope);\n\t\tif (!listId) {\n\t\t\tif (!assignedCanonicalIds.has(sourceId)) {\n\t\t\t\tlistId = sourceId;\n\t\t\t} else {\n\t\t\t\tlet attempt = 0;\n\t\t\t\tdo {\n\t\t\t\t\tlistId = createRepairId(sourceId, scope, attempt++);\n\t\t\t\t} while (assignedCanonicalIds.has(listId));\n\t\t\t}\n\t\t\tcanonicalBySourceScope.set(sourceScope, listId);\n\t\t\tassignedCanonicalIds.add(listId);\n\t\t}\n\t\treturn {\n\t\t\t...list,\n\t\t\tlistId,\n\t\t\tscopeKey: JSON.stringify([listId, list.depth, list.context]),\n\t\t};\n\t});\n\n\tconst bases = new Map<string, number>();\n\tfor (const list of lists) {\n\t\tconst listStart = normalizeListStart(list.node.attrs?.listStart);\n\t\tif (listStart !== undefined && !bases.has(list.scopeKey)) {\n\t\t\tbases.set(list.scopeKey, listStart);\n\t\t}\n\t}\n\tfor (const list of lists) {\n\t\tif (!bases.has(list.scopeKey)) {\n\t\t\tbases.set(list.scopeKey, normalizeListStart(list.node.attrs?.start) ?? 1);\n\t\t}\n\t}\n\n\tconst counts = new Map<string, number>();\n\tfor (const list of lists) {\n\t\tconst listStart = bases.get(list.scopeKey)!;\n\t\tconst count = counts.get(list.scopeKey) ?? 0;\n\t\tconst start = normalizeListStart(listStart + count) ?? 1;\n\t\tconst directItemCount =\n\t\t\tlist.node.content?.filter((node) => node.type === \"listItem\").length ?? 0;\n\t\tcounts.set(list.scopeKey, count + directItemCount);\n\t\tlist.node.attrs = { ...list.node.attrs, listId: list.listId, listStart, start };\n\t}\n\treturn normalized;\n}\n","import { Extension, Mark, Node, type Extensions } from \"@tiptap/core\";\n\nimport type { PortableTextBlock, PortableTextMarkDef } from \"./types.js\";\n\nexport const PORTABLE_TEXT_BLOCK_NODE = \"emdashPortableTextBlock\";\nexport const PORTABLE_TEXT_BLOCK_ATTR = \"emdashPortableTextBlock\";\nexport const PORTABLE_TEXT_KEY_ATTR = \"emdashPortableTextKey\";\nexport const PORTABLE_TEXT_SPAN_MARK = \"emdashPortableTextSpan\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function attrsWithPortableTextKey(\n\tattrs: Record<string, unknown> | undefined,\n\tkey: string,\n): Record<string, unknown> {\n\treturn { ...attrs, [PORTABLE_TEXT_KEY_ATTR]: key };\n}\n\nexport function portableTextKeyFromAttrs(\n\tattrs: Record<string, unknown> | undefined,\n): string | undefined {\n\tconst key = attrs?.[PORTABLE_TEXT_KEY_ATTR];\n\treturn typeof key === \"string\" && key ? key : undefined;\n}\n\nexport function portableTextSpanKeyFromMarks(marks: unknown[] | undefined): string | undefined {\n\tfor (const mark of marks ?? []) {\n\t\tif (!isRecord(mark) || mark.type !== PORTABLE_TEXT_SPAN_MARK || !isRecord(mark.attrs)) continue;\n\t\tconst key = mark.attrs.key;\n\t\tif (typeof key === \"string\" && key) return key;\n\t}\n\treturn undefined;\n}\n\nexport function portableTextMarkDefsFromMarks(marks: unknown[] | undefined): PortableTextMarkDef[] {\n\tconst identity = (marks ?? []).find(\n\t\t(mark) => isRecord(mark) && mark.type === PORTABLE_TEXT_SPAN_MARK && isRecord(mark.attrs),\n\t);\n\tif (!isRecord(identity) || !isRecord(identity.attrs) || !Array.isArray(identity.attrs.markDefs)) {\n\t\treturn [];\n\t}\n\treturn identity.attrs.markDefs.filter(\n\t\t(markDef): markDef is PortableTextMarkDef =>\n\t\t\tisRecord(markDef) && typeof markDef._type === \"string\" && typeof markDef._key === \"string\",\n\t);\n}\n\nexport function portableTextBlockFromAttrs(\n\tattrs: Record<string, unknown> | undefined,\n): PortableTextBlock | undefined {\n\tconst block = attrs?.[PORTABLE_TEXT_BLOCK_ATTR];\n\tif (!isRecord(block) || typeof block._type !== \"string\" || typeof block._key !== \"string\") {\n\t\treturn undefined;\n\t}\n\treturn { ...block, _type: block._type, _key: block._key };\n}\n\nexport const PortableTextIdentityExtension = Extension.create({\n\tname: \"emdashPortableTextIdentity\",\n\n\taddGlobalAttributes() {\n\t\tconst hiddenAttribute = { default: null, rendered: false };\n\t\treturn [\n\t\t\t{\n\t\t\t\ttypes: [\n\t\t\t\t\t\"paragraph\",\n\t\t\t\t\t\"heading\",\n\t\t\t\t\t\"blockquote\",\n\t\t\t\t\t\"codeBlock\",\n\t\t\t\t\t\"htmlBlock\",\n\t\t\t\t\t\"iframeBlock\",\n\t\t\t\t\t\"image\",\n\t\t\t\t\t\"videoBlock\",\n\t\t\t\t\t\"horizontalRule\",\n\t\t\t\t\t\"gallery\",\n\t\t\t\t\tPORTABLE_TEXT_BLOCK_NODE,\n\t\t\t\t],\n\t\t\t\tattributes: { [PORTABLE_TEXT_KEY_ATTR]: hiddenAttribute },\n\t\t\t},\n\t\t];\n\t},\n});\n\nexport const PortableTextSpanIdentity = Mark.create({\n\tname: PORTABLE_TEXT_SPAN_MARK,\n\tinclusive: false,\n\tspanning: false,\n\n\taddAttributes() {\n\t\treturn {\n\t\t\tkey: { default: null, rendered: false },\n\t\t\tmarkDefs: { default: [], rendered: false },\n\t\t};\n\t},\n\n\tparseHTML() {\n\t\treturn [];\n\t},\n\n\trenderHTML() {\n\t\treturn [\"span\", 0];\n\t},\n});\n\nexport const PortableTextOpaqueBlock = Node.create({\n\tname: PORTABLE_TEXT_BLOCK_NODE,\n\tgroup: \"block\",\n\tatom: true,\n\tselectable: true,\n\tdraggable: true,\n\n\taddAttributes() {\n\t\treturn {\n\t\t\t[PORTABLE_TEXT_BLOCK_ATTR]: { default: null, rendered: false },\n\t\t};\n\t},\n\n\tparseHTML() {\n\t\treturn [{ tag: \"div[data-emdash-portable-text-block]\" }];\n\t},\n\n\trenderHTML({ node }) {\n\t\tconst blockType = portableTextBlockFromAttrs(node.attrs)?._type ?? \"unknown\";\n\t\treturn [\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\t\"data-emdash-portable-text-block\": blockType,\n\t\t\t\tcontenteditable: \"false\",\n\t\t\t},\n\t\t\t`[Unknown block type: ${blockType}]`,\n\t\t];\n\t},\n});\n\nexport const portableTextIdentityExtensions: Extensions = [\n\tPortableTextIdentityExtension,\n\tPortableTextSpanIdentity,\n\tPortableTextOpaqueBlock,\n];\n","/**\n * ProseMirror to Portable Text Converter\n *\n * Converts TipTap's ProseMirror JSON format to Portable Text for storage.\n */\n\nimport { htmlBlockFields } from \"@emdash-cms/admin/html-block\";\nimport {\n\tUnsafePortableTextTableError,\n\tproseMirrorTableToPortableText,\n} from \"@emdash-cms/admin/portable-text-table\";\n\nimport { sanitizeGalleryImages } from \"./gallery.js\";\nimport {\n\tUnsupportedPortableTextMarksError,\n\tassertProseMirrorMarksSupported,\n} from \"./mark-safety.js\";\nimport { readOrderedListMetadata, type OrderedListMetadata } from \"./numbered-list.js\";\nimport {\n\tPORTABLE_TEXT_BLOCK_NODE,\n\tPORTABLE_TEXT_SPAN_MARK,\n\tportableTextBlockFromAttrs,\n\tportableTextKeyFromAttrs,\n\tportableTextMarkDefsFromMarks,\n\tportableTextSpanKeyFromMarks,\n} from \"./portable-text-identity.js\";\nimport type {\n\tProseMirrorDocument,\n\tProseMirrorNode,\n\tProseMirrorMark,\n\tPortableTextBlock,\n\tPortableTextTextBlock,\n\tPortableTextSpan,\n\tPortableTextMarkDef,\n\tPortableTextImageBlock,\n\tPortableTextGalleryBlock,\n\tPortableTextCodeBlock,\n\tPortableTextHtmlBlock,\n\tPortableTextIframeBlock,\n\tPortableTextVideoBlock,\n} from \"./types.js\";\nimport { videoBlockFields } from \"./video.js\";\n\n/**\n * Generate a unique key for Portable Text blocks\n */\nfunction generateKey(): string {\n\treturn Math.random().toString(36).substring(2, 11);\n}\n\n/**\n * Convert ProseMirror document to Portable Text\n */\nexport function prosemirrorToPortableText(doc: ProseMirrorDocument): PortableTextBlock[] {\n\tif (!doc || doc.type !== \"doc\" || !doc.content) {\n\t\treturn [];\n\t}\n\tassertProseMirrorMarksSupported(doc);\n\n\tconst blocks: PortableTextBlock[] = [];\n\tconst usedBlockKeys = new Set<string>();\n\n\tfor (const [i, node] of doc.content.entries()) {\n\t\tif (i === doc.content.length - 1 && isUnkeyedEmptyParagraph(node)) continue;\n\t\tconst converted = convertNode(node, `root:${i}`);\n\t\tfor (const block of converted ? (Array.isArray(converted) ? converted : [converted]) : []) {\n\t\t\tlet key = block._key;\n\t\t\tif (usedBlockKeys.has(key)) {\n\t\t\t\tdo key = generateKey();\n\t\t\t\twhile (usedBlockKeys.has(key));\n\t\t\t}\n\t\t\tusedBlockKeys.add(key);\n\t\t\tblocks.push(key === block._key ? block : { ...block, _key: key });\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\nfunction isUnkeyedEmptyParagraph(node: ProseMirrorNode): boolean {\n\treturn (\n\t\tnode.type === \"paragraph\" &&\n\t\t(node.content?.length ?? 0) === 0 &&\n\t\tportableTextKeyFromAttrs(node.attrs) === undefined\n\t);\n}\n\n/**\n * Convert a single ProseMirror node to Portable Text block(s)\n */\nfunction convertNode(\n\tnode: ProseMirrorNode,\n\tpath: string,\n): PortableTextBlock | PortableTextBlock[] | null {\n\tswitch (node.type) {\n\t\tcase PORTABLE_TEXT_BLOCK_NODE:\n\t\t\treturn portableTextBlockFromAttrs(node.attrs) ?? null;\n\n\t\tcase \"paragraph\":\n\t\t\treturn convertParagraph(node);\n\n\t\tcase \"heading\":\n\t\t\treturn convertHeading(node);\n\n\t\tcase \"bulletList\":\n\t\t\treturn convertList(node, \"bullet\", path);\n\n\t\tcase \"orderedList\":\n\t\t\treturn convertList(node, \"number\", path);\n\n\t\tcase \"blockquote\":\n\t\t\treturn convertBlockquote(node);\n\n\t\tcase \"codeBlock\":\n\t\t\treturn convertCodeBlock(node);\n\n\t\tcase \"htmlBlock\":\n\t\t\treturn convertHtmlBlock(node);\n\n\t\tcase \"iframeBlock\":\n\t\t\treturn convertIframeBlock(node);\n\n\t\tcase \"image\":\n\t\t\treturn convertImage(node);\n\n\t\tcase \"videoBlock\":\n\t\t\treturn convertVideo(node);\n\n\t\tcase \"gallery\":\n\t\t\treturn convertGallery(node);\n\n\t\tcase \"table\": {\n\t\t\tconst result = proseMirrorTableToPortableText(node, {\n\t\t\t\tpath,\n\t\t\t\tcreateKey: generateKey,\n\t\t\t\tinlineToSpans: (content) => {\n\t\t\t\t\tconst { children, markDefs } = convertInlineContent(content, true);\n\t\t\t\t\treturn { content: children, markDefs };\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (!result.ok) {\n\t\t\t\tthrow new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);\n\t\t\t}\n\t\t\treturn result.table;\n\t\t}\n\n\t\tcase \"horizontalRule\":\n\t\t\treturn {\n\t\t\t\t_type: \"break\",\n\t\t\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\t\t\tstyle: \"lineBreak\",\n\t\t\t};\n\n\t\tdefault:\n\t\t\t// Preserve unknown blocks\n\t\t\treturn {\n\t\t\t\t_type: node.type,\n\t\t\t\t_key: generateKey(),\n\t\t\t\t...node.attrs,\n\t\t\t\t_pmContent: node.content,\n\t\t\t};\n\t}\n}\n\n/**\n * Convert paragraph to Portable Text block\n */\nfunction convertParagraph(node: ProseMirrorNode): PortableTextTextBlock | null {\n\tconst { children, markDefs } = convertInlineContent(node.content || []);\n\n\t// Skip empty paragraphs\n\tif (children.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst ta = node.attrs?.textAlign;\n\tconst textAlign = ta === \"center\" || ta === \"right\" || ta === \"justify\" ? ta : undefined;\n\n\treturn {\n\t\t_type: \"block\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tstyle: \"normal\",\n\t\tchildren,\n\t\t...(markDefs.length > 0 ? { markDefs } : {}),\n\t\t...(textAlign ? { textAlign } : {}),\n\t};\n}\n\n/** Map heading level number to Portable Text style */\nfunction headingLevelToStyle(level: number): PortableTextTextBlock[\"style\"] {\n\tswitch (level) {\n\t\tcase 1:\n\t\t\treturn \"h1\";\n\t\tcase 2:\n\t\t\treturn \"h2\";\n\t\tcase 3:\n\t\t\treturn \"h3\";\n\t\tcase 4:\n\t\t\treturn \"h4\";\n\t\tcase 5:\n\t\t\treturn \"h5\";\n\t\tcase 6:\n\t\t\treturn \"h6\";\n\t\tdefault:\n\t\t\treturn \"h1\";\n\t}\n}\n\n/**\n * Convert heading to Portable Text block\n */\nfunction convertHeading(node: ProseMirrorNode): PortableTextTextBlock | null {\n\tconst { children, markDefs } = convertInlineContent(node.content || []);\n\tconst rawLevel = typeof node.attrs?.level === \"number\" ? node.attrs.level : 1;\n\tconst style = headingLevelToStyle(rawLevel);\n\n\tif (children.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst ta = node.attrs?.textAlign;\n\tconst textAlign = ta === \"center\" || ta === \"right\" || ta === \"justify\" ? ta : undefined;\n\n\treturn {\n\t\t_type: \"block\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tstyle,\n\t\tchildren,\n\t\tmarkDefs: markDefs.length > 0 ? markDefs : undefined,\n\t\t...(textAlign ? { textAlign } : {}),\n\t};\n}\n\n/**\n * Convert list to Portable Text blocks\n */\nfunction convertList(\n\tnode: ProseMirrorNode,\n\tlistItem: \"bullet\" | \"number\",\n\tpath: string,\n): PortableTextTextBlock[] {\n\tconst blocks: PortableTextTextBlock[] = [];\n\tconst metadata = listItem === \"number\" ? readOrderedListMetadata(node.attrs, path) : undefined;\n\n\tfor (const [i, item] of (node.content ?? []).entries()) {\n\t\tif (item.type === \"listItem\") {\n\t\t\tconst itemBlocks = convertListItem(item, listItem, 1, `${path}:${i}`, metadata);\n\t\t\tblocks.push(...itemBlocks);\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Convert list item to Portable Text blocks\n */\nfunction convertListItem(\n\titem: ProseMirrorNode,\n\tlistItem: \"bullet\" | \"number\",\n\tlevel: number,\n\tpath: string,\n\tmetadata?: OrderedListMetadata,\n): PortableTextTextBlock[] {\n\tconst blocks: PortableTextTextBlock[] = [];\n\n\tfor (const [i, child] of (item.content ?? []).entries()) {\n\t\tif (child.type === \"paragraph\") {\n\t\t\tconst { children, markDefs } = convertInlineContent(child.content || []);\n\n\t\t\tif (children.length > 0) {\n\t\t\t\tblocks.push({\n\t\t\t\t\t_type: \"block\",\n\t\t\t\t\t_key: portableTextKeyFromAttrs(child.attrs) ?? generateKey(),\n\t\t\t\t\tstyle: \"normal\",\n\t\t\t\t\tlistItem,\n\t\t\t\t\tlevel,\n\t\t\t\t\t...metadata,\n\t\t\t\t\tchildren,\n\t\t\t\t\tmarkDefs: markDefs.length > 0 ? markDefs : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (child.type === \"bulletList\") {\n\t\t\tblocks.push(...convertListItemNested(child, \"bullet\", level + 1, `${path}:${i}`));\n\t\t} else if (child.type === \"orderedList\") {\n\t\t\tblocks.push(...convertListItemNested(child, \"number\", level + 1, `${path}:${i}`));\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Convert nested list\n */\nfunction convertListItemNested(\n\tnode: ProseMirrorNode,\n\tlistItem: \"bullet\" | \"number\",\n\tlevel: number,\n\tpath: string,\n): PortableTextTextBlock[] {\n\tconst blocks: PortableTextTextBlock[] = [];\n\tconst metadata = listItem === \"number\" ? readOrderedListMetadata(node.attrs, path) : undefined;\n\n\tfor (const [i, item] of (node.content ?? []).entries()) {\n\t\tif (item.type === \"listItem\") {\n\t\t\tblocks.push(...convertListItem(item, listItem, level, `${path}:${i}`, metadata));\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Convert blockquote to Portable Text blocks\n */\nfunction convertBlockquote(\n\tnode: ProseMirrorNode,\n): PortableTextTextBlock | PortableTextTextBlock[] | null {\n\t// Blockquotes in PT are just blocks with style: \"blockquote\"\n\tconst blocks: PortableTextTextBlock[] = [];\n\n\tfor (const child of node.content || []) {\n\t\tif (child.type === \"paragraph\") {\n\t\t\tconst { children, markDefs } = convertInlineContent(child.content || []);\n\n\t\t\tif (children.length > 0) {\n\t\t\t\tblocks.push({\n\t\t\t\t\t_type: \"block\",\n\t\t\t\t\t_key:\n\t\t\t\t\t\tportableTextKeyFromAttrs(child.attrs) ??\n\t\t\t\t\t\tportableTextKeyFromAttrs(node.attrs) ??\n\t\t\t\t\t\tgenerateKey(),\n\t\t\t\t\tstyle: \"blockquote\",\n\t\t\t\t\tchildren,\n\t\t\t\t\tmarkDefs: markDefs.length > 0 ? markDefs : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn blocks.length === 1 ? blocks[0] : blocks.length > 0 ? blocks : null;\n}\n\n/**\n * Convert code block to Portable Text\n */\nfunction convertCodeBlock(node: ProseMirrorNode): PortableTextCodeBlock {\n\tconst code = node.content?.map((n) => n.text || \"\").join(\"\") || \"\";\n\tconst language = typeof node.attrs?.language === \"string\" ? node.attrs.language : undefined;\n\n\treturn {\n\t\t_type: \"code\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tcode,\n\t\tlanguage: language || undefined,\n\t};\n}\n\n/**\n * Convert HTML block to Portable Text\n */\nfunction convertHtmlBlock(node: ProseMirrorNode): PortableTextHtmlBlock {\n\treturn {\n\t\t_type: \"htmlBlock\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\t...htmlBlockFields(node.attrs ?? {}),\n\t};\n}\n\n/**\n * Convert iframe block to Portable Text, writing optional fields only when set\n */\nfunction convertIframeBlock(node: ProseMirrorNode): PortableTextIframeBlock {\n\tconst { src, title, width, height, allow, allowFullscreen } = node.attrs ?? {};\n\tconst block: PortableTextIframeBlock = {\n\t\t_type: \"iframe\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tsrc: typeof src === \"string\" ? src : \"\",\n\t};\n\tif (typeof title === \"string\" && title) block.title = title;\n\tif (isFrameDimension(width)) block.width = width;\n\tif (isFrameDimension(height)) block.height = height;\n\tif (typeof allow === \"string\" && allow) block.allow = allow;\n\tif (allowFullscreen === true) block.allowFullscreen = true;\n\treturn block;\n}\n\n/**\n * Convert video block to Portable Text\n */\nfunction convertVideo(node: ProseMirrorNode): PortableTextVideoBlock {\n\treturn {\n\t\t_type: \"video\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\t...videoBlockFields(node.attrs ?? {}),\n\t};\n}\n\nfunction isFrameDimension(value: unknown): value is number {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= 10_000;\n}\n\nfunction imageDimension(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? value : undefined;\n}\n\n/**\n * Convert image to Portable Text\n */\nfunction convertImage(node: ProseMirrorNode): PortableTextImageBlock {\n\tconst attrs = node.attrs;\n\tconst provider = typeof attrs?.provider === \"string\" ? attrs.provider : undefined;\n\tconst mediaId = typeof attrs?.mediaId === \"string\" ? attrs.mediaId : undefined;\n\tconst src = typeof attrs?.src === \"string\" ? attrs.src : \"\";\n\tconst alt = typeof attrs?.alt === \"string\" ? attrs.alt : undefined;\n\tconst title = typeof attrs?.title === \"string\" ? attrs.title : undefined;\n\tconst caption =\n\t\tattrs && Object.hasOwn(attrs, \"caption\")\n\t\t\t? typeof attrs.caption === \"string\"\n\t\t\t\t? attrs.caption\n\t\t\t\t: undefined\n\t\t\t: title;\n\tconst width = imageDimension(attrs?.width);\n\tconst height = imageDimension(attrs?.height);\n\tconst displayWidth = imageDimension(attrs?.displayWidth);\n\tconst displayHeight = imageDimension(attrs?.displayHeight);\n\tconst alignment = attrs?.alignment;\n\n\t// Normalise link: drop entirely when href is missing or empty so half-populated\n\t// { blank: true } objects don't round-trip.\n\tlet link: { href: string; blank?: boolean } | undefined;\n\tconst rawLink = attrs?.link;\n\tif (rawLink && typeof rawLink === \"object\") {\n\t\tconst linkObj = rawLink as { href?: unknown; blank?: unknown };\n\t\tconst href = typeof linkObj.href === \"string\" ? linkObj.href.trim() : \"\";\n\t\tif (href) {\n\t\t\tlink = { href };\n\t\t\tif (linkObj.blank === true) link.blank = true;\n\t\t}\n\t}\n\n\treturn {\n\t\t_type: \"image\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tasset: {\n\t\t\t// Use mediaId as _ref if available (for proper provider lookups)\n\t\t\t_ref: mediaId || src || \"\",\n\t\t\t// Store URL for admin preview and fallback rendering\n\t\t\turl: src || \"\",\n\t\t\t// Store provider for external media\n\t\t\tprovider: provider && provider !== \"local\" ? provider : undefined,\n\t\t},\n\t\talt: alt || undefined,\n\t\tcaption: caption || (title ? \"\" : undefined),\n\t\ttitle: title || undefined,\n\t\twidth: width || undefined,\n\t\theight: height || undefined,\n\t\tdisplayWidth: displayWidth || undefined,\n\t\tdisplayHeight: displayHeight || undefined,\n\t\talignment:\n\t\t\talignment === \"left\" ||\n\t\t\talignment === \"center\" ||\n\t\t\talignment === \"right\" ||\n\t\t\talignment === \"wide\" ||\n\t\t\talignment === \"full\"\n\t\t\t\t? alignment\n\t\t\t\t: undefined,\n\t\tlink,\n\t};\n}\n\n/**\n * Convert gallery node to Portable Text\n */\nfunction convertGallery(node: ProseMirrorNode): PortableTextGalleryBlock {\n\tconst columns = node.attrs?.columns;\n\treturn {\n\t\t_type: \"gallery\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\timages: sanitizeGalleryImages(node.attrs?.images, generateKey),\n\t\t...(typeof columns === \"number\" ? { columns } : {}),\n\t};\n}\n\n/**\n * Convert inline content (text nodes with marks) to Portable Text spans\n */\nfunction convertInlineContent(\n\tnodes: ProseMirrorNode[],\n\tpreserveHardBreakBoundary = false,\n): {\n\tchildren: PortableTextSpan[];\n\tmarkDefs: PortableTextMarkDef[];\n} {\n\tconst children: PortableTextSpan[] = [];\n\tconst markDefs: PortableTextMarkDef[] = [];\n\tconst markDefMap = new Map<string, string>();\n\tconst usedSpanKeys = new Set<string>();\n\tconst claimSpanKey = (preferred?: string) => {\n\t\tif (preferred && !usedSpanKeys.has(preferred)) {\n\t\t\tusedSpanKeys.add(preferred);\n\t\t\treturn preferred;\n\t\t}\n\t\tlet key: string;\n\t\tdo key = generateKey();\n\t\twhile (usedSpanKeys.has(key));\n\t\tusedSpanKeys.add(key);\n\t\treturn key;\n\t};\n\n\tfor (const node of nodes) {\n\t\tif (node.type === \"text\" && node.text) {\n\t\t\tconst marks: string[] = [];\n\t\t\tconst originalMarkDefs = portableTextMarkDefsFromMarks(node.marks);\n\n\t\t\tfor (const mark of node.marks || []) {\n\t\t\t\tconst markType = convertMark(mark, markDefs, markDefMap, originalMarkDefs);\n\t\t\t\tif (markType) {\n\t\t\t\t\tmarks.push(markType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst preferredKey =\n\t\t\t\tportableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs);\n\t\t\tconst normalizedMarks = marks.length > 0 ? marks : undefined;\n\t\t\tconst previous = children.at(-1);\n\t\t\tif (\n\t\t\t\tpreferredKey &&\n\t\t\t\tprevious?._key === preferredKey &&\n\t\t\t\tJSON.stringify(previous.marks) === JSON.stringify(normalizedMarks)\n\t\t\t) {\n\t\t\t\tprevious.text += node.text;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tchildren.push({\n\t\t\t\t_type: \"span\",\n\t\t\t\t_key: claimSpanKey(preferredKey),\n\t\t\t\ttext: node.text,\n\t\t\t\tmarks: normalizedMarks,\n\t\t\t});\n\t\t} else if (node.type === \"hardBreak\") {\n\t\t\t// Hard breaks become newlines in the text\n\t\t\tif (children.length > 0 && !preserveHardBreakBoundary) {\n\t\t\t\tconst lastChild = children.at(-1)!;\n\t\t\t\tlastChild.text += \"\\n\";\n\t\t\t} else {\n\t\t\t\tchildren.push({\n\t\t\t\t\t_type: \"span\",\n\t\t\t\t\t_key: claimSpanKey(\n\t\t\t\t\t\tportableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs),\n\t\t\t\t\t),\n\t\t\t\t\ttext: \"\\n\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Ensure at least one span exists\n\tif (children.length === 0) {\n\t\tchildren.push({\n\t\t\t_type: \"span\",\n\t\t\t_key: claimSpanKey(),\n\t\t\ttext: \"\",\n\t\t});\n\t}\n\n\treturn { children, markDefs };\n}\n\n/**\n * Convert a ProseMirror mark to Portable Text mark\n */\nfunction convertMark(\n\tmark: ProseMirrorMark,\n\tmarkDefs: PortableTextMarkDef[],\n\tmarkDefMap: Map<string, string>,\n\toriginalMarkDefs: PortableTextMarkDef[],\n): string | null {\n\tswitch (mark.type) {\n\t\tcase \"bold\":\n\t\tcase \"strong\":\n\t\t\treturn \"strong\";\n\n\t\tcase \"italic\":\n\t\tcase \"em\":\n\t\t\treturn \"em\";\n\n\t\tcase \"underline\":\n\t\t\treturn \"underline\";\n\n\t\tcase \"strike\":\n\t\tcase \"strikethrough\":\n\t\t\treturn \"strike-through\";\n\n\t\tcase \"subscript\":\n\t\t\treturn \"subscript\";\n\n\t\tcase \"superscript\":\n\t\t\treturn \"superscript\";\n\n\t\tcase \"code\":\n\t\t\treturn \"code\";\n\n\t\tcase PORTABLE_TEXT_SPAN_MARK:\n\t\t\treturn null;\n\n\t\tcase \"link\": {\n\t\t\tconst href = (typeof mark.attrs?.href === \"string\" ? mark.attrs.href : \"\") || \"\";\n\t\t\tconst blank = mark.attrs?.target === \"_blank\";\n\t\t\tconst originalMarkDef = originalMarkDefs.find((markDef) => markDef._type === \"link\");\n\t\t\tconst mapKey = originalMarkDef\n\t\t\t\t? `key:${originalMarkDef._key}`\n\t\t\t\t: `value:${JSON.stringify([href, blank])}`;\n\n\t\t\t// Check if we already have a mark def for this link\n\t\t\tif (markDefMap.has(mapKey)) {\n\t\t\t\treturn markDefMap.get(mapKey)!;\n\t\t\t}\n\n\t\t\t// Create new mark def\n\t\t\tconst key = originalMarkDef?._key || generateKey();\n\t\t\tmarkDefs.push({\n\t\t\t\t...originalMarkDef,\n\t\t\t\t_type: \"link\",\n\t\t\t\t_key: key,\n\t\t\t\thref,\n\t\t\t\t...(originalMarkDef\n\t\t\t\t\t? blank || Object.hasOwn(originalMarkDef, \"blank\")\n\t\t\t\t\t\t? { blank }\n\t\t\t\t\t\t: {}\n\t\t\t\t\t: { blank }),\n\t\t\t});\n\t\t\tmarkDefMap.set(mapKey, key);\n\n\t\t\treturn key;\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new UnsupportedPortableTextMarksError([mark.type]);\n\t}\n}\n","/**\n * Image link normalisation.\n *\n * A Portable Text image block carries its optional link in one of two shapes:\n *\n * - `{ href, blank? }` — the canonical shape the editor writes\n * - `\"https://…\"` — a bare string, emitted by `gutenberg-to-portable-text`\n * for linked images and therefore present on WordPress-imported content\n *\n * Every consumer reads through this helper so the legacy shape keeps working\n * and is upgraded to the canonical shape the first time the block round-trips\n * through the editor.\n */\nimport type { PortableTextImageLink } from \"./types.js\";\n\nexport function normalizeImageLink(raw: unknown): PortableTextImageLink | null {\n\tif (typeof raw === \"string\") {\n\t\tconst href = raw.trim();\n\t\treturn href ? { href } : null;\n\t}\n\tif (typeof raw !== \"object\" || raw === null) return null;\n\tconst { href, blank } = raw as { href?: unknown; blank?: unknown };\n\tif (typeof href !== \"string\") return null;\n\tconst trimmed = href.trim();\n\tif (!trimmed) return null;\n\treturn blank === true ? { href: trimmed, blank: true } : { href: trimmed };\n}\n","/**\n * Portable Text to ProseMirror Converter\n *\n * Converts Portable Text to TipTap's ProseMirror JSON format for editing.\n */\n\nimport { htmlBlockFields } from \"@emdash-cms/admin/html-block\";\nimport {\n\tUnsafePortableTextTableError,\n\tportableTextTableToProseMirror,\n} from \"@emdash-cms/admin/portable-text-table\";\n\nimport { resolveImageMedia, sanitizeGalleryImages } from \"./gallery.js\";\nimport { normalizeImageLink } from \"./image-link.js\";\nimport {\n\tUnsupportedPortableTextMarksError,\n\tassertPortableTextMarksSupported,\n} from \"./mark-safety.js\";\nimport {\n\tderiveLegacyListId,\n\tnormalizeProseMirrorOrderedListJson,\n\tnormalizeListId,\n\tnormalizeListStart,\n} from \"./numbered-list.js\";\nimport {\n\tPORTABLE_TEXT_BLOCK_ATTR,\n\tPORTABLE_TEXT_BLOCK_NODE,\n\tPORTABLE_TEXT_SPAN_MARK,\n\tattrsWithPortableTextKey,\n} from \"./portable-text-identity.js\";\nimport type {\n\tProseMirrorDocument,\n\tProseMirrorNode,\n\tProseMirrorMark,\n\tPortableTextBlock,\n\tPortableTextTextBlock,\n\tPortableTextSpan,\n\tPortableTextMarkDef,\n\tPortableTextImageBlock,\n\tPortableTextGalleryBlock,\n\tPortableTextCodeBlock,\n\tPortableTextIframeBlock,\n} from \"./types.js\";\nimport { isPortableTextVideoBlock, videoNodeAttrs } from \"./video.js\";\n\nfunction generateKey(): string {\n\treturn Math.random().toString(36).substring(2, 11);\n}\n\nexport interface PortableTextToProsemirrorOptions {\n\t/**\n\t * Preserve custom blocks and Portable Text keys through a ProseMirror round trip.\n\t * Add `portableTextIdentityExtensions` to the TipTap schema when this is enabled.\n\t */\n\tpreserveIdentity?: boolean;\n}\n\n/** Convert Portable Text to a ProseMirror document. */\nexport function portableTextToProsemirror(\n\tblocks: PortableTextBlock[],\n\toptions: PortableTextToProsemirrorOptions = {},\n): ProseMirrorDocument {\n\tif (!blocks || blocks.length === 0) {\n\t\treturn {\n\t\t\ttype: \"doc\",\n\t\t\tcontent: [{ type: \"paragraph\" }],\n\t\t};\n\t}\n\tassertPortableTextMarksSupported(blocks);\n\tconst preserveIdentity = options.preserveIdentity === true;\n\n\tconst content: ProseMirrorNode[] = [];\n\tlet i = 0;\n\n\twhile (i < blocks.length) {\n\t\tconst block = blocks[i];\n\n\t\t// Check for list items\n\t\tif (isTextBlock(block) && block.listItem) {\n\t\t\t// Collect a list \"run\": the level=1 anchor plus everything that\n\t\t\t// nests under it (level > 1, regardless of listItem type — a number\n\t\t\t// child under a bullet parent is still part of the same tree). A\n\t\t\t// level=1 block with a different listItem ends the run. Without the\n\t\t\t// `level > 1` carve-out the run breaks on the first nested type\n\t\t\t// switch and the descendant subtree leaks out as its own top-level\n\t\t\t// list (e.g. `[bullet L1, number L2, bullet L1]` would render as\n\t\t\t// three sibling lists instead of one bullet list with a numbered\n\t\t\t// child).\n\t\t\tconst listBlocks: PortableTextTextBlock[] = [];\n\t\t\tconst listType = block.listItem;\n\t\t\tconst runStart = i;\n\t\t\tconst rootId = listType === \"number\" ? normalizeListId(block.listId) : undefined;\n\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst current = blocks[i];\n\t\t\t\tif (!isTextBlock(current) || !current.listItem) break;\n\t\t\t\tconst level = current.level || 1;\n\t\t\t\tconst currentId =\n\t\t\t\t\tcurrent.listItem === \"number\" ? normalizeListId(current.listId) : undefined;\n\t\t\t\tconst sameRootIdentity =\n\t\t\t\t\tlistType !== \"number\" ||\n\t\t\t\t\tlevel > 1 ||\n\t\t\t\t\t(rootId ? currentId === rootId : currentId === undefined);\n\t\t\t\tif (level > 1 || (current.listItem === listType && sameRootIdentity)) {\n\t\t\t\t\tlistBlocks.push(current);\n\t\t\t\t\ti++;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontent.push(convertList(listBlocks, listType, `root:${runStart}`, preserveIdentity));\n\t\t} else if (isTextBlock(block) && block.style === \"blockquote\") {\n\t\t\t// Collect a blockquote \"run\": Portable Text is flat, so a\n\t\t\t// multi-paragraph quote is stored as consecutive blocks with\n\t\t\t// style \"blockquote\" (that's what the Gutenberg importer emits\n\t\t\t// and what prosemirrorToPortableText serializes back to).\n\t\t\t// Without this grouping each paragraph became its own quote\n\t\t\t// node, and editor merges reverted on reload.\n\t\t\tconst quoteBlocks: PortableTextTextBlock[] = [];\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst current = blocks[i];\n\t\t\t\tif (\n\t\t\t\t\t!isTextBlock(current) ||\n\t\t\t\t\tcurrent.style !== \"blockquote\" ||\n\t\t\t\t\tcurrent.listItem !== undefined\n\t\t\t\t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tquoteBlocks.push(current);\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\tcontent.push({\n\t\t\t\ttype: \"blockquote\",\n\t\t\t\tcontent: quoteBlocks.map((quoteBlock) => {\n\t\t\t\t\tconst paragraph = convertSpans(\n\t\t\t\t\t\tquoteBlock.children,\n\t\t\t\t\t\tquoteBlock.markDefs || [],\n\t\t\t\t\t\tpreserveIdentity,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\t\tattrs: identityAttrs(undefined, quoteBlock._key, preserveIdentity),\n\t\t\t\t\t\tcontent: paragraph.length > 0 ? paragraph : undefined,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t});\n\t\t} else {\n\t\t\tconst converted = convertBlock(block, `root:${i}`, preserveIdentity);\n\t\t\tif (converted) {\n\t\t\t\tcontent.push(converted);\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\n\treturn normalizeProseMirrorOrderedListJson({\n\t\ttype: \"doc\",\n\t\tcontent: content.length > 0 ? content : [{ type: \"paragraph\" }],\n\t});\n}\n\nfunction identityAttrs(\n\tattrs: Record<string, unknown> | undefined,\n\tkey: string,\n\tpreserveIdentity: boolean,\n): Record<string, unknown> | undefined {\n\treturn preserveIdentity ? attrsWithPortableTextKey(attrs, key) : attrs;\n}\n\nfunction getListMetadata(\n\titem: PortableTextTextBlock,\n\tfallbackSeed: string,\n): { listId: string; listStart?: number } {\n\tconst listId = normalizeListId(item.listId) ?? deriveLegacyListId(fallbackSeed);\n\tconst listStart = normalizeListStart(item.listStart);\n\treturn {\n\t\tlistId,\n\t\t...(listStart === undefined ? {} : { listStart }),\n\t};\n}\n\nfunction belongsToNestedGroup(\n\titem: PortableTextTextBlock,\n\tminLevel: number,\n\tparentListType: \"bullet\" | \"number\",\n\tanchorType: \"bullet\" | \"number\",\n\tanchorId: string | undefined,\n): boolean {\n\tif ((item.level || 2) > minLevel) return true;\n\tif ((item.listItem || parentListType) !== anchorType) return false;\n\tif (anchorType !== \"number\") return true;\n\tconst itemId = normalizeListId(item.listId);\n\treturn anchorId ? itemId === anchorId : itemId === undefined;\n}\n\n/**\n * Type guard for text blocks\n */\nfunction isTextBlock(block: PortableTextBlock): block is PortableTextTextBlock {\n\treturn block._type === \"block\";\n}\n\n/**\n * Type guard for image blocks.\n * Checks both `_type` and that `asset` is a valid object — image blocks\n * without an `asset` wrapper (e.g. `{ _type: \"image\", url: \"...\" }`) are\n * malformed and should not be cast to `PortableTextImageBlock`.\n */\nfunction isImageBlock(block: PortableTextBlock): block is PortableTextImageBlock {\n\treturn (\n\t\tblock._type === \"image\" &&\n\t\t\"asset\" in block &&\n\t\ttypeof block.asset === \"object\" &&\n\t\tblock.asset !== null\n\t);\n}\n\n/**\n * Type guard for gallery blocks that carry a usable `images` array.\n * Galleries without one are handled separately in `convertBlock`.\n */\nfunction isGalleryBlock(block: PortableTextBlock): block is PortableTextGalleryBlock {\n\treturn block._type === \"gallery\" && \"images\" in block && Array.isArray(block.images);\n}\n\nconst isString = (value: unknown) => typeof value === \"string\";\nconst isFrameDimension = (value: unknown) =>\n\ttypeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= 10_000;\n\nconst IFRAME_BLOCK_FIELDS = new Map<string, (value: unknown) => boolean>([\n\t[\"_type\", () => true],\n\t[\"_key\", () => true],\n\t[\"src\", isString],\n\t[\"title\", isString],\n\t[\"width\", isFrameDimension],\n\t[\"height\", isFrameDimension],\n\t[\"allow\", isString],\n\t[\"allowFullscreen\", (value) => typeof value === \"boolean\"],\n]);\n\n/**\n * An `iframe` block with other fields, or with values of other types, belongs\n * to a plugin and stays a generic block.\n */\nfunction isIframeBlock(block: PortableTextBlock): block is PortableTextIframeBlock {\n\treturn (\n\t\tblock._type === \"iframe\" &&\n\t\ttypeof block.src === \"string\" &&\n\t\tObject.entries(block).every(\n\t\t\t([key, value]) => value === undefined || (IFRAME_BLOCK_FIELDS.get(key)?.(value) ?? false),\n\t\t)\n\t);\n}\n\n/**\n * Type guard for code blocks\n */\nfunction isCodeBlock(block: PortableTextBlock): block is PortableTextCodeBlock {\n\treturn block._type === \"code\";\n}\n\n/**\n * Convert a single Portable Text block to ProseMirror node\n */\nfunction convertBlock(\n\tblock: PortableTextBlock,\n\tpath: string,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode | null {\n\tif (isTextBlock(block)) {\n\t\treturn convertTextBlock(block, preserveIdentity);\n\t}\n\tif (isImageBlock(block)) {\n\t\treturn convertImage(block, preserveIdentity);\n\t}\n\tif (block._type === \"image\") {\n\t\t// Malformed image block (no asset wrapper) — extract url from top level\n\t\treturn convertMalformedImage(block, preserveIdentity);\n\t}\n\tif (isGalleryBlock(block)) {\n\t\treturn {\n\t\t\ttype: \"gallery\",\n\t\t\tattrs: identityAttrs(\n\t\t\t\t{\n\t\t\t\t\timages: sanitizeGalleryImages(block.images),\n\t\t\t\t\tcolumns: typeof block.columns === \"number\" ? block.columns : undefined,\n\t\t\t\t},\n\t\t\t\tblock._key,\n\t\t\t\tpreserveIdentity,\n\t\t\t),\n\t\t};\n\t}\n\tif (isCodeBlock(block)) {\n\t\treturn convertCodeBlock(block, preserveIdentity);\n\t}\n\tif (block._type === \"htmlBlock\") {\n\t\treturn {\n\t\t\ttype: \"htmlBlock\",\n\t\t\tattrs: identityAttrs({ ...htmlBlockFields(block) }, block._key, preserveIdentity),\n\t\t};\n\t}\n\tif (isIframeBlock(block)) {\n\t\tconst { _type, _key, ...attrs } = block;\n\t\treturn { type: \"iframeBlock\", attrs: identityAttrs(attrs, _key, preserveIdentity) };\n\t}\n\tif (isPortableTextVideoBlock(block)) {\n\t\treturn {\n\t\t\ttype: \"videoBlock\",\n\t\t\tattrs: identityAttrs(videoNodeAttrs(block), block._key, preserveIdentity),\n\t\t};\n\t}\n\tif (block._type === \"break\") {\n\t\treturn {\n\t\t\ttype: \"horizontalRule\",\n\t\t\tattrs: identityAttrs(undefined, block._key, preserveIdentity),\n\t\t};\n\t}\n\tif (block._type === \"gallery\") {\n\t\tif (preserveIdentity) {\n\t\t\treturn {\n\t\t\t\ttype: PORTABLE_TEXT_BLOCK_NODE,\n\t\t\t\tattrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block },\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\ttype: \"paragraph\",\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `[Unknown block type: ${block._type}]`,\n\t\t\t\t\tmarks: [{ type: \"code\" }],\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\tif (preserveIdentity) {\n\t\treturn {\n\t\t\ttype: PORTABLE_TEXT_BLOCK_NODE,\n\t\t\tattrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block },\n\t\t};\n\t}\n\tif (block._type === \"table\") {\n\t\tconst result = portableTextTableToProseMirror(block, {\n\t\t\tpath,\n\t\t\tcreateKey: generateKey,\n\t\t\tspansToInline: (content, markDefs) => convertSpans(content, markDefs, preserveIdentity),\n\t\t});\n\t\tif (!result.ok) {\n\t\t\tthrow new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);\n\t\t}\n\t\treturn result.node;\n\t}\n\treturn {\n\t\ttype: \"paragraph\",\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `[Unknown block type: ${block._type}]`,\n\t\t\t\tmarks: [{ type: \"code\" }],\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Convert text block to ProseMirror paragraph or heading\n */\nfunction convertTextBlock(\n\tblock: PortableTextTextBlock,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode | null {\n\tconst { style = \"normal\", children, markDefs = [] } = block;\n\n\t// Convert children to ProseMirror nodes\n\tconst content = convertSpans(children, markDefs, preserveIdentity);\n\n\t// Determine node type based on style\n\tswitch (style) {\n\t\tcase \"h1\":\n\t\tcase \"h2\":\n\t\tcase \"h3\":\n\t\tcase \"h4\":\n\t\tcase \"h5\":\n\t\tcase \"h6\": {\n\t\t\tconst level = parseInt(style.substring(1), 10);\n\t\t\treturn {\n\t\t\t\ttype: \"heading\",\n\t\t\t\tattrs: identityAttrs(\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\t...(block.textAlign ? { textAlign: block.textAlign } : {}),\n\t\t\t\t\t},\n\t\t\t\t\tblock._key,\n\t\t\t\t\tpreserveIdentity,\n\t\t\t\t),\n\t\t\t\tcontent: content.length > 0 ? content : undefined,\n\t\t\t};\n\t\t}\n\n\t\tcase \"blockquote\":\n\t\t\treturn {\n\t\t\t\ttype: \"blockquote\",\n\t\t\t\tattrs: identityAttrs(undefined, block._key, preserveIdentity),\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\t\tcontent: content.length > 0 ? content : undefined,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\n\t\tcase \"normal\":\n\t\tdefault:\n\t\t\treturn {\n\t\t\t\ttype: \"paragraph\",\n\t\t\t\tattrs: identityAttrs(\n\t\t\t\t\tblock.textAlign ? { textAlign: block.textAlign } : undefined,\n\t\t\t\t\tblock._key,\n\t\t\t\t\tpreserveIdentity,\n\t\t\t\t),\n\t\t\t\tcontent: content.length > 0 ? content : undefined,\n\t\t\t};\n\t}\n}\n\n/**\n * Convert list items to ProseMirror list\n */\nfunction convertList(\n\titems: PortableTextTextBlock[],\n\tlistType: \"bullet\" | \"number\",\n\tcontext: string,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\t// Group items by level\n\tconst rootItems: ProseMirrorNode[] = [];\n\tlet i = 0;\n\n\twhile (i < items.length) {\n\t\tconst item = items[i];\n\t\tconst level = item.level || 1;\n\n\t\tif (level === 1) {\n\t\t\t// Collect nested items for this root item\n\t\t\tconst nestedItems: PortableTextTextBlock[] = [];\n\t\t\ti++;\n\n\t\t\twhile (i < items.length && (items[i].level || 1) > 1) {\n\t\t\t\tnestedItems.push(items[i]);\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\trootItems.push(\n\t\t\t\tconvertListItem(\n\t\t\t\t\titem,\n\t\t\t\t\tnestedItems,\n\t\t\t\t\tlistType,\n\t\t\t\t\t`${context}:${rootItems.length}`,\n\t\t\t\t\tpreserveIdentity,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\t// Orphan nested item - treat as root\n\t\t\trootItems.push(\n\t\t\t\tconvertListItem(item, [], listType, `${context}:${rootItems.length}`, preserveIdentity),\n\t\t\t);\n\t\t\ti++;\n\t\t}\n\t}\n\n\tconst metadata =\n\t\tlistType === \"number\" ? getListMetadata(items[0], `${context}:${items[0]._key}`) : undefined;\n\n\treturn {\n\t\ttype: listType === \"bullet\" ? \"bulletList\" : \"orderedList\",\n\t\tattrs: metadata ? { ...metadata, start: metadata.listStart ?? 1 } : undefined,\n\t\tcontent: rootItems,\n\t};\n}\n\n/**\n * Convert a single list item to ProseMirror\n */\nfunction convertListItem(\n\titem: PortableTextTextBlock,\n\tnestedItems: PortableTextTextBlock[],\n\tparentListType: \"bullet\" | \"number\",\n\tcontext: string,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\tconst content: ProseMirrorNode[] = [];\n\n\t// Add paragraph content\n\tconst spans = convertSpans(item.children, item.markDefs || [], preserveIdentity);\n\tcontent.push({\n\t\ttype: \"paragraph\",\n\t\tattrs: identityAttrs(undefined, item._key, preserveIdentity),\n\t\tcontent: spans.length > 0 ? spans : undefined,\n\t});\n\n\t// Handle nested items\n\tif (nestedItems.length > 0) {\n\t\t// The shallowest level in `nestedItems` is the effective root of this\n\t\t// item's nested subtree. A new sub-list only starts when we hit\n\t\t// another block at that root level with a different `listItem` type;\n\t\t// deeper blocks (level > minLevel) belong to the current group as\n\t\t// descendants regardless of their own `listItem`. A deep mixed tree\n\t\t// like `bullet L1 → number L2 → bullet L3 → number L2` stays nested\n\t\t// under B(L2) and preserves its original level on round-trip.\n\t\tlet minLevel = Infinity;\n\t\tfor (const ni of nestedItems) {\n\t\t\tconst level = ni.level || 2;\n\t\t\tif (level < minLevel) minLevel = level;\n\t\t}\n\n\t\tlet j = 0;\n\t\twhile (j < nestedItems.length) {\n\t\t\tconst anchorType: \"bullet\" | \"number\" = nestedItems[j].listItem || parentListType;\n\t\t\tconst anchorId = anchorType === \"number\" ? normalizeListId(nestedItems[j].listId) : undefined;\n\t\t\tconst nestedGroup: PortableTextTextBlock[] = [];\n\n\t\t\tdo {\n\t\t\t\tnestedGroup.push(nestedItems[j]);\n\t\t\t\tj++;\n\t\t\t} while (\n\t\t\t\tj < nestedItems.length &&\n\t\t\t\tbelongsToNestedGroup(nestedItems[j], minLevel, parentListType, anchorType, anchorId)\n\t\t\t);\n\n\t\t\tif (nestedGroup.length > 0) {\n\t\t\t\t// Decrease level for nested conversion\n\t\t\t\tconst adjustedGroup = nestedGroup.map((ni) => ({\n\t\t\t\t\t...ni,\n\t\t\t\t\tlevel: (ni.level || 2) - 1,\n\t\t\t\t}));\n\t\t\t\tcontent.push(\n\t\t\t\t\tconvertList(\n\t\t\t\t\t\tadjustedGroup,\n\t\t\t\t\t\tanchorType,\n\t\t\t\t\t\t`${context}:nested:${j - nestedGroup.length}`,\n\t\t\t\t\t\tpreserveIdentity,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: \"listItem\",\n\t\tcontent,\n\t};\n}\n\n/**\n * Convert Portable Text spans to ProseMirror text nodes\n */\nfunction convertSpans(\n\tspans: PortableTextSpan[],\n\tmarkDefs: PortableTextMarkDef[],\n\tpreserveIdentity: boolean,\n): ProseMirrorNode[] {\n\tconst nodes: ProseMirrorNode[] = [];\n\tconst markDefsMap = new Map(markDefs.map((md) => [md._key, md]));\n\n\tfor (const span of spans) {\n\t\tif (span._type !== \"span\") continue;\n\t\tconst referencedMarkDefs = markDefs.filter((markDef) => span.marks?.includes(markDef._key));\n\n\t\t// Handle newlines in text\n\t\tconst parts = span.text.split(\"\\n\");\n\n\t\tfor (let i = 0; i < parts.length; i++) {\n\t\t\tconst text = parts[i];\n\n\t\t\t// Add text node\n\t\t\tif (text.length > 0) {\n\t\t\t\tconst marks = convertMarks(span.marks || [], markDefsMap);\n\t\t\t\tif (preserveIdentity) {\n\t\t\t\t\tmarks.push({\n\t\t\t\t\t\ttype: PORTABLE_TEXT_SPAN_MARK,\n\t\t\t\t\t\tattrs: { key: span._key, markDefs: referencedMarkDefs },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst node: ProseMirrorNode = {\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext,\n\t\t\t\t};\n\t\t\t\tif (marks.length > 0) node.marks = marks;\n\t\t\t\tnodes.push(node);\n\t\t\t}\n\n\t\t\t// Add hard break between parts (not after last)\n\t\t\tif (i < parts.length - 1) {\n\t\t\t\tnodes.push(\n\t\t\t\t\tpreserveIdentity\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\ttype: \"hardBreak\",\n\t\t\t\t\t\t\t\tmarks: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: PORTABLE_TEXT_SPAN_MARK,\n\t\t\t\t\t\t\t\t\t\tattrs: { key: span._key, markDefs: referencedMarkDefs },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: { type: \"hardBreak\" },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nodes;\n}\n\n/**\n * Convert Portable Text marks to ProseMirror marks\n */\nfunction convertMarks(\n\tmarks: string[],\n\tmarkDefs: Map<string, PortableTextMarkDef>,\n): ProseMirrorMark[] {\n\tconst pmMarks: ProseMirrorMark[] = [];\n\n\tfor (const mark of marks) {\n\t\tswitch (mark) {\n\t\t\tcase \"strong\":\n\t\t\t\tpmMarks.push({ type: \"bold\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"em\":\n\t\t\t\tpmMarks.push({ type: \"italic\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"underline\":\n\t\t\t\tpmMarks.push({ type: \"underline\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"strike-through\":\n\t\t\t\tpmMarks.push({ type: \"strike\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"subscript\":\n\t\t\t\tpmMarks.push({ type: \"subscript\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"superscript\":\n\t\t\t\tpmMarks.push({ type: \"superscript\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"code\":\n\t\t\t\tpmMarks.push({ type: \"code\" });\n\t\t\t\tbreak;\n\n\t\t\tdefault: {\n\t\t\t\t// Check if it's a mark definition reference\n\t\t\t\tconst markDef = markDefs.get(mark);\n\t\t\t\tif (markDef?._type === \"link\") {\n\t\t\t\t\tpmMarks.push({\n\t\t\t\t\t\ttype: \"link\",\n\t\t\t\t\t\tattrs: {\n\t\t\t\t\t\t\thref: markDef.href,\n\t\t\t\t\t\t\ttarget: markDef.blank ? \"_blank\" : null,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthrow new UnsupportedPortableTextMarksError([\n\t\t\t\t\t\ttypeof markDef?._type === \"string\" ? markDef._type : mark,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn pmMarks;\n}\n\nfunction imageAlignment(value: unknown): PortableTextImageBlock[\"alignment\"] {\n\treturn value === \"left\" ||\n\t\tvalue === \"center\" ||\n\t\tvalue === \"right\" ||\n\t\tvalue === \"wide\" ||\n\t\tvalue === \"full\"\n\t\t? value\n\t\t: undefined;\n}\n\nfunction imageDimension(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? value : undefined;\n}\n\n/**\n * Convert image block to ProseMirror\n */\nfunction convertImage(block: PortableTextImageBlock, preserveIdentity: boolean): ProseMirrorNode {\n\tconst { asset, alt, width, height } = resolveImageMedia(block);\n\treturn {\n\t\ttype: \"image\",\n\t\tattrs: identityAttrs(\n\t\t\t{\n\t\t\t\tsrc: asset.url || asset._ref,\n\t\t\t\talt: alt || \"\",\n\t\t\t\ttitle: block.title || \"\",\n\t\t\t\tcaption: Object.hasOwn(block, \"caption\") ? block.caption || \"\" : block.title || \"\",\n\t\t\t\tmediaId: asset._ref,\n\t\t\t\tprovider: asset.provider,\n\t\t\t\twidth: imageDimension(width),\n\t\t\t\theight: imageDimension(height),\n\t\t\t\tdisplayWidth: imageDimension(block.displayWidth),\n\t\t\t\tdisplayHeight: imageDimension(block.displayHeight),\n\t\t\t\talignment: imageAlignment(block.alignment),\n\t\t\t\tlink: normalizeImageLink(block.link),\n\t\t\t},\n\t\t\tblock._key,\n\t\t\tpreserveIdentity,\n\t\t),\n\t};\n}\n\n/**\n * Convert a malformed image block (missing `asset` wrapper) to ProseMirror.\n * Handles blocks like `{ _type: \"image\", url: \"...\", alt: \"...\" }` that may\n * originate from migrations or third-party imports.\n */\nfunction convertMalformedImage(\n\tblock: PortableTextBlock,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\t// PortableTextUnknownBlock allows indexed access via [key: string]: unknown\n\tconst url = \"url\" in block && typeof block.url === \"string\" ? block.url : \"\";\n\tconst alt = \"alt\" in block && typeof block.alt === \"string\" ? block.alt : \"\";\n\tconst title = \"title\" in block && typeof block.title === \"string\" ? block.title : \"\";\n\tconst rawCaption = \"caption\" in block ? block.caption : undefined;\n\tconst caption = Object.hasOwn(block, \"caption\")\n\t\t? typeof rawCaption === \"string\"\n\t\t\t? rawCaption\n\t\t\t: \"\"\n\t\t: title;\n\tconst width = imageDimension(\"width\" in block ? block.width : undefined);\n\tconst height = imageDimension(\"height\" in block ? block.height : undefined);\n\tconst displayWidth = imageDimension(\"displayWidth\" in block ? block.displayWidth : undefined);\n\tconst displayHeight = imageDimension(\"displayHeight\" in block ? block.displayHeight : undefined);\n\treturn {\n\t\ttype: \"image\",\n\t\tattrs: identityAttrs(\n\t\t\t{\n\t\t\t\tsrc: url,\n\t\t\t\talt,\n\t\t\t\ttitle,\n\t\t\t\tcaption,\n\t\t\t\tmediaId: undefined,\n\t\t\t\tprovider: undefined,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tdisplayWidth,\n\t\t\t\tdisplayHeight,\n\t\t\t\talignment: imageAlignment(\"alignment\" in block ? block.alignment : undefined),\n\t\t\t},\n\t\t\tblock._key,\n\t\t\tpreserveIdentity,\n\t\t),\n\t};\n}\n\n/**\n * Convert code block to ProseMirror\n */\nfunction convertCodeBlock(\n\tblock: PortableTextCodeBlock,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\treturn {\n\t\ttype: \"codeBlock\",\n\t\tattrs: identityAttrs(\n\t\t\t{\n\t\t\t\tlanguage: block.language || null,\n\t\t\t},\n\t\t\tblock._key,\n\t\t\tpreserveIdentity,\n\t\t),\n\t\tcontent: block.code ? [{ type: \"text\", text: block.code }] : undefined,\n\t};\n}\n","/**\n * Plugin Manager v2\n *\n * Central orchestrator for the plugin system:\n * - Loads and resolves plugins\n * - Manages plugin lifecycle (install, activate, deactivate, uninstall)\n * - Dispatches hooks across all plugins\n * - Routes API requests to plugins\n *\n */\n\nimport type { Kysely } from \"kysely\";\nimport { sql } from \"kysely\";\n\nimport { OptionsRepository } from \"../database/repositories/options.js\";\nimport type { Database } from \"../database/types.js\";\nimport type { Storage } from \"../storage/types.js\";\nimport type { PluginContextFactoryOptions } from \"./context.js\";\nimport { setCronTasksEnabled } from \"./cron.js\";\nimport { definePlugin } from \"./define-plugin.js\";\nimport type { EmailPipeline } from \"./email.js\";\nimport {\n\tHookPipeline,\n\ttype HookResult,\n\tresolveExclusiveHooks as resolveExclusiveHooksShared,\n} from \"./hooks.js\";\nimport { PluginRouteRegistry, type RouteResult, type InvokeRouteOptions } from \"./routes.js\";\nimport type {\n\tActorInfo,\n\tContentSaveHookDetails,\n\tPluginDefinition,\n\tResolvedPlugin,\n\tPluginStorageConfig,\n\tMediaItem,\n\tCronEvent,\n} from \"./types.js\";\n\n/** Options table key prefix for exclusive hook DB reads via PluginManager */\nconst EXCLUSIVE_HOOK_KEY_PREFIX = \"emdash:exclusive_hook:\";\n\n/**\n * Plugin state in the manager\n */\nexport type PluginState = \"registered\" | \"installed\" | \"active\" | \"inactive\";\n\n/**\n * Plugin entry in the manager\n */\ninterface PluginEntry {\n\tplugin: ResolvedPlugin;\n\tstate: PluginState;\n}\n\n/**\n * Plugin manager options\n */\nexport interface PluginManagerOptions {\n\t/** Database instance */\n\tdb: Kysely<Database>;\n\t/** Storage backend for direct media uploads */\n\tstorage?: Storage;\n\t/** Function to generate upload URLs for media */\n\tgetUploadUrl?: (\n\t\tfilename: string,\n\t\tcontentType: string,\n\t) => Promise<{ uploadUrl: string; mediaId: string }>;\n\t/**\n\t * Pre-resolved list of trusted proxy header names for client-IP\n\t * resolution in plugin route handlers. Thread through from the runtime.\n\t */\n\ttrustedProxyHeaders?: string[];\n\t/** Whether media uploads should generate server-side image placeholders. */\n\timagePlaceholders?: boolean;\n}\n\n/**\n * Plugin Manager v2\n *\n * Manages the full lifecycle of plugins and coordinates hooks/routes.\n */\nexport class PluginManager {\n\tprivate plugins: Map<string, PluginEntry> = new Map();\n\tprivate hookPipeline: HookPipeline | null = null;\n\tprivate routeRegistry: PluginRouteRegistry | null = null;\n\tprivate factoryOptions: PluginContextFactoryOptions;\n\tprivate initialized = false;\n\n\tconstructor(private options: PluginManagerOptions) {\n\t\tthis.factoryOptions = {\n\t\t\tdb: options.db,\n\t\t\tstorage: options.storage,\n\t\t\tgetUploadUrl: options.getUploadUrl,\n\t\t\ttrustedProxyHeaders: options.trustedProxyHeaders,\n\t\t\timagePlaceholders: options.imagePlaceholders,\n\t\t};\n\t}\n\n\t/**\n\t * Set the email pipeline used when creating plugin contexts.\n\t * Reinitializes routes/hooks if already initialized so ctx.email is available immediately.\n\t */\n\tsetEmailPipeline(pipeline: EmailPipeline): void {\n\t\tthis.factoryOptions.emailPipeline = pipeline;\n\t\tif (this.initialized) {\n\t\t\tthis.reinitialize();\n\t\t}\n\t}\n\n\t// =========================================================================\n\t// Plugin Registration\n\t// =========================================================================\n\n\t/**\n\t * Register a plugin definition\n\t * This resolves the definition and adds it to the manager, but doesn't install it\n\t */\n\tregister<TStorage extends PluginStorageConfig>(\n\t\tdefinition: PluginDefinition<TStorage>,\n\t): ResolvedPlugin<TStorage> {\n\t\tconst resolved = definePlugin(definition);\n\n\t\tif (this.plugins.has(resolved.id)) {\n\t\t\tthrow new Error(`Plugin \"${resolved.id}\" is already registered`);\n\t\t}\n\n\t\tthis.plugins.set(resolved.id, {\n\t\t\tplugin: resolved,\n\t\t\tstate: \"registered\",\n\t\t});\n\n\t\t// Mark as needing reinitialization\n\t\tthis.initialized = false;\n\n\t\treturn resolved;\n\t}\n\n\t/**\n\t * Register multiple plugins\n\t */\n\tregisterAll(definitions: PluginDefinition[]): void {\n\t\tfor (const def of definitions) {\n\t\t\tthis.register(def);\n\t\t}\n\t}\n\n\t/**\n\t * Unregister a plugin\n\t * Plugin must be inactive or just registered\n\t */\n\tunregister(pluginId: string): boolean {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) return false;\n\n\t\tif (entry.state === \"active\") {\n\t\t\tthrow new Error(`Cannot unregister active plugin \"${pluginId}\". Deactivate it first.`);\n\t\t}\n\n\t\tthis.plugins.delete(pluginId);\n\t\tthis.initialized = false;\n\t\treturn true;\n\t}\n\n\t// =========================================================================\n\t// Plugin Lifecycle\n\t// =========================================================================\n\n\t/**\n\t * Install a plugin (run install hooks, set up storage)\n\t */\n\tasync install(pluginId: string): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\tif (entry.state !== \"registered\") {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" is already installed (state: ${entry.state})`);\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run install hooks\n\t\tconst results = await this.hookPipeline!.runPluginInstall(pluginId);\n\n\t\t// Check for errors\n\t\tconst failed = results.find((r) => !r.success);\n\t\tif (failed) {\n\t\t\tthrow new Error(`Plugin install failed: ${failed.error?.message ?? \"Unknown error\"}`);\n\t\t}\n\n\t\tentry.state = \"installed\";\n\t\treturn results;\n\t}\n\n\t/**\n\t * Activate a plugin (run activate hooks, enable hooks/routes)\n\t */\n\tasync activate(pluginId: string): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\tif (entry.state === \"active\") {\n\t\t\treturn []; // Already active\n\t\t}\n\n\t\tif (entry.state === \"registered\") {\n\t\t\t// Auto-install if not installed\n\t\t\tawait this.install(pluginId);\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run activate hooks\n\t\tconst results = await this.hookPipeline!.runPluginActivate(pluginId);\n\n\t\t// Check for errors\n\t\tconst failed = results.find((r) => !r.success);\n\t\tif (failed) {\n\t\t\tthrow new Error(`Plugin activation failed: ${failed.error?.message ?? \"Unknown error\"}`);\n\t\t}\n\n\t\tentry.state = \"active\";\n\n\t\t// Re-enable cron tasks for the activated plugin\n\t\tawait setCronTasksEnabled(this.options.db, pluginId, true);\n\n\t\t// Reinitialize pipeline so the newly active plugin's hooks are registered\n\t\tthis.reinitialize();\n\n\t\t// Resolve exclusive hooks (new provider may need auto-selection)\n\t\tawait this.resolveExclusiveHooks();\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Deactivate a plugin (run deactivate hooks, disable hooks/routes)\n\t */\n\tasync deactivate(pluginId: string): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\tif (entry.state !== \"active\") {\n\t\t\treturn []; // Not active\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run deactivate hooks\n\t\tconst results = await this.hookPipeline!.runPluginDeactivate(pluginId);\n\n\t\t// Disable cron tasks for the deactivated plugin\n\t\tawait setCronTasksEnabled(this.options.db, pluginId, false);\n\n\t\tentry.state = \"inactive\";\n\n\t\t// Reinitialize pipeline so the deactivated plugin's hooks are removed\n\t\tthis.reinitialize();\n\n\t\t// Resolve exclusive hooks (deactivated provider may need clearing)\n\t\tawait this.resolveExclusiveHooks();\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Uninstall a plugin (run uninstall hooks, optionally delete data)\n\t */\n\tasync uninstall(pluginId: string, deleteData: boolean = false): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\t// Deactivate first if active (this also resolves exclusive hooks)\n\t\tif (entry.state === \"active\") {\n\t\t\tawait this.deactivate(pluginId);\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run uninstall hooks\n\t\tconst results = await this.hookPipeline!.runPluginUninstall(pluginId, deleteData);\n\n\t\t// Delete all cron tasks for the uninstalled plugin\n\t\tawait this.deleteCronTasks(pluginId);\n\n\t\t// Remove from manager\n\t\tthis.plugins.delete(pluginId);\n\t\tthis.initialized = false;\n\n\t\t// Resolve exclusive hooks after removal\n\t\tawait this.resolveExclusiveHooks();\n\n\t\treturn results;\n\t}\n\n\t// =========================================================================\n\t// Hook Dispatch\n\t// =========================================================================\n\n\t/**\n\t * Run content:beforeSave hooks across all active plugins\n\t */\n\tasync runContentBeforeSave(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t\tisNew: boolean,\n\t\tid?: string,\n\t\tactor?: ActorInfo,\n\t\tdetails?: ContentSaveHookDetails,\n\t): Promise<{\n\t\tcontent: Record<string, unknown>;\n\t\tresults: HookResult<Record<string, unknown>>[];\n\t}> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentBeforeSave(content, collection, isNew, id, actor, details);\n\t}\n\n\t/**\n\t * Run content:afterSave hooks across all active plugins\n\t */\n\tasync runContentAfterSave(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t\tisNew: boolean,\n\t\tactor?: ActorInfo,\n\t\tdetails?: ContentSaveHookDetails,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterSave(\n\t\t\tcontent,\n\t\t\tcollection,\n\t\t\tisNew,\n\t\t\tactor,\n\t\t\tundefined,\n\t\t\tdetails,\n\t\t);\n\t}\n\n\t/**\n\t * Run content:beforeDelete hooks across all active plugins\n\t */\n\tasync runContentBeforeDelete(\n\t\tid: string,\n\t\tcollection: string,\n\t): Promise<{ allowed: boolean; results: HookResult<boolean>[] }> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentBeforeDelete(id, collection);\n\t}\n\n\t/**\n\t * Run content:afterDelete hooks across all active plugins\n\t */\n\tasync runContentAfterDelete(\n\t\tid: string,\n\t\tcollection: string,\n\t\tpermanent: boolean,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterDelete(id, collection, permanent);\n\t}\n\n\t/**\n\t * Run content:afterPublish hooks across all active plugins\n\t */\n\tasync runContentAfterPublish(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterPublish(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterUnpublish hooks across all active plugins\n\t */\n\tasync runContentAfterUnpublish(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterUnpublish(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterRestore hooks across all active plugins\n\t */\n\tasync runContentAfterRestore(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterRestore(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterSchedule hooks across all active plugins\n\t */\n\tasync runContentAfterSchedule(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterSchedule(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterUnschedule hooks across all active plugins\n\t */\n\tasync runContentAfterUnschedule(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterUnschedule(content, collection);\n\t}\n\n\t/**\n\t * Run media:beforeUpload hooks across all active plugins\n\t */\n\tasync runMediaBeforeUpload(file: { name: string; type: string; size: number }): Promise<{\n\t\tfile: { name: string; type: string; size: number };\n\t\tresults: HookResult<{ name: string; type: string; size: number }>[];\n\t}> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runMediaBeforeUpload(file);\n\t}\n\n\t/**\n\t * Run media:afterUpload hooks across all active plugins\n\t */\n\tasync runMediaAfterUpload(media: MediaItem): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runMediaAfterUpload(media);\n\t}\n\n\t/**\n\t * Invoke the cron hook for a specific plugin (per-plugin dispatch).\n\t * Used as the InvokeCronHookFn callback for CronExecutor.\n\t */\n\tasync invokeCronHook(pluginId: string, event: CronEvent): Promise<void> {\n\t\tthis.ensureInitialized();\n\t\tconst result = await this.hookPipeline!.invokeCronHook(pluginId, event);\n\t\tif (!result.success && result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\t}\n\n\t// =========================================================================\n\t// Route Dispatch\n\t// =========================================================================\n\n\t/**\n\t * Invoke a plugin route\n\t */\n\tasync invokeRoute(\n\t\tpluginId: string,\n\t\trouteName: string,\n\t\toptions: InvokeRouteOptions,\n\t): Promise<RouteResult> {\n\t\tthis.ensureInitialized();\n\t\treturn this.routeRegistry!.invoke(pluginId, routeName, options);\n\t}\n\n\t/**\n\t * Get all routes for a plugin\n\t */\n\tgetPluginRoutes(pluginId: string): string[] {\n\t\tthis.ensureInitialized();\n\t\treturn this.routeRegistry!.getRoutes(pluginId);\n\t}\n\n\t// =========================================================================\n\t// Query Methods\n\t// =========================================================================\n\n\t/**\n\t * Get a plugin by ID\n\t */\n\tgetPlugin(pluginId: string): ResolvedPlugin | undefined {\n\t\treturn this.plugins.get(pluginId)?.plugin;\n\t}\n\n\t/**\n\t * Get plugin state\n\t */\n\tgetPluginState(pluginId: string): PluginState | undefined {\n\t\treturn this.plugins.get(pluginId)?.state;\n\t}\n\n\t/**\n\t * Get all registered plugins\n\t */\n\tgetAllPlugins(): Array<{ plugin: ResolvedPlugin; state: PluginState }> {\n\t\treturn Array.from(this.plugins.values(), (entry) => ({\n\t\t\tplugin: entry.plugin,\n\t\t\tstate: entry.state,\n\t\t}));\n\t}\n\n\t/**\n\t * Get all active plugins\n\t */\n\tgetActivePlugins(): ResolvedPlugin[] {\n\t\treturn [...this.plugins.values()]\n\t\t\t.filter((entry) => entry.state === \"active\")\n\t\t\t.map((entry) => entry.plugin);\n\t}\n\n\t/**\n\t * Check if a plugin exists\n\t */\n\thasPlugin(pluginId: string): boolean {\n\t\treturn this.plugins.has(pluginId);\n\t}\n\n\t/**\n\t * Check if a plugin is active\n\t */\n\tisActive(pluginId: string): boolean {\n\t\treturn this.plugins.get(pluginId)?.state === \"active\";\n\t}\n\n\t// =========================================================================\n\t// Exclusive Hooks\n\t// =========================================================================\n\n\t/**\n\t * Get all plugins that registered a handler for an exclusive hook.\n\t */\n\tgetExclusiveHookProviders(hookName: string): Array<{ pluginId: string; pluginName: string }> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.getExclusiveHookProviders(hookName).map((p) => {\n\t\t\tconst plugin = this.plugins.get(p.pluginId);\n\t\t\treturn {\n\t\t\t\tpluginId: p.pluginId,\n\t\t\t\tpluginName: plugin?.plugin.id ?? p.pluginId,\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * Read the selected provider for an exclusive hook from the options table.\n\t */\n\tasync getExclusiveHookSelection(hookName: string): Promise<string | null> {\n\t\tconst optionsRepo = new OptionsRepository(this.options.db);\n\t\treturn optionsRepo.get<string>(`${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`);\n\t}\n\n\t/**\n\t * Set the selected provider for an exclusive hook in the options table.\n\t * Pass null to clear the selection.\n\t */\n\tasync setExclusiveHookSelection(hookName: string, pluginId: string | null): Promise<void> {\n\t\tconst optionsRepo = new OptionsRepository(this.options.db);\n\t\tconst key = `${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`;\n\n\t\tif (pluginId === null) {\n\t\t\tawait optionsRepo.delete(key);\n\t\t\tthis.hookPipeline?.clearExclusiveSelection(hookName);\n\t\t\treturn;\n\t\t}\n\n\t\t// Validate plugin exists and is active\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\t\tif (entry.state !== \"active\") {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" is not active`);\n\t\t}\n\n\t\tawait optionsRepo.set(key, pluginId);\n\t\tthis.hookPipeline?.setExclusiveSelection(hookName, pluginId);\n\t}\n\n\t/**\n\t * Resolution algorithm for exclusive hooks.\n\t *\n\t * Delegates to the shared resolveExclusiveHooks() function.\n\t * See hooks.ts for the full algorithm description.\n\t */\n\tasync resolveExclusiveHooks(preferredHints?: Map<string, string[]>): Promise<void> {\n\t\tthis.ensureInitialized();\n\n\t\tconst optionsRepo = new OptionsRepository(this.options.db);\n\n\t\tawait resolveExclusiveHooksShared({\n\t\t\tpipeline: this.hookPipeline!,\n\t\t\tisActive: (pluginId) => this.isActive(pluginId),\n\t\t\tgetOption: (key) => optionsRepo.get<string>(key),\n\t\t\tgetOptions: (keys) => optionsRepo.getMany<string>(keys),\n\t\t\tsetOption: (key, value) => optionsRepo.set(key, value),\n\t\t\tdeleteOption: async (key) => {\n\t\t\t\tawait optionsRepo.delete(key);\n\t\t\t},\n\t\t\tpreferredHints,\n\t\t});\n\t}\n\n\t/**\n\t * Get all exclusive hooks with their providers and current selections.\n\t * Used by the admin API.\n\t */\n\tasync getExclusiveHooksInfo(): Promise<\n\t\tArray<{\n\t\t\thookName: string;\n\t\t\tproviders: Array<{ pluginId: string }>;\n\t\t\tselectedPluginId: string | null;\n\t\t}>\n\t> {\n\t\tthis.ensureInitialized();\n\t\tconst exclusiveHookNames = this.hookPipeline!.getRegisteredExclusiveHooks();\n\t\tconst result = [];\n\n\t\tfor (const hookName of exclusiveHookNames) {\n\t\t\tconst providers = this.hookPipeline!.getExclusiveHookProviders(hookName);\n\t\t\tconst selection = await this.getExclusiveHookSelection(hookName);\n\t\t\tresult.push({\n\t\t\t\thookName,\n\t\t\t\tproviders,\n\t\t\t\tselectedPluginId: selection,\n\t\t\t});\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// =========================================================================\n\t// Internal Methods\n\t// =========================================================================\n\n\t/**\n\t * Initialize or reinitialize the hook pipeline and route registry\n\t */\n\tprivate ensureInitialized(): void {\n\t\tif (this.initialized) return;\n\n\t\t// Get all active plugins for hooks\n\t\tconst activePlugins = this.getActivePlugins();\n\n\t\t// Create hook pipeline with active plugins\n\t\tthis.hookPipeline = new HookPipeline(activePlugins, this.factoryOptions);\n\n\t\t// Create route registry\n\t\tthis.routeRegistry = new PluginRouteRegistry(this.factoryOptions);\n\n\t\t// Register routes for active plugins\n\t\tfor (const plugin of activePlugins) {\n\t\t\tthis.routeRegistry.register(plugin);\n\t\t}\n\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * Force reinitialization (useful after plugin state changes)\n\t */\n\treinitialize(): void {\n\t\tthis.initialized = false;\n\t\tthis.ensureInitialized();\n\t}\n\n\t/**\n\t * Delete all cron tasks for a plugin.\n\t * Used during uninstall.\n\t */\n\tprivate async deleteCronTasks(pluginId: string): Promise<void> {\n\t\ttry {\n\t\t\tawait sql`\n\t\t\t\tDELETE FROM _emdash_cron_tasks\n\t\t\t\tWHERE plugin_id = ${pluginId}\n\t\t\t`.execute(this.options.db);\n\t\t} catch {\n\t\t\t// Cron table may not exist yet (pre-migration). Non-fatal.\n\t\t}\n\t}\n}\n\n/**\n * Create a plugin manager\n */\nexport function createPluginManager(options: PluginManagerOptions): PluginManager {\n\treturn new PluginManager(options);\n}\n","/**\n * Node.js cron scheduler — setTimeout-based.\n *\n * Queries the executor for the next due time and sets a timeout. Re-arms\n * after each tick and when reschedule() is called (new task scheduled or\n * cancelled).\n *\n * Suitable for single-process deployments (local dev, single-node).\n *\n */\n\nimport type { CronExecutor } from \"../cron.js\";\nimport type { CronScheduler, SystemCleanupFn } from \"./types.js\";\n\n/** Minimum polling interval (ms) — prevents tight loops if next_run_at is in the past */\nconst MIN_INTERVAL_MS = 1000;\n\n/**\n * Maximum polling interval (ms). Each wake runs the maintenance pass — stale\n * lock recovery *and* the scheduled-publishing sweep + system cleanup. The cap\n * is the worst-case latency for scheduled content when no plugin cron task is\n * due sooner (`getNextDueTime()` only knows about cron tasks, not content\n * `scheduled_at`). Held at 60s so Node publish latency matches the Cloudflare\n * Cron Trigger cadence (`* * * * *`) rather than lagging up to five minutes.\n */\nconst MAX_INTERVAL_MS = 60 * 1000;\n\nexport class NodeCronScheduler implements CronScheduler {\n\tprivate timer: ReturnType<typeof setTimeout> | null = null;\n\tprivate running = false;\n\tprivate systemCleanup: SystemCleanupFn | null = null;\n\n\tconstructor(private executor: CronExecutor) {}\n\n\tsetSystemCleanup(fn: SystemCleanupFn): void {\n\t\tthis.systemCleanup = fn;\n\t}\n\n\tstart(): void {\n\t\tthis.running = true;\n\t\tthis.arm();\n\t}\n\n\tstop(): void {\n\t\tthis.running = false;\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = null;\n\t\t}\n\t}\n\n\treschedule(): void {\n\t\tif (!this.running) return;\n\t\t// Clear existing timer and re-arm with fresh next due time\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = null;\n\t\t}\n\t\tthis.arm();\n\t}\n\n\tprivate arm(): void {\n\t\tif (!this.running) return;\n\n\t\t// Query the next due time, then schedule a wake-up\n\t\tvoid this.executor\n\t\t\t.getNextDueTime()\n\t\t\t.then((nextDue) => {\n\t\t\t\tif (!this.running) return undefined;\n\n\t\t\t\tlet delayMs: number;\n\t\t\t\tif (nextDue) {\n\t\t\t\t\tconst dueAt = new Date(nextDue).getTime();\n\t\t\t\t\tdelayMs = Math.max(dueAt - Date.now(), MIN_INTERVAL_MS);\n\t\t\t\t\tdelayMs = Math.min(delayMs, MAX_INTERVAL_MS);\n\t\t\t\t} else {\n\t\t\t\t\t// No tasks scheduled — poll at max interval for stale lock recovery\n\t\t\t\t\tdelayMs = MAX_INTERVAL_MS;\n\t\t\t\t}\n\n\t\t\t\tthis.timer = setTimeout(() => {\n\t\t\t\t\tif (!this.running) return;\n\t\t\t\t\tthis.executeTick();\n\t\t\t\t}, delayMs);\n\n\t\t\t\t// Don't prevent process exit\n\t\t\t\tif (this.timer && typeof this.timer === \"object\" && \"unref\" in this.timer) {\n\t\t\t\t\tthis.timer.unref();\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tconsole.error(\"[cron:node] Failed to get next due time:\", error);\n\t\t\t\t// Retry after max interval\n\t\t\t\tif (this.running) {\n\t\t\t\t\tthis.timer = setTimeout(() => this.arm(), MAX_INTERVAL_MS);\n\t\t\t\t\tif (this.timer && typeof this.timer === \"object\" && \"unref\" in this.timer) {\n\t\t\t\t\t\tthis.timer.unref();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tprivate executeTick(): void {\n\t\tif (!this.running) return;\n\n\t\t// Run tick + stale lock recovery + system cleanup, then re-arm\n\t\tconst tasks: Promise<unknown>[] = [this.executor.tick(), this.executor.recoverStaleLocks()];\n\t\tif (this.systemCleanup) {\n\t\t\ttasks.push(this.systemCleanup());\n\t\t}\n\n\t\tvoid Promise.allSettled(tasks)\n\t\t\t.then((results) => {\n\t\t\t\tfor (const r of results) {\n\t\t\t\t\tif (r.status === \"rejected\") {\n\t\t\t\t\t\tconsole.error(\"[cron:node] Tick task failed:\", r.reason);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.running) {\n\t\t\t\t\tthis.arm();\n\t\t\t\t}\n\t\t\t});\n\t}\n}\n","/**\n * No-op Sandbox Runner\n *\n * Default implementation that doesn't support sandboxing.\n * Used on platforms without Worker Loader (Node.js, Deno, etc.).\n *\n */\n\nimport type { PluginManifest } from \"../types.js\";\nimport type { SandboxRunner, SandboxedPluginInstance, SandboxOptions } from \"./types.js\";\n\n/**\n * Error thrown when attempting to use sandboxing on an unsupported platform.\n */\nexport class SandboxNotAvailableError extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Plugin sandboxing is not available. \" +\n\t\t\t\t\"Configure a sandbox runner: use @emdash-cms/cloudflare/sandbox on Cloudflare, \" +\n\t\t\t\t\"or @emdash-cms/sandbox-workerd/sandbox on Node.js (requires workerd). \" +\n\t\t\t\t\"Without sandboxing, use trusted plugins (from config) instead.\",\n\t\t);\n\t\tthis.name = \"SandboxNotAvailableError\";\n\t}\n}\n\n/**\n * No-op sandbox runner for platforms without isolation support.\n *\n * - `isAvailable()` returns false\n * - `load()` throws SandboxNotAvailableError\n * - `terminateAll()` is a no-op\n *\n * This is the default runner when no platform adapter is configured.\n */\nexport class NoopSandboxRunner implements SandboxRunner {\n\t/**\n\t * Always returns false - sandboxing is not available.\n\t */\n\tisAvailable(): boolean {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Always returns false - no sandbox runtime to be healthy.\n\t */\n\tisHealthy(): boolean {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Always throws - can't load sandboxed plugins without isolation.\n\t */\n\tasync load(\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_manifest: PluginManifest,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_code: string,\n\t): Promise<SandboxedPluginInstance> {\n\t\tthrow new SandboxNotAvailableError();\n\t}\n\n\t/**\n\t * No-op - sandboxing not available, email callback is irrelevant.\n\t */\n\tsetEmailSend(): void {\n\t\t// Nothing to do\n\t}\n\n\t/**\n\t * No-op - nothing to terminate.\n\t */\n\tasync terminateAll(): Promise<void> {\n\t\t// Nothing to do\n\t}\n}\n\n/**\n * Create a no-op sandbox runner.\n * This is used as the default when no platform adapter is configured.\n */\nexport function createNoopSandboxRunner(_options?: SandboxOptions): SandboxRunner {\n\treturn new NoopSandboxRunner();\n}\n","/**\n * Sections import functions\n *\n * Import reusable blocks from WordPress WXR exports as EmDash sections.\n */\n\nimport type { PortableTextBlock } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport { gutenbergToPortableText } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport type { Kysely } from \"kysely\";\nimport { ulid } from \"ulidx\";\n\nimport type { WxrPost } from \"../cli/wxr/parser.js\";\nimport type { Database } from \"../database/types.js\";\nimport { slugify } from \"../utils/slugify.js\";\n\n/**\n * Result of sections import operation\n */\nexport interface SectionsImportResult {\n\t/** Number of sections created */\n\tsectionsCreated: number;\n\t/** Number of sections skipped (already exist) */\n\tsectionsSkipped: number;\n\t/** Errors encountered during import */\n\terrors: Array<{ title: string; error: string }>;\n}\n\n/**\n * Import reusable blocks (wp_block post type) from WXR as sections\n *\n * @param posts - All posts from WXR (will filter to wp_block)\n * @param db - Database connection\n * @returns Import result with counts\n */\nexport async function importReusableBlocksAsSections(\n\tposts: WxrPost[],\n\tdb: Kysely<Database>,\n): Promise<SectionsImportResult> {\n\tconst result: SectionsImportResult = {\n\t\tsectionsCreated: 0,\n\t\tsectionsSkipped: 0,\n\t\terrors: [],\n\t};\n\n\t// Filter to only wp_block posts\n\tconst reusableBlocks = posts.filter((post) => post.postType === \"wp_block\");\n\n\tif (reusableBlocks.length === 0) {\n\t\treturn result;\n\t}\n\n\tfor (const block of reusableBlocks) {\n\t\ttry {\n\t\t\tconst slug = block.postName || slugify(block.title || `block-${block.id || Date.now()}`);\n\n\t\t\t// Check if section already exists\n\t\t\tconst existing = await db\n\t\t\t\t.selectFrom(\"_emdash_sections\")\n\t\t\t\t.select(\"id\")\n\t\t\t\t.where(\"slug\", \"=\", slug)\n\t\t\t\t.executeTakeFirst();\n\n\t\t\tif (existing) {\n\t\t\t\tresult.sectionsSkipped++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Convert Gutenberg content to Portable Text\n\t\t\tconst content: PortableTextBlock[] = block.content\n\t\t\t\t? gutenbergToPortableText(block.content)\n\t\t\t\t: [];\n\n\t\t\tconst id = ulid();\n\t\t\tconst now = new Date().toISOString();\n\n\t\t\tawait db\n\t\t\t\t.insertInto(\"_emdash_sections\")\n\t\t\t\t.values({\n\t\t\t\t\tid,\n\t\t\t\t\tslug,\n\t\t\t\t\ttitle: block.title || \"Untitled Block\",\n\t\t\t\t\tdescription: null,\n\t\t\t\t\tkeywords: null,\n\t\t\t\t\tcontent: JSON.stringify(content),\n\t\t\t\t\tpreview_media_id: null,\n\t\t\t\t\tsource: \"import\",\n\t\t\t\t\ttheme_id: null,\n\t\t\t\t\tcreated_at: now,\n\t\t\t\t\tupdated_at: now,\n\t\t\t\t})\n\t\t\t\t.execute();\n\n\t\t\tresult.sectionsCreated++;\n\t\t} catch (error) {\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: block.title || \"Untitled Block\",\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn result;\n}\n","/**\n * Preview helpers for Astro pages\n */\n\n/**\n * Check if a request is a preview request\n *\n * @example\n * ```ts\n * const isPreview = isPreviewRequest(Astro.url);\n * ```\n */\nexport function isPreviewRequest(url: URL): boolean {\n\treturn url.searchParams.has(\"_preview\");\n}\n\n/**\n * Get the preview token from a URL\n *\n * @example\n * ```ts\n * const token = getPreviewToken(Astro.url);\n * ```\n */\nexport function getPreviewToken(url: URL): string | null {\n\treturn url.searchParams.get(\"_preview\");\n}\n","/**\n * Comment ranking utilities (Tier 1 of the best-in-class comments RFC).\n *\n * Wilson score lower-bound (95% confidence) — the same primitive Reddit uses\n * for its \"Best\" comment sort. Ranks by the statistical lower bound of the\n * positive-reaction proportion rather than the raw count, so a comment with a\n * couple of reactions can't outrank a heavily-reacted one until it earns\n * confidence, and a late-but-popular comment still rises (submission time is\n * irrelevant).\n *\n * Positive-only reactions (the recommended default) degrade gracefully: with\n * `down = 0` the score still increases monotonically with `up` while penalising\n * low-sample comments — wilson(1,0) ≈ 0.21, wilson(10,0) ≈ 0.73,\n * wilson(200,0) ≈ 0.98.\n */\n\n/** z for a 95% two-sided confidence interval. */\nconst DEFAULT_Z = 1.96;\n\n/** Reactions that count against a comment when both signals are in use. */\nconst NEGATIVE_REACTIONS: ReadonlySet<string> = new Set([\"dislike\", \"down\"]);\n\n/**\n * Wilson score lower bound of the positive proportion.\n *\n * @param up count of positive reactions\n * @param down count of negative reactions\n * @returns a score in [0, 1]; 0 when there are no reactions\n */\nexport function wilsonLowerBound(up: number, down: number, z: number = DEFAULT_Z): number {\n\tconst n = up + down;\n\tif (n <= 0) return 0;\n\tconst phat = up / n;\n\tconst z2 = z * z;\n\tconst denom = 1 + z2 / n;\n\tconst centre = phat + z2 / (2 * n);\n\tconst margin = z * Math.sqrt((phat * (1 - phat) + z2 / (4 * n)) / n);\n\treturn (centre - margin) / denom;\n}\n\n/**\n * Reduce a per-reaction count map to a single rank score via the Wilson\n * lower bound. Any reaction not in {@link NEGATIVE_REACTIONS} is treated as\n * positive, so the positive-only default (just `like`) works without special\n * casing.\n */\nexport function reactionScore(counts: Record<string, number>): number {\n\tlet up = 0;\n\tlet down = 0;\n\tfor (const [reaction, count] of Object.entries(counts)) {\n\t\tif (NEGATIVE_REACTIONS.has(reaction)) {\n\t\t\tdown += count;\n\t\t} else {\n\t\t\tup += count;\n\t\t}\n\t}\n\treturn wilsonLowerBound(up, down);\n}\n","/**\n * Comment query functions for Astro templates\n *\n * Same pattern as getMenu() — uses getDb() for ambient DB access.\n * These are called from .astro pages/components, not from API routes.\n */\n\nimport type { Kysely } from \"kysely\";\n\nimport { CommentReactionRepository } from \"../database/repositories/comment-reaction.js\";\nimport { CommentRepository } from \"../database/repositories/comment.js\";\nimport type { PublicComment } from \"../database/repositories/comment.js\";\nimport type { Database } from \"../database/types.js\";\nimport { getDb } from \"../loader.js\";\nimport { cachedQuery, CacheNamespace } from \"../object-cache/index.js\";\nimport { reactionScore } from \"./ranking.js\";\n\nexport interface GetCommentsOptions {\n\tcollection: string;\n\tcontentId: string;\n\tthreaded?: boolean;\n\t/** Attach aggregate reaction counts to each comment. */\n\treactions?: boolean;\n\t/**\n\t * Order of top-level comments. `oldest` (default) preserves the existing\n\t * chronological display; `best` ranks by Wilson-scored reactions (implies\n\t * `reactions`). Replies always stay chronological.\n\t */\n\tsort?: \"oldest\" | \"best\";\n}\n\nexport interface GetCommentsResult {\n\titems: PublicComment[];\n\ttotal: number;\n}\n\n/**\n * Get approved comments for a content item.\n *\n * @example\n * ```ts\n * import { getComments } from \"emdash\";\n *\n * const { items, total } = await getComments({\n * collection: \"posts\",\n * contentId: post.id,\n * threaded: true,\n * });\n * ```\n */\nexport async function getComments(options: GetCommentsOptions): Promise<GetCommentsResult> {\n\t// The result varies by every option getCommentsWithDb branches on, so all of\n\t// them belong in the key. `best` implies reactions, so normalize the reaction\n\t// flag — `{ sort: \"best\" }` and `{ sort: \"best\", reactions: true }` produce\n\t// identical output and should share one entry.\n\tconst sort = options.sort ?? \"oldest\";\n\tconst withReactions = options.reactions || sort === \"best\";\n\tconst threaded = options.threaded ? \"t\" : \"f\";\n\treturn cachedQuery({\n\t\tnamespace: CacheNamespace.COMMENTS,\n\t\tkey: `comments:${options.collection}:${options.contentId}:${threaded}:${withReactions ? \"r\" : \"n\"}:${sort}`,\n\t\tload: async () => {\n\t\t\tconst db = await getDb();\n\t\t\treturn getCommentsWithDb(db, options);\n\t\t},\n\t});\n}\n\n/**\n * Get approved comments with an explicit db handle.\n *\n * @internal Use `getComments()` in templates. This variant is for routes\n * that already have a database handle.\n */\nexport async function getCommentsWithDb(\n\tdb: Kysely<Database>,\n\toptions: GetCommentsOptions,\n): Promise<GetCommentsResult> {\n\tconst repo = new CommentRepository(db);\n\n\t// Server-rendered: fetch all comments (capped for safety).\n\t// The API route handles paginated access; this is for full-page renders.\n\tconst MAX_COMMENTS = 500;\n\n\tconst result = await repo.findByContent(options.collection, options.contentId, {\n\t\tstatus: \"approved\",\n\t\tlimit: MAX_COMMENTS,\n\t});\n\n\t// When the list is not truncated, the total is available from the page\n\t// itself and we can skip the separate COUNT query. Fall back only when\n\t// cursor pagination signals there are more rows.\n\tconst total =\n\t\tresult.nextCursor === undefined\n\t\t\t? result.items.length\n\t\t\t: await repo.countByContent(options.collection, options.contentId, \"approved\");\n\n\tconst items: PublicComment[] = options.threaded\n\t\t? CommentRepository.assembleThreads(result.items).map((c) =>\n\t\t\t\tCommentRepository.toPublicComment(c),\n\t\t\t)\n\t\t: result.items.map((c) => CommentRepository.toPublicComment(c));\n\n\t// `best` sort needs reaction data, so it implies reactions.\n\tif (options.reactions || options.sort === \"best\") {\n\t\tawait attachReactions(db, items);\n\t\tif (options.sort === \"best\") {\n\t\t\tsortByBest(items);\n\t\t}\n\t}\n\n\treturn { items, total };\n}\n\n/**\n * Attach aggregate reaction counts to a list of public comments (and their\n * replies), in a single batched query.\n */\nasync function attachReactions(db: Kysely<Database>, items: PublicComment[]): Promise<void> {\n\tconst ids: string[] = [];\n\tfor (const comment of items) {\n\t\tids.push(comment.id);\n\t\tif (comment.replies) {\n\t\t\tfor (const reply of comment.replies) ids.push(reply.id);\n\t\t}\n\t}\n\tif (ids.length === 0) return;\n\n\tconst counts = await new CommentReactionRepository(db).countsForComments(ids);\n\n\tconst assign = (comment: PublicComment) => {\n\t\tconst reactions = counts.get(comment.id);\n\t\tif (reactions) comment.reactions = reactions;\n\t};\n\tfor (const comment of items) {\n\t\tassign(comment);\n\t\tcomment.replies?.forEach(assign);\n\t}\n}\n\n/**\n * Sort top-level comments by Wilson-scored reactions (descending), tie-broken\n * by oldest-first to keep ordering stable.\n */\nfunction sortByBest(items: PublicComment[]): void {\n\titems.sort((a, b) => {\n\t\tconst scoreDelta = reactionScore(b.reactions ?? {}) - reactionScore(a.reactions ?? {});\n\t\tif (scoreDelta !== 0) return scoreDelta;\n\t\tif (a.createdAt < b.createdAt) return -1;\n\t\tif (a.createdAt > b.createdAt) return 1;\n\t\treturn 0;\n\t});\n}\n\n/**\n * Get the count of approved comments for a content item.\n *\n * @example\n * ```ts\n * import { getCommentCount } from \"emdash\";\n *\n * const count = await getCommentCount(\"posts\", post.id);\n * ```\n */\nexport async function getCommentCount(collection: string, contentId: string): Promise<number> {\n\tconst db = await getDb();\n\treturn getCommentCountWithDb(db, collection, contentId);\n}\n\n/**\n * Get comment count with an explicit db handle.\n *\n * @internal Use `getCommentCount()` in templates.\n */\nexport async function getCommentCountWithDb(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tcontentId: string,\n): Promise<number> {\n\tconst repo = new CommentRepository(db);\n\treturn repo.countByContent(collection, contentId, \"approved\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,cAAc,EAAE,OAAO;CAC5B,IAAI,EAAE,QAAQ;CACd,KAAK,EAAE,QAAQ,CAAC,UAAU;CAC1B,KAAK,EAAE,QAAQ,CAAC,UAAU;CAC1B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,eAAe,EAAE,QAAQ,CAAC,UAAU;CACpC,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,UAAU;CAClD,CAAC;AAEF,MAAM,cAAc,YAAY,OAAO,EACtC,aAAa,YAAY,UAAU,EACnC,CAAC;AAUF,SAAgB,MAAM,UAAwB,EAAE,EAA2C;CAC1F,MAAM,aACL,QAAQ,gBAAgB,QAAQ,aAAa,SAA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;AACf,UAAQ,SAAS,QAAQ,OAAO;;;;;;;AAQlC,SAAS,WAAW,OAA8B;AACjD,OAAM,MAAM,GAAG,MAAM;EACpB,MAAM,aAAa,cAAc,EAAE,aAAa,EAAE,CAAC,GAAG,cAAc,EAAE,aAAa,EAAE,CAAC;AACtF,MAAI,eAAe,EAAG,QAAO;AAC7B,MAAI,EAAE,YAAY,EAAE,UAAW,QAAO;AACtC,MAAI,EAAE,YAAY,EAAE,UAAW,QAAO;AACtC,SAAO;GACN;;;;;;;;;;;;AAaH,eAAsB,gBAAgB,YAAoB,WAAoC;AAE7F,QAAO,sBADI,MAAM,OAAO,EACS,YAAY,UAAU;;;;;;;AAQxD,eAAsB,sBACrB,IACA,YACA,WACkB;AAElB,QADa,IAAI,kBAAkB,GAAG,CAC1B,eAAe,YAAY,WAAW,WAAW"}
1
+ {"version":3,"file":"index.mjs","names":["isRecord","generateKey","convertList","convertCodeBlock","convertImage","convertListItem","isFrameDimension","imageDimension","resolveExclusiveHooksShared","ulid"],"sources":["../src/fields/image.ts","../src/fields/file.ts","../src/fields/reference.ts","../src/fields/portable-text.ts","../src/content/converters/mark-safety.ts","../src/content/converters/numbered-list.ts","../src/content/converters/portable-text-identity.ts","../src/content/converters/prosemirror-to-portable-text.ts","../src/content/converters/image-link.ts","../src/content/converters/portable-text-to-prosemirror.ts","../src/plugins/manager.ts","../src/plugins/scheduler/node.ts","../src/plugins/sandbox/noop.ts","../src/import/sections.ts","../src/preview/helpers.ts","../src/comments/ranking.ts","../src/comments/query.ts"],"sourcesContent":["import { z } from \"astro/zod\";\n\nimport type { FieldDefinition, ImageValue } from \"./types.js\";\n\nconst mediaSchema = z.object({\n\tid: z.string(),\n\tsrc: z.string().optional(),\n\talt: z.string().optional(),\n\tcaption: z.string().optional(),\n\twidth: z.number().optional(),\n\theight: z.number().optional(),\n\tfilename: z.string().optional(),\n\tmimeType: z.string().optional(),\n\tblurhash: z.string().optional(),\n\tdominantColor: z.string().optional(),\n\tfocalX: z.number().optional(),\n\tfocalY: z.number().optional(),\n\tprovider: z.string().optional(),\n\tpreviewUrl: z.string().optional(),\n\tmeta: z.record(z.string(), z.unknown()).optional(),\n});\n\nconst imageSchema = mediaSchema.extend({\n\tdarkVariant: mediaSchema.optional(),\n});\n\nexport interface ImageOptions {\n\trequired?: boolean;\n\tmaxSize?: number; // in bytes\n\tallowedTypes?: string[]; // MIME types — exact or prefix\n\t/** Offer editors a second slot for a dark-color-scheme counterpart of the image. */\n\tdarkVariant?: boolean;\n}\n\nexport function image(options: ImageOptions = {}): FieldDefinition<ImageValue | undefined> {\n\tconst validation =\n\t\toptions.allowedTypes && options.allowedTypes.length > 0\n\t\t\t? { allowedMimeTypes: [...options.allowedTypes] }\n\t\t\t: undefined;\n\n\treturn {\n\t\ttype: \"image\",\n\t\tcolumnType: \"TEXT\",\n\t\tschema: options.required === false ? imageSchema.optional() : imageSchema,\n\t\toptions,\n\t\tui: {\n\t\t\twidget: \"image\",\n\t\t},\n\t\tvalidation,\n\t};\n}\n","import { z } from \"astro/zod\";\n\nimport type { FieldDefinition, FieldUIHints, FileValue } from \"./types.js\";\n\nexport interface FileOptions {\n\trequired?: boolean;\n\tmaxSize?: number; // In bytes\n\tallowedTypes?: string[]; // MIME types — exact (image/png) or prefix (image/)\n\thelpText?: string;\n}\n\nexport function file(options: FileOptions = {}): FieldDefinition<FileValue> {\n\tconst fileObjSchema = z.object({\n\t\tid: z.string(),\n\t\turl: z.string().optional(),\n\t\tsrc: z.string().optional(),\n\t\tfilename: z.string().optional(),\n\t\tmimeType: z.string().optional(),\n\t\tsize: z.number().optional(),\n\t\tprovider: z.string().optional(),\n\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t});\n\n\tconst schema: z.ZodType = options.required ? fileObjSchema : fileObjSchema.optional();\n\n\tconst ui: FieldUIHints = {\n\t\twidget: \"file\",\n\t\thelpText: options.helpText,\n\t\tmaxSize: options.maxSize,\n\t};\n\n\tconst validation =\n\t\toptions.allowedTypes && options.allowedTypes.length > 0\n\t\t\t? { allowedMimeTypes: [...options.allowedTypes] }\n\t\t\t: undefined;\n\n\treturn {\n\t\ttype: \"file\",\n\t\tcolumnType: \"TEXT\",\n\t\tschema,\n\t\toptions,\n\t\tui,\n\t\tvalidation,\n\t};\n}\n","import { z } from \"astro/zod\";\n\nimport type { FieldDefinition } from \"./types.js\";\n\n/**\n * Reference field\n * References another content item by ID\n */\nexport function reference(\n\tcollection: string,\n\toptions?: {\n\t\trequired?: boolean;\n\t},\n): FieldDefinition<string | undefined> {\n\tconst schema = z.string();\n\n\treturn {\n\t\ttype: \"reference\",\n\t\tcolumnType: \"TEXT\",\n\t\tschema: options?.required === false ? schema.optional() : schema,\n\t\toptions: {\n\t\t\t...options,\n\t\t\tcollection,\n\t\t},\n\t\tui: {\n\t\t\twidget: \"reference\",\n\t\t},\n\t};\n}\n","import { z } from \"astro/zod\";\n\nimport type { FieldDefinition, PortableTextBlock } from \"./types.js\";\n\n/**\n * Portable Text block schema\n */\nconst portableTextBlockSchema: z.ZodType<PortableTextBlock> = z\n\t.object({\n\t\t_type: z.string(),\n\t\t_key: z.string(),\n\t})\n\t.loose();\n\n/**\n * Portable Text field\n * Stores structured content in Portable Text format\n */\nexport function portableText(options?: {\n\trequired?: boolean;\n}): FieldDefinition<PortableTextBlock[] | undefined> {\n\tconst schema = z.array(portableTextBlockSchema);\n\n\treturn {\n\t\ttype: \"portableText\",\n\t\tcolumnType: \"JSON\",\n\t\tschema: options?.required === false ? schema.optional() : schema,\n\t\toptions,\n\t\tui: {\n\t\t\twidget: \"portableText\",\n\t\t},\n\t};\n}\n","import type { ProseMirrorDocument, ProseMirrorNode } from \"./types.js\";\n\nconst SUPPORTED_PORTABLE_TEXT_DECORATORS = new Set([\n\t\"strong\",\n\t\"em\",\n\t\"underline\",\n\t\"strike-through\",\n\t\"subscript\",\n\t\"superscript\",\n\t\"code\",\n]);\n\nconst SUPPORTED_PROSEMIRROR_MARKS = new Set([\n\t\"bold\",\n\t\"strong\",\n\t\"italic\",\n\t\"em\",\n\t\"underline\",\n\t\"strike\",\n\t\"strikethrough\",\n\t\"subscript\",\n\t\"superscript\",\n\t\"code\",\n\t\"link\",\n\t\"emdashPortableTextSpan\",\n]);\n\ntype UnknownRecord = Record<string, unknown>;\n\nfunction isRecord(value: unknown): value is UnknownRecord {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction collectPortableTextMarks(\n\tvalue: unknown,\n\tinheritedMarkDefs: ReadonlyMap<string, UnknownRecord>,\n\tunsupported: Set<string>,\n): void {\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tcollectPortableTextMarks(item, inheritedMarkDefs, unsupported);\n\t\t}\n\t\treturn;\n\t}\n\tif (!isRecord(value)) return;\n\n\tlet markDefs: ReadonlyMap<string, UnknownRecord> = inheritedMarkDefs;\n\tif (Array.isArray(value.markDefs)) {\n\t\tconst localMarkDefs = new Map(inheritedMarkDefs);\n\t\tfor (const markDef of value.markDefs) {\n\t\t\tif (isRecord(markDef) && typeof markDef._key === \"string\") {\n\t\t\t\tlocalMarkDefs.set(markDef._key, markDef);\n\t\t\t}\n\t\t}\n\t\tmarkDefs = localMarkDefs;\n\t}\n\n\tif (value._type === \"span\" && Array.isArray(value.marks)) {\n\t\tfor (const mark of value.marks) {\n\t\t\tif (typeof mark !== \"string\" || SUPPORTED_PORTABLE_TEXT_DECORATORS.has(mark)) continue;\n\t\t\tconst markDef = markDefs.get(mark);\n\t\t\tif (markDef?._type === \"link\") continue;\n\t\t\tunsupported.add(typeof markDef?._type === \"string\" ? markDef._type : mark);\n\t\t}\n\t}\n\n\tfor (const [key, child] of Object.entries(value)) {\n\t\tif (key !== \"markDefs\") {\n\t\t\tcollectPortableTextMarks(child, markDefs, unsupported);\n\t\t}\n\t}\n}\n\nfunction collectProseMirrorMarks(node: ProseMirrorNode, unsupported: Set<string>): void {\n\tfor (const mark of node.marks ?? []) {\n\t\tif (!SUPPORTED_PROSEMIRROR_MARKS.has(mark.type)) {\n\t\t\tunsupported.add(mark.type);\n\t\t}\n\t}\n\tfor (const child of node.content ?? []) {\n\t\tcollectProseMirrorMarks(child, unsupported);\n\t}\n}\n\nexport class UnsupportedPortableTextMarksError extends Error {\n\treadonly marks: string[];\n\n\tconstructor(marks: Iterable<string>) {\n\t\tconst sortedMarks = [...new Set(marks)].toSorted();\n\t\tsuper(`Unsupported Portable Text marks: ${sortedMarks.join(\", \")}`);\n\t\tthis.name = \"UnsupportedPortableTextMarksError\";\n\t\tthis.marks = sortedMarks;\n\t}\n}\n\nexport function findUnsupportedPortableTextMarks(blocks: readonly { _type: string }[]): string[] {\n\tconst unsupported = new Set<string>();\n\tfor (const block of blocks) {\n\t\tif (block._type === \"block\" || block._type === \"table\") {\n\t\t\tcollectPortableTextMarks(block, new Map(), unsupported);\n\t\t}\n\t}\n\treturn [...unsupported].toSorted();\n}\n\nexport function assertPortableTextMarksSupported(blocks: readonly { _type: string }[]): void {\n\tconst unsupported = findUnsupportedPortableTextMarks(blocks);\n\tif (unsupported.length > 0) {\n\t\tthrow new UnsupportedPortableTextMarksError(unsupported);\n\t}\n}\n\nexport function assertProseMirrorMarksSupported(document: ProseMirrorDocument): void {\n\tconst unsupported = new Set<string>();\n\tfor (const node of document.content) {\n\t\tcollectProseMirrorMarks(node, unsupported);\n\t}\n\tif (unsupported.size > 0) {\n\t\tthrow new UnsupportedPortableTextMarksError(unsupported);\n\t}\n}\n","import type { ProseMirrorDocument, ProseMirrorNode } from \"./types.js\";\n\nexport const MAX_ORDERED_LIST_START = 2_147_483_647;\n\nexport interface OrderedListMetadata {\n\tlistId: string;\n\tlistStart: number;\n}\n\nexport function normalizeListId(value: unknown): string | undefined {\n\tif (typeof value !== \"string\") return undefined;\n\tconst normalized = value.trim();\n\treturn normalized.length > 0 && normalized.length <= 128 ? normalized : undefined;\n}\n\nexport function normalizeListStart(value: unknown): number | undefined {\n\treturn typeof value === \"number\" &&\n\t\tNumber.isInteger(value) &&\n\t\tvalue >= 1 &&\n\t\tvalue <= MAX_ORDERED_LIST_START\n\t\t? value\n\t\t: undefined;\n}\n\nexport function deriveLegacyListId(seed: string): string {\n\tconst readable = `legacy:${seed}`;\n\tif (readable.length <= 128) return readable;\n\tlet hash = 2_166_136_261;\n\tfor (let i = 0; i < seed.length; i++) {\n\t\thash ^= seed.charCodeAt(i);\n\t\thash = Math.imul(hash, 16_777_619);\n\t}\n\treturn `legacy:${seed.slice(0, 96)}:${(hash >>> 0).toString(36)}:${seed.length.toString(36)}`;\n}\n\nexport function readOrderedListMetadata(\n\tattrs: Record<string, unknown> | undefined,\n\tfallbackId: string,\n): OrderedListMetadata {\n\treturn {\n\t\tlistId: normalizeListId(attrs?.listId) ?? deriveLegacyListId(fallbackId),\n\t\tlistStart: normalizeListStart(attrs?.listStart) ?? normalizeListStart(attrs?.start) ?? 1,\n\t};\n}\n\ninterface ProseMirrorListDescriptor {\n\tnode: ProseMirrorNode;\n\tpath: string;\n\tdepth: number;\n\tcontext: string;\n}\n\nfunction collectProseMirrorOrderedLists(doc: ProseMirrorDocument): ProseMirrorListDescriptor[] {\n\tconst lists: ProseMirrorListDescriptor[] = [];\n\tconst visit = (node: ProseMirrorNode, path: string, depth: number, context: string) => {\n\t\tif (node.type === \"orderedList\") lists.push({ node, path, depth, context });\n\t\tfor (const [index, child] of (node.content ?? []).entries()) {\n\t\t\tconst childPath = `${path}:${index}`;\n\t\t\tvisit(\n\t\t\t\tchild,\n\t\t\t\tchildPath,\n\t\t\t\tdepth + 1,\n\t\t\t\tchild.type === \"listItem\" ? `listItem:${childPath}` : context,\n\t\t\t);\n\t\t}\n\t};\n\tfor (const [index, node] of doc.content.entries()) {\n\t\tvisit(node, `root:${index}`, 0, \"root\");\n\t}\n\treturn lists;\n}\n\nfunction cloneProseMirrorNode(node: ProseMirrorNode): ProseMirrorNode {\n\treturn {\n\t\t...node,\n\t\tattrs: node.attrs ? { ...node.attrs } : undefined,\n\t\tcontent: node.content?.map(cloneProseMirrorNode),\n\t\tmarks: node.marks?.map((mark) => ({\n\t\t\t...mark,\n\t\t\tattrs: mark.attrs ? { ...mark.attrs } : undefined,\n\t\t})),\n\t};\n}\n\nfunction createRepairId(sourceId: string, scope: string, attempt: number): string {\n\tconst base = deriveLegacyListId(`repair:${sourceId}:${scope}`);\n\tconst suffix = `:${attempt.toString(36)}`;\n\treturn `${base.slice(0, 128 - suffix.length)}${suffix}`;\n}\n\nexport function normalizeProseMirrorOrderedListJson(doc: ProseMirrorDocument): ProseMirrorDocument {\n\tconst normalized = {\n\t\t...doc,\n\t\tcontent: doc.content.map(cloneProseMirrorNode),\n\t};\n\tconst canonicalBySourceScope = new Map<string, string>();\n\tconst assignedCanonicalIds = new Set<string>();\n\tconst lists = collectProseMirrorOrderedLists(normalized).map((list) => {\n\t\tconst sourceId =\n\t\t\tnormalizeListId(list.node.attrs?.listId) ??\n\t\t\tderiveLegacyListId(`pm-json:${list.path}:${list.depth}:${list.context}`);\n\t\tconst scope = JSON.stringify([list.depth, list.context]);\n\t\tconst sourceScope = JSON.stringify([sourceId, scope]);\n\t\tlet listId = canonicalBySourceScope.get(sourceScope);\n\t\tif (!listId) {\n\t\t\tif (!assignedCanonicalIds.has(sourceId)) {\n\t\t\t\tlistId = sourceId;\n\t\t\t} else {\n\t\t\t\tlet attempt = 0;\n\t\t\t\tdo {\n\t\t\t\t\tlistId = createRepairId(sourceId, scope, attempt++);\n\t\t\t\t} while (assignedCanonicalIds.has(listId));\n\t\t\t}\n\t\t\tcanonicalBySourceScope.set(sourceScope, listId);\n\t\t\tassignedCanonicalIds.add(listId);\n\t\t}\n\t\treturn {\n\t\t\t...list,\n\t\t\tlistId,\n\t\t\tscopeKey: JSON.stringify([listId, list.depth, list.context]),\n\t\t};\n\t});\n\n\tconst bases = new Map<string, number>();\n\tfor (const list of lists) {\n\t\tconst listStart = normalizeListStart(list.node.attrs?.listStart);\n\t\tif (listStart !== undefined && !bases.has(list.scopeKey)) {\n\t\t\tbases.set(list.scopeKey, listStart);\n\t\t}\n\t}\n\tfor (const list of lists) {\n\t\tif (!bases.has(list.scopeKey)) {\n\t\t\tbases.set(list.scopeKey, normalizeListStart(list.node.attrs?.start) ?? 1);\n\t\t}\n\t}\n\n\tconst counts = new Map<string, number>();\n\tfor (const list of lists) {\n\t\tconst listStart = bases.get(list.scopeKey)!;\n\t\tconst count = counts.get(list.scopeKey) ?? 0;\n\t\tconst start = normalizeListStart(listStart + count) ?? 1;\n\t\tconst directItemCount =\n\t\t\tlist.node.content?.filter((node) => node.type === \"listItem\").length ?? 0;\n\t\tcounts.set(list.scopeKey, count + directItemCount);\n\t\tlist.node.attrs = { ...list.node.attrs, listId: list.listId, listStart, start };\n\t}\n\treturn normalized;\n}\n","import { Extension, Mark, Node, type Extensions } from \"@tiptap/core\";\n\nimport type { PortableTextBlock, PortableTextMarkDef } from \"./types.js\";\n\nexport const PORTABLE_TEXT_BLOCK_NODE = \"emdashPortableTextBlock\";\nexport const PORTABLE_TEXT_BLOCK_ATTR = \"emdashPortableTextBlock\";\nexport const PORTABLE_TEXT_KEY_ATTR = \"emdashPortableTextKey\";\nexport const PORTABLE_TEXT_SPAN_MARK = \"emdashPortableTextSpan\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function attrsWithPortableTextKey(\n\tattrs: Record<string, unknown> | undefined,\n\tkey: string,\n): Record<string, unknown> {\n\treturn { ...attrs, [PORTABLE_TEXT_KEY_ATTR]: key };\n}\n\nexport function portableTextKeyFromAttrs(\n\tattrs: Record<string, unknown> | undefined,\n): string | undefined {\n\tconst key = attrs?.[PORTABLE_TEXT_KEY_ATTR];\n\treturn typeof key === \"string\" && key ? key : undefined;\n}\n\nexport function portableTextSpanKeyFromMarks(marks: unknown[] | undefined): string | undefined {\n\tfor (const mark of marks ?? []) {\n\t\tif (!isRecord(mark) || mark.type !== PORTABLE_TEXT_SPAN_MARK || !isRecord(mark.attrs)) continue;\n\t\tconst key = mark.attrs.key;\n\t\tif (typeof key === \"string\" && key) return key;\n\t}\n\treturn undefined;\n}\n\nexport function portableTextMarkDefsFromMarks(marks: unknown[] | undefined): PortableTextMarkDef[] {\n\tconst identity = (marks ?? []).find(\n\t\t(mark) => isRecord(mark) && mark.type === PORTABLE_TEXT_SPAN_MARK && isRecord(mark.attrs),\n\t);\n\tif (!isRecord(identity) || !isRecord(identity.attrs) || !Array.isArray(identity.attrs.markDefs)) {\n\t\treturn [];\n\t}\n\treturn identity.attrs.markDefs.filter(\n\t\t(markDef): markDef is PortableTextMarkDef =>\n\t\t\tisRecord(markDef) && typeof markDef._type === \"string\" && typeof markDef._key === \"string\",\n\t);\n}\n\nexport function portableTextBlockFromAttrs(\n\tattrs: Record<string, unknown> | undefined,\n): PortableTextBlock | undefined {\n\tconst block = attrs?.[PORTABLE_TEXT_BLOCK_ATTR];\n\tif (!isRecord(block) || typeof block._type !== \"string\" || typeof block._key !== \"string\") {\n\t\treturn undefined;\n\t}\n\treturn { ...block, _type: block._type, _key: block._key };\n}\n\nexport const PortableTextIdentityExtension = Extension.create({\n\tname: \"emdashPortableTextIdentity\",\n\n\taddGlobalAttributes() {\n\t\tconst hiddenAttribute = { default: null, rendered: false };\n\t\treturn [\n\t\t\t{\n\t\t\t\ttypes: [\n\t\t\t\t\t\"paragraph\",\n\t\t\t\t\t\"heading\",\n\t\t\t\t\t\"blockquote\",\n\t\t\t\t\t\"codeBlock\",\n\t\t\t\t\t\"htmlBlock\",\n\t\t\t\t\t\"iframeBlock\",\n\t\t\t\t\t\"image\",\n\t\t\t\t\t\"videoBlock\",\n\t\t\t\t\t\"horizontalRule\",\n\t\t\t\t\t\"gallery\",\n\t\t\t\t\tPORTABLE_TEXT_BLOCK_NODE,\n\t\t\t\t],\n\t\t\t\tattributes: { [PORTABLE_TEXT_KEY_ATTR]: hiddenAttribute },\n\t\t\t},\n\t\t];\n\t},\n});\n\nexport const PortableTextSpanIdentity = Mark.create({\n\tname: PORTABLE_TEXT_SPAN_MARK,\n\tinclusive: false,\n\tspanning: false,\n\n\taddAttributes() {\n\t\treturn {\n\t\t\tkey: { default: null, rendered: false },\n\t\t\tmarkDefs: { default: [], rendered: false },\n\t\t};\n\t},\n\n\tparseHTML() {\n\t\treturn [];\n\t},\n\n\trenderHTML() {\n\t\treturn [\"span\", 0];\n\t},\n});\n\nexport const PortableTextOpaqueBlock = Node.create({\n\tname: PORTABLE_TEXT_BLOCK_NODE,\n\tgroup: \"block\",\n\tatom: true,\n\tselectable: true,\n\tdraggable: true,\n\n\taddAttributes() {\n\t\treturn {\n\t\t\t[PORTABLE_TEXT_BLOCK_ATTR]: { default: null, rendered: false },\n\t\t};\n\t},\n\n\tparseHTML() {\n\t\treturn [{ tag: \"div[data-emdash-portable-text-block]\" }];\n\t},\n\n\trenderHTML({ node }) {\n\t\tconst blockType = portableTextBlockFromAttrs(node.attrs)?._type ?? \"unknown\";\n\t\treturn [\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\t\"data-emdash-portable-text-block\": blockType,\n\t\t\t\tcontenteditable: \"false\",\n\t\t\t},\n\t\t\t`[Unknown block type: ${blockType}]`,\n\t\t];\n\t},\n});\n\nexport const portableTextIdentityExtensions: Extensions = [\n\tPortableTextIdentityExtension,\n\tPortableTextSpanIdentity,\n\tPortableTextOpaqueBlock,\n];\n","/**\n * ProseMirror to Portable Text Converter\n *\n * Converts TipTap's ProseMirror JSON format to Portable Text for storage.\n */\n\nimport { htmlBlockFields } from \"@emdash-cms/admin/html-block\";\nimport {\n\tUnsafePortableTextTableError,\n\tproseMirrorTableToPortableText,\n} from \"@emdash-cms/admin/portable-text-table\";\n\nimport { sanitizeGalleryImages } from \"./gallery.js\";\nimport {\n\tUnsupportedPortableTextMarksError,\n\tassertProseMirrorMarksSupported,\n} from \"./mark-safety.js\";\nimport { readOrderedListMetadata, type OrderedListMetadata } from \"./numbered-list.js\";\nimport {\n\tPORTABLE_TEXT_BLOCK_NODE,\n\tPORTABLE_TEXT_SPAN_MARK,\n\tportableTextBlockFromAttrs,\n\tportableTextKeyFromAttrs,\n\tportableTextMarkDefsFromMarks,\n\tportableTextSpanKeyFromMarks,\n} from \"./portable-text-identity.js\";\nimport type {\n\tProseMirrorDocument,\n\tProseMirrorNode,\n\tProseMirrorMark,\n\tPortableTextBlock,\n\tPortableTextTextBlock,\n\tPortableTextSpan,\n\tPortableTextMarkDef,\n\tPortableTextImageBlock,\n\tPortableTextGalleryBlock,\n\tPortableTextCodeBlock,\n\tPortableTextHtmlBlock,\n\tPortableTextIframeBlock,\n\tPortableTextVideoBlock,\n} from \"./types.js\";\nimport { videoBlockFields } from \"./video.js\";\n\n/**\n * Generate a unique key for Portable Text blocks\n */\nfunction generateKey(): string {\n\treturn Math.random().toString(36).substring(2, 11);\n}\n\n/**\n * Convert ProseMirror document to Portable Text\n */\nexport function prosemirrorToPortableText(doc: ProseMirrorDocument): PortableTextBlock[] {\n\tif (!doc || doc.type !== \"doc\" || !doc.content) {\n\t\treturn [];\n\t}\n\tassertProseMirrorMarksSupported(doc);\n\n\tconst blocks: PortableTextBlock[] = [];\n\tconst usedBlockKeys = new Set<string>();\n\n\tfor (const [i, node] of doc.content.entries()) {\n\t\tif (i === doc.content.length - 1 && isUnkeyedEmptyParagraph(node)) continue;\n\t\tconst converted = convertNode(node, `root:${i}`);\n\t\tfor (const block of converted ? (Array.isArray(converted) ? converted : [converted]) : []) {\n\t\t\tlet key = block._key;\n\t\t\tif (usedBlockKeys.has(key)) {\n\t\t\t\tdo key = generateKey();\n\t\t\t\twhile (usedBlockKeys.has(key));\n\t\t\t}\n\t\t\tusedBlockKeys.add(key);\n\t\t\tblocks.push(key === block._key ? block : { ...block, _key: key });\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\nfunction isUnkeyedEmptyParagraph(node: ProseMirrorNode): boolean {\n\treturn (\n\t\tnode.type === \"paragraph\" &&\n\t\t(node.content?.length ?? 0) === 0 &&\n\t\tportableTextKeyFromAttrs(node.attrs) === undefined\n\t);\n}\n\n/**\n * Convert a single ProseMirror node to Portable Text block(s)\n */\nfunction convertNode(\n\tnode: ProseMirrorNode,\n\tpath: string,\n): PortableTextBlock | PortableTextBlock[] | null {\n\tswitch (node.type) {\n\t\tcase PORTABLE_TEXT_BLOCK_NODE:\n\t\t\treturn portableTextBlockFromAttrs(node.attrs) ?? null;\n\n\t\tcase \"paragraph\":\n\t\t\treturn convertParagraph(node);\n\n\t\tcase \"heading\":\n\t\t\treturn convertHeading(node);\n\n\t\tcase \"bulletList\":\n\t\t\treturn convertList(node, \"bullet\", path);\n\n\t\tcase \"orderedList\":\n\t\t\treturn convertList(node, \"number\", path);\n\n\t\tcase \"blockquote\":\n\t\t\treturn convertBlockquote(node);\n\n\t\tcase \"codeBlock\":\n\t\t\treturn convertCodeBlock(node);\n\n\t\tcase \"htmlBlock\":\n\t\t\treturn convertHtmlBlock(node);\n\n\t\tcase \"iframeBlock\":\n\t\t\treturn convertIframeBlock(node);\n\n\t\tcase \"image\":\n\t\t\treturn convertImage(node);\n\n\t\tcase \"videoBlock\":\n\t\t\treturn convertVideo(node);\n\n\t\tcase \"gallery\":\n\t\t\treturn convertGallery(node);\n\n\t\tcase \"table\": {\n\t\t\tconst result = proseMirrorTableToPortableText(node, {\n\t\t\t\tpath,\n\t\t\t\tcreateKey: generateKey,\n\t\t\t\tinlineToSpans: (content) => {\n\t\t\t\t\tconst { children, markDefs } = convertInlineContent(content, true);\n\t\t\t\t\treturn { content: children, markDefs };\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (!result.ok) {\n\t\t\t\tthrow new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);\n\t\t\t}\n\t\t\treturn result.table;\n\t\t}\n\n\t\tcase \"horizontalRule\":\n\t\t\treturn {\n\t\t\t\t_type: \"break\",\n\t\t\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\t\t\tstyle: \"lineBreak\",\n\t\t\t};\n\n\t\tdefault:\n\t\t\t// Preserve unknown blocks\n\t\t\treturn {\n\t\t\t\t_type: node.type,\n\t\t\t\t_key: generateKey(),\n\t\t\t\t...node.attrs,\n\t\t\t\t_pmContent: node.content,\n\t\t\t};\n\t}\n}\n\n/**\n * Convert paragraph to Portable Text block\n */\nfunction convertParagraph(node: ProseMirrorNode): PortableTextTextBlock | null {\n\tconst { children, markDefs } = convertInlineContent(node.content || []);\n\n\t// Skip empty paragraphs\n\tif (children.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst ta = node.attrs?.textAlign;\n\tconst textAlign = ta === \"center\" || ta === \"right\" || ta === \"justify\" ? ta : undefined;\n\n\treturn {\n\t\t_type: \"block\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tstyle: \"normal\",\n\t\tchildren,\n\t\t...(markDefs.length > 0 ? { markDefs } : {}),\n\t\t...(textAlign ? { textAlign } : {}),\n\t};\n}\n\n/** Map heading level number to Portable Text style */\nfunction headingLevelToStyle(level: number): PortableTextTextBlock[\"style\"] {\n\tswitch (level) {\n\t\tcase 1:\n\t\t\treturn \"h1\";\n\t\tcase 2:\n\t\t\treturn \"h2\";\n\t\tcase 3:\n\t\t\treturn \"h3\";\n\t\tcase 4:\n\t\t\treturn \"h4\";\n\t\tcase 5:\n\t\t\treturn \"h5\";\n\t\tcase 6:\n\t\t\treturn \"h6\";\n\t\tdefault:\n\t\t\treturn \"h1\";\n\t}\n}\n\n/**\n * Convert heading to Portable Text block\n */\nfunction convertHeading(node: ProseMirrorNode): PortableTextTextBlock | null {\n\tconst { children, markDefs } = convertInlineContent(node.content || []);\n\tconst rawLevel = typeof node.attrs?.level === \"number\" ? node.attrs.level : 1;\n\tconst style = headingLevelToStyle(rawLevel);\n\n\tif (children.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst ta = node.attrs?.textAlign;\n\tconst textAlign = ta === \"center\" || ta === \"right\" || ta === \"justify\" ? ta : undefined;\n\n\treturn {\n\t\t_type: \"block\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tstyle,\n\t\tchildren,\n\t\tmarkDefs: markDefs.length > 0 ? markDefs : undefined,\n\t\t...(textAlign ? { textAlign } : {}),\n\t};\n}\n\n/**\n * Convert list to Portable Text blocks\n */\nfunction convertList(\n\tnode: ProseMirrorNode,\n\tlistItem: \"bullet\" | \"number\",\n\tpath: string,\n): PortableTextTextBlock[] {\n\tconst blocks: PortableTextTextBlock[] = [];\n\tconst metadata = listItem === \"number\" ? readOrderedListMetadata(node.attrs, path) : undefined;\n\n\tfor (const [i, item] of (node.content ?? []).entries()) {\n\t\tif (item.type === \"listItem\") {\n\t\t\tconst itemBlocks = convertListItem(item, listItem, 1, `${path}:${i}`, metadata);\n\t\t\tblocks.push(...itemBlocks);\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Convert list item to Portable Text blocks\n */\nfunction convertListItem(\n\titem: ProseMirrorNode,\n\tlistItem: \"bullet\" | \"number\",\n\tlevel: number,\n\tpath: string,\n\tmetadata?: OrderedListMetadata,\n): PortableTextTextBlock[] {\n\tconst blocks: PortableTextTextBlock[] = [];\n\n\tfor (const [i, child] of (item.content ?? []).entries()) {\n\t\tif (child.type === \"paragraph\") {\n\t\t\tconst { children, markDefs } = convertInlineContent(child.content || []);\n\n\t\t\tif (children.length > 0) {\n\t\t\t\tblocks.push({\n\t\t\t\t\t_type: \"block\",\n\t\t\t\t\t_key: portableTextKeyFromAttrs(child.attrs) ?? generateKey(),\n\t\t\t\t\tstyle: \"normal\",\n\t\t\t\t\tlistItem,\n\t\t\t\t\tlevel,\n\t\t\t\t\t...metadata,\n\t\t\t\t\tchildren,\n\t\t\t\t\tmarkDefs: markDefs.length > 0 ? markDefs : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (child.type === \"bulletList\") {\n\t\t\tblocks.push(...convertListItemNested(child, \"bullet\", level + 1, `${path}:${i}`));\n\t\t} else if (child.type === \"orderedList\") {\n\t\t\tblocks.push(...convertListItemNested(child, \"number\", level + 1, `${path}:${i}`));\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Convert nested list\n */\nfunction convertListItemNested(\n\tnode: ProseMirrorNode,\n\tlistItem: \"bullet\" | \"number\",\n\tlevel: number,\n\tpath: string,\n): PortableTextTextBlock[] {\n\tconst blocks: PortableTextTextBlock[] = [];\n\tconst metadata = listItem === \"number\" ? readOrderedListMetadata(node.attrs, path) : undefined;\n\n\tfor (const [i, item] of (node.content ?? []).entries()) {\n\t\tif (item.type === \"listItem\") {\n\t\t\tblocks.push(...convertListItem(item, listItem, level, `${path}:${i}`, metadata));\n\t\t}\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Convert blockquote to Portable Text blocks\n */\nfunction convertBlockquote(\n\tnode: ProseMirrorNode,\n): PortableTextTextBlock | PortableTextTextBlock[] | null {\n\t// Blockquotes in PT are just blocks with style: \"blockquote\"\n\tconst blocks: PortableTextTextBlock[] = [];\n\n\tfor (const child of node.content || []) {\n\t\tif (child.type === \"paragraph\") {\n\t\t\tconst { children, markDefs } = convertInlineContent(child.content || []);\n\n\t\t\tif (children.length > 0) {\n\t\t\t\tblocks.push({\n\t\t\t\t\t_type: \"block\",\n\t\t\t\t\t_key:\n\t\t\t\t\t\tportableTextKeyFromAttrs(child.attrs) ??\n\t\t\t\t\t\tportableTextKeyFromAttrs(node.attrs) ??\n\t\t\t\t\t\tgenerateKey(),\n\t\t\t\t\tstyle: \"blockquote\",\n\t\t\t\t\tchildren,\n\t\t\t\t\tmarkDefs: markDefs.length > 0 ? markDefs : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn blocks.length === 1 ? blocks[0] : blocks.length > 0 ? blocks : null;\n}\n\n/**\n * Convert code block to Portable Text\n */\nfunction convertCodeBlock(node: ProseMirrorNode): PortableTextCodeBlock {\n\tconst code = node.content?.map((n) => n.text || \"\").join(\"\") || \"\";\n\tconst language = typeof node.attrs?.language === \"string\" ? node.attrs.language : undefined;\n\n\treturn {\n\t\t_type: \"code\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tcode,\n\t\tlanguage: language || undefined,\n\t};\n}\n\n/**\n * Convert HTML block to Portable Text\n */\nfunction convertHtmlBlock(node: ProseMirrorNode): PortableTextHtmlBlock {\n\treturn {\n\t\t_type: \"htmlBlock\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\t...htmlBlockFields(node.attrs ?? {}),\n\t};\n}\n\n/**\n * Convert iframe block to Portable Text, writing optional fields only when set\n */\nfunction convertIframeBlock(node: ProseMirrorNode): PortableTextIframeBlock {\n\tconst { src, title, width, height, allow, allowFullscreen } = node.attrs ?? {};\n\tconst block: PortableTextIframeBlock = {\n\t\t_type: \"iframe\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tsrc: typeof src === \"string\" ? src : \"\",\n\t};\n\tif (typeof title === \"string\" && title) block.title = title;\n\tif (isFrameDimension(width)) block.width = width;\n\tif (isFrameDimension(height)) block.height = height;\n\tif (typeof allow === \"string\" && allow) block.allow = allow;\n\tif (allowFullscreen === true) block.allowFullscreen = true;\n\treturn block;\n}\n\n/**\n * Convert video block to Portable Text\n */\nfunction convertVideo(node: ProseMirrorNode): PortableTextVideoBlock {\n\treturn {\n\t\t_type: \"video\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\t...videoBlockFields(node.attrs ?? {}),\n\t};\n}\n\nfunction isFrameDimension(value: unknown): value is number {\n\treturn typeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= 10_000;\n}\n\nfunction imageDimension(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? value : undefined;\n}\n\n/**\n * Convert image to Portable Text\n */\nfunction convertImage(node: ProseMirrorNode): PortableTextImageBlock {\n\tconst attrs = node.attrs;\n\tconst provider = typeof attrs?.provider === \"string\" ? attrs.provider : undefined;\n\tconst mediaId = typeof attrs?.mediaId === \"string\" ? attrs.mediaId : undefined;\n\tconst src = typeof attrs?.src === \"string\" ? attrs.src : \"\";\n\tconst alt = typeof attrs?.alt === \"string\" ? attrs.alt : undefined;\n\tconst title = typeof attrs?.title === \"string\" ? attrs.title : undefined;\n\tconst caption =\n\t\tattrs && Object.hasOwn(attrs, \"caption\")\n\t\t\t? typeof attrs.caption === \"string\"\n\t\t\t\t? attrs.caption\n\t\t\t\t: undefined\n\t\t\t: title;\n\tconst width = imageDimension(attrs?.width);\n\tconst height = imageDimension(attrs?.height);\n\tconst displayWidth = imageDimension(attrs?.displayWidth);\n\tconst displayHeight = imageDimension(attrs?.displayHeight);\n\tconst alignment = attrs?.alignment;\n\n\t// Normalise link: drop entirely when href is missing or empty so half-populated\n\t// { blank: true } objects don't round-trip.\n\tlet link: { href: string; blank?: boolean } | undefined;\n\tconst rawLink = attrs?.link;\n\tif (rawLink && typeof rawLink === \"object\") {\n\t\tconst linkObj = rawLink as { href?: unknown; blank?: unknown };\n\t\tconst href = typeof linkObj.href === \"string\" ? linkObj.href.trim() : \"\";\n\t\tif (href) {\n\t\t\tlink = { href };\n\t\t\tif (linkObj.blank === true) link.blank = true;\n\t\t}\n\t}\n\n\treturn {\n\t\t_type: \"image\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\tasset: {\n\t\t\t// Use mediaId as _ref if available (for proper provider lookups)\n\t\t\t_ref: mediaId || src || \"\",\n\t\t\t// Store URL for admin preview and fallback rendering\n\t\t\turl: src || \"\",\n\t\t\t// Store provider for external media\n\t\t\tprovider: provider && provider !== \"local\" ? provider : undefined,\n\t\t},\n\t\talt: alt || undefined,\n\t\tcaption: caption || (title ? \"\" : undefined),\n\t\ttitle: title || undefined,\n\t\twidth: width || undefined,\n\t\theight: height || undefined,\n\t\tdisplayWidth: displayWidth || undefined,\n\t\tdisplayHeight: displayHeight || undefined,\n\t\talignment:\n\t\t\talignment === \"left\" ||\n\t\t\talignment === \"center\" ||\n\t\t\talignment === \"right\" ||\n\t\t\talignment === \"wide\" ||\n\t\t\talignment === \"full\"\n\t\t\t\t? alignment\n\t\t\t\t: undefined,\n\t\tlink,\n\t};\n}\n\n/**\n * Convert gallery node to Portable Text\n */\nfunction convertGallery(node: ProseMirrorNode): PortableTextGalleryBlock {\n\tconst columns = node.attrs?.columns;\n\treturn {\n\t\t_type: \"gallery\",\n\t\t_key: portableTextKeyFromAttrs(node.attrs) ?? generateKey(),\n\t\timages: sanitizeGalleryImages(node.attrs?.images, generateKey),\n\t\t...(typeof columns === \"number\" ? { columns } : {}),\n\t};\n}\n\n/**\n * Convert inline content (text nodes with marks) to Portable Text spans\n */\nfunction convertInlineContent(\n\tnodes: ProseMirrorNode[],\n\tpreserveHardBreakBoundary = false,\n): {\n\tchildren: PortableTextSpan[];\n\tmarkDefs: PortableTextMarkDef[];\n} {\n\tconst children: PortableTextSpan[] = [];\n\tconst markDefs: PortableTextMarkDef[] = [];\n\tconst markDefMap = new Map<string, string>();\n\tconst usedSpanKeys = new Set<string>();\n\tconst claimSpanKey = (preferred?: string) => {\n\t\tif (preferred && !usedSpanKeys.has(preferred)) {\n\t\t\tusedSpanKeys.add(preferred);\n\t\t\treturn preferred;\n\t\t}\n\t\tlet key: string;\n\t\tdo key = generateKey();\n\t\twhile (usedSpanKeys.has(key));\n\t\tusedSpanKeys.add(key);\n\t\treturn key;\n\t};\n\n\tfor (const node of nodes) {\n\t\tif (node.type === \"text\" && node.text) {\n\t\t\tconst marks: string[] = [];\n\t\t\tconst originalMarkDefs = portableTextMarkDefsFromMarks(node.marks);\n\n\t\t\tfor (const mark of node.marks || []) {\n\t\t\t\tconst markType = convertMark(mark, markDefs, markDefMap, originalMarkDefs);\n\t\t\t\tif (markType) {\n\t\t\t\t\tmarks.push(markType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst preferredKey =\n\t\t\t\tportableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs);\n\t\t\tconst normalizedMarks = marks.length > 0 ? marks : undefined;\n\t\t\tconst previous = children.at(-1);\n\t\t\tif (\n\t\t\t\tpreferredKey &&\n\t\t\t\tprevious?._key === preferredKey &&\n\t\t\t\tJSON.stringify(previous.marks) === JSON.stringify(normalizedMarks)\n\t\t\t) {\n\t\t\t\tprevious.text += node.text;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tchildren.push({\n\t\t\t\t_type: \"span\",\n\t\t\t\t_key: claimSpanKey(preferredKey),\n\t\t\t\ttext: node.text,\n\t\t\t\tmarks: normalizedMarks,\n\t\t\t});\n\t\t} else if (node.type === \"hardBreak\") {\n\t\t\t// Hard breaks become newlines in the text\n\t\t\tif (children.length > 0 && !preserveHardBreakBoundary) {\n\t\t\t\tconst lastChild = children.at(-1)!;\n\t\t\t\tlastChild.text += \"\\n\";\n\t\t\t} else {\n\t\t\t\tchildren.push({\n\t\t\t\t\t_type: \"span\",\n\t\t\t\t\t_key: claimSpanKey(\n\t\t\t\t\t\tportableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs),\n\t\t\t\t\t),\n\t\t\t\t\ttext: \"\\n\",\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Ensure at least one span exists\n\tif (children.length === 0) {\n\t\tchildren.push({\n\t\t\t_type: \"span\",\n\t\t\t_key: claimSpanKey(),\n\t\t\ttext: \"\",\n\t\t});\n\t}\n\n\treturn { children, markDefs };\n}\n\n/**\n * Convert a ProseMirror mark to Portable Text mark\n */\nfunction convertMark(\n\tmark: ProseMirrorMark,\n\tmarkDefs: PortableTextMarkDef[],\n\tmarkDefMap: Map<string, string>,\n\toriginalMarkDefs: PortableTextMarkDef[],\n): string | null {\n\tswitch (mark.type) {\n\t\tcase \"bold\":\n\t\tcase \"strong\":\n\t\t\treturn \"strong\";\n\n\t\tcase \"italic\":\n\t\tcase \"em\":\n\t\t\treturn \"em\";\n\n\t\tcase \"underline\":\n\t\t\treturn \"underline\";\n\n\t\tcase \"strike\":\n\t\tcase \"strikethrough\":\n\t\t\treturn \"strike-through\";\n\n\t\tcase \"subscript\":\n\t\t\treturn \"subscript\";\n\n\t\tcase \"superscript\":\n\t\t\treturn \"superscript\";\n\n\t\tcase \"code\":\n\t\t\treturn \"code\";\n\n\t\tcase PORTABLE_TEXT_SPAN_MARK:\n\t\t\treturn null;\n\n\t\tcase \"link\": {\n\t\t\tconst href = (typeof mark.attrs?.href === \"string\" ? mark.attrs.href : \"\") || \"\";\n\t\t\tconst blank = mark.attrs?.target === \"_blank\";\n\t\t\tconst originalMarkDef = originalMarkDefs.find((markDef) => markDef._type === \"link\");\n\t\t\tconst mapKey = originalMarkDef\n\t\t\t\t? `key:${originalMarkDef._key}`\n\t\t\t\t: `value:${JSON.stringify([href, blank])}`;\n\n\t\t\t// Check if we already have a mark def for this link\n\t\t\tif (markDefMap.has(mapKey)) {\n\t\t\t\treturn markDefMap.get(mapKey)!;\n\t\t\t}\n\n\t\t\t// Create new mark def\n\t\t\tconst key = originalMarkDef?._key || generateKey();\n\t\t\tmarkDefs.push({\n\t\t\t\t...originalMarkDef,\n\t\t\t\t_type: \"link\",\n\t\t\t\t_key: key,\n\t\t\t\thref,\n\t\t\t\t...(originalMarkDef\n\t\t\t\t\t? blank || Object.hasOwn(originalMarkDef, \"blank\")\n\t\t\t\t\t\t? { blank }\n\t\t\t\t\t\t: {}\n\t\t\t\t\t: { blank }),\n\t\t\t});\n\t\t\tmarkDefMap.set(mapKey, key);\n\n\t\t\treturn key;\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new UnsupportedPortableTextMarksError([mark.type]);\n\t}\n}\n","/**\n * Image link normalisation.\n *\n * A Portable Text image block carries its optional link in one of two shapes:\n *\n * - `{ href, blank? }` — the canonical shape the editor writes\n * - `\"https://…\"` — a bare string, emitted by `gutenberg-to-portable-text`\n * for linked images and therefore present on WordPress-imported content\n *\n * Every consumer reads through this helper so the legacy shape keeps working\n * and is upgraded to the canonical shape the first time the block round-trips\n * through the editor.\n */\nimport type { PortableTextImageLink } from \"./types.js\";\n\nexport function normalizeImageLink(raw: unknown): PortableTextImageLink | null {\n\tif (typeof raw === \"string\") {\n\t\tconst href = raw.trim();\n\t\treturn href ? { href } : null;\n\t}\n\tif (typeof raw !== \"object\" || raw === null) return null;\n\tconst { href, blank } = raw as { href?: unknown; blank?: unknown };\n\tif (typeof href !== \"string\") return null;\n\tconst trimmed = href.trim();\n\tif (!trimmed) return null;\n\treturn blank === true ? { href: trimmed, blank: true } : { href: trimmed };\n}\n","/**\n * Portable Text to ProseMirror Converter\n *\n * Converts Portable Text to TipTap's ProseMirror JSON format for editing.\n */\n\nimport { htmlBlockFields } from \"@emdash-cms/admin/html-block\";\nimport {\n\tUnsafePortableTextTableError,\n\tportableTextTableToProseMirror,\n} from \"@emdash-cms/admin/portable-text-table\";\n\nimport { resolveImageMedia, sanitizeGalleryImages } from \"./gallery.js\";\nimport { normalizeImageLink } from \"./image-link.js\";\nimport {\n\tUnsupportedPortableTextMarksError,\n\tassertPortableTextMarksSupported,\n} from \"./mark-safety.js\";\nimport {\n\tderiveLegacyListId,\n\tnormalizeProseMirrorOrderedListJson,\n\tnormalizeListId,\n\tnormalizeListStart,\n} from \"./numbered-list.js\";\nimport {\n\tPORTABLE_TEXT_BLOCK_ATTR,\n\tPORTABLE_TEXT_BLOCK_NODE,\n\tPORTABLE_TEXT_SPAN_MARK,\n\tattrsWithPortableTextKey,\n} from \"./portable-text-identity.js\";\nimport type {\n\tProseMirrorDocument,\n\tProseMirrorNode,\n\tProseMirrorMark,\n\tPortableTextBlock,\n\tPortableTextTextBlock,\n\tPortableTextSpan,\n\tPortableTextMarkDef,\n\tPortableTextImageBlock,\n\tPortableTextGalleryBlock,\n\tPortableTextCodeBlock,\n\tPortableTextIframeBlock,\n} from \"./types.js\";\nimport { isPortableTextVideoBlock, videoNodeAttrs } from \"./video.js\";\n\nfunction generateKey(): string {\n\treturn Math.random().toString(36).substring(2, 11);\n}\n\nexport interface PortableTextToProsemirrorOptions {\n\t/**\n\t * Preserve custom blocks and Portable Text keys through a ProseMirror round trip.\n\t * Add `portableTextIdentityExtensions` to the TipTap schema when this is enabled.\n\t */\n\tpreserveIdentity?: boolean;\n}\n\n/** Convert Portable Text to a ProseMirror document. */\nexport function portableTextToProsemirror(\n\tblocks: PortableTextBlock[],\n\toptions: PortableTextToProsemirrorOptions = {},\n): ProseMirrorDocument {\n\tif (!blocks || blocks.length === 0) {\n\t\treturn {\n\t\t\ttype: \"doc\",\n\t\t\tcontent: [{ type: \"paragraph\" }],\n\t\t};\n\t}\n\tassertPortableTextMarksSupported(blocks);\n\tconst preserveIdentity = options.preserveIdentity === true;\n\n\tconst content: ProseMirrorNode[] = [];\n\tlet i = 0;\n\n\twhile (i < blocks.length) {\n\t\tconst block = blocks[i];\n\n\t\t// Check for list items\n\t\tif (isTextBlock(block) && block.listItem) {\n\t\t\t// Collect a list \"run\": the level=1 anchor plus everything that\n\t\t\t// nests under it (level > 1, regardless of listItem type — a number\n\t\t\t// child under a bullet parent is still part of the same tree). A\n\t\t\t// level=1 block with a different listItem ends the run. Without the\n\t\t\t// `level > 1` carve-out the run breaks on the first nested type\n\t\t\t// switch and the descendant subtree leaks out as its own top-level\n\t\t\t// list (e.g. `[bullet L1, number L2, bullet L1]` would render as\n\t\t\t// three sibling lists instead of one bullet list with a numbered\n\t\t\t// child).\n\t\t\tconst listBlocks: PortableTextTextBlock[] = [];\n\t\t\tconst listType = block.listItem;\n\t\t\tconst runStart = i;\n\t\t\tconst rootId = listType === \"number\" ? normalizeListId(block.listId) : undefined;\n\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst current = blocks[i];\n\t\t\t\tif (!isTextBlock(current) || !current.listItem) break;\n\t\t\t\tconst level = current.level || 1;\n\t\t\t\tconst currentId =\n\t\t\t\t\tcurrent.listItem === \"number\" ? normalizeListId(current.listId) : undefined;\n\t\t\t\tconst sameRootIdentity =\n\t\t\t\t\tlistType !== \"number\" ||\n\t\t\t\t\tlevel > 1 ||\n\t\t\t\t\t(rootId ? currentId === rootId : currentId === undefined);\n\t\t\t\tif (level > 1 || (current.listItem === listType && sameRootIdentity)) {\n\t\t\t\t\tlistBlocks.push(current);\n\t\t\t\t\ti++;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontent.push(convertList(listBlocks, listType, `root:${runStart}`, preserveIdentity));\n\t\t} else if (isTextBlock(block) && block.style === \"blockquote\") {\n\t\t\t// Collect a blockquote \"run\": Portable Text is flat, so a\n\t\t\t// multi-paragraph quote is stored as consecutive blocks with\n\t\t\t// style \"blockquote\" (that's what the Gutenberg importer emits\n\t\t\t// and what prosemirrorToPortableText serializes back to).\n\t\t\t// Without this grouping each paragraph became its own quote\n\t\t\t// node, and editor merges reverted on reload.\n\t\t\tconst quoteBlocks: PortableTextTextBlock[] = [];\n\t\t\twhile (i < blocks.length) {\n\t\t\t\tconst current = blocks[i];\n\t\t\t\tif (\n\t\t\t\t\t!isTextBlock(current) ||\n\t\t\t\t\tcurrent.style !== \"blockquote\" ||\n\t\t\t\t\tcurrent.listItem !== undefined\n\t\t\t\t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tquoteBlocks.push(current);\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\tcontent.push({\n\t\t\t\ttype: \"blockquote\",\n\t\t\t\tcontent: quoteBlocks.map((quoteBlock) => {\n\t\t\t\t\tconst paragraph = convertSpans(\n\t\t\t\t\t\tquoteBlock.children,\n\t\t\t\t\t\tquoteBlock.markDefs || [],\n\t\t\t\t\t\tpreserveIdentity,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\t\tattrs: identityAttrs(undefined, quoteBlock._key, preserveIdentity),\n\t\t\t\t\t\tcontent: paragraph.length > 0 ? paragraph : undefined,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t});\n\t\t} else {\n\t\t\tconst converted = convertBlock(block, `root:${i}`, preserveIdentity);\n\t\t\tif (converted) {\n\t\t\t\tcontent.push(converted);\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t}\n\n\treturn normalizeProseMirrorOrderedListJson({\n\t\ttype: \"doc\",\n\t\tcontent: content.length > 0 ? content : [{ type: \"paragraph\" }],\n\t});\n}\n\nfunction identityAttrs(\n\tattrs: Record<string, unknown> | undefined,\n\tkey: string,\n\tpreserveIdentity: boolean,\n): Record<string, unknown> | undefined {\n\treturn preserveIdentity ? attrsWithPortableTextKey(attrs, key) : attrs;\n}\n\nfunction getListMetadata(\n\titem: PortableTextTextBlock,\n\tfallbackSeed: string,\n): { listId: string; listStart?: number } {\n\tconst listId = normalizeListId(item.listId) ?? deriveLegacyListId(fallbackSeed);\n\tconst listStart = normalizeListStart(item.listStart);\n\treturn {\n\t\tlistId,\n\t\t...(listStart === undefined ? {} : { listStart }),\n\t};\n}\n\nfunction belongsToNestedGroup(\n\titem: PortableTextTextBlock,\n\tminLevel: number,\n\tparentListType: \"bullet\" | \"number\",\n\tanchorType: \"bullet\" | \"number\",\n\tanchorId: string | undefined,\n): boolean {\n\tif ((item.level || 2) > minLevel) return true;\n\tif ((item.listItem || parentListType) !== anchorType) return false;\n\tif (anchorType !== \"number\") return true;\n\tconst itemId = normalizeListId(item.listId);\n\treturn anchorId ? itemId === anchorId : itemId === undefined;\n}\n\n/**\n * Type guard for text blocks\n */\nfunction isTextBlock(block: PortableTextBlock): block is PortableTextTextBlock {\n\treturn block._type === \"block\";\n}\n\n/**\n * Type guard for image blocks.\n * Checks both `_type` and that `asset` is a valid object — image blocks\n * without an `asset` wrapper (e.g. `{ _type: \"image\", url: \"...\" }`) are\n * malformed and should not be cast to `PortableTextImageBlock`.\n */\nfunction isImageBlock(block: PortableTextBlock): block is PortableTextImageBlock {\n\treturn (\n\t\tblock._type === \"image\" &&\n\t\t\"asset\" in block &&\n\t\ttypeof block.asset === \"object\" &&\n\t\tblock.asset !== null\n\t);\n}\n\n/**\n * Type guard for gallery blocks that carry a usable `images` array.\n * Galleries without one are handled separately in `convertBlock`.\n */\nfunction isGalleryBlock(block: PortableTextBlock): block is PortableTextGalleryBlock {\n\treturn block._type === \"gallery\" && \"images\" in block && Array.isArray(block.images);\n}\n\nconst isString = (value: unknown) => typeof value === \"string\";\nconst isFrameDimension = (value: unknown) =>\n\ttypeof value === \"number\" && Number.isInteger(value) && value >= 1 && value <= 10_000;\n\nconst IFRAME_BLOCK_FIELDS = new Map<string, (value: unknown) => boolean>([\n\t[\"_type\", () => true],\n\t[\"_key\", () => true],\n\t[\"src\", isString],\n\t[\"title\", isString],\n\t[\"width\", isFrameDimension],\n\t[\"height\", isFrameDimension],\n\t[\"allow\", isString],\n\t[\"allowFullscreen\", (value) => typeof value === \"boolean\"],\n]);\n\n/**\n * An `iframe` block with other fields, or with values of other types, belongs\n * to a plugin and stays a generic block.\n */\nfunction isIframeBlock(block: PortableTextBlock): block is PortableTextIframeBlock {\n\treturn (\n\t\tblock._type === \"iframe\" &&\n\t\ttypeof block.src === \"string\" &&\n\t\tObject.entries(block).every(\n\t\t\t([key, value]) => value === undefined || (IFRAME_BLOCK_FIELDS.get(key)?.(value) ?? false),\n\t\t)\n\t);\n}\n\n/**\n * Type guard for code blocks\n */\nfunction isCodeBlock(block: PortableTextBlock): block is PortableTextCodeBlock {\n\treturn block._type === \"code\";\n}\n\n/**\n * Convert a single Portable Text block to ProseMirror node\n */\nfunction convertBlock(\n\tblock: PortableTextBlock,\n\tpath: string,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode | null {\n\tif (isTextBlock(block)) {\n\t\treturn convertTextBlock(block, preserveIdentity);\n\t}\n\tif (isImageBlock(block)) {\n\t\treturn convertImage(block, preserveIdentity);\n\t}\n\tif (block._type === \"image\") {\n\t\t// Malformed image block (no asset wrapper) — extract url from top level\n\t\treturn convertMalformedImage(block, preserveIdentity);\n\t}\n\tif (isGalleryBlock(block)) {\n\t\treturn {\n\t\t\ttype: \"gallery\",\n\t\t\tattrs: identityAttrs(\n\t\t\t\t{\n\t\t\t\t\timages: sanitizeGalleryImages(block.images),\n\t\t\t\t\tcolumns: typeof block.columns === \"number\" ? block.columns : undefined,\n\t\t\t\t},\n\t\t\t\tblock._key,\n\t\t\t\tpreserveIdentity,\n\t\t\t),\n\t\t};\n\t}\n\tif (isCodeBlock(block)) {\n\t\treturn convertCodeBlock(block, preserveIdentity);\n\t}\n\tif (block._type === \"htmlBlock\") {\n\t\treturn {\n\t\t\ttype: \"htmlBlock\",\n\t\t\tattrs: identityAttrs({ ...htmlBlockFields(block) }, block._key, preserveIdentity),\n\t\t};\n\t}\n\tif (isIframeBlock(block)) {\n\t\tconst { _type, _key, ...attrs } = block;\n\t\treturn { type: \"iframeBlock\", attrs: identityAttrs(attrs, _key, preserveIdentity) };\n\t}\n\tif (isPortableTextVideoBlock(block)) {\n\t\treturn {\n\t\t\ttype: \"videoBlock\",\n\t\t\tattrs: identityAttrs(videoNodeAttrs(block), block._key, preserveIdentity),\n\t\t};\n\t}\n\tif (block._type === \"break\") {\n\t\treturn {\n\t\t\ttype: \"horizontalRule\",\n\t\t\tattrs: identityAttrs(undefined, block._key, preserveIdentity),\n\t\t};\n\t}\n\tif (block._type === \"gallery\") {\n\t\tif (preserveIdentity) {\n\t\t\treturn {\n\t\t\t\ttype: PORTABLE_TEXT_BLOCK_NODE,\n\t\t\t\tattrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block },\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\ttype: \"paragraph\",\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `[Unknown block type: ${block._type}]`,\n\t\t\t\t\tmarks: [{ type: \"code\" }],\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n\tif (preserveIdentity) {\n\t\treturn {\n\t\t\ttype: PORTABLE_TEXT_BLOCK_NODE,\n\t\t\tattrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block },\n\t\t};\n\t}\n\tif (block._type === \"table\") {\n\t\tconst result = portableTextTableToProseMirror(block, {\n\t\t\tpath,\n\t\t\tcreateKey: generateKey,\n\t\t\tspansToInline: (content, markDefs) => convertSpans(content, markDefs, preserveIdentity),\n\t\t});\n\t\tif (!result.ok) {\n\t\t\tthrow new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);\n\t\t}\n\t\treturn result.node;\n\t}\n\treturn {\n\t\ttype: \"paragraph\",\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `[Unknown block type: ${block._type}]`,\n\t\t\t\tmarks: [{ type: \"code\" }],\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Convert text block to ProseMirror paragraph or heading\n */\nfunction convertTextBlock(\n\tblock: PortableTextTextBlock,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode | null {\n\tconst { style = \"normal\", children, markDefs = [] } = block;\n\n\t// Convert children to ProseMirror nodes\n\tconst content = convertSpans(children, markDefs, preserveIdentity);\n\n\t// Determine node type based on style\n\tswitch (style) {\n\t\tcase \"h1\":\n\t\tcase \"h2\":\n\t\tcase \"h3\":\n\t\tcase \"h4\":\n\t\tcase \"h5\":\n\t\tcase \"h6\": {\n\t\t\tconst level = parseInt(style.substring(1), 10);\n\t\t\treturn {\n\t\t\t\ttype: \"heading\",\n\t\t\t\tattrs: identityAttrs(\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\t...(block.textAlign ? { textAlign: block.textAlign } : {}),\n\t\t\t\t\t},\n\t\t\t\t\tblock._key,\n\t\t\t\t\tpreserveIdentity,\n\t\t\t\t),\n\t\t\t\tcontent: content.length > 0 ? content : undefined,\n\t\t\t};\n\t\t}\n\n\t\tcase \"blockquote\":\n\t\t\treturn {\n\t\t\t\ttype: \"blockquote\",\n\t\t\t\tattrs: identityAttrs(undefined, block._key, preserveIdentity),\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\t\tcontent: content.length > 0 ? content : undefined,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\n\t\tcase \"normal\":\n\t\tdefault:\n\t\t\treturn {\n\t\t\t\ttype: \"paragraph\",\n\t\t\t\tattrs: identityAttrs(\n\t\t\t\t\tblock.textAlign ? { textAlign: block.textAlign } : undefined,\n\t\t\t\t\tblock._key,\n\t\t\t\t\tpreserveIdentity,\n\t\t\t\t),\n\t\t\t\tcontent: content.length > 0 ? content : undefined,\n\t\t\t};\n\t}\n}\n\n/**\n * Convert list items to ProseMirror list\n */\nfunction convertList(\n\titems: PortableTextTextBlock[],\n\tlistType: \"bullet\" | \"number\",\n\tcontext: string,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\t// Group items by level\n\tconst rootItems: ProseMirrorNode[] = [];\n\tlet i = 0;\n\n\twhile (i < items.length) {\n\t\tconst item = items[i];\n\t\tconst level = item.level || 1;\n\n\t\tif (level === 1) {\n\t\t\t// Collect nested items for this root item\n\t\t\tconst nestedItems: PortableTextTextBlock[] = [];\n\t\t\ti++;\n\n\t\t\twhile (i < items.length && (items[i].level || 1) > 1) {\n\t\t\t\tnestedItems.push(items[i]);\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\trootItems.push(\n\t\t\t\tconvertListItem(\n\t\t\t\t\titem,\n\t\t\t\t\tnestedItems,\n\t\t\t\t\tlistType,\n\t\t\t\t\t`${context}:${rootItems.length}`,\n\t\t\t\t\tpreserveIdentity,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\t// Orphan nested item - treat as root\n\t\t\trootItems.push(\n\t\t\t\tconvertListItem(item, [], listType, `${context}:${rootItems.length}`, preserveIdentity),\n\t\t\t);\n\t\t\ti++;\n\t\t}\n\t}\n\n\tconst metadata =\n\t\tlistType === \"number\" ? getListMetadata(items[0], `${context}:${items[0]._key}`) : undefined;\n\n\treturn {\n\t\ttype: listType === \"bullet\" ? \"bulletList\" : \"orderedList\",\n\t\tattrs: metadata ? { ...metadata, start: metadata.listStart ?? 1 } : undefined,\n\t\tcontent: rootItems,\n\t};\n}\n\n/**\n * Convert a single list item to ProseMirror\n */\nfunction convertListItem(\n\titem: PortableTextTextBlock,\n\tnestedItems: PortableTextTextBlock[],\n\tparentListType: \"bullet\" | \"number\",\n\tcontext: string,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\tconst content: ProseMirrorNode[] = [];\n\n\t// Add paragraph content\n\tconst spans = convertSpans(item.children, item.markDefs || [], preserveIdentity);\n\tcontent.push({\n\t\ttype: \"paragraph\",\n\t\tattrs: identityAttrs(undefined, item._key, preserveIdentity),\n\t\tcontent: spans.length > 0 ? spans : undefined,\n\t});\n\n\t// Handle nested items\n\tif (nestedItems.length > 0) {\n\t\t// The shallowest level in `nestedItems` is the effective root of this\n\t\t// item's nested subtree. A new sub-list only starts when we hit\n\t\t// another block at that root level with a different `listItem` type;\n\t\t// deeper blocks (level > minLevel) belong to the current group as\n\t\t// descendants regardless of their own `listItem`. A deep mixed tree\n\t\t// like `bullet L1 → number L2 → bullet L3 → number L2` stays nested\n\t\t// under B(L2) and preserves its original level on round-trip.\n\t\tlet minLevel = Infinity;\n\t\tfor (const ni of nestedItems) {\n\t\t\tconst level = ni.level || 2;\n\t\t\tif (level < minLevel) minLevel = level;\n\t\t}\n\n\t\tlet j = 0;\n\t\twhile (j < nestedItems.length) {\n\t\t\tconst anchorType: \"bullet\" | \"number\" = nestedItems[j].listItem || parentListType;\n\t\t\tconst anchorId = anchorType === \"number\" ? normalizeListId(nestedItems[j].listId) : undefined;\n\t\t\tconst nestedGroup: PortableTextTextBlock[] = [];\n\n\t\t\tdo {\n\t\t\t\tnestedGroup.push(nestedItems[j]);\n\t\t\t\tj++;\n\t\t\t} while (\n\t\t\t\tj < nestedItems.length &&\n\t\t\t\tbelongsToNestedGroup(nestedItems[j], minLevel, parentListType, anchorType, anchorId)\n\t\t\t);\n\n\t\t\tif (nestedGroup.length > 0) {\n\t\t\t\t// Decrease level for nested conversion\n\t\t\t\tconst adjustedGroup = nestedGroup.map((ni) => ({\n\t\t\t\t\t...ni,\n\t\t\t\t\tlevel: (ni.level || 2) - 1,\n\t\t\t\t}));\n\t\t\t\tcontent.push(\n\t\t\t\t\tconvertList(\n\t\t\t\t\t\tadjustedGroup,\n\t\t\t\t\t\tanchorType,\n\t\t\t\t\t\t`${context}:nested:${j - nestedGroup.length}`,\n\t\t\t\t\t\tpreserveIdentity,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: \"listItem\",\n\t\tcontent,\n\t};\n}\n\n/**\n * Convert Portable Text spans to ProseMirror text nodes\n */\nfunction convertSpans(\n\tspans: PortableTextSpan[],\n\tmarkDefs: PortableTextMarkDef[],\n\tpreserveIdentity: boolean,\n): ProseMirrorNode[] {\n\tconst nodes: ProseMirrorNode[] = [];\n\tconst markDefsMap = new Map(markDefs.map((md) => [md._key, md]));\n\n\tfor (const span of spans) {\n\t\tif (span._type !== \"span\") continue;\n\t\tconst referencedMarkDefs = markDefs.filter((markDef) => span.marks?.includes(markDef._key));\n\n\t\t// Handle newlines in text\n\t\tconst parts = span.text.split(\"\\n\");\n\n\t\tfor (let i = 0; i < parts.length; i++) {\n\t\t\tconst text = parts[i];\n\n\t\t\t// Add text node\n\t\t\tif (text.length > 0) {\n\t\t\t\tconst marks = convertMarks(span.marks || [], markDefsMap);\n\t\t\t\tif (preserveIdentity) {\n\t\t\t\t\tmarks.push({\n\t\t\t\t\t\ttype: PORTABLE_TEXT_SPAN_MARK,\n\t\t\t\t\t\tattrs: { key: span._key, markDefs: referencedMarkDefs },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst node: ProseMirrorNode = {\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext,\n\t\t\t\t};\n\t\t\t\tif (marks.length > 0) node.marks = marks;\n\t\t\t\tnodes.push(node);\n\t\t\t}\n\n\t\t\t// Add hard break between parts (not after last)\n\t\t\tif (i < parts.length - 1) {\n\t\t\t\tnodes.push(\n\t\t\t\t\tpreserveIdentity\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\ttype: \"hardBreak\",\n\t\t\t\t\t\t\t\tmarks: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: PORTABLE_TEXT_SPAN_MARK,\n\t\t\t\t\t\t\t\t\t\tattrs: { key: span._key, markDefs: referencedMarkDefs },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: { type: \"hardBreak\" },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nodes;\n}\n\n/**\n * Convert Portable Text marks to ProseMirror marks\n */\nfunction convertMarks(\n\tmarks: string[],\n\tmarkDefs: Map<string, PortableTextMarkDef>,\n): ProseMirrorMark[] {\n\tconst pmMarks: ProseMirrorMark[] = [];\n\n\tfor (const mark of marks) {\n\t\tswitch (mark) {\n\t\t\tcase \"strong\":\n\t\t\t\tpmMarks.push({ type: \"bold\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"em\":\n\t\t\t\tpmMarks.push({ type: \"italic\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"underline\":\n\t\t\t\tpmMarks.push({ type: \"underline\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"strike-through\":\n\t\t\t\tpmMarks.push({ type: \"strike\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"subscript\":\n\t\t\t\tpmMarks.push({ type: \"subscript\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"superscript\":\n\t\t\t\tpmMarks.push({ type: \"superscript\" });\n\t\t\t\tbreak;\n\n\t\t\tcase \"code\":\n\t\t\t\tpmMarks.push({ type: \"code\" });\n\t\t\t\tbreak;\n\n\t\t\tdefault: {\n\t\t\t\t// Check if it's a mark definition reference\n\t\t\t\tconst markDef = markDefs.get(mark);\n\t\t\t\tif (markDef?._type === \"link\") {\n\t\t\t\t\tpmMarks.push({\n\t\t\t\t\t\ttype: \"link\",\n\t\t\t\t\t\tattrs: {\n\t\t\t\t\t\t\thref: markDef.href,\n\t\t\t\t\t\t\ttarget: markDef.blank ? \"_blank\" : null,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthrow new UnsupportedPortableTextMarksError([\n\t\t\t\t\t\ttypeof markDef?._type === \"string\" ? markDef._type : mark,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn pmMarks;\n}\n\nfunction imageAlignment(value: unknown): PortableTextImageBlock[\"alignment\"] {\n\treturn value === \"left\" ||\n\t\tvalue === \"center\" ||\n\t\tvalue === \"right\" ||\n\t\tvalue === \"wide\" ||\n\t\tvalue === \"full\"\n\t\t? value\n\t\t: undefined;\n}\n\nfunction imageDimension(value: unknown): number | undefined {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? value : undefined;\n}\n\n/**\n * Convert image block to ProseMirror\n */\nfunction convertImage(block: PortableTextImageBlock, preserveIdentity: boolean): ProseMirrorNode {\n\tconst { asset, alt, width, height } = resolveImageMedia(block);\n\treturn {\n\t\ttype: \"image\",\n\t\tattrs: identityAttrs(\n\t\t\t{\n\t\t\t\tsrc: asset.url || asset._ref,\n\t\t\t\talt: alt || \"\",\n\t\t\t\ttitle: block.title || \"\",\n\t\t\t\tcaption: Object.hasOwn(block, \"caption\") ? block.caption || \"\" : block.title || \"\",\n\t\t\t\tmediaId: asset._ref,\n\t\t\t\tprovider: asset.provider,\n\t\t\t\twidth: imageDimension(width),\n\t\t\t\theight: imageDimension(height),\n\t\t\t\tdisplayWidth: imageDimension(block.displayWidth),\n\t\t\t\tdisplayHeight: imageDimension(block.displayHeight),\n\t\t\t\talignment: imageAlignment(block.alignment),\n\t\t\t\tlink: normalizeImageLink(block.link),\n\t\t\t},\n\t\t\tblock._key,\n\t\t\tpreserveIdentity,\n\t\t),\n\t};\n}\n\n/**\n * Convert a malformed image block (missing `asset` wrapper) to ProseMirror.\n * Handles blocks like `{ _type: \"image\", url: \"...\", alt: \"...\" }` that may\n * originate from migrations or third-party imports.\n */\nfunction convertMalformedImage(\n\tblock: PortableTextBlock,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\t// PortableTextUnknownBlock allows indexed access via [key: string]: unknown\n\tconst url = \"url\" in block && typeof block.url === \"string\" ? block.url : \"\";\n\tconst alt = \"alt\" in block && typeof block.alt === \"string\" ? block.alt : \"\";\n\tconst title = \"title\" in block && typeof block.title === \"string\" ? block.title : \"\";\n\tconst rawCaption = \"caption\" in block ? block.caption : undefined;\n\tconst caption = Object.hasOwn(block, \"caption\")\n\t\t? typeof rawCaption === \"string\"\n\t\t\t? rawCaption\n\t\t\t: \"\"\n\t\t: title;\n\tconst width = imageDimension(\"width\" in block ? block.width : undefined);\n\tconst height = imageDimension(\"height\" in block ? block.height : undefined);\n\tconst displayWidth = imageDimension(\"displayWidth\" in block ? block.displayWidth : undefined);\n\tconst displayHeight = imageDimension(\"displayHeight\" in block ? block.displayHeight : undefined);\n\treturn {\n\t\ttype: \"image\",\n\t\tattrs: identityAttrs(\n\t\t\t{\n\t\t\t\tsrc: url,\n\t\t\t\talt,\n\t\t\t\ttitle,\n\t\t\t\tcaption,\n\t\t\t\tmediaId: undefined,\n\t\t\t\tprovider: undefined,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tdisplayWidth,\n\t\t\t\tdisplayHeight,\n\t\t\t\talignment: imageAlignment(\"alignment\" in block ? block.alignment : undefined),\n\t\t\t},\n\t\t\tblock._key,\n\t\t\tpreserveIdentity,\n\t\t),\n\t};\n}\n\n/**\n * Convert code block to ProseMirror\n */\nfunction convertCodeBlock(\n\tblock: PortableTextCodeBlock,\n\tpreserveIdentity: boolean,\n): ProseMirrorNode {\n\treturn {\n\t\ttype: \"codeBlock\",\n\t\tattrs: identityAttrs(\n\t\t\t{\n\t\t\t\tlanguage: block.language || null,\n\t\t\t},\n\t\t\tblock._key,\n\t\t\tpreserveIdentity,\n\t\t),\n\t\tcontent: block.code ? [{ type: \"text\", text: block.code }] : undefined,\n\t};\n}\n","/**\n * Plugin Manager v2\n *\n * Central orchestrator for the plugin system:\n * - Loads and resolves plugins\n * - Manages plugin lifecycle (install, activate, deactivate, uninstall)\n * - Dispatches hooks across all plugins\n * - Routes API requests to plugins\n *\n */\n\nimport type { Kysely } from \"kysely\";\nimport { sql } from \"kysely\";\n\nimport { OptionsRepository } from \"../database/repositories/options.js\";\nimport type { Database } from \"../database/types.js\";\nimport type { Storage } from \"../storage/types.js\";\nimport type { PluginContextFactoryOptions } from \"./context.js\";\nimport { setCronTasksEnabled } from \"./cron.js\";\nimport { definePlugin } from \"./define-plugin.js\";\nimport type { EmailPipeline } from \"./email.js\";\nimport {\n\tHookPipeline,\n\ttype HookResult,\n\tresolveExclusiveHooks as resolveExclusiveHooksShared,\n} from \"./hooks.js\";\nimport { PluginRouteRegistry, type RouteResult, type InvokeRouteOptions } from \"./routes.js\";\nimport type {\n\tActorInfo,\n\tContentSaveHookDetails,\n\tPluginDefinition,\n\tResolvedPlugin,\n\tPluginStorageConfig,\n\tMediaItem,\n\tCronEvent,\n} from \"./types.js\";\n\n/** Options table key prefix for exclusive hook DB reads via PluginManager */\nconst EXCLUSIVE_HOOK_KEY_PREFIX = \"emdash:exclusive_hook:\";\n\n/**\n * Plugin state in the manager\n */\nexport type PluginState = \"registered\" | \"installed\" | \"active\" | \"inactive\";\n\n/**\n * Plugin entry in the manager\n */\ninterface PluginEntry {\n\tplugin: ResolvedPlugin;\n\tstate: PluginState;\n}\n\n/**\n * Plugin manager options\n */\nexport interface PluginManagerOptions {\n\t/** Database instance */\n\tdb: Kysely<Database>;\n\t/** Storage backend for direct media uploads */\n\tstorage?: Storage;\n\t/** Function to generate upload URLs for media */\n\tgetUploadUrl?: (\n\t\tfilename: string,\n\t\tcontentType: string,\n\t) => Promise<{ uploadUrl: string; mediaId: string }>;\n\t/**\n\t * Pre-resolved list of trusted proxy header names for client-IP\n\t * resolution in plugin route handlers. Thread through from the runtime.\n\t */\n\ttrustedProxyHeaders?: string[];\n\t/** Whether media uploads should generate server-side image placeholders. */\n\timagePlaceholders?: boolean;\n}\n\n/**\n * Plugin Manager v2\n *\n * Manages the full lifecycle of plugins and coordinates hooks/routes.\n */\nexport class PluginManager {\n\tprivate plugins: Map<string, PluginEntry> = new Map();\n\tprivate hookPipeline: HookPipeline | null = null;\n\tprivate routeRegistry: PluginRouteRegistry | null = null;\n\tprivate factoryOptions: PluginContextFactoryOptions;\n\tprivate initialized = false;\n\n\tconstructor(private options: PluginManagerOptions) {\n\t\tthis.factoryOptions = {\n\t\t\tdb: options.db,\n\t\t\tstorage: options.storage,\n\t\t\tgetUploadUrl: options.getUploadUrl,\n\t\t\ttrustedProxyHeaders: options.trustedProxyHeaders,\n\t\t\timagePlaceholders: options.imagePlaceholders,\n\t\t};\n\t}\n\n\t/**\n\t * Set the email pipeline used when creating plugin contexts.\n\t * Reinitializes routes/hooks if already initialized so ctx.email is available immediately.\n\t */\n\tsetEmailPipeline(pipeline: EmailPipeline): void {\n\t\tthis.factoryOptions.emailPipeline = pipeline;\n\t\tif (this.initialized) {\n\t\t\tthis.reinitialize();\n\t\t}\n\t}\n\n\t// =========================================================================\n\t// Plugin Registration\n\t// =========================================================================\n\n\t/**\n\t * Register a plugin definition\n\t * This resolves the definition and adds it to the manager, but doesn't install it\n\t */\n\tregister<TStorage extends PluginStorageConfig>(\n\t\tdefinition: PluginDefinition<TStorage>,\n\t): ResolvedPlugin<TStorage> {\n\t\tconst resolved = definePlugin(definition);\n\n\t\tif (this.plugins.has(resolved.id)) {\n\t\t\tthrow new Error(`Plugin \"${resolved.id}\" is already registered`);\n\t\t}\n\n\t\tthis.plugins.set(resolved.id, {\n\t\t\tplugin: resolved,\n\t\t\tstate: \"registered\",\n\t\t});\n\n\t\t// Mark as needing reinitialization\n\t\tthis.initialized = false;\n\n\t\treturn resolved;\n\t}\n\n\t/**\n\t * Register multiple plugins\n\t */\n\tregisterAll(definitions: PluginDefinition[]): void {\n\t\tfor (const def of definitions) {\n\t\t\tthis.register(def);\n\t\t}\n\t}\n\n\t/**\n\t * Unregister a plugin\n\t * Plugin must be inactive or just registered\n\t */\n\tunregister(pluginId: string): boolean {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) return false;\n\n\t\tif (entry.state === \"active\") {\n\t\t\tthrow new Error(`Cannot unregister active plugin \"${pluginId}\". Deactivate it first.`);\n\t\t}\n\n\t\tthis.plugins.delete(pluginId);\n\t\tthis.initialized = false;\n\t\treturn true;\n\t}\n\n\t// =========================================================================\n\t// Plugin Lifecycle\n\t// =========================================================================\n\n\t/**\n\t * Install a plugin (run install hooks, set up storage)\n\t */\n\tasync install(pluginId: string): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\tif (entry.state !== \"registered\") {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" is already installed (state: ${entry.state})`);\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run install hooks\n\t\tconst results = await this.hookPipeline!.runPluginInstall(pluginId);\n\n\t\t// Check for errors\n\t\tconst failed = results.find((r) => !r.success);\n\t\tif (failed) {\n\t\t\tthrow new Error(`Plugin install failed: ${failed.error?.message ?? \"Unknown error\"}`);\n\t\t}\n\n\t\tentry.state = \"installed\";\n\t\treturn results;\n\t}\n\n\t/**\n\t * Activate a plugin (run activate hooks, enable hooks/routes)\n\t */\n\tasync activate(pluginId: string): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\tif (entry.state === \"active\") {\n\t\t\treturn []; // Already active\n\t\t}\n\n\t\tif (entry.state === \"registered\") {\n\t\t\t// Auto-install if not installed\n\t\t\tawait this.install(pluginId);\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run activate hooks\n\t\tconst results = await this.hookPipeline!.runPluginActivate(pluginId);\n\n\t\t// Check for errors\n\t\tconst failed = results.find((r) => !r.success);\n\t\tif (failed) {\n\t\t\tthrow new Error(`Plugin activation failed: ${failed.error?.message ?? \"Unknown error\"}`);\n\t\t}\n\n\t\tentry.state = \"active\";\n\n\t\t// Re-enable cron tasks for the activated plugin\n\t\tawait setCronTasksEnabled(this.options.db, pluginId, true);\n\n\t\t// Reinitialize pipeline so the newly active plugin's hooks are registered\n\t\tthis.reinitialize();\n\n\t\t// Resolve exclusive hooks (new provider may need auto-selection)\n\t\tawait this.resolveExclusiveHooks();\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Deactivate a plugin (run deactivate hooks, disable hooks/routes)\n\t */\n\tasync deactivate(pluginId: string): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\tif (entry.state !== \"active\") {\n\t\t\treturn []; // Not active\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run deactivate hooks\n\t\tconst results = await this.hookPipeline!.runPluginDeactivate(pluginId);\n\n\t\t// Disable cron tasks for the deactivated plugin\n\t\tawait setCronTasksEnabled(this.options.db, pluginId, false);\n\n\t\tentry.state = \"inactive\";\n\n\t\t// Reinitialize pipeline so the deactivated plugin's hooks are removed\n\t\tthis.reinitialize();\n\n\t\t// Resolve exclusive hooks (deactivated provider may need clearing)\n\t\tawait this.resolveExclusiveHooks();\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Uninstall a plugin (run uninstall hooks, optionally delete data)\n\t */\n\tasync uninstall(pluginId: string, deleteData: boolean = false): Promise<HookResult<void>[]> {\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\n\t\t// Deactivate first if active (this also resolves exclusive hooks)\n\t\tif (entry.state === \"active\") {\n\t\t\tawait this.deactivate(pluginId);\n\t\t}\n\n\t\tthis.ensureInitialized();\n\n\t\t// Run uninstall hooks\n\t\tconst results = await this.hookPipeline!.runPluginUninstall(pluginId, deleteData);\n\n\t\t// Delete all cron tasks for the uninstalled plugin\n\t\tawait this.deleteCronTasks(pluginId);\n\n\t\t// Remove from manager\n\t\tthis.plugins.delete(pluginId);\n\t\tthis.initialized = false;\n\n\t\t// Resolve exclusive hooks after removal\n\t\tawait this.resolveExclusiveHooks();\n\n\t\treturn results;\n\t}\n\n\t// =========================================================================\n\t// Hook Dispatch\n\t// =========================================================================\n\n\t/**\n\t * Run content:beforeSave hooks across all active plugins\n\t */\n\tasync runContentBeforeSave(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t\tisNew: boolean,\n\t\tid?: string,\n\t\tactor?: ActorInfo,\n\t\tdetails?: ContentSaveHookDetails,\n\t): Promise<{\n\t\tcontent: Record<string, unknown>;\n\t\tresults: HookResult<Record<string, unknown>>[];\n\t}> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentBeforeSave(content, collection, isNew, id, actor, details);\n\t}\n\n\t/**\n\t * Run content:afterSave hooks across all active plugins\n\t */\n\tasync runContentAfterSave(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t\tisNew: boolean,\n\t\tactor?: ActorInfo,\n\t\tdetails?: ContentSaveHookDetails,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterSave(\n\t\t\tcontent,\n\t\t\tcollection,\n\t\t\tisNew,\n\t\t\tactor,\n\t\t\tundefined,\n\t\t\tdetails,\n\t\t);\n\t}\n\n\t/**\n\t * Run content:beforeDelete hooks across all active plugins\n\t */\n\tasync runContentBeforeDelete(\n\t\tid: string,\n\t\tcollection: string,\n\t): Promise<{ allowed: boolean; results: HookResult<boolean>[] }> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentBeforeDelete(id, collection);\n\t}\n\n\t/**\n\t * Run content:afterDelete hooks across all active plugins\n\t */\n\tasync runContentAfterDelete(\n\t\tid: string,\n\t\tcollection: string,\n\t\tpermanent: boolean,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterDelete(id, collection, permanent);\n\t}\n\n\t/**\n\t * Run content:afterPublish hooks across all active plugins\n\t */\n\tasync runContentAfterPublish(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterPublish(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterUnpublish hooks across all active plugins\n\t */\n\tasync runContentAfterUnpublish(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterUnpublish(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterRestore hooks across all active plugins\n\t */\n\tasync runContentAfterRestore(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterRestore(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterSchedule hooks across all active plugins\n\t */\n\tasync runContentAfterSchedule(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterSchedule(content, collection);\n\t}\n\n\t/**\n\t * Run content:afterUnschedule hooks across all active plugins\n\t */\n\tasync runContentAfterUnschedule(\n\t\tcontent: Record<string, unknown>,\n\t\tcollection: string,\n\t): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runContentAfterUnschedule(content, collection);\n\t}\n\n\t/**\n\t * Run media:beforeUpload hooks across all active plugins\n\t */\n\tasync runMediaBeforeUpload(file: { name: string; type: string; size: number }): Promise<{\n\t\tfile: { name: string; type: string; size: number };\n\t\tresults: HookResult<{ name: string; type: string; size: number }>[];\n\t}> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runMediaBeforeUpload(file);\n\t}\n\n\t/**\n\t * Run media:afterUpload hooks across all active plugins\n\t */\n\tasync runMediaAfterUpload(media: MediaItem): Promise<HookResult<void>[]> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.runMediaAfterUpload(media);\n\t}\n\n\t/**\n\t * Invoke the cron hook for a specific plugin (per-plugin dispatch).\n\t * Used as the InvokeCronHookFn callback for CronExecutor.\n\t */\n\tasync invokeCronHook(pluginId: string, event: CronEvent): Promise<void> {\n\t\tthis.ensureInitialized();\n\t\tconst result = await this.hookPipeline!.invokeCronHook(pluginId, event);\n\t\tif (!result.success && result.error) {\n\t\t\tthrow result.error;\n\t\t}\n\t}\n\n\t// =========================================================================\n\t// Route Dispatch\n\t// =========================================================================\n\n\t/**\n\t * Invoke a plugin route\n\t */\n\tasync invokeRoute(\n\t\tpluginId: string,\n\t\trouteName: string,\n\t\toptions: InvokeRouteOptions,\n\t): Promise<RouteResult> {\n\t\tthis.ensureInitialized();\n\t\treturn this.routeRegistry!.invoke(pluginId, routeName, options);\n\t}\n\n\t/**\n\t * Get all routes for a plugin\n\t */\n\tgetPluginRoutes(pluginId: string): string[] {\n\t\tthis.ensureInitialized();\n\t\treturn this.routeRegistry!.getRoutes(pluginId);\n\t}\n\n\t// =========================================================================\n\t// Query Methods\n\t// =========================================================================\n\n\t/**\n\t * Get a plugin by ID\n\t */\n\tgetPlugin(pluginId: string): ResolvedPlugin | undefined {\n\t\treturn this.plugins.get(pluginId)?.plugin;\n\t}\n\n\t/**\n\t * Get plugin state\n\t */\n\tgetPluginState(pluginId: string): PluginState | undefined {\n\t\treturn this.plugins.get(pluginId)?.state;\n\t}\n\n\t/**\n\t * Get all registered plugins\n\t */\n\tgetAllPlugins(): Array<{ plugin: ResolvedPlugin; state: PluginState }> {\n\t\treturn Array.from(this.plugins.values(), (entry) => ({\n\t\t\tplugin: entry.plugin,\n\t\t\tstate: entry.state,\n\t\t}));\n\t}\n\n\t/**\n\t * Get all active plugins\n\t */\n\tgetActivePlugins(): ResolvedPlugin[] {\n\t\treturn [...this.plugins.values()]\n\t\t\t.filter((entry) => entry.state === \"active\")\n\t\t\t.map((entry) => entry.plugin);\n\t}\n\n\t/**\n\t * Check if a plugin exists\n\t */\n\thasPlugin(pluginId: string): boolean {\n\t\treturn this.plugins.has(pluginId);\n\t}\n\n\t/**\n\t * Check if a plugin is active\n\t */\n\tisActive(pluginId: string): boolean {\n\t\treturn this.plugins.get(pluginId)?.state === \"active\";\n\t}\n\n\t// =========================================================================\n\t// Exclusive Hooks\n\t// =========================================================================\n\n\t/**\n\t * Get all plugins that registered a handler for an exclusive hook.\n\t */\n\tgetExclusiveHookProviders(hookName: string): Array<{ pluginId: string; pluginName: string }> {\n\t\tthis.ensureInitialized();\n\t\treturn this.hookPipeline!.getExclusiveHookProviders(hookName).map((p) => {\n\t\t\tconst plugin = this.plugins.get(p.pluginId);\n\t\t\treturn {\n\t\t\t\tpluginId: p.pluginId,\n\t\t\t\tpluginName: plugin?.plugin.id ?? p.pluginId,\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * Read the selected provider for an exclusive hook from the options table.\n\t */\n\tasync getExclusiveHookSelection(hookName: string): Promise<string | null> {\n\t\tconst optionsRepo = new OptionsRepository(this.options.db);\n\t\treturn optionsRepo.get<string>(`${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`);\n\t}\n\n\t/**\n\t * Set the selected provider for an exclusive hook in the options table.\n\t * Pass null to clear the selection.\n\t */\n\tasync setExclusiveHookSelection(hookName: string, pluginId: string | null): Promise<void> {\n\t\tconst optionsRepo = new OptionsRepository(this.options.db);\n\t\tconst key = `${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`;\n\n\t\tif (pluginId === null) {\n\t\t\tawait optionsRepo.delete(key);\n\t\t\tthis.hookPipeline?.clearExclusiveSelection(hookName);\n\t\t\treturn;\n\t\t}\n\n\t\t// Validate plugin exists and is active\n\t\tconst entry = this.plugins.get(pluginId);\n\t\tif (!entry) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" not found`);\n\t\t}\n\t\tif (entry.state !== \"active\") {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" is not active`);\n\t\t}\n\n\t\tawait optionsRepo.set(key, pluginId);\n\t\tthis.hookPipeline?.setExclusiveSelection(hookName, pluginId);\n\t}\n\n\t/**\n\t * Resolution algorithm for exclusive hooks.\n\t *\n\t * Delegates to the shared resolveExclusiveHooks() function.\n\t * See hooks.ts for the full algorithm description.\n\t */\n\tasync resolveExclusiveHooks(preferredHints?: Map<string, string[]>): Promise<void> {\n\t\tthis.ensureInitialized();\n\n\t\tconst optionsRepo = new OptionsRepository(this.options.db);\n\n\t\tawait resolveExclusiveHooksShared({\n\t\t\tpipeline: this.hookPipeline!,\n\t\t\tisActive: (pluginId) => this.isActive(pluginId),\n\t\t\tgetOption: (key) => optionsRepo.get<string>(key),\n\t\t\tgetOptions: (keys) => optionsRepo.getMany<string>(keys),\n\t\t\tsetOption: (key, value) => optionsRepo.set(key, value),\n\t\t\tdeleteOption: async (key) => {\n\t\t\t\tawait optionsRepo.delete(key);\n\t\t\t},\n\t\t\tpreferredHints,\n\t\t});\n\t}\n\n\t/**\n\t * Get all exclusive hooks with their providers and current selections.\n\t * Used by the admin API.\n\t */\n\tasync getExclusiveHooksInfo(): Promise<\n\t\tArray<{\n\t\t\thookName: string;\n\t\t\tproviders: Array<{ pluginId: string }>;\n\t\t\tselectedPluginId: string | null;\n\t\t}>\n\t> {\n\t\tthis.ensureInitialized();\n\t\tconst exclusiveHookNames = this.hookPipeline!.getRegisteredExclusiveHooks();\n\t\tconst result = [];\n\n\t\tfor (const hookName of exclusiveHookNames) {\n\t\t\tconst providers = this.hookPipeline!.getExclusiveHookProviders(hookName);\n\t\t\tconst selection = await this.getExclusiveHookSelection(hookName);\n\t\t\tresult.push({\n\t\t\t\thookName,\n\t\t\t\tproviders,\n\t\t\t\tselectedPluginId: selection,\n\t\t\t});\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// =========================================================================\n\t// Internal Methods\n\t// =========================================================================\n\n\t/**\n\t * Initialize or reinitialize the hook pipeline and route registry\n\t */\n\tprivate ensureInitialized(): void {\n\t\tif (this.initialized) return;\n\n\t\t// Get all active plugins for hooks\n\t\tconst activePlugins = this.getActivePlugins();\n\n\t\t// Create hook pipeline with active plugins\n\t\tthis.hookPipeline = new HookPipeline(activePlugins, this.factoryOptions);\n\n\t\t// Create route registry\n\t\tthis.routeRegistry = new PluginRouteRegistry(this.factoryOptions);\n\n\t\t// Register routes for active plugins\n\t\tfor (const plugin of activePlugins) {\n\t\t\tthis.routeRegistry.register(plugin);\n\t\t}\n\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * Force reinitialization (useful after plugin state changes)\n\t */\n\treinitialize(): void {\n\t\tthis.initialized = false;\n\t\tthis.ensureInitialized();\n\t}\n\n\t/**\n\t * Delete all cron tasks for a plugin.\n\t * Used during uninstall.\n\t */\n\tprivate async deleteCronTasks(pluginId: string): Promise<void> {\n\t\ttry {\n\t\t\tawait sql`\n\t\t\t\tDELETE FROM _emdash_cron_tasks\n\t\t\t\tWHERE plugin_id = ${pluginId}\n\t\t\t`.execute(this.options.db);\n\t\t} catch {\n\t\t\t// Cron table may not exist yet (pre-migration). Non-fatal.\n\t\t}\n\t}\n}\n\n/**\n * Create a plugin manager\n */\nexport function createPluginManager(options: PluginManagerOptions): PluginManager {\n\treturn new PluginManager(options);\n}\n","/**\n * Node.js cron scheduler — setTimeout-based.\n *\n * Queries the executor for the next due time and sets a timeout. Re-arms\n * after each tick and when reschedule() is called (new task scheduled or\n * cancelled).\n *\n * Suitable for single-process deployments (local dev, single-node).\n *\n */\n\nimport type { CronExecutor } from \"../cron.js\";\nimport type { CronScheduler, SystemCleanupFn } from \"./types.js\";\n\n/** Minimum polling interval (ms) — prevents tight loops if next_run_at is in the past */\nconst MIN_INTERVAL_MS = 1000;\n\n/**\n * Maximum polling interval (ms). Each wake runs the maintenance pass — stale\n * lock recovery *and* the scheduled-publishing sweep + system cleanup.\n * `getNextDueTime()` only knows about cron tasks, not content `scheduled_at`,\n * so the scheduler also wakes at the start of every minute: the admin\n * schedules content to the minute, and a wake on the boundary publishes it on\n * time instead of up to a minute late.\n */\nconst MAX_INTERVAL_MS = 60 * 1000;\n\n/** Wakes just after the minute starts, so a timer that fires early still lands on it. */\nconst MINUTE_BOUNDARY_SLACK_MS = 25;\n\nfunction msUntilNextMinute(now: number): number {\n\tconst sinceMinute = now % MAX_INTERVAL_MS;\n\tif (sinceMinute < MINUTE_BOUNDARY_SLACK_MS) return MINUTE_BOUNDARY_SLACK_MS - sinceMinute;\n\treturn MAX_INTERVAL_MS - sinceMinute + MINUTE_BOUNDARY_SLACK_MS;\n}\n\nexport class NodeCronScheduler implements CronScheduler {\n\tprivate timer: ReturnType<typeof setTimeout> | null = null;\n\tprivate running = false;\n\tprivate systemCleanup: SystemCleanupFn | null = null;\n\n\tconstructor(private executor: CronExecutor) {}\n\n\tsetSystemCleanup(fn: SystemCleanupFn): void {\n\t\tthis.systemCleanup = fn;\n\t}\n\n\tstart(): void {\n\t\tthis.running = true;\n\t\tthis.arm();\n\t}\n\n\tstop(): void {\n\t\tthis.running = false;\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = null;\n\t\t}\n\t}\n\n\treschedule(): void {\n\t\tif (!this.running) return;\n\t\t// Clear existing timer and re-arm with fresh next due time\n\t\tif (this.timer) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = null;\n\t\t}\n\t\tthis.arm();\n\t}\n\n\tprivate arm(): void {\n\t\tif (!this.running) return;\n\n\t\t// Query the next due time, then schedule a wake-up\n\t\tvoid this.executor\n\t\t\t.getNextDueTime()\n\t\t\t.then((nextDue) => {\n\t\t\t\tif (!this.running) return undefined;\n\n\t\t\t\tconst now = Date.now();\n\t\t\t\tlet delayMs = msUntilNextMinute(now);\n\t\t\t\tif (nextDue) {\n\t\t\t\t\tconst dueAt = new Date(nextDue).getTime();\n\t\t\t\t\tdelayMs = Math.min(delayMs, Math.max(dueAt - now, MIN_INTERVAL_MS));\n\t\t\t\t}\n\n\t\t\t\tthis.timer = setTimeout(() => {\n\t\t\t\t\tif (!this.running) return;\n\t\t\t\t\tthis.executeTick();\n\t\t\t\t}, delayMs);\n\n\t\t\t\t// Don't prevent process exit\n\t\t\t\tif (this.timer && typeof this.timer === \"object\" && \"unref\" in this.timer) {\n\t\t\t\t\tthis.timer.unref();\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tconsole.error(\"[cron:node] Failed to get next due time:\", error);\n\t\t\t\t// Retry after max interval\n\t\t\t\tif (this.running) {\n\t\t\t\t\tthis.timer = setTimeout(() => this.arm(), MAX_INTERVAL_MS);\n\t\t\t\t\tif (this.timer && typeof this.timer === \"object\" && \"unref\" in this.timer) {\n\t\t\t\t\t\tthis.timer.unref();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tprivate executeTick(): void {\n\t\tif (!this.running) return;\n\n\t\t// Run tick + stale lock recovery + system cleanup, then re-arm\n\t\tconst tasks: Promise<unknown>[] = [this.executor.tick(), this.executor.recoverStaleLocks()];\n\t\tif (this.systemCleanup) {\n\t\t\ttasks.push(this.systemCleanup());\n\t\t}\n\n\t\tvoid Promise.allSettled(tasks)\n\t\t\t.then((results) => {\n\t\t\t\tfor (const r of results) {\n\t\t\t\t\tif (r.status === \"rejected\") {\n\t\t\t\t\t\tconsole.error(\"[cron:node] Tick task failed:\", r.reason);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tif (this.running) {\n\t\t\t\t\tthis.arm();\n\t\t\t\t}\n\t\t\t});\n\t}\n}\n","/**\n * No-op Sandbox Runner\n *\n * Default implementation that doesn't support sandboxing.\n * Used on platforms without Worker Loader (Node.js, Deno, etc.).\n *\n */\n\nimport type { PluginManifest } from \"../types.js\";\nimport type { SandboxRunner, SandboxedPluginInstance, SandboxOptions } from \"./types.js\";\n\n/**\n * Error thrown when attempting to use sandboxing on an unsupported platform.\n */\nexport class SandboxNotAvailableError extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Plugin sandboxing is not available. \" +\n\t\t\t\t\"Configure a sandbox runner: use @emdash-cms/cloudflare/sandbox on Cloudflare, \" +\n\t\t\t\t\"or @emdash-cms/sandbox-workerd/sandbox on Node.js (requires workerd). \" +\n\t\t\t\t\"Without sandboxing, use trusted plugins (from config) instead.\",\n\t\t);\n\t\tthis.name = \"SandboxNotAvailableError\";\n\t}\n}\n\n/**\n * No-op sandbox runner for platforms without isolation support.\n *\n * - `isAvailable()` returns false\n * - `load()` throws SandboxNotAvailableError\n * - `terminateAll()` is a no-op\n *\n * This is the default runner when no platform adapter is configured.\n */\nexport class NoopSandboxRunner implements SandboxRunner {\n\t/**\n\t * Always returns false - sandboxing is not available.\n\t */\n\tisAvailable(): boolean {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Always returns false - no sandbox runtime to be healthy.\n\t */\n\tisHealthy(): boolean {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Always throws - can't load sandboxed plugins without isolation.\n\t */\n\tasync load(\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_manifest: PluginManifest,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_code: string,\n\t): Promise<SandboxedPluginInstance> {\n\t\tthrow new SandboxNotAvailableError();\n\t}\n\n\t/**\n\t * No-op - sandboxing not available, email callback is irrelevant.\n\t */\n\tsetEmailSend(): void {\n\t\t// Nothing to do\n\t}\n\n\t/**\n\t * No-op - nothing to terminate.\n\t */\n\tasync terminateAll(): Promise<void> {\n\t\t// Nothing to do\n\t}\n}\n\n/**\n * Create a no-op sandbox runner.\n * This is used as the default when no platform adapter is configured.\n */\nexport function createNoopSandboxRunner(_options?: SandboxOptions): SandboxRunner {\n\treturn new NoopSandboxRunner();\n}\n","/**\n * Sections import functions\n *\n * Import reusable blocks from WordPress WXR exports as EmDash sections.\n */\n\nimport type { PortableTextBlock } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport { gutenbergToPortableText } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport type { Kysely } from \"kysely\";\nimport { ulid } from \"ulidx\";\n\nimport type { WxrPost } from \"../cli/wxr/parser.js\";\nimport type { Database } from \"../database/types.js\";\nimport { slugify } from \"../utils/slugify.js\";\n\n/**\n * Result of sections import operation\n */\nexport interface SectionsImportResult {\n\t/** Number of sections created */\n\tsectionsCreated: number;\n\t/** Number of sections skipped (already exist) */\n\tsectionsSkipped: number;\n\t/** Errors encountered during import */\n\terrors: Array<{ title: string; error: string }>;\n}\n\n/**\n * Import reusable blocks (wp_block post type) from WXR as sections\n *\n * @param posts - All posts from WXR (will filter to wp_block)\n * @param db - Database connection\n * @returns Import result with counts\n */\nexport async function importReusableBlocksAsSections(\n\tposts: WxrPost[],\n\tdb: Kysely<Database>,\n): Promise<SectionsImportResult> {\n\tconst result: SectionsImportResult = {\n\t\tsectionsCreated: 0,\n\t\tsectionsSkipped: 0,\n\t\terrors: [],\n\t};\n\n\t// Filter to only wp_block posts\n\tconst reusableBlocks = posts.filter((post) => post.postType === \"wp_block\");\n\n\tif (reusableBlocks.length === 0) {\n\t\treturn result;\n\t}\n\n\tfor (const block of reusableBlocks) {\n\t\ttry {\n\t\t\tconst slug = block.postName || slugify(block.title || `block-${block.id || Date.now()}`);\n\n\t\t\t// Check if section already exists\n\t\t\tconst existing = await db\n\t\t\t\t.selectFrom(\"_emdash_sections\")\n\t\t\t\t.select(\"id\")\n\t\t\t\t.where(\"slug\", \"=\", slug)\n\t\t\t\t.executeTakeFirst();\n\n\t\t\tif (existing) {\n\t\t\t\tresult.sectionsSkipped++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Convert Gutenberg content to Portable Text\n\t\t\tconst content: PortableTextBlock[] = block.content\n\t\t\t\t? gutenbergToPortableText(block.content)\n\t\t\t\t: [];\n\n\t\t\tconst id = ulid();\n\t\t\tconst now = new Date().toISOString();\n\n\t\t\tawait db\n\t\t\t\t.insertInto(\"_emdash_sections\")\n\t\t\t\t.values({\n\t\t\t\t\tid,\n\t\t\t\t\tslug,\n\t\t\t\t\ttitle: block.title || \"Untitled Block\",\n\t\t\t\t\tdescription: null,\n\t\t\t\t\tkeywords: null,\n\t\t\t\t\tcontent: JSON.stringify(content),\n\t\t\t\t\tpreview_media_id: null,\n\t\t\t\t\tsource: \"import\",\n\t\t\t\t\ttheme_id: null,\n\t\t\t\t\tcreated_at: now,\n\t\t\t\t\tupdated_at: now,\n\t\t\t\t})\n\t\t\t\t.execute();\n\n\t\t\tresult.sectionsCreated++;\n\t\t} catch (error) {\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: block.title || \"Untitled Block\",\n\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t}\n\t}\n\n\treturn result;\n}\n","/**\n * Preview helpers for Astro pages\n */\n\n/**\n * Check if a request is a preview request\n *\n * @example\n * ```ts\n * const isPreview = isPreviewRequest(Astro.url);\n * ```\n */\nexport function isPreviewRequest(url: URL): boolean {\n\treturn url.searchParams.has(\"_preview\");\n}\n\n/**\n * Get the preview token from a URL\n *\n * @example\n * ```ts\n * const token = getPreviewToken(Astro.url);\n * ```\n */\nexport function getPreviewToken(url: URL): string | null {\n\treturn url.searchParams.get(\"_preview\");\n}\n","/**\n * Comment ranking utilities (Tier 1 of the best-in-class comments RFC).\n *\n * Wilson score lower-bound (95% confidence) — the same primitive Reddit uses\n * for its \"Best\" comment sort. Ranks by the statistical lower bound of the\n * positive-reaction proportion rather than the raw count, so a comment with a\n * couple of reactions can't outrank a heavily-reacted one until it earns\n * confidence, and a late-but-popular comment still rises (submission time is\n * irrelevant).\n *\n * Positive-only reactions (the recommended default) degrade gracefully: with\n * `down = 0` the score still increases monotonically with `up` while penalising\n * low-sample comments — wilson(1,0) ≈ 0.21, wilson(10,0) ≈ 0.73,\n * wilson(200,0) ≈ 0.98.\n */\n\n/** z for a 95% two-sided confidence interval. */\nconst DEFAULT_Z = 1.96;\n\n/** Reactions that count against a comment when both signals are in use. */\nconst NEGATIVE_REACTIONS: ReadonlySet<string> = new Set([\"dislike\", \"down\"]);\n\n/**\n * Wilson score lower bound of the positive proportion.\n *\n * @param up count of positive reactions\n * @param down count of negative reactions\n * @returns a score in [0, 1]; 0 when there are no reactions\n */\nexport function wilsonLowerBound(up: number, down: number, z: number = DEFAULT_Z): number {\n\tconst n = up + down;\n\tif (n <= 0) return 0;\n\tconst phat = up / n;\n\tconst z2 = z * z;\n\tconst denom = 1 + z2 / n;\n\tconst centre = phat + z2 / (2 * n);\n\tconst margin = z * Math.sqrt((phat * (1 - phat) + z2 / (4 * n)) / n);\n\treturn (centre - margin) / denom;\n}\n\n/**\n * Reduce a per-reaction count map to a single rank score via the Wilson\n * lower bound. Any reaction not in {@link NEGATIVE_REACTIONS} is treated as\n * positive, so the positive-only default (just `like`) works without special\n * casing.\n */\nexport function reactionScore(counts: Record<string, number>): number {\n\tlet up = 0;\n\tlet down = 0;\n\tfor (const [reaction, count] of Object.entries(counts)) {\n\t\tif (NEGATIVE_REACTIONS.has(reaction)) {\n\t\t\tdown += count;\n\t\t} else {\n\t\t\tup += count;\n\t\t}\n\t}\n\treturn wilsonLowerBound(up, down);\n}\n","/**\n * Comment query functions for Astro templates\n *\n * Same pattern as getMenu() — uses getDb() for ambient DB access.\n * These are called from .astro pages/components, not from API routes.\n */\n\nimport type { Kysely } from \"kysely\";\n\nimport { CommentReactionRepository } from \"../database/repositories/comment-reaction.js\";\nimport { CommentRepository } from \"../database/repositories/comment.js\";\nimport type { PublicComment } from \"../database/repositories/comment.js\";\nimport type { Database } from \"../database/types.js\";\nimport { getDb } from \"../loader.js\";\nimport { cachedQuery, CacheNamespace } from \"../object-cache/index.js\";\nimport { reactionScore } from \"./ranking.js\";\n\nexport interface GetCommentsOptions {\n\tcollection: string;\n\tcontentId: string;\n\tthreaded?: boolean;\n\t/** Attach aggregate reaction counts to each comment. */\n\treactions?: boolean;\n\t/**\n\t * Order of top-level comments. `oldest` (default) preserves the existing\n\t * chronological display; `best` ranks by Wilson-scored reactions (implies\n\t * `reactions`). Replies always stay chronological.\n\t */\n\tsort?: \"oldest\" | \"best\";\n}\n\nexport interface GetCommentsResult {\n\titems: PublicComment[];\n\ttotal: number;\n}\n\n/**\n * Get approved comments for a content item.\n *\n * @example\n * ```ts\n * import { getComments } from \"emdash\";\n *\n * const { items, total } = await getComments({\n * collection: \"posts\",\n * contentId: post.id,\n * threaded: true,\n * });\n * ```\n */\nexport async function getComments(options: GetCommentsOptions): Promise<GetCommentsResult> {\n\t// The result varies by every option getCommentsWithDb branches on, so all of\n\t// them belong in the key. `best` implies reactions, so normalize the reaction\n\t// flag — `{ sort: \"best\" }` and `{ sort: \"best\", reactions: true }` produce\n\t// identical output and should share one entry.\n\tconst sort = options.sort ?? \"oldest\";\n\tconst withReactions = options.reactions || sort === \"best\";\n\tconst threaded = options.threaded ? \"t\" : \"f\";\n\treturn cachedQuery({\n\t\tnamespace: CacheNamespace.COMMENTS,\n\t\tkey: `comments:${options.collection}:${options.contentId}:${threaded}:${withReactions ? \"r\" : \"n\"}:${sort}`,\n\t\tload: async () => {\n\t\t\tconst db = await getDb();\n\t\t\treturn getCommentsWithDb(db, options);\n\t\t},\n\t});\n}\n\n/**\n * Get approved comments with an explicit db handle.\n *\n * @internal Use `getComments()` in templates. This variant is for routes\n * that already have a database handle.\n */\nexport async function getCommentsWithDb(\n\tdb: Kysely<Database>,\n\toptions: GetCommentsOptions,\n): Promise<GetCommentsResult> {\n\tconst repo = new CommentRepository(db);\n\n\t// Server-rendered: fetch all comments (capped for safety).\n\t// The API route handles paginated access; this is for full-page renders.\n\tconst MAX_COMMENTS = 500;\n\n\tconst result = await repo.findByContent(options.collection, options.contentId, {\n\t\tstatus: \"approved\",\n\t\tlimit: MAX_COMMENTS,\n\t});\n\n\t// When the list is not truncated, the total is available from the page\n\t// itself and we can skip the separate COUNT query. Fall back only when\n\t// cursor pagination signals there are more rows.\n\tconst total =\n\t\tresult.nextCursor === undefined\n\t\t\t? result.items.length\n\t\t\t: await repo.countByContent(options.collection, options.contentId, \"approved\");\n\n\tconst items: PublicComment[] = options.threaded\n\t\t? CommentRepository.assembleThreads(result.items).map((c) =>\n\t\t\t\tCommentRepository.toPublicComment(c),\n\t\t\t)\n\t\t: result.items.map((c) => CommentRepository.toPublicComment(c));\n\n\t// `best` sort needs reaction data, so it implies reactions.\n\tif (options.reactions || options.sort === \"best\") {\n\t\tawait attachReactions(db, items);\n\t\tif (options.sort === \"best\") {\n\t\t\tsortByBest(items);\n\t\t}\n\t}\n\n\treturn { items, total };\n}\n\n/**\n * Attach aggregate reaction counts to a list of public comments (and their\n * replies), in a single batched query.\n */\nasync function attachReactions(db: Kysely<Database>, items: PublicComment[]): Promise<void> {\n\tconst ids: string[] = [];\n\tfor (const comment of items) {\n\t\tids.push(comment.id);\n\t\tif (comment.replies) {\n\t\t\tfor (const reply of comment.replies) ids.push(reply.id);\n\t\t}\n\t}\n\tif (ids.length === 0) return;\n\n\tconst counts = await new CommentReactionRepository(db).countsForComments(ids);\n\n\tconst assign = (comment: PublicComment) => {\n\t\tconst reactions = counts.get(comment.id);\n\t\tif (reactions) comment.reactions = reactions;\n\t};\n\tfor (const comment of items) {\n\t\tassign(comment);\n\t\tcomment.replies?.forEach(assign);\n\t}\n}\n\n/**\n * Sort top-level comments by Wilson-scored reactions (descending), tie-broken\n * by oldest-first to keep ordering stable.\n */\nfunction sortByBest(items: PublicComment[]): void {\n\titems.sort((a, b) => {\n\t\tconst scoreDelta = reactionScore(b.reactions ?? {}) - reactionScore(a.reactions ?? {});\n\t\tif (scoreDelta !== 0) return scoreDelta;\n\t\tif (a.createdAt < b.createdAt) return -1;\n\t\tif (a.createdAt > b.createdAt) return 1;\n\t\treturn 0;\n\t});\n}\n\n/**\n * Get the count of approved comments for a content item.\n *\n * @example\n * ```ts\n * import { getCommentCount } from \"emdash\";\n *\n * const count = await getCommentCount(\"posts\", post.id);\n * ```\n */\nexport async function getCommentCount(collection: string, contentId: string): Promise<number> {\n\tconst db = await getDb();\n\treturn getCommentCountWithDb(db, collection, contentId);\n}\n\n/**\n * Get comment count with an explicit db handle.\n *\n * @internal Use `getCommentCount()` in templates.\n */\nexport async function getCommentCountWithDb(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tcontentId: string,\n): Promise<number> {\n\tconst repo = new CommentRepository(db);\n\treturn repo.countByContent(collection, contentId, \"approved\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,cAAc,EAAE,OAAO;CAC5B,IAAI,EAAE,QAAQ;CACd,KAAK,EAAE,QAAQ,CAAC,UAAU;CAC1B,KAAK,EAAE,QAAQ,CAAC,UAAU;CAC1B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,eAAe,EAAE,QAAQ,CAAC,UAAU;CACp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