@aiquants/markdown 6.2.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +61 -3
  2. package/dist/{abnfDiagram-VRR7QNED-DX6eyf4O.cjs → abnfDiagram-VRR7QNED-B4qwBPG8.cjs} +1 -1
  3. package/dist/{abnfDiagram-VRR7QNED-Csrzuwyl.js → abnfDiagram-VRR7QNED-DJQK-fno.js} +3 -3
  4. package/dist/{arc-Gw7Urszo.js → arc-B5-ynLRd.js} +1 -1
  5. package/dist/{arc-ZAQ3z7kr.cjs → arc-CXmyMsv9.cjs} +1 -1
  6. package/dist/{architectureDiagram-ZJ3FMSHR-Coy6_Fcg.js → architectureDiagram-ZJ3FMSHR-C_JEocx6.js} +2 -2
  7. package/dist/{architectureDiagram-ZJ3FMSHR-DxzMbkp1.cjs → architectureDiagram-ZJ3FMSHR-DyhTbYvV.cjs} +1 -1
  8. package/dist/{blockDiagram-677ZJIJ3-THmR4OyE.cjs → blockDiagram-677ZJIJ3-BsWnBpmo.cjs} +1 -1
  9. package/dist/{blockDiagram-677ZJIJ3-CbR-wn2x.js → blockDiagram-677ZJIJ3-COWsJwrz.js} +3 -3
  10. package/dist/{c4Diagram-LMCZKHZV-DHMqNO9p.js → c4Diagram-LMCZKHZV-BJGPyybb.js} +2 -2
  11. package/dist/{c4Diagram-LMCZKHZV-BcJpuXK1.cjs → c4Diagram-LMCZKHZV-C8SAoymj.cjs} +1 -1
  12. package/dist/{channel-Cryph4zI.cjs → channel-Catm-7_m.cjs} +1 -1
  13. package/dist/{channel-CfC4eqki.js → channel-gEEzHgMK.js} +1 -1
  14. package/dist/{chunk-2Q5K7J3B-C3BIc3MH.js → chunk-2Q5K7J3B-BrZPj48S.js} +1 -1
  15. package/dist/{chunk-2Q5K7J3B-CxWyY331.cjs → chunk-2Q5K7J3B-D2pUNN7e.cjs} +1 -1
  16. package/dist/{chunk-32BRIVSS-C3w_aYfI.cjs → chunk-32BRIVSS-BHwCDqTA.cjs} +1 -1
  17. package/dist/{chunk-32BRIVSS-C37ccuiX.js → chunk-32BRIVSS-Qjp2CRZG.js} +1 -1
  18. package/dist/{chunk-5VM5RSS4-Cbt79-V5.cjs → chunk-5VM5RSS4-C-2Xl1mK.cjs} +1 -1
  19. package/dist/{chunk-5VM5RSS4-DVLmkcyq.js → chunk-5VM5RSS4-Cz-1oXF8.js} +1 -1
  20. package/dist/{chunk-EX3LRPZG-BZOxrSRn.cjs → chunk-EX3LRPZG-CcWHrBHu.cjs} +1 -1
  21. package/dist/{chunk-EX3LRPZG-Co0Bql0-.js → chunk-EX3LRPZG-DOly63cQ.js} +4 -4
  22. package/dist/{chunk-JWPE2WC7-DUndc3Wb.js → chunk-JWPE2WC7-D8oKuUKk.js} +1 -1
  23. package/dist/{chunk-JWPE2WC7-Cvt_ToFU.cjs → chunk-JWPE2WC7-uLMzLWor.cjs} +1 -1
  24. package/dist/{chunk-MOJQB5TN-AAMW2q8N.cjs → chunk-MOJQB5TN-CFHULd2m.cjs} +1 -1
  25. package/dist/{chunk-MOJQB5TN-aTSDPliR.js → chunk-MOJQB5TN-DFfn4gwS.js} +1 -1
  26. package/dist/{chunk-PUDLZKDR-Q5QzbDtY.js → chunk-PUDLZKDR-BSXgzvcs.js} +6 -6
  27. package/dist/{chunk-PUDLZKDR-CzCdcyAN.cjs → chunk-PUDLZKDR-CdXVWW4P.cjs} +1 -1
  28. package/dist/{chunk-RYQCIY6F-DbjhsOnH.cjs → chunk-RYQCIY6F-CVamSMzr.cjs} +1 -1
  29. package/dist/{chunk-RYQCIY6F-O6wbIIFF.js → chunk-RYQCIY6F-D7rBCtF6.js} +1 -1
  30. package/dist/{chunk-V7JOEXUC-OTS1fN7j.js → chunk-V7JOEXUC-BEGUrMN0.js} +5 -5
  31. package/dist/{chunk-V7JOEXUC-B6Qc5ABc.cjs → chunk-V7JOEXUC-DJuvtTef.cjs} +1 -1
  32. package/dist/{chunk-VR4S4FIN-D4tY80kq.js → chunk-VR4S4FIN-DbzCqIxB.js} +1 -1
  33. package/dist/{chunk-VR4S4FIN-DlneMFEg.cjs → chunk-VR4S4FIN-Okfemb3d.cjs} +1 -1
  34. package/dist/{chunk-XXDRQBXY-CvhBfnFQ.cjs → chunk-XXDRQBXY-DQBgFSg2.cjs} +1 -1
  35. package/dist/{chunk-XXDRQBXY-58rTAwvh.js → chunk-XXDRQBXY-DzmhMVRC.js} +1 -1
  36. package/dist/{classDiagram-v2-EOCWNBFH-hcuKRiyp.js → classDiagram-OUVF2IWQ-BGn-HjT8.js} +2 -2
  37. package/dist/{classDiagram-OUVF2IWQ-C0S2HAJU.cjs → classDiagram-OUVF2IWQ-DR8DD7tr.cjs} +1 -1
  38. package/dist/{classDiagram-OUVF2IWQ-hcuKRiyp.js → classDiagram-v2-EOCWNBFH-BGn-HjT8.js} +2 -2
  39. package/dist/{classDiagram-v2-EOCWNBFH-C0S2HAJU.cjs → classDiagram-v2-EOCWNBFH-DR8DD7tr.cjs} +1 -1
  40. package/dist/components/MermaidDiagram.d.ts +1 -0
  41. package/dist/components/mathRendering.d.ts +1 -0
  42. package/dist/components/mdastNodes/CodeNode.d.ts +2 -1
  43. package/dist/conversion.d.ts +26 -0
  44. package/dist/converter/NOTICES.md +178 -0
  45. package/dist/converter/createMarkdownConverter.d.ts +12 -0
  46. package/dist/converter/protocol.d.ts +58 -0
  47. package/dist/converter/serve.d.ts +12 -0
  48. package/dist/converter/worker.d.ts +1 -0
  49. package/dist/converter/worker.js +76 -0
  50. package/dist/converter.cjs +1 -0
  51. package/dist/converter.d.ts +4 -0
  52. package/dist/converter.js +109 -0
  53. package/dist/converter.wasm +0 -0
  54. package/dist/{cose-bilkent-JH36ORCC-BwltbHKG.js → cose-bilkent-JH36ORCC-CXaSZTQh.js} +1 -1
  55. package/dist/{cose-bilkent-JH36ORCC-DVZVn03H.cjs → cose-bilkent-JH36ORCC-DKpnPAKO.cjs} +1 -1
  56. package/dist/{cynefinDiagram-TSTJHNR4-ogTeIoNY.js → cynefinDiagram-TSTJHNR4-BQSdT_2p.js} +2 -2
  57. package/dist/{cynefinDiagram-TSTJHNR4-DYCBxaEi.cjs → cynefinDiagram-TSTJHNR4-WzHtBOXU.cjs} +1 -1
  58. package/dist/{dagre-VKFMJZFB-DJW9o9XX.cjs → dagre-VKFMJZFB-BOlxvZO9.cjs} +1 -1
  59. package/dist/{dagre-VKFMJZFB-BfNdgMHQ.js → dagre-VKFMJZFB-DQ5e1PJD.js} +2 -2
  60. package/dist/{diagram-FQU43EPY-BRpNVpgn.cjs → diagram-FQU43EPY-DdDxGx-M.cjs} +1 -1
  61. package/dist/{diagram-FQU43EPY-CJf3yD8h.js → diagram-FQU43EPY-DlCF28sn.js} +2 -2
  62. package/dist/{diagram-G47NLZAW-5rZfUeWV.cjs → diagram-G47NLZAW-Cvts7_pn.cjs} +1 -1
  63. package/dist/{diagram-G47NLZAW-D0-6oupP.js → diagram-G47NLZAW-DVdw7HhH.js} +3 -3
  64. package/dist/{diagram-NH7WQ7WH-BwrWWWZJ.js → diagram-NH7WQ7WH-BkU3b82h.js} +2 -2
  65. package/dist/{diagram-NH7WQ7WH-g7m8p5fK.cjs → diagram-NH7WQ7WH-Cs_Dyb0p.cjs} +1 -1
  66. package/dist/{diagram-OA4YK3LP-BBqA1m8s.js → diagram-OA4YK3LP-D39RUkK3.js} +3 -3
  67. package/dist/{diagram-OA4YK3LP-BxP8KUna.cjs → diagram-OA4YK3LP-ONhluSWR.cjs} +1 -1
  68. package/dist/{diagram-WEI45ONY-CMexm2GN.js → diagram-WEI45ONY-CMD5pSfn.js} +2 -2
  69. package/dist/{diagram-WEI45ONY-DgJyq1w0.cjs → diagram-WEI45ONY-DyEvKt6H.cjs} +1 -1
  70. package/dist/{ebnfDiagram-CCIWWBDH-sfiWOXCW.cjs → ebnfDiagram-CCIWWBDH-Bi-wg1C0.cjs} +1 -1
  71. package/dist/{ebnfDiagram-CCIWWBDH-DvLr_8nV.js → ebnfDiagram-CCIWWBDH-Z3TtxdlL.js} +3 -3
  72. package/dist/{erDiagram-Q63AITRT-D6U6Ng3Y.js → erDiagram-Q63AITRT-C-O8hBWj.js} +4 -4
  73. package/dist/{erDiagram-Q63AITRT-B11THykZ.cjs → erDiagram-Q63AITRT-DQO3kH0H.cjs} +1 -1
  74. package/dist/errors-BW5JXRoX.cjs +1 -0
  75. package/dist/errors-Blk_XJ9C.js +55 -0
  76. package/dist/errors.d.ts +12 -0
  77. package/dist/extractHeadings-DSlyjlEb.cjs +311 -0
  78. package/dist/{extractHeadings-CdLPwHlC.js → extractHeadings-DkKFCMIW.js} +5195 -5149
  79. package/dist/flowDiagram-23GEKE2U-BHV7jjdl.js +7 -0
  80. package/dist/flowDiagram-23GEKE2U-Bn8nX3mJ.cjs +1 -0
  81. package/dist/{ganttDiagram-NO4QXBWP-CGCdgj0K.js → ganttDiagram-NO4QXBWP-BgxDDjW1.js} +2 -2
  82. package/dist/{ganttDiagram-NO4QXBWP-BLlXK3zo.cjs → ganttDiagram-NO4QXBWP-C6v1dyOv.cjs} +1 -1
  83. package/dist/gen/markdown/v1/markdown_pb.d.ts +1 -0
  84. package/dist/{gitGraphDiagram-IHSO6WYX-Bib3c0C6.js → gitGraphDiagram-IHSO6WYX-BSIaczat.js} +3 -3
  85. package/dist/{gitGraphDiagram-IHSO6WYX-BHOyibqH.cjs → gitGraphDiagram-IHSO6WYX-Dly6wuUW.cjs} +1 -1
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.client.cjs +1 -1
  88. package/dist/index.client.js +1 -1
  89. package/dist/index.js +1 -1
  90. package/dist/index.server.cjs +1 -1
  91. package/dist/index.server.d.ts +3 -1
  92. package/dist/index.server.js +185 -178
  93. package/dist/{infoDiagram-FWYZ7A6U-BUqDBIaP.js → infoDiagram-FWYZ7A6U-BJpiPMD3.js} +1 -1
  94. package/dist/{infoDiagram-FWYZ7A6U-BcDp6g1Y.cjs → infoDiagram-FWYZ7A6U-CRxeian2.cjs} +1 -1
  95. package/dist/{ishikawaDiagram-FXEZZL3T-CcPh4nuP.js → ishikawaDiagram-FXEZZL3T-B3tCfTEo.js} +1 -1
  96. package/dist/{ishikawaDiagram-FXEZZL3T-C3QHQ1ia.cjs → ishikawaDiagram-FXEZZL3T-jEnTu6LN.cjs} +1 -1
  97. package/dist/{journeyDiagram-5HDEW3XC-B17v98Wb.cjs → journeyDiagram-5HDEW3XC-BXFW-Svx.cjs} +1 -1
  98. package/dist/{journeyDiagram-5HDEW3XC-MdxndgF1.js → journeyDiagram-5HDEW3XC-D7U-NNAM.js} +4 -4
  99. package/dist/{kanban-definition-HUTT4EX6-JhfZ6Qik.js → kanban-definition-HUTT4EX6-B14iIRCh.js} +2 -2
  100. package/dist/{kanban-definition-HUTT4EX6-BApVXeVQ.cjs → kanban-definition-HUTT4EX6-DSprt7D2.cjs} +1 -1
  101. package/dist/{linear-CIVwb13z.cjs → linear-B-_z7_Qw.cjs} +1 -1
  102. package/dist/{linear-dbOUbGpD.js → linear-DZOg62FH.js} +1 -1
  103. package/dist/{mindmap-definition-LN4V7U3C-BUbo0u-Y.cjs → mindmap-definition-LN4V7U3C-Bs_ccQ71.cjs} +1 -1
  104. package/dist/{mindmap-definition-LN4V7U3C-gNTBga2z.js → mindmap-definition-LN4V7U3C-Dh-Z6t4L.js} +3 -3
  105. package/dist/{pegDiagram-2B236MQR-BqjpbNkG.js → pegDiagram-2B236MQR-6OQwK0r-.js} +3 -3
  106. package/dist/{pegDiagram-2B236MQR-DZiQVxu1.cjs → pegDiagram-2B236MQR-BunF191h.cjs} +1 -1
  107. package/dist/{pieDiagram-ENE6RG2P-D2nxDVFV.cjs → pieDiagram-ENE6RG2P-BUdykoZb.cjs} +1 -1
  108. package/dist/{pieDiagram-ENE6RG2P-C1Gr48CK.js → pieDiagram-ENE6RG2P-DjvAa5zD.js} +3 -3
  109. package/dist/{quadrantDiagram-ABIIQ3AL-DuD9ZdUQ.js → quadrantDiagram-ABIIQ3AL-DfiOa0GN.js} +2 -2
  110. package/dist/{quadrantDiagram-ABIIQ3AL-C855tL3K.cjs → quadrantDiagram-ABIIQ3AL-ksoulitn.cjs} +1 -1
  111. package/dist/{railroadDiagram-RFXS5EU6-BZsnhaQd.cjs → railroadDiagram-RFXS5EU6-BWupYLwR.cjs} +1 -1
  112. package/dist/{railroadDiagram-RFXS5EU6-xx1d3Md8.js → railroadDiagram-RFXS5EU6-DxJ3t05t.js} +3 -3
  113. package/dist/remarkProcessor.server.d.ts +1 -27
  114. package/dist/{requirementDiagram-TGXJPOKE-CCu1UYFH.js → requirementDiagram-TGXJPOKE-CxplHHB8.js} +3 -3
  115. package/dist/{requirementDiagram-TGXJPOKE-D_NbFRkb.cjs → requirementDiagram-TGXJPOKE-D17FjoFO.cjs} +1 -1
  116. package/dist/{sankeyDiagram-HTMAVEWB-Dn2Ta-XX.cjs → sankeyDiagram-HTMAVEWB-CDXvEE-n.cjs} +1 -1
  117. package/dist/{sankeyDiagram-HTMAVEWB-QGzXzczJ.js → sankeyDiagram-HTMAVEWB-DFOQ2fD-.js} +1 -1
  118. package/dist/{sequenceDiagram-DBY2YBRQ-BA3Oc4pz.cjs → sequenceDiagram-DBY2YBRQ-D-aVI5Yt.cjs} +1 -1
  119. package/dist/{sequenceDiagram-DBY2YBRQ-CjnUnaw9.js → sequenceDiagram-DBY2YBRQ-Gf5VRPPO.js} +3 -3
  120. package/dist/{sizeCapture-X5ZJPWSS-BPQhVBe0.cjs → sizeCapture-X5ZJPWSS-BAB3SekL.cjs} +1 -1
  121. package/dist/{sizeCapture-X5ZJPWSS-nb9uU-BE.js → sizeCapture-X5ZJPWSS-DyErW1EK.js} +1 -1
  122. package/dist/source-lines.cjs +1 -0
  123. package/dist/source-lines.d.ts +6 -0
  124. package/dist/source-lines.js +11 -0
  125. package/dist/{stateDiagram-2N3HPSRC-DSqLqSY5.cjs → stateDiagram-2N3HPSRC-BrUDPgXu.cjs} +1 -1
  126. package/dist/{stateDiagram-2N3HPSRC-Byg3E1AA.js → stateDiagram-2N3HPSRC-lxQmuBDw.js} +2 -2
  127. package/dist/{stateDiagram-v2-6OUMAXLB-VRhXyf-C.cjs → stateDiagram-v2-6OUMAXLB-B67PZ7bz.cjs} +1 -1
  128. package/dist/{stateDiagram-v2-6OUMAXLB-hKcuYy9t.js → stateDiagram-v2-6OUMAXLB-l5VmN12f.js} +2 -2
  129. package/dist/{swimlanes-5IMT3BWC-DyIDdThc.js → swimlanes-5IMT3BWC-CMkiOd-R.js} +3 -3
  130. package/dist/{swimlanes-5IMT3BWC-CVnOKNcb.cjs → swimlanes-5IMT3BWC-DW61y4w7.cjs} +1 -1
  131. package/dist/{swimlanesDiagram-G3AALYLV-BF1ofRjP.js → swimlanesDiagram-G3AALYLV-CaDY11RK.js} +2 -2
  132. package/dist/{swimlanesDiagram-G3AALYLV-C3U5wLlX.cjs → swimlanesDiagram-G3AALYLV-DN1x1exB.cjs} +1 -1
  133. package/dist/{timeline-definition-FHXFAJF6-KUETCXLT.cjs → timeline-definition-FHXFAJF6-DCW8SrSN.cjs} +1 -1
  134. package/dist/{timeline-definition-FHXFAJF6-DBmE_qU3.js → timeline-definition-FHXFAJF6-GIvmYQNR.js} +2 -2
  135. package/dist/{vennDiagram-L72KCM5P-C6j4k5X-.js → vennDiagram-L72KCM5P-DtN1NFNM.js} +1 -1
  136. package/dist/{vennDiagram-L72KCM5P-DkSV3dIE.cjs → vennDiagram-L72KCM5P-wENEw3FH.cjs} +1 -1
  137. package/dist/{wardleyDiagram-EHGQE667-BaG6Cf_u.js → wardleyDiagram-EHGQE667-CPYTbfuJ.js} +2 -2
  138. package/dist/{wardleyDiagram-EHGQE667-uWMTMxL-.cjs → wardleyDiagram-EHGQE667-Daugt2NV.cjs} +1 -1
  139. package/dist/{xychartDiagram-FW5EYKEG-QAFE-xqg.cjs → xychartDiagram-FW5EYKEG-B3D8pi1c.cjs} +1 -1
  140. package/dist/{xychartDiagram-FW5EYKEG-BPl5BnMB.js → xychartDiagram-FW5EYKEG-C-NgU5xv.js} +2 -2
  141. package/package.json +23 -8
  142. package/dist/extractHeadings-DRUBnhbi.cjs +0 -311
  143. package/dist/flowDiagram-23GEKE2U-CDscoQ9F.cjs +0 -1
  144. package/dist/flowDiagram-23GEKE2U-CLibi_u4.js +0 -7
@@ -1,19 +1,21 @@
1
- import { l as L, L as O, a as se, b as ke } from "./linkCards-1JxY8wdm.js";
1
+ import { R as ge, c as ke, a as be } from "./errors-Blk_XJ9C.js";
2
+ import { d as er } from "./errors-Blk_XJ9C.js";
3
+ import { l as L, L as O, a as ae, b as Ee } from "./linkCards-1JxY8wdm.js";
2
4
  import { l as h } from "./simple-logger-DwH1YQvq.js";
3
- import { Resolver as be } from "node:dns/promises";
4
- import * as ie from "node:net";
5
- import { BlockList as ye, isIP as le, connect as Te } from "node:net";
6
- import { Agent as Se, buildConnector as Y, fetch as ve } from "undici";
7
- import { Parser as Ae } from "htmlparser2";
8
- import { spawn as _e } from "node:child_process";
9
- import { existsSync as M, unlinkSync as Re } from "node:fs";
10
- import { createRequire as Le } from "node:module";
11
- import * as C from "node:path";
12
- import { fileURLToPath as Oe } from "node:url";
13
- import { createClient as Pe, ConnectError as Me, Code as Ce } from "@connectrpc/connect";
14
- import { Http2SessionManager as Ie, createConnectTransport as xe } from "@connectrpc/connect-node";
15
- import { Message as x, proto3 as d, MethodKind as Ne } from "@bufbuild/protobuf";
16
- const De = [
5
+ import { Resolver as Te } from "node:dns/promises";
6
+ import * as se from "node:net";
7
+ import { BlockList as ve, isIP as ie, connect as Se } from "node:net";
8
+ import { Agent as ye, buildConnector as Y, fetch as Ae } from "undici";
9
+ import { Parser as _e } from "htmlparser2";
10
+ import { spawn as Re } from "node:child_process";
11
+ import { existsSync as C, unlinkSync as Le } from "node:fs";
12
+ import { createRequire as Oe } from "node:module";
13
+ import * as M from "node:path";
14
+ import { fileURLToPath as Pe } from "node:url";
15
+ import { createClient as Ce, ConnectError as Me, Code as Ie } from "@connectrpc/connect";
16
+ import { Http2SessionManager as xe, createConnectTransport as Ne } from "@connectrpc/connect-node";
17
+ import { Message as x, proto3 as d, MethodKind as De } from "@bufbuild/protobuf";
18
+ const Be = [
17
19
  [[0], 8],
18
20
  [[10], 8],
19
21
  [[100, 64], 10],
@@ -28,7 +30,7 @@ const De = [
28
30
  [[203, 0, 113], 24],
29
31
  [[224], 4],
30
32
  [[240], 4]
31
- ], Be = [
33
+ ], Ue = [
32
34
  [[100, 65435], 32],
33
35
  [[0, 0, 0, 0, 65535, 0], 96],
34
36
  [[256, 0, 0, 0], 64],
@@ -43,31 +45,31 @@ const De = [
43
45
  [[65152], 10],
44
46
  [[65216], 10],
45
47
  [[65280], 8]
46
- ], y = new ye();
47
- for (const [r, t] of De) {
48
+ ], T = new ve();
49
+ for (const [r, t] of Be) {
48
50
  const e = [...r, 0, 0, 0].slice(0, 4).join(".");
49
- y.addSubnet(e, t, "ipv4"), y.addSubnet(`::ffff:${e}`, 96 + t, "ipv6"), y.addSubnet(`::${e}`, 96 + t, "ipv6");
51
+ T.addSubnet(e, t, "ipv4"), T.addSubnet(`::ffff:${e}`, 96 + t, "ipv6"), T.addSubnet(`::${e}`, 96 + t, "ipv6");
50
52
  }
51
- for (const [r, t] of Be)
52
- y.addSubnet(`${r.map((e) => e.toString(16)).join(":")}::`, t, "ipv6");
53
- const U = (r) => {
54
- const t = r.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e = le(t);
55
- return e !== 0 && y.check(t, e === 4 ? "ipv4" : "ipv6");
56
- }, ce = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new be({ timeout: Z.timeoutMs, tries: Z.tries }), Q = (r, t) => ({
57
- error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${r} -> ${t}`), { code: ce })
58
- }), He = async (r, t) => {
59
- const e = le(r);
53
+ for (const [r, t] of Ue)
54
+ T.addSubnet(`${r.map((e) => e.toString(16)).join(":")}::`, t, "ipv6");
55
+ const $ = (r) => {
56
+ const t = r.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e = ie(t);
57
+ return e !== 0 && T.check(t, e === 4 ? "ipv4" : "ipv6");
58
+ }, le = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new Te({ timeout: Z.timeoutMs, tries: Z.tries }), Q = (r, t) => ({
59
+ error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${r} -> ${t}`), { code: le })
60
+ }), $e = async (r, t) => {
61
+ const e = ie(r);
60
62
  if (e !== 0)
61
- return U(r) ? Q(r, r) : { error: null, family: e === 4 ? 4 : 6, addresses: [r] };
62
- const [n, o] = await Promise.allSettled([t === 6 ? Promise.resolve([]) : q.resolve4(r), t === 4 ? Promise.resolve([]) : q.resolve6(r)]), s = n.status === "fulfilled" ? n.value : [], a = o.status === "fulfilled" ? o.value : [], i = [...s, ...a].find((R) => U(R));
63
+ return $(r) ? Q(r, r) : { error: null, family: e === 4 ? 4 : 6, addresses: [r] };
64
+ const [n, o] = await Promise.allSettled([t === 6 ? Promise.resolve([]) : q.resolve4(r), t === 4 ? Promise.resolve([]) : q.resolve6(r)]), s = n.status === "fulfilled" ? n.value : [], a = o.status === "fulfilled" ? o.value : [], i = [...s, ...a].find((R) => $(R));
63
65
  if (i !== void 0) return Q(r, i);
64
66
  const [l, ...c] = s;
65
67
  if (l !== void 0) return { error: null, family: 4, addresses: [l, ...c] };
66
68
  const [f, ...S] = a;
67
69
  return f !== void 0 ? { error: null, family: 6, addresses: [f, ...S] } : n.status === "rejected" ? { error: n.reason } : o.status === "rejected" ? { error: o.reason } : { error: Object.assign(new Error(`No address for ${r}`), { code: "ENOTFOUND" }) };
68
- }, Ue = (r, t, e) => {
70
+ }, He = (r, t, e) => {
69
71
  const n = t.family === 4 || t.family === "IPv4" ? 4 : t.family === 6 || t.family === "IPv6" ? 6 : 0;
70
- He(r, n).then((o) => {
72
+ $e(r, n).then((o) => {
71
73
  if (o.error !== null) {
72
74
  e(o.error, "");
73
75
  return;
@@ -78,7 +80,7 @@ const U = (r) => {
78
80
  a.map((i) => ({ address: i, family: s }))
79
81
  ) : e(null, a[0], s);
80
82
  });
81
- }, $e = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), je = [".local", ".internal", ".home.arpa"], j = (r, t) => {
83
+ }, je = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), ze = [".local", ".internal", ".home.arpa"], j = (r, t) => {
82
84
  let e;
83
85
  try {
84
86
  e = new URL(r);
@@ -91,8 +93,8 @@ const U = (r) => {
91
93
  return { ok: !1, reason: "forbidden-url", detail: "URLs with a user name or password are not allowed" };
92
94
  e.hash = "";
93
95
  const n = e.hostname.replace(/\.+$/u, "");
94
- return n === "localhost" || n.endsWith(".localhost") || $e.has(n) ? { ok: !1, reason: "private-network", detail: "Localhost access is not allowed" } : U(n) ? { ok: !1, reason: "private-network", detail: "Private network access is not allowed" } : !(n.startsWith("[") || n.includes(".")) || je.some((s) => n.endsWith(s)) ? { ok: !1, reason: "private-network", detail: "Internal domain access is not allowed" } : { ok: !0, href: e.href };
95
- }, ue = (r) => {
96
+ return n === "localhost" || n.endsWith(".localhost") || je.has(n) ? { ok: !1, reason: "private-network", detail: "Localhost access is not allowed" } : $(n) ? { ok: !1, reason: "private-network", detail: "Private network access is not allowed" } : !(n.startsWith("[") || n.includes(".")) || ze.some((s) => n.endsWith(s)) ? { ok: !1, reason: "private-network", detail: "Internal domain access is not allowed" } : { ok: !0, href: e.href };
97
+ }, ce = (r) => {
96
98
  let t;
97
99
  try {
98
100
  t = new URL(r);
@@ -100,20 +102,20 @@ const U = (r) => {
100
102
  return "(unparsable URL)";
101
103
  }
102
104
  return t.protocol !== "http:" && t.protocol !== "https:" ? `(a ${t.protocol} URL)` : (t.username = "", t.password = "", t.href);
103
- }, de = 1024, ze = /^[\t\n\f\r ]$/u, w = (r) => ze.test(r), B = (r) => r.replace(/[A-Z]/gu, (t) => t.toLowerCase()), $ = (r) => {
105
+ }, ue = 1024, Je = /^[\t\n\f\r ]$/u, w = (r) => Je.test(r), B = (r) => r.replace(/[A-Z]/gu, (t) => t.toLowerCase()), H = (r) => {
104
106
  try {
105
107
  return new TextDecoder(r).encoding;
106
108
  } catch {
107
109
  return null;
108
110
  }
109
- }, Je = (r) => r[0] === 239 && r[1] === 187 && r[2] === 191 ? "utf-8" : r[0] === 254 && r[1] === 255 ? "utf-16be" : r[0] === 255 && r[1] === 254 ? "utf-16le" : null, Ke = (r) => {
111
+ }, Ke = (r) => r[0] === 239 && r[1] === 187 && r[2] === 191 ? "utf-8" : r[0] === 254 && r[1] === 255 ? "utf-16be" : r[0] === 255 && r[1] === 254 ? "utf-16le" : null, Fe = (r) => {
110
112
  for (const t of r.split(";").slice(1)) {
111
113
  const e = t.indexOf("=");
112
114
  if (e !== -1 && t.slice(0, e).trim().toLowerCase() === "charset")
113
115
  return t.slice(e + 1).trim().replace(/^"(.*)"$/su, "$1");
114
116
  }
115
117
  return null;
116
- }, Fe = (r) => {
118
+ }, Ge = (r) => {
117
119
  let t = 0;
118
120
  for (; ; ) {
119
121
  const e = r.indexOf("charset", t);
@@ -133,7 +135,7 @@ const U = (r) => {
133
135
  const s = r.slice(n).search(/[\t\n\f\r ;]/u);
134
136
  return s === -1 ? r.slice(n) : r.slice(n, n + s);
135
137
  }
136
- }, fe = (r, t) => {
138
+ }, de = (r, t) => {
137
139
  let e = t;
138
140
  for (; w(r.charAt(e)) || r.charAt(e) === "/"; ) e += 1;
139
141
  if (r.charAt(e) === ">" || e >= r.length) return { attribute: null, end: e };
@@ -159,23 +161,23 @@ const U = (r) => {
159
161
  if (o === ">") return { attribute: { name: n, value: "" }, end: e };
160
162
  const s = r.slice(e).search(/[\t\n\f\r >]/u);
161
163
  return s === -1 ? { attribute: null, end: r.length } : { attribute: { name: n, value: B(r.slice(e, e + s)) }, end: e + s };
162
- }, Ge = (r, t) => {
164
+ }, Xe = (r, t) => {
163
165
  const e = /* @__PURE__ */ new Set();
164
166
  let n = !1, o = null, s = null, a = t;
165
167
  for (; ; ) {
166
- const { attribute: i, end: l } = fe(r, a);
168
+ const { attribute: i, end: l } = de(r, a);
167
169
  if (a = l, i === null) break;
168
170
  if (!e.has(i.name))
169
171
  if (e.add(i.name), i.name === "http-equiv")
170
172
  n = i.value === "content-type";
171
173
  else if (i.name === "content") {
172
- const c = Fe(i.value), f = c === null ? null : $(c);
174
+ const c = Ge(i.value), f = c === null ? null : H(c);
173
175
  f !== null && s === null && (s = f, o = !0);
174
- } else i.name === "charset" && (s = $(i.value) ?? !1, o = !1);
176
+ } else i.name === "charset" && (s = H(i.value) ?? !1, o = !1);
175
177
  }
176
178
  return o === null || typeof s != "string" || o && !n ? { encoding: null, end: a } : s === "utf-16be" || s === "utf-16le" ? { encoding: "utf-8", end: a } : { encoding: s === "x-user-defined" ? "windows-1252" : s, end: a };
177
- }, Xe = (r) => {
178
- const t = Array.from(r.subarray(0, de), (n) => String.fromCharCode(n)).join("");
179
+ }, Ve = (r) => {
180
+ const t = Array.from(r.subarray(0, ue), (n) => String.fromCharCode(n)).join("");
179
181
  let e = 0;
180
182
  for (; e < t.length; )
181
183
  if (t.startsWith("<!--", e)) {
@@ -183,14 +185,14 @@ const U = (r) => {
183
185
  if (n === -1) return null;
184
186
  e = n + 3;
185
187
  } else if (/^<meta[\t\n\f\r /]$/iu.test(t.slice(e, e + 6))) {
186
- const { encoding: n, end: o } = Ge(t, e + 5);
188
+ const { encoding: n, end: o } = Xe(t, e + 5);
187
189
  if (n !== null) return n;
188
190
  e = o + 1;
189
191
  } else if (/^<\/?[A-Za-z]/u.test(t.slice(e, e + 3))) {
190
192
  let n = e + 1;
191
193
  for (; n < t.length && !w(t.charAt(n)) && t.charAt(n) !== ">"; ) n += 1;
192
194
  for (; ; ) {
193
- const o = fe(t, n);
195
+ const o = de(t, n);
194
196
  if (n = o.end, o.attribute === null) break;
195
197
  }
196
198
  e = n + 1;
@@ -201,35 +203,35 @@ const U = (r) => {
201
203
  } else
202
204
  e += 1;
203
205
  return null;
204
- }, Ve = (r, t) => {
205
- const e = Je(r);
206
- if (e !== null) return e;
207
- const n = Ke(t), o = n === null ? null : $(n);
208
- return o !== null ? o : Xe(r) ?? "utf-8";
209
206
  }, We = (r, t) => {
207
+ const e = Ke(r);
208
+ if (e !== null) return e;
209
+ const n = Fe(t), o = n === null ? null : H(n);
210
+ return o !== null ? o : Ve(r) ?? "utf-8";
211
+ }, Ye = (r, t) => {
210
212
  const e = new Uint8Array(t);
211
213
  let n = 0;
212
214
  for (const o of r)
213
215
  e.set(o, n), n += o.byteLength;
214
216
  return e;
215
- }, Ye = (r) => {
217
+ }, Ze = (r) => {
216
218
  const t = [];
217
219
  let e = 0, n = null;
218
220
  const o = () => {
219
- const s = We(t, e);
221
+ const s = Ye(t, e);
220
222
  t.length = 0;
221
- const a = new TextDecoder(Ve(s, r));
223
+ const a = new TextDecoder(We(s, r));
222
224
  return n = a, { started: a, text: a.decode(s, { stream: !0 }) };
223
225
  };
224
226
  return {
225
- write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e < de ? "" : o().text),
227
+ write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e < ue ? "" : o().text),
226
228
  end: () => {
227
229
  if (n !== null) return n.decode();
228
230
  const { started: s, text: a } = o();
229
231
  return a + s.decode();
230
232
  }
231
233
  };
232
- }, Ze = (r, t, e) => {
234
+ }, qe = (r, t, e) => {
233
235
  const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
234
236
  return (s) => {
235
237
  const a = n.get(s);
@@ -241,41 +243,41 @@ const U = (r) => {
241
243
  });
242
244
  return o.set(s, l), l;
243
245
  };
244
- }, qe = 65536, Qe = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), et = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]), tt = /* @__PURE__ */ new Set(["ERR_IP_BLOCKED", ce]), me = Object.freeze({ timeoutMs: 5e3, maxRedirects: 5, maxBodyBytes: 8 * 1024 * 1024 }), rt = Object.freeze({ lookup: Ue, blockList: y }), nt = (r, t) => {
246
+ }, Qe = 65536, et = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), tt = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]), rt = /* @__PURE__ */ new Set(["ERR_IP_BLOCKED", le]), fe = Object.freeze({ timeoutMs: 5e3, maxRedirects: 5, maxBodyBytes: 8 * 1024 * 1024 }), nt = Object.freeze({ lookup: He, blockList: T }), ot = (r, t) => {
245
247
  const e = Y({ lookup: r.lookup, blockList: r.blockList, timeout: t }), n = Y({ timeout: t });
246
248
  return (o, s) => {
247
249
  if (o.protocol !== "https:") {
248
250
  e(o, s);
249
251
  return;
250
252
  }
251
- const a = Te({ host: o.hostname, port: Number(o.port === "" ? 443 : o.port), lookup: r.lookup, blockList: r.blockList }), i = (l) => {
253
+ const a = Se({ host: o.hostname, port: Number(o.port === "" ? 443 : o.port), lookup: r.lookup, blockList: r.blockList }), i = (l) => {
252
254
  a.destroy(), s(l, null);
253
255
  };
254
256
  a.setTimeout(t, () => i(Object.assign(new Error(`Connect timeout: ${o.hostname}`), { code: "UND_ERR_CONNECT_TIMEOUT" }))), a.once("error", i), a.once("connect", () => {
255
257
  a.setTimeout(0), a.removeListener("error", i), n({ ...o, httpSocket: a }, s);
256
258
  });
257
259
  };
258
- }, ot = (r) => new Se({
259
- maxHeaderSize: qe,
260
- connect: nt(rt, me.timeoutMs)
261
- }), H = async (r) => {
260
+ }, at = (r) => new ye({
261
+ maxHeaderSize: Qe,
262
+ connect: ot(nt, fe.timeoutMs)
263
+ }), U = async (r) => {
262
264
  r.body !== null && await Promise.allSettled([r.body.cancel()]);
263
- }, at = (r) => r !== null && et.has(r.split(";", 1)[0].trim().toLowerCase()), st = (r) => {
265
+ }, st = (r) => r !== null && tt.has(r.split(";", 1)[0].trim().toLowerCase()), it = (r) => {
264
266
  const t = [r];
265
267
  for (let e = 0; e < 16 && t.length > 0; e += 1) {
266
268
  const n = t.shift();
267
269
  if (!(n instanceof Error)) continue;
268
270
  const o = n.code;
269
- if (typeof o == "string" && tt.has(o)) return n.message;
271
+ if (typeof o == "string" && rt.has(o)) return n.message;
270
272
  t.push(n.cause, ...n instanceof AggregateError ? n.errors : []);
271
273
  }
272
274
  return null;
273
- }, pe = (r, t) => {
274
- const e = st(r);
275
+ }, me = (r, t) => {
276
+ const e = it(r);
275
277
  return e !== null ? (h.info("Refused link-card connection to a private address:", t, e), { ok: !1, reason: "private-network" }) : (h.error("Error fetching link-card metadata:", r), { ok: !1, reason: "unreachable" });
276
- }, it = () => new Promise((r) => {
278
+ }, lt = () => new Promise((r) => {
277
279
  setImmediate(r);
278
- }), lt = async (r, t, e, n) => {
280
+ }), ct = async (r, t, e, n) => {
279
281
  if (r.body === null) return { ok: !0, value: t.end() };
280
282
  const o = r.body.getReader();
281
283
  let s = 0;
@@ -284,7 +286,7 @@ const U = (r) => {
284
286
  try {
285
287
  a = await o.read();
286
288
  } catch (f) {
287
- return pe(f, n);
289
+ return me(f, n);
288
290
  }
289
291
  if (a.done) break;
290
292
  const i = e - s, l = a.value.byteLength > i, c = l ? a.value.subarray(0, i) : a.value;
@@ -296,26 +298,26 @@ const U = (r) => {
296
298
  await Promise.allSettled([o.cancel()]), h.warn("Link-card page body exceeds the size limit; parsing only its first bytes:", n, e);
297
299
  break;
298
300
  }
299
- await it();
301
+ await lt();
300
302
  }
301
303
  return { ok: !0, value: t.end() };
302
- }, ct = async (r, t, e, n) => {
304
+ }, ut = async (r, t, e, n) => {
303
305
  let o = r;
304
306
  for (let s = 0; s <= t.limits.maxRedirects; s += 1) {
305
307
  let a;
306
308
  try {
307
- a = await ve(o, { signal: n, redirect: "manual", dispatcher: t.agent });
309
+ a = await Ae(o, { signal: n, redirect: "manual", dispatcher: t.agent });
308
310
  } catch (f) {
309
- return pe(f, o);
311
+ return me(f, o);
310
312
  }
311
- const i = Qe.has(a.status) ? a.headers.get("location")?.trim() ?? "" : "";
313
+ const i = et.has(a.status) ? a.headers.get("location")?.trim() ?? "" : "";
312
314
  if (i === "") {
313
315
  if (!a.ok)
314
- return await H(a), { ok: !1, reason: "unreachable" };
316
+ return await U(a), { ok: !1, reason: "unreachable" };
315
317
  const f = a.headers.get("content-type");
316
- return at(f) ? lt(a, e({ url: o, contentType: f }), t.limits.maxBodyBytes, o) : (await H(a), { ok: !1, reason: "not-html" });
318
+ return st(f) ? ct(a, e({ url: o, contentType: f }), t.limits.maxBodyBytes, o) : (await U(a), { ok: !1, reason: "not-html" });
317
319
  }
318
- await H(a);
320
+ await U(a);
319
321
  let l;
320
322
  try {
321
323
  l = new URL(i, o);
@@ -324,16 +326,16 @@ const U = (r) => {
324
326
  }
325
327
  const c = j(l.href);
326
328
  if (!c.ok)
327
- return h.info("Refused link-card redirect:", ue(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
329
+ return h.info("Refused link-card redirect:", ce(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
328
330
  o = c.href;
329
331
  }
330
332
  return h.error("Too many redirects while fetching link-card metadata:", r), { ok: !1, reason: "unreachable" };
331
- }, ut = (r, t, e) => {
333
+ }, dt = (r, t, e) => {
332
334
  const n = new AbortController(), o = setTimeout(() => n.abort(), t.limits.timeoutMs);
333
- return ct(r, t, e, n.signal).finally(() => {
335
+ return ut(r, t, e, n.signal).finally(() => {
334
336
  clearTimeout(o);
335
337
  });
336
- }, dt = 256, ft = 4096, mt = 64, pt = /* @__PURE__ */ new Set(["html", "head", "title", "meta", "link", "base", "basefont", "bgsound", "noframes", "script", "style", "template", "noscript"]), ht = /* @__PURE__ */ new Set(["title", "script", "style"]), wt = /* @__PURE__ */ new Set(["noscript", "template", "noframes"]), gt = (r) => r?.toLowerCase().split(/[\t\n\f\r ]+/u).includes("icon") === !0, Et = (r, t) => {
338
+ }, ft = 256, mt = 4096, pt = 64, ht = /* @__PURE__ */ new Set(["html", "head", "title", "meta", "link", "base", "basefont", "bgsound", "noframes", "script", "style", "template", "noscript"]), wt = /* @__PURE__ */ new Set(["title", "script", "style"]), gt = /* @__PURE__ */ new Set(["noscript", "template", "noframes"]), kt = (r) => r?.toLowerCase().split(/[\t\n\f\r ]+/u).includes("icon") === !0, bt = (r, t) => {
337
339
  if (r === void 0) return t;
338
340
  let e;
339
341
  try {
@@ -341,7 +343,7 @@ const U = (r) => {
341
343
  } catch {
342
344
  return t;
343
345
  }
344
- return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= se ? e.href : t;
346
+ return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= ae ? e.href : t;
345
347
  }, ee = (r, t, e) => {
346
348
  const n = r?.trim();
347
349
  if (n === void 0 || n === "") return;
@@ -351,30 +353,30 @@ const U = (r) => {
351
353
  } catch {
352
354
  return;
353
355
  }
354
- return o.href.length <= se && j(o.href).ok ? o.href : void 0;
355
- }, kt = (r, t) => {
356
+ return o.href.length <= ae && j(o.href).ok ? o.href : void 0;
357
+ }, Et = (r, t) => {
356
358
  let e = !1, n = 0, o = 0, s = 0, a = null, i = null, l = null, c, f, S, R, z, J, K = !1, F, G = !1;
357
359
  const N = () => {
358
360
  e = !0, D.pause();
359
- }, D = new Ae(
361
+ }, D = new _e(
360
362
  {
361
363
  onopentagname(u) {
362
- n += 1, o += 1, s = 0, (n > dt || o > ft || a === null && !pt.has(u)) && N();
364
+ n += 1, o += 1, s = 0, (n > ft || o > mt || a === null && !ht.has(u)) && N();
363
365
  },
364
366
  onattribute() {
365
- s += 1, s > mt && N();
367
+ s += 1, s > pt && N();
366
368
  },
367
369
  onopentag(u, m) {
368
370
  if (!(e || a !== null)) {
369
- if (wt.has(u)) {
371
+ if (gt.has(u)) {
370
372
  a = n;
371
373
  return;
372
374
  }
373
375
  if (u === "meta") {
374
376
  const p = m.content;
375
377
  m.property === "og:site_name" && (R = p), m.property === "og:title" && (f = p), m.property === "og:description" && (S = p), m.property === "og:image" && (z = p), m.name === "description" && (S = p);
376
- } else u === "link" && !K && gt(m.rel) ? (K = !0, J = m.href) : u === "base" && !G && Object.hasOwn(m, "href") && (G = !0, F = m.href);
377
- ht.has(u) && (i = u, u === "title" && c === void 0 && (l = ""));
378
+ } else u === "link" && !K && kt(m.rel) ? (K = !0, J = m.href) : u === "base" && !G && Object.hasOwn(m, "href") && (G = !0, F = m.href);
379
+ wt.has(u) && (i = u, u === "title" && c === void 0 && (l = ""));
378
380
  }
379
381
  },
380
382
  ontext(u) {
@@ -396,7 +398,7 @@ const U = (r) => {
396
398
  write: (u) => (e || D.write(u), !e),
397
399
  end: () => {
398
400
  e || D.end();
399
- const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = Et(F, r), V = ee(z, X), W = ee(J, X);
401
+ const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = bt(F, r), V = ee(z, X), W = ee(J, X);
400
402
  return {
401
403
  ...u === null ? {} : { title: u },
402
404
  ...m === null ? {} : { description: m },
@@ -406,54 +408,54 @@ const U = (r) => {
406
408
  };
407
409
  }
408
410
  };
409
- }, bt = /* @__PURE__ */ new Set(["authorize"]), yt = "private, max-age=1800", Tt = 3600 * 1e3, he = Object.freeze({ "private-network": 1800, "forbidden-url": 1800, unreachable: 300, "not-html": 300 }), St = 1e3, P = "no-store", v = (r, t, e, n, o = {}) => new Response(r.method === "HEAD" ? null : JSON.stringify(e), {
411
+ }, Tt = /* @__PURE__ */ new Set(["authorize"]), vt = "private, max-age=1800", St = 3600 * 1e3, pe = Object.freeze({ "private-network": 1800, "forbidden-url": 1800, unreachable: 300, "not-html": 300 }), yt = 1e3, P = "no-store", y = (r, t, e, n, o = {}) => new Response(r.method === "HEAD" ? null : JSON.stringify(e), {
410
412
  status: t,
411
413
  headers: { "Content-Type": "application/json; charset=utf-8", "Cache-Control": n, "X-Content-Type-Options": "nosniff", ...o }
412
414
  }), te = (r) => new Response(null, {
413
415
  status: 204,
414
- headers: { "Cache-Control": `private, max-age=${he[r]}`, "X-Content-Type-Options": "nosniff", [ke]: r }
415
- }), vt = (r) => {
416
+ headers: { "Cache-Control": `private, max-age=${pe[r]}`, "X-Content-Type-Options": "nosniff", [Ee]: r }
417
+ }), At = (r) => {
416
418
  if (typeof r != "object" || r === null)
417
419
  throw new TypeError("createLinkCardHandler: options must be an object with an authorize function");
418
420
  if (typeof r.authorize != "function")
419
421
  throw new TypeError("createLinkCardHandler: options.authorize must be a function (pass () => true to serve everyone)");
420
- const t = Object.keys(r).filter((e) => !bt.has(e));
422
+ const t = Object.keys(r).filter((e) => !Tt.has(e));
421
423
  if (t.length > 0)
422
424
  throw new TypeError(`createLinkCardHandler: unknown option(s): ${t.join(", ")}`);
423
- }, At = (r) => (t) => {
424
- const e = Ye(t.contentType), n = kt(t.url);
425
+ }, _t = (r) => (t) => {
426
+ const e = Ze(t.contentType), n = Et(t.url);
425
427
  return {
426
428
  write: (o) => n.write(e.write(o)),
427
429
  end: () => (n.write(e.end()), n.end())
428
430
  };
429
- }, _t = (r, t) => {
430
- vt(r);
431
- const { authorize: e } = r, n = ot(), o = Ze(
432
- (s) => ut(s, { agent: n, scope: t, limits: me }, At()),
433
- { maxEntries: St, ttlMsOf: (s) => s.ok ? Tt : he[s.reason] * 1e3 },
431
+ }, Rt = (r, t) => {
432
+ At(r);
433
+ const { authorize: e } = r, n = at(), o = qe(
434
+ (s) => dt(s, { agent: n, scope: t, limits: fe }, _t()),
435
+ { maxEntries: yt, ttlMsOf: (s) => s.ok ? St : pe[s.reason] * 1e3 },
434
436
  Date.now
435
437
  );
436
438
  return async (s) => {
437
439
  if (s.method !== "GET" && s.method !== "HEAD")
438
- return v(s, 405, { error: "Method Not Allowed" }, P, { Allow: "GET, HEAD" });
440
+ return y(s, 405, { error: "Method Not Allowed" }, P, { Allow: "GET, HEAD" });
439
441
  if (await e(s) !== !0)
440
- return v(s, 401, { error: "Unauthorized" }, P);
442
+ return y(s, 401, { error: "Unauthorized" }, P);
441
443
  const a = new URL(s.url).searchParams.get("url");
442
444
  if (a === null || a === "")
443
- return v(s, 400, { error: "Missing 'url' parameter" }, P);
445
+ return y(s, 400, { error: "Missing 'url' parameter" }, P);
444
446
  const i = j(a);
445
447
  if (!i.ok)
446
- return h.info("Refused link-card URL:", ue(a), `(${i.reason}: ${i.detail})`), te(i.reason);
448
+ return h.info("Refused link-card URL:", ce(a), `(${i.reason}: ${i.detail})`), te(i.reason);
447
449
  let l;
448
450
  try {
449
451
  l = await o(i.href);
450
452
  } catch (c) {
451
- return h.error("Unexpected error while reading link-card metadata:", i.href, c), v(s, 500, { error: "Internal Server Error" }, P);
453
+ return h.error("Unexpected error while reading link-card metadata:", i.href, c), y(s, 500, { error: "Internal Server Error" }, P);
452
454
  }
453
- return l.ok ? v(s, 200, l.value, yt) : te(l.reason);
455
+ return l.ok ? y(s, 200, l.value, vt) : te(l.reason);
454
456
  };
455
- }, Yt = (r) => _t(r, "public");
456
- class E extends x {
457
+ }, Yt = (r) => Rt(r, "public");
458
+ class k extends x {
457
459
  /**
458
460
  * @generated from field: string markdown_text = 1;
459
461
  */
@@ -549,6 +551,19 @@ class E extends x {
549
551
  * @generated from field: markdown.v1.DenyRules deny = 13;
550
552
  */
551
553
  deny;
554
+ /**
555
+ * Annotates every rendered block with `data-source-lines="<first>-<last>"`:
556
+ * the 1-based lines of `markdown_text` it came from, both inclusive (with
557
+ * `resolve_imports`, the lines of the text with every import expanded). A
558
+ * block that spans no line of its own (a thematic break) and a raw HTML
559
+ * block carry none. False by default; either way, a `data-source-lines` an
560
+ * author wrote is removed, so the attribute in the HTML is always the
561
+ * converter's own. With it, the HTML is the HTML without it plus the
562
+ * attribute alone.
563
+ *
564
+ * @generated from field: bool include_source_lines = 14;
565
+ */
566
+ includeSourceLines = !1;
552
567
  constructor(t) {
553
568
  super(), d.util.initPartial(t, this);
554
569
  }
@@ -597,19 +612,26 @@ class E extends x {
597
612
  /* ScalarType.BOOL */
598
613
  },
599
614
  { no: 12, name: "max_html_bytes", kind: "scalar", T: 13, opt: !0 },
600
- { no: 13, name: "deny", kind: "message", T: g }
615
+ { no: 13, name: "deny", kind: "message", T: g },
616
+ {
617
+ no: 14,
618
+ name: "include_source_lines",
619
+ kind: "scalar",
620
+ T: 8
621
+ /* ScalarType.BOOL */
622
+ }
601
623
  ]);
602
624
  static fromBinary(t, e) {
603
- return new E().fromBinary(t, e);
625
+ return new k().fromBinary(t, e);
604
626
  }
605
627
  static fromJson(t, e) {
606
- return new E().fromJson(t, e);
628
+ return new k().fromJson(t, e);
607
629
  }
608
630
  static fromJsonString(t, e) {
609
- return new E().fromJsonString(t, e);
631
+ return new k().fromJsonString(t, e);
610
632
  }
611
633
  static equals(t, e) {
612
- return d.util.equals(E, t, e);
634
+ return d.util.equals(k, t, e);
613
635
  }
614
636
  }
615
637
  class g extends x {
@@ -636,7 +658,7 @@ class g extends x {
636
658
  return d.util.equals(g, t, e);
637
659
  }
638
660
  }
639
- class k extends x {
661
+ class b extends x {
640
662
  /**
641
663
  * @generated from field: string html_content = 1;
642
664
  */
@@ -658,22 +680,22 @@ class k extends x {
658
680
  T: 9
659
681
  /* ScalarType.STRING */
660
682
  },
661
- { no: 2, name: "headings", kind: "message", T: b, repeated: !0 }
683
+ { no: 2, name: "headings", kind: "message", T: E, repeated: !0 }
662
684
  ]);
663
685
  static fromBinary(t, e) {
664
- return new k().fromBinary(t, e);
686
+ return new b().fromBinary(t, e);
665
687
  }
666
688
  static fromJson(t, e) {
667
- return new k().fromJson(t, e);
689
+ return new b().fromJson(t, e);
668
690
  }
669
691
  static fromJsonString(t, e) {
670
- return new k().fromJsonString(t, e);
692
+ return new b().fromJsonString(t, e);
671
693
  }
672
694
  static equals(t, e) {
673
- return d.util.equals(k, t, e);
695
+ return d.util.equals(b, t, e);
674
696
  }
675
697
  }
676
- class b extends x {
698
+ class E extends x {
677
699
  /**
678
700
  * @generated from field: string text = 1;
679
701
  */
@@ -715,19 +737,19 @@ class b extends x {
715
737
  }
716
738
  ]);
717
739
  static fromBinary(t, e) {
718
- return new b().fromBinary(t, e);
740
+ return new E().fromBinary(t, e);
719
741
  }
720
742
  static fromJson(t, e) {
721
- return new b().fromJson(t, e);
743
+ return new E().fromJson(t, e);
722
744
  }
723
745
  static fromJsonString(t, e) {
724
- return new b().fromJsonString(t, e);
746
+ return new E().fromJsonString(t, e);
725
747
  }
726
748
  static equals(t, e) {
727
- return d.util.equals(b, t, e);
749
+ return d.util.equals(E, t, e);
728
750
  }
729
751
  }
730
- const Rt = {
752
+ const Lt = {
731
753
  typeName: "markdown.v1.MarkdownService",
732
754
  methods: {
733
755
  /**
@@ -735,82 +757,70 @@ const Rt = {
735
757
  */
736
758
  convert: {
737
759
  name: "Convert",
738
- I: E,
739
- O: k,
740
- kind: Ne.Unary
760
+ I: k,
761
+ O: b,
762
+ kind: De.Unary
741
763
  }
742
764
  }
743
- }, T = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", Lt = new Ie("http://localhost", void 0, {
744
- createConnection: () => ie.connect(T)
745
- }), we = 64 * 1024, Ot = 4294967295, re = Math.floor((Ot - we) / 2);
746
- class Pt extends Error {
747
- /**
748
- * Wraps the service's or the transport's resource-exhausted error.
749
- * サービスか転送の resource exhausted のエラーを包む処理。
750
- *
751
- * @param cause - The connect error. connect のエラー。
752
- */
753
- constructor(t) {
754
- super(t.rawMessage, { cause: t }), this.name = "MarkdownResourceExhaustedError";
755
- }
756
- }
757
- const ne = () => {
765
+ }, v = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", Ot = new xe("http://localhost", void 0, {
766
+ createConnection: () => se.connect(v)
767
+ }), re = () => {
758
768
  try {
759
- return C.dirname(Oe(import.meta.url));
769
+ return M.dirname(Pe(import.meta.url));
760
770
  } catch {
761
771
  return __dirname;
762
772
  }
763
- }, ge = () => `@aiquants/markdown-${process.platform}-${process.arch}`, oe = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Mt = () => {
773
+ }, he = () => `@aiquants/markdown-${process.platform}-${process.arch}`, ne = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Pt = () => {
764
774
  const r = process.env.MARKDOWN_API_BINARY;
765
- if (r && M(r))
775
+ if (r && C(r))
766
776
  return r;
767
777
  try {
768
- const e = Le(C.join(ne(), "index.js")).resolve(`${ge()}/${oe()}`);
769
- if (M(e))
778
+ const e = Oe(M.join(re(), "index.js")).resolve(`${he()}/${ne()}`);
779
+ if (C(e))
770
780
  return e;
771
781
  } catch {
772
782
  }
773
- const t = C.join(ne(), "..", "..", "go", "markdown-api", "dist", C.basename(oe()));
774
- return M(t) ? t : void 0;
783
+ const t = M.join(re(), "..", "..", "go", "markdown-api", "dist", M.basename(ne()));
784
+ return C(t) ? t : void 0;
775
785
  }, Ct = () => [
776
786
  `markdown-api binary not found for ${process.platform}-${process.arch}.`,
777
- `Expected the optional dependency ${ge()} to be installed.`,
787
+ `Expected the optional dependency ${he()} to be installed.`,
778
788
  "If your platform is unsupported, build the service yourself",
779
789
  "(https://github.com/fehde-k/aiquants/tree/main/packages/go/markdown-api)",
780
790
  "and point MARKDOWN_API_BINARY at it."
781
- ].join(" "), Ee = () => new Promise((r) => {
782
- const t = ie.connect(T);
791
+ ].join(" "), we = () => new Promise((r) => {
792
+ const t = se.connect(v);
783
793
  t.on("connect", () => {
784
794
  t.destroy(), r(!0);
785
795
  }), t.on("error", () => r(!1));
786
- }), ae = async (r) => {
796
+ }), oe = async (r) => {
787
797
  const t = Date.now();
788
798
  for (; Date.now() - t < r; ) {
789
- if (await Ee()) return !0;
799
+ if (await we()) return !0;
790
800
  await new Promise((e) => setTimeout(e, 100));
791
801
  }
792
802
  return !1;
793
803
  };
794
804
  let A = null, _ = null;
795
- const It = 2e3, xt = () => {
805
+ const Mt = 2e3, It = () => {
796
806
  const r = Number(process.env.MARKDOWN_API_STARTUP_TIMEOUT_MS);
797
807
  return Number.isFinite(r) && r > 0 ? r : 1e4;
798
808
  };
799
809
  let I = null;
800
- const Nt = async () => {
801
- if (await Ee()) return !0;
810
+ const xt = async () => {
811
+ if (await we()) return !0;
802
812
  if (_) return _;
803
813
  _ = (async () => {
804
- const t = Mt();
814
+ const t = Pt();
805
815
  if (!t)
806
- return await ae(It) ? !0 : (I = Ct(), !1);
816
+ return await oe(Mt) ? !0 : (I = Ct(), !1);
807
817
  I = null;
808
818
  try {
809
- M(T) && Re(T);
819
+ C(v) && Le(v);
810
820
  } catch {
811
821
  }
812
822
  try {
813
- A = _e(t, [], { stdio: "ignore" });
823
+ A = Re(t, [], { stdio: "ignore" });
814
824
  const e = () => {
815
825
  if (A) {
816
826
  try {
@@ -820,28 +830,24 @@ const Nt = async () => {
820
830
  A = null;
821
831
  }
822
832
  };
823
- return process.once("exit", e), await ae(xt()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", T), e(), process.removeListener("exit", e), !1);
833
+ return process.once("exit", e), await oe(It()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", v), e(), process.removeListener("exit", e), !1);
824
834
  } catch (e) {
825
835
  return console.error("Failed to spawn markdown-api Go server:", e), A = null, !1;
826
836
  }
827
837
  })();
828
838
  const r = await _;
829
839
  return r || (_ = null), r;
830
- }, Dt = (r) => {
831
- if (!Array.isArray(r.deniedPathSegments))
832
- throw new TypeError("parseMarkdown: deniedPathSegments must be an array of path segment patterns (an empty array denies nothing)");
833
- if (!Number.isSafeInteger(r.maxHtmlBytes) || r.maxHtmlBytes <= 0 || r.maxHtmlBytes > re)
834
- throw new RangeError(`parseMarkdown: maxHtmlBytes must be an integer from 1 to ${re}, got ${r.maxHtmlBytes}`);
835
- if (r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
840
+ }, Nt = (r) => {
841
+ if (be(r, "parseMarkdown"), r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
836
842
  throw new RangeError(`parseMarkdown: timeoutMs must be a positive integer, got ${r.timeoutMs}`);
837
843
  }, Zt = async (r, t, e, n, o) => {
838
- if (Dt(o), !await Nt()) {
844
+ if (Nt(o), !await xt()) {
839
845
  const i = I ? ` ${I}` : "";
840
- throw new Error(`markdown service is not reachable on ${T}.${i}`);
846
+ throw new Error(`markdown service is not reachable on ${v}.${i}`);
841
847
  }
842
848
  const s = {};
843
849
  n && (s.Authorization = `Bearer ${n}`);
844
- const a = Pe(Rt, xe({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Lt, readMaxBytes: 2 * o.maxHtmlBytes + we }));
850
+ const a = Ce(Lt, Ne({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Ot, readMaxBytes: 2 * o.maxHtmlBytes + ge }));
845
851
  try {
846
852
  const i = await a.convert(
847
853
  {
@@ -856,6 +862,7 @@ const Nt = async () => {
856
862
  enableEmbeds: o.enableEmbeds,
857
863
  enableZennDirectives: o.enableZennDirectives,
858
864
  resolveImports: o.resolveImports ?? !1,
865
+ includeSourceLines: o.includeSourceLines ?? !1,
859
866
  maxHtmlBytes: o.maxHtmlBytes,
860
867
  deny: new g({ segmentPatterns: [...o.deniedPathSegments] })
861
868
  },
@@ -870,12 +877,12 @@ const Nt = async () => {
870
877
  }))
871
878
  };
872
879
  } catch (i) {
873
- throw i instanceof Me && i.code === Ce.ResourceExhausted ? new Pt(i) : i;
880
+ throw i instanceof Me && i.code === Ie.ResourceExhausted ? new ke(i.rawMessage, { cause: i }) : i;
874
881
  }
875
882
  };
876
883
  export {
877
- re as MAX_HTML_BYTES_LIMIT,
878
- Pt as MarkdownResourceExhaustedError,
884
+ er as MAX_HTML_BYTES_LIMIT,
885
+ ke as MarkdownResourceExhaustedError,
879
886
  Yt as createLinkCardHandler,
880
887
  Zt as parseMarkdown
881
888
  };