@aiquants/markdown 3.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +56 -7
  2. package/dist/{abnfDiagram-VRR7QNED-BEW-pzlz.cjs → abnfDiagram-VRR7QNED-CfVjEUzG.cjs} +1 -1
  3. package/dist/{abnfDiagram-VRR7QNED-ashFdTvJ.js → abnfDiagram-VRR7QNED-DeHJ63Vu.js} +3 -3
  4. package/dist/{arc-CV_3A_PF.js → arc-DH6k2JIR.js} +1 -1
  5. package/dist/{arc-DVw3O83w.cjs → arc-XFFLkHkK.cjs} +1 -1
  6. package/dist/{architectureDiagram-ZJ3FMSHR-ClwjWrgh.cjs → architectureDiagram-ZJ3FMSHR-7xJ6YYGu.cjs} +1 -1
  7. package/dist/{architectureDiagram-ZJ3FMSHR-BsYF-1vK.js → architectureDiagram-ZJ3FMSHR-CQ1m3MUB.js} +2 -2
  8. package/dist/{blockDiagram-677ZJIJ3-CG0redjq.js → blockDiagram-677ZJIJ3-BPC3se0e.js} +3 -3
  9. package/dist/{blockDiagram-677ZJIJ3-Dv1BULkl.cjs → blockDiagram-677ZJIJ3-CJOFqwiW.cjs} +1 -1
  10. package/dist/{c4Diagram-LMCZKHZV-Bp8B3b7f.js → c4Diagram-LMCZKHZV-BEIrp4t6.js} +2 -2
  11. package/dist/{c4Diagram-LMCZKHZV-DC4usA2R.cjs → c4Diagram-LMCZKHZV-D8ytYGhR.cjs} +1 -1
  12. package/dist/{channel-Cg0ufK1F.cjs → channel-CJQcZr8o.cjs} +1 -1
  13. package/dist/{channel-NjFKsGs9.js → channel-DoH_tsOQ.js} +1 -1
  14. package/dist/{chunk-2Q5K7J3B-BY6lLkFO.cjs → chunk-2Q5K7J3B-BbMQR3Sm.cjs} +1 -1
  15. package/dist/{chunk-2Q5K7J3B-XXQGFlOd.js → chunk-2Q5K7J3B-l8ly7Yjr.js} +1 -1
  16. package/dist/{chunk-32BRIVSS-DgnH6GLY.js → chunk-32BRIVSS-BhQJBlVw.js} +1 -1
  17. package/dist/{chunk-32BRIVSS-kO6eHILC.cjs → chunk-32BRIVSS-BwDfmprN.cjs} +1 -1
  18. package/dist/{chunk-5VM5RSS4-BhA4Tl7P.js → chunk-5VM5RSS4-Bfis-x7E.js} +1 -1
  19. package/dist/{chunk-5VM5RSS4-BITLjZU7.cjs → chunk-5VM5RSS4-CqDQlS7v.cjs} +1 -1
  20. package/dist/{chunk-EX3LRPZG-CJr2-IiP.cjs → chunk-EX3LRPZG-9aDULZwJ.cjs} +1 -1
  21. package/dist/{chunk-EX3LRPZG-DSylTHty.js → chunk-EX3LRPZG-DUTbzwDM.js} +4 -4
  22. package/dist/{chunk-JWPE2WC7-BTz8xxEq.cjs → chunk-JWPE2WC7-5cM5nFf6.cjs} +1 -1
  23. package/dist/{chunk-JWPE2WC7-Cr_-c4Em.js → chunk-JWPE2WC7-DpcSSOP5.js} +1 -1
  24. package/dist/{chunk-MOJQB5TN-vnYqNQhm.cjs → chunk-MOJQB5TN-Cw864mUL.cjs} +1 -1
  25. package/dist/{chunk-MOJQB5TN-DngSrRvI.js → chunk-MOJQB5TN-D_h6bolU.js} +1 -1
  26. package/dist/{chunk-PUDLZKDR-Jnb9X3uo.js → chunk-PUDLZKDR-B0wZjmzv.js} +6 -6
  27. package/dist/{chunk-PUDLZKDR-BTwddg7A.cjs → chunk-PUDLZKDR-yLvT3c9x.cjs} +1 -1
  28. package/dist/{chunk-RYQCIY6F-CwJsUgE_.js → chunk-RYQCIY6F-DTKYsCgk.js} +1 -1
  29. package/dist/{chunk-RYQCIY6F-DxECu9__.cjs → chunk-RYQCIY6F-hj9dRWMT.cjs} +1 -1
  30. package/dist/{chunk-V7JOEXUC-gEKuI7OI.js → chunk-V7JOEXUC-COa9uddv.js} +5 -5
  31. package/dist/{chunk-V7JOEXUC-DgGwolBn.cjs → chunk-V7JOEXUC-DIQ8n1AN.cjs} +1 -1
  32. package/dist/{chunk-VR4S4FIN-8cM_PVeG.js → chunk-VR4S4FIN-B72PxPVm.js} +1 -1
  33. package/dist/{chunk-VR4S4FIN-DKbaKheJ.cjs → chunk-VR4S4FIN-Cy-2mZJB.cjs} +1 -1
  34. package/dist/{chunk-XXDRQBXY-CN2bL4d4.js → chunk-XXDRQBXY-D2Sgptl-.js} +1 -1
  35. package/dist/{chunk-XXDRQBXY-CDD2QRgB.cjs → chunk-XXDRQBXY-DmoUE7-y.cjs} +1 -1
  36. package/dist/{classDiagram-v2-EOCWNBFH-_cymiFSf.js → classDiagram-OUVF2IWQ-Dah4_VL7.js} +2 -2
  37. package/dist/{classDiagram-OUVF2IWQ-DpgKwDbm.cjs → classDiagram-OUVF2IWQ-GjsCEuKI.cjs} +1 -1
  38. package/dist/{classDiagram-OUVF2IWQ-_cymiFSf.js → classDiagram-v2-EOCWNBFH-Dah4_VL7.js} +2 -2
  39. package/dist/{classDiagram-v2-EOCWNBFH-DpgKwDbm.cjs → classDiagram-v2-EOCWNBFH-GjsCEuKI.cjs} +1 -1
  40. package/dist/components/MarkdownRenderer.d.ts +4 -2
  41. package/dist/components/MarkdownViewer.d.ts +3 -1
  42. package/dist/components/MermaidDiagram.d.ts +1 -0
  43. package/dist/components/mathRendering.d.ts +11 -0
  44. package/dist/components/mdastNodes/MathNode.d.ts +10 -0
  45. package/dist/{cose-bilkent-JH36ORCC-BYBqAjZw.js → cose-bilkent-JH36ORCC-Pi0l3C5o.js} +1 -1
  46. package/dist/{cose-bilkent-JH36ORCC-DnfyBXGg.cjs → cose-bilkent-JH36ORCC-Vi9pHFwc.cjs} +1 -1
  47. package/dist/{cynefinDiagram-TSTJHNR4-C8EYsJAe.cjs → cynefinDiagram-TSTJHNR4-BQ2k9Z6b.cjs} +1 -1
  48. package/dist/{cynefinDiagram-TSTJHNR4-BWEOxUpI.js → cynefinDiagram-TSTJHNR4-CIh03JTU.js} +2 -2
  49. package/dist/{dagre-VKFMJZFB-Dzz7AfJC.cjs → dagre-VKFMJZFB-DI2wSrAy.cjs} +1 -1
  50. package/dist/{dagre-VKFMJZFB-D9yci9ce.js → dagre-VKFMJZFB-cINcPwV3.js} +2 -2
  51. package/dist/{diagram-FQU43EPY-B_jbLFxw.cjs → diagram-FQU43EPY-B6iUH2l5.cjs} +1 -1
  52. package/dist/{diagram-FQU43EPY-Byd0f28a.js → diagram-FQU43EPY-BonrBTG_.js} +2 -2
  53. package/dist/{diagram-G47NLZAW-CzGLTuaI.js → diagram-G47NLZAW-5N876QQA.js} +3 -3
  54. package/dist/{diagram-G47NLZAW-BD7Qvt5F.cjs → diagram-G47NLZAW-CY6mWS2R.cjs} +1 -1
  55. package/dist/{diagram-NH7WQ7WH-D6J_ePSr.js → diagram-NH7WQ7WH-LFuTbHxY.js} +2 -2
  56. package/dist/{diagram-NH7WQ7WH-DtE40O1y.cjs → diagram-NH7WQ7WH-x3SaRfd6.cjs} +1 -1
  57. package/dist/{diagram-OA4YK3LP-BV_3h5ls.cjs → diagram-OA4YK3LP-B9mVw8cB.cjs} +1 -1
  58. package/dist/{diagram-OA4YK3LP-BRkpKDSL.js → diagram-OA4YK3LP-Cinpbl0B.js} +3 -3
  59. package/dist/{diagram-WEI45ONY-CMtm1y9S.cjs → diagram-WEI45ONY-BRYVUhRr.cjs} +1 -1
  60. package/dist/{diagram-WEI45ONY-TZvlAD74.js → diagram-WEI45ONY-HPCHpafe.js} +2 -2
  61. package/dist/{ebnfDiagram-CCIWWBDH-DgZ7GeJ2.cjs → ebnfDiagram-CCIWWBDH-DhFlIi0a.cjs} +1 -1
  62. package/dist/{ebnfDiagram-CCIWWBDH-CK7wZZmM.js → ebnfDiagram-CCIWWBDH-oLOdtH39.js} +3 -3
  63. package/dist/{erDiagram-Q63AITRT-ByF7VP5D.js → erDiagram-Q63AITRT-CCtzpK78.js} +4 -4
  64. package/dist/{erDiagram-Q63AITRT-C4Tmp1ar.cjs → erDiagram-Q63AITRT-DCCFR1Ai.cjs} +1 -1
  65. package/dist/{extractHeadings-CS-qqdgu.js → extractHeadings-CGJexznE.js} +5148 -5067
  66. package/dist/{extractHeadings-DZwpYYZa.cjs → extractHeadings-lDHB2sBb.cjs} +70 -70
  67. package/dist/flowDiagram-23GEKE2U-ORytlvmX.js +7 -0
  68. package/dist/flowDiagram-23GEKE2U-h2WZTCCn.cjs +1 -0
  69. package/dist/{ganttDiagram-NO4QXBWP-CWaEb7A9.cjs → ganttDiagram-NO4QXBWP-C9RPyo4r.cjs} +1 -1
  70. package/dist/{ganttDiagram-NO4QXBWP-BxYBLrwg.js → ganttDiagram-NO4QXBWP-Dfi3nINO.js} +2 -2
  71. package/dist/{gitGraphDiagram-IHSO6WYX-DinEtmt2.js → gitGraphDiagram-IHSO6WYX-CjAqPhww.js} +3 -3
  72. package/dist/{gitGraphDiagram-IHSO6WYX-Bj41cd84.cjs → gitGraphDiagram-IHSO6WYX-mT3NNT7T.cjs} +1 -1
  73. package/dist/index.cjs +1 -1
  74. package/dist/index.client.cjs +1 -1
  75. package/dist/index.client.d.ts +1 -0
  76. package/dist/index.client.js +1 -1
  77. package/dist/index.js +1 -1
  78. package/dist/index.server.js +7 -7
  79. package/dist/{infoDiagram-FWYZ7A6U-D0pXl2DF.cjs → infoDiagram-FWYZ7A6U-0Co9BitR.cjs} +1 -1
  80. package/dist/{infoDiagram-FWYZ7A6U-Cvu8wgVT.js → infoDiagram-FWYZ7A6U-BXWQ9Vy4.js} +1 -1
  81. package/dist/{ishikawaDiagram-FXEZZL3T-C4ywo5e2.cjs → ishikawaDiagram-FXEZZL3T-BKqUBw1i.cjs} +1 -1
  82. package/dist/{ishikawaDiagram-FXEZZL3T-a_OKoT7W.js → ishikawaDiagram-FXEZZL3T-CZp5P1WE.js} +1 -1
  83. package/dist/{journeyDiagram-5HDEW3XC-Bf5zZtzp.cjs → journeyDiagram-5HDEW3XC-CeumPQ1I.cjs} +1 -1
  84. package/dist/{journeyDiagram-5HDEW3XC-BKYDr_AO.js → journeyDiagram-5HDEW3XC-DYVTgOOE.js} +4 -4
  85. package/dist/{kanban-definition-HUTT4EX6-CRrw6nZl.cjs → kanban-definition-HUTT4EX6-Cg5KnsE9.cjs} +1 -1
  86. package/dist/{kanban-definition-HUTT4EX6-uCk_xnx6.js → kanban-definition-HUTT4EX6-CnleRy80.js} +2 -2
  87. package/dist/{linear-RwkMjaFq.js → linear-Cf8i6Rsk.js} +1 -1
  88. package/dist/{linear-BNrZe-4B.cjs → linear-qqwu6T0F.cjs} +1 -1
  89. package/dist/markdown.css +1 -1
  90. package/dist/{mindmap-definition-LN4V7U3C-CtNh9-A3.cjs → mindmap-definition-LN4V7U3C-DfFWeFph.cjs} +1 -1
  91. package/dist/{mindmap-definition-LN4V7U3C-DLgc7_Ea.js → mindmap-definition-LN4V7U3C-lBin9VOm.js} +3 -3
  92. package/dist/{pegDiagram-2B236MQR-BI08u62h.js → pegDiagram-2B236MQR-BiD21lOj.js} +3 -3
  93. package/dist/{pegDiagram-2B236MQR-gjNvnRzE.cjs → pegDiagram-2B236MQR-Cf1f-3yi.cjs} +1 -1
  94. package/dist/{pieDiagram-ENE6RG2P-CqqtfJsQ.js → pieDiagram-ENE6RG2P-BqZb6gaV.js} +3 -3
  95. package/dist/{pieDiagram-ENE6RG2P-C6mPk_9r.cjs → pieDiagram-ENE6RG2P-jwhVsZgX.cjs} +1 -1
  96. package/dist/{quadrantDiagram-ABIIQ3AL-BAudlbem.js → quadrantDiagram-ABIIQ3AL-CNe9fRLO.js} +2 -2
  97. package/dist/{quadrantDiagram-ABIIQ3AL-k1wF3el0.cjs → quadrantDiagram-ABIIQ3AL-sO_sIA7b.cjs} +1 -1
  98. package/dist/{railroadDiagram-RFXS5EU6-BV-FtI-Y.js → railroadDiagram-RFXS5EU6-53YTkJrs.js} +3 -3
  99. package/dist/{railroadDiagram-RFXS5EU6-qTQnd_2E.cjs → railroadDiagram-RFXS5EU6-Dkc8k3e9.cjs} +1 -1
  100. package/dist/{requirementDiagram-TGXJPOKE-DXxySydn.cjs → requirementDiagram-TGXJPOKE-C0GMlJO4.cjs} +1 -1
  101. package/dist/{requirementDiagram-TGXJPOKE-CSI9iBde.js → requirementDiagram-TGXJPOKE-D8Gz7jzA.js} +3 -3
  102. package/dist/{sankeyDiagram-HTMAVEWB-DU5j0Hpe.cjs → sankeyDiagram-HTMAVEWB-Bw9J2Ay2.cjs} +1 -1
  103. package/dist/{sankeyDiagram-HTMAVEWB-BYAMj1wQ.js → sankeyDiagram-HTMAVEWB-CEC0GaCg.js} +1 -1
  104. package/dist/{sequenceDiagram-DBY2YBRQ-Dbk1YO-l.cjs → sequenceDiagram-DBY2YBRQ-BuqPCreB.cjs} +1 -1
  105. package/dist/{sequenceDiagram-DBY2YBRQ-BruqK1lr.js → sequenceDiagram-DBY2YBRQ-CKb4m3I0.js} +3 -3
  106. package/dist/{sizeCapture-X5ZJPWSS-BSn0u1_t.js → sizeCapture-X5ZJPWSS-CotnTNAA.js} +1 -1
  107. package/dist/{sizeCapture-X5ZJPWSS-qz-hVWx4.cjs → sizeCapture-X5ZJPWSS-Dm3rsxXw.cjs} +1 -1
  108. package/dist/{stateDiagram-2N3HPSRC-CtoTfzmG.cjs → stateDiagram-2N3HPSRC-5Y-OlePe.cjs} +1 -1
  109. package/dist/{stateDiagram-2N3HPSRC-CKh5ZWdm.js → stateDiagram-2N3HPSRC-GWEIP-C9.js} +2 -2
  110. package/dist/{stateDiagram-v2-6OUMAXLB-BmILy7Yi.js → stateDiagram-v2-6OUMAXLB-BZFV8swJ.js} +2 -2
  111. package/dist/{stateDiagram-v2-6OUMAXLB-D9tt3CyI.cjs → stateDiagram-v2-6OUMAXLB-v77D3Qyf.cjs} +1 -1
  112. package/dist/styles/markdown.css +1 -1
  113. package/dist/{swimlanes-5IMT3BWC-CgWWlJUL.cjs → swimlanes-5IMT3BWC-B1hLl8Ph.cjs} +1 -1
  114. package/dist/{swimlanes-5IMT3BWC-8aqGUD9B.js → swimlanes-5IMT3BWC-DujAOwAt.js} +3 -3
  115. package/dist/{swimlanesDiagram-G3AALYLV-0sUz7qWx.js → swimlanesDiagram-G3AALYLV-B-5z3jDg.js} +2 -2
  116. package/dist/{swimlanesDiagram-G3AALYLV-BQL_l0K6.cjs → swimlanesDiagram-G3AALYLV-Cklgsxbg.cjs} +1 -1
  117. package/dist/{timeline-definition-FHXFAJF6-CnMWGedg.cjs → timeline-definition-FHXFAJF6-B2m-aQLI.cjs} +1 -1
  118. package/dist/{timeline-definition-FHXFAJF6-Cps3CVTR.js → timeline-definition-FHXFAJF6-Fmzt_lvR.js} +2 -2
  119. package/dist/{vennDiagram-L72KCM5P-Duki5CI_.cjs → vennDiagram-L72KCM5P-rL7UDYbl.cjs} +1 -1
  120. package/dist/{vennDiagram-L72KCM5P-C3u6VbZv.js → vennDiagram-L72KCM5P-zIXK42Cx.js} +1 -1
  121. package/dist/{wardleyDiagram-EHGQE667-DiefhIvI.cjs → wardleyDiagram-EHGQE667-CNLieFen.cjs} +1 -1
  122. package/dist/{wardleyDiagram-EHGQE667-CKNXRrYV.js → wardleyDiagram-EHGQE667-pTeeZ0uM.js} +2 -2
  123. package/dist/{xychartDiagram-FW5EYKEG-lymeWtXL.js → xychartDiagram-FW5EYKEG-B6UdSSVZ.js} +2 -2
  124. package/dist/{xychartDiagram-FW5EYKEG-DGB2SKXi.cjs → xychartDiagram-FW5EYKEG-CD5ik4HK.cjs} +1 -1
  125. package/package.json +8 -7
  126. package/dist/flowDiagram-23GEKE2U-BPhnjQfA.cjs +0 -1
  127. package/dist/flowDiagram-23GEKE2U-UIracYlJ.js +0 -7
package/README.md CHANGED
@@ -126,7 +126,7 @@ const parseResult = await parseMarkdown(
126
126
  deniedPathSegments: hostDenyRules, // required; [] denies nothing
127
127
  maxHtmlBytes: 4 * 1024 * 1024, // required; the largest HTML in bytes
128
128
  resolveImports: false, // expand <!-- @import "path" --> (default false)
129
- validateExistence: true, // mark missing local images and doc links (default true)
129
+ validateExistence: true, // probe local images and doc links (data-asset-exists / data-doc-exists; default true)
130
130
  signal: controller.signal, // cancels the conversion in the service too
131
131
  timeoutMs: 10_000, // the conversion's deadline
132
132
  enableSubscript: false, // Disable subscript (leaves ~2~ as plain text)
@@ -144,18 +144,26 @@ const parseResult = await parseMarkdown(
144
144
  | `deniedPathSegments` | ✅ | Deny rules applied to every target the conversion resolves: `@import` targets, images and links. A pattern matches one whole path segment (`*` matches any run of characters within it), compared after NFKC normalization and case folding at every percent-decoding level (the semantics of `@aiquants/markdown-explorer`'s deny rules). Local targets must also stay inside `workspaceRoot`, also once symbolic links are resolved. A refused image renders without `src`, a refused link without a destination (with `validateExistence`, both are marked like a missing target, whether or not the target exists), and a refused import rejects the call. |
145
145
  | `maxHtmlBytes` | ✅ | The largest HTML in bytes, a positive integer up to `MAX_HTML_BYTES_LIMIT`. The service stops while it renders and the call rejects with `MarkdownResourceExhaustedError`; the response the call accepts is bounded by twice this plus 64 KiB. |
146
146
  | `resolveImports` | | Expand `<!-- @import "path" -->` directives (default `false`: a directive stays an HTML comment and nothing is read). Only Markdown (`.md`) targets the deny rules admit are read, nested imports included; a refused target rejects the call with `permission_denied`. |
147
- | `validateExistence` | | Mark missing local images (`data-asset-exists="false"`, `data-asset-src`) and doc links (`data-doc-exists`) (default `true`). |
147
+ | `validateExistence` | | Probe local targets (default `true`): a local storage image also gets `data-asset-exists` (`"true"` or `"false"`) and a local doc link `data-doc-exists` (`"true"` or `"false"`). Cloud targets are never probed, and `data-asset-src` is written for every admitted storage image either way. |
148
148
  | `signal` | | Cancels the call; the service stops converting. |
149
149
  | `timeoutMs` | | The conversion's deadline in milliseconds (a positive integer); the service stops at it or at `MARKDOWN_CONVERT_TIMEOUT`, whichever comes first. |
150
150
  | `enable*` | | Switch the syntax extensions and HTML plugins (each enabled unless `false`). The text plugins leave `summary` text (a `:::details` title included) as written. |
151
151
 
152
152
  Invalid options throw `TypeError` / `RangeError` before any request. A conversion stopped at a size limit (the HTML limit, the service's source limit or a message limit) rejects with `MarkdownResourceExhaustedError` (its `cause` is the connect error); every other failure rejects with the `ConnectError` of the service (`invalid_argument`, `permission_denied`, `canceled`, `deadline_exceeded`, `internal`).
153
153
 
154
- ### Local image URLs
154
+ ### Image and link targets
155
155
 
156
+ The converter writes document paths, never URLs, so a host decides how its files are served.
156
157
  An image destination is a URL decoded once: `![](a%2541.png)` names the file `a%41.png`, while `![](a%41.png)` names `aA.png` (a `%` not followed by two hexadecimal digits, as in `100%.png`, may be written as it is).
157
- A local image's `src` is `/assets/` followed by its path from `workspaceRoot`, written as `@aiquants/markdown-explorer`'s README asks of an asset URL ("Serving images and media"): each path segment percent-encoded after every `%` is written as `%25`, and a final `.data` written as `%2Edata` (`資料/進捗100%.png` becomes `/assets/%E8%B3%87%E6%96%99/%E9%80%B2%E6%8D%97100%2525.png`, `x.data` becomes `/assets/x%2Edata`).
158
- Serve `/assets/*` from a route that decodes the path once and then turns only `%25` back into `%` (in a React Router splat route, replace `%25` with `%` in the splat React Router has decoded); every file name then arrives unchanged.
158
+
159
+ - **Storage images** (a local file inside `workspaceRoot`, or a `gcs://` / `gdrive://` object) have no `src`. Their document path is in `data-asset-src`, unescaped: the path from `workspaceRoot` for a local file (`資料/進捗100%.png`, `x.data`), the URI decoded once for a cloud object (`gcs://bucket/reports/fig 1.png`). The host writes the `src` from it, encoding the path for its own route; no URL is signed.
160
+ - **Existence**: with `validateExistence`, a local storage image also carries `data-asset-exists` (`"true"` or `"false"`); a cloud image is never probed.
161
+ - **Refused targets** (the deny rules, or outside `workspaceRoot`) have neither a `src` nor `data-asset-src`; with `validateExistence` they carry `data-asset-exists="false"` whether or not they exist.
162
+ - **Storage links** are `data-link-kind="doc"`: they keep the authored `href` (its fragment is what a host reads) and carry the document path in `data-doc-path`; a local one also gets `data-doc-exists` under `validateExistence`.
163
+ - `data-asset-src` and `data-asset-exists` come only from the converter: markers written in the document's raw HTML or by an HTML plugin are removed.
164
+ - Of an element's duplicate attributes only the first counts, as in a browser: the converter drops the rest, so the HTML carries no duplicate attribute and a repeated `src` or marker cannot make the converter and the browser read different values.
165
+
166
+ `MarkdownRenderer` shows an image without a `src` (or with `data-asset-exists="false"`) as a placeholder naming its `data-asset-src`, so HTML rendered before the host wrote the URLs shows which files are missing instead of blank space.
159
167
 
160
168
  ## Viewer, embeds and links
161
169
 
@@ -203,7 +211,7 @@ Every renderer of the package — `MarkdownRenderer` (and so `MarkdownViewer`) f
203
211
 
204
212
  ### Links
205
213
 
206
- - A link is external when its `href` names a scheme in any case (`https:`, `HTTPS:`, `mailto:`) or another host (`//host/…`, `/\host/…`), whatever its `data-link-kind` says (only `asset` links, the converter's storage objects, may carry an absolute URL and stay with `linkComponent`), and when `data-link-kind` is `external`. An external link opens in a new tab with `rel="noreferrer"` and is never handed to `linkComponent`. The author's `target` and `rel` never survive.
214
+ - A link is external when its `href` names a scheme in any case (`https:`, `HTTPS:`, `mailto:`) or another host (`//host/…`, `/\host/…`), whatever its `data-link-kind` says, and when `data-link-kind` is `external`. An external link opens in a new tab with `rel="noreferrer"` and is never handed to `linkComponent`. The author's `target` and `rel` never survive.
207
215
  - `linkComponent` receives `href`, `kind`, `docPath`, `docExists`, `className`, `children` and `attributes`: the link's `id`, `title`, `lang`, `dir`, `role`, `aria-*` and `data-footnote-*` (event handlers, `style` and `href`-like attributes never pass). Spread `attributes` onto the anchor you render so footnote references keep their `id` and `aria-describedby` and back-references keep their `aria-label`:
208
216
 
209
217
  ```tsx
@@ -216,6 +224,31 @@ const AppLink = ({ href, className, attributes, children }: MarkdownLinkProps) =
216
224
 
217
225
  - Only a link that wraps an image or block content is laid out as a box (`inline-block`); a link around text stays inline, so a footnote reference inside `<sup>` keeps the height of its glyphs and shows its focus ring.
218
226
 
227
+ ### Content column and alignment
228
+
229
+ `MarkdownViewer` lays the document out in one column, `[data-aqmd-content]`, inside the scroll container's padding:
230
+
231
+ | Prop | Effect |
232
+ | --- | --- |
233
+ | `width` | The column's CSS `width`. Unset, the column is `100%` wide: the full width of the scroll container's track, whatever the content, so a short document and a diagram drawn at the column's width get the whole width |
234
+ | `maxWidth` | The column's CSS `max-width` (`"1200px"`, `"min(1200px, 100%)"` …). Unset, nothing caps the column beyond `width` |
235
+ | `align` | Places a column narrower than the track: `left` (`margin-inline: 0 auto`), `center` (`auto`) or `right` (`auto 0`). It shows only when `width` or `maxWidth` makes the column narrower than the track |
236
+
237
+ The alignment button needs `onAlignChange`, `showAlign` (on by default) and a `width` or `maxWidth`. Without either of the two, the column fills the track and no alignment can move it, so the viewer does not render the button, whatever `showAlign` says.
238
+
239
+ With the `GitHub` and `Zenn` styles of `DEFAULT_MARKDOWN_STYLES`, a wide table or a long code line scrolls inside its own box. Content with a fixed width wider than the column, such as an embedded `<iframe>` whose `width` attribute exceeds it, overflows the column, and so does any wide content under the `None` style, which loads no stylesheet; the scroll container then scrolls sideways.
240
+
241
+ ### Mermaid diagrams
242
+
243
+ A fenced code block in the `mermaid` language renders as `MermaidDiagram`, a block that takes its containing block's width (its slot). The slot's first child is a hidden measuring element, `[data-aqmd-mermaid-measure]` (no height, clipped, `visibility: hidden`, `aria-hidden`), present while the diagram loads, shows or fails; the component measures the slot's width with it.
244
+ Each drawing gets its own drawing host, `[data-aqmd-mermaid-host]`: a hidden element (`visibility: hidden`, `aria-hidden`, absolutely positioned just outside the start edge, `contain: strict`) appended to the main document's `<body>`, with its width set to the measured width in px.
245
+ Mermaid draws in that element and the component shows the result in the slot, so a gantt chart, whose width Mermaid takes from where it is drawn, is exactly as wide as the slot. Because Mermaid looks its drawing up through the main document, the host lives in the main document's light DOM, and a diagram in a slot inside a shadow root is drawn the same way.
246
+
247
+ - The component removes a drawing host when its drawing settles (shown, failed, or discarded as stale) and when the component unmounts or its text changes, so none is left behind, not even the error drawing Mermaid leaves for a text it cannot parse.
248
+ - Nothing is drawn while the slot has no width (inside a closed `<details>` the browser does not lay out, or a hidden panel): the loading text stays until the slot gets a width. A drawing already under way when the slot loses its width finishes at the width it was given.
249
+ - When the width of a slot showing a gantt chart changes (a splitter drag, a window resize), the chart is drawn again at the new width 200 ms after the last change, unless the slot then has no width or the width of the latest drawing. The shown chart stays until the new one replaces it, and the new one starts at the initial zoom and pan. Other diagram types take their size from their text and are never drawn again for a width change.
250
+ - A drawing that finishes after a newer one started, after the diagram's text changed or after the component unmounted is discarded.
251
+
219
252
  ### Viewer toolbar
220
253
 
221
254
  `MarkdownViewer` shows its alignment, style and table-of-contents buttons as one fixed row, in that visual and tab order, spaced in `rem` so they never overlap at large text sizes. Place the row with two package-scoped custom properties, both `0px` unless set:
@@ -296,7 +329,9 @@ The parser supports the following extended markdown syntax in addition to Common
296
329
 
297
330
  ### LaTeX Math Expressions
298
331
 
299
- - Inline math: `$y=x^2$`
332
+ - Inline math: `$y=x^2$`. A single `$` follows the `tex_math_dollars` rule of Pandoc 3.12: the opening `$` must be followed by a character that is not white space, and the formula ends at the first `$` after it that is not escaped by `\` and not inside a `\text{…}` group whose braces close; that `$` must follow a character that is not white space (a character escaped by `\`, such as the space in `$a\ $`, is not) and must not be followed by an ASCII digit; otherwise the `$` stays text.
333
+ Stricter than Pandoc, white space is Unicode's (the ideographic space included) and a `$` at the start of a line never closes. So `$20,000 and $30,000`, `$100〜$200`, `$HOME and $PATH` and `$ x $` are text, while `$x$`, `$a\$b$`, `$a\ $` and `$\text{for all $x$}$` are formulas; write a literal dollar as `\$` or inside a code span.
334
+ - Within a line of text, `$$ … $$` is inline math too (`Cost $$ x $$ here` is the formula `x`): it ends at the next run of as many `$`, with white space allowed inside its ends. An inline formula may continue on the paragraph's next line.
300
335
  - Display math: a multi-line block, or a whole line `$$ e^{i\theta} = \cos\theta + i\sin\theta $$` (at most three spaces of indentation; it can follow a paragraph line directly). Both forms render the same. Inside code blocks the lines stay code.
301
336
  - A multi-line block opens on a line of two or more `$` whose rest holds no `$` (that rest is not part of the formula) and closes on a line of two or more `$` alone. Any other `$$ … $$` — within a line of text, or followed by more text on its line (`$$E=mc^2$$.`) — is inline math in its paragraph.
302
337
  - A formula reaches KaTeX exactly as written: `0<x<1`, `a & b`, quotes and `x^2 + y^2` included (the converter escapes the formula's text once, the viewer reads the text back once, and the subscript, superscript and highlight syntax never applies inside a formula).
@@ -307,6 +342,20 @@ e^{i\theta} = \cos\theta + i\sin\theta
307
342
  $$
308
343
  ```
309
344
 
345
+ Every renderer (`MarkdownRenderer`, `MarkdownViewer`, `NodesRenderer`) renders a formula with the same KaTeX options: `throwOnError: false` (an invalid formula shows its source in red) and display math in display mode.
346
+ Nothing KaTeX says about a formula reaches the console, in the browser or on the server: its reports about LaTeX-incompatible input that still renders (a text-mode accent such as `\r` in math mode, an unknown symbol, `\\` in display math), its warning about a character its fonts have no metrics for (※, ①, ★, €, an emoji: code `noCharacterMetrics`), and the TeX console commands `\message`, `\errmessage` and `\show`, which render nothing (code `consoleCommand`).
347
+ `MarkdownRenderer` and `MarkdownViewer` hand them to `onMathDiagnostics` as `MarkdownMathDiagnostic` objects (`{ code, message, formula, displayMode }`): after the commit, once per document, and only when there is one; the viewer's function may change on any render without the document being parsed again.
348
+ Japanese or other non-Latin letters inside a formula (`\frac{売上}{原価}`) are not reported, since KaTeX renders them as written; `\text{…}` is the LaTeX way to write words inside a formula.
349
+
350
+ ```tsx
351
+ <MarkdownViewer
352
+ {...props}
353
+ onMathDiagnostics={(diagnostics) => {
354
+ for (const { code, message, formula } of diagnostics) logger.debug(`[math] ${code}: ${message} — ${formula}`)
355
+ }}
356
+ />
357
+ ```
358
+
310
359
  ### GitHub Alerts
311
360
 
312
361
  ```markdown
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./chunk-MOJQB5TN-vnYqNQhm.cjs"),u=require("./chunk-JWPE2WC7-BTz8xxEq.cjs"),n=require("./extractHeadings-DZwpYYZa.cjs"),i=require("./cynefin-VYW2F7L2-MpAliYy9.cjs");var p=i.createRailroadAbnfServices().RailroadAbnf.parser.LangiumParser,o=n.__name(e=>{const r=e.alternatives.map(c);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),c=n.__name(e=>{const r=e.elements.map(d);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),f=n.__name(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),d=n.__name(e=>{const r=b(e.primary);if(!e.repeat)return r;const{min:t,max:s}=f(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),b=n.__name(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return o(e.element);case"AbnfOptionalGroup":return{type:"optional",element:o(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),g=n.__name(e=>({name:e.name,definition:o(e.definition)}),"transformRule"),v=n.__name(e=>{u.populateCommonDb(e,a.db),e.title&&a.db.setTitle(e.title),e.rules.map(r=>a.db.addRule(g(r)))},"populateDb"),y={parse:n.__name(e=>{a.db.clear(),n.log.debug("[ABNF Parser] Starting Langium parse");const r=p.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new i.MermaidParseError(r);const t=r.value;n.log.debug("[ABNF Parser] Parsed rules:",t.rules.length),v(t),n.log.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a.db}},_={parser:y,db:a.db,renderer:a.renderer,styles:a.getStyles};exports.diagram=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./chunk-MOJQB5TN-Cw864mUL.cjs"),u=require("./chunk-JWPE2WC7-5cM5nFf6.cjs"),n=require("./extractHeadings-lDHB2sBb.cjs"),i=require("./cynefin-VYW2F7L2-MpAliYy9.cjs");var p=i.createRailroadAbnfServices().RailroadAbnf.parser.LangiumParser,o=n.__name(e=>{const r=e.alternatives.map(c);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),c=n.__name(e=>{const r=e.elements.map(d);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),f=n.__name(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),d=n.__name(e=>{const r=b(e.primary);if(!e.repeat)return r;const{min:t,max:s}=f(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),b=n.__name(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return o(e.element);case"AbnfOptionalGroup":return{type:"optional",element:o(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),g=n.__name(e=>({name:e.name,definition:o(e.definition)}),"transformRule"),v=n.__name(e=>{u.populateCommonDb(e,a.db),e.title&&a.db.setTitle(e.title),e.rules.map(r=>a.db.addRule(g(r)))},"populateDb"),y={parse:n.__name(e=>{a.db.clear(),n.log.debug("[ABNF Parser] Starting Langium parse");const r=p.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new i.MermaidParseError(r);const t=r.value;n.log.debug("[ABNF Parser] Parsed rules:",t.rules.length),v(t),n.log.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a.db}},_={parser:y,db:a.db,renderer:a.renderer,styles:a.getStyles};exports.diagram=_;
@@ -1,6 +1,6 @@
1
- import { g as p, r as u, d as a } from "./chunk-MOJQB5TN-DngSrRvI.js";
2
- import { p as f } from "./chunk-JWPE2WC7-Cr_-c4Em.js";
3
- import { _ as n, $ as o } from "./extractHeadings-CS-qqdgu.js";
1
+ import { g as p, r as u, d as a } from "./chunk-MOJQB5TN-D_h6bolU.js";
2
+ import { p as f } from "./chunk-JWPE2WC7-DpcSSOP5.js";
3
+ import { _ as n, $ as o } from "./extractHeadings-CGJexznE.js";
4
4
  import { M as c, b as d } from "./cynefin-VYW2F7L2-Bkk-F_Js.js";
5
5
  var v = d().RailroadAbnf.parser.LangiumParser, i = /* @__PURE__ */ n((e) => {
6
6
  const r = e.alternatives.map(g);
@@ -1,4 +1,4 @@
1
- import { aK as ln, aL as an, aM as y, aN as tn, aO as V, aP as O, aQ as _, aR as un, aS as rn, aT as Y, aU as o, aV as M, aW as sn, aX as on, aY as fn } from "./extractHeadings-CS-qqdgu.js";
1
+ import { aK as ln, aL as an, aM as y, aN as tn, aO as V, aP as O, aQ as _, aR as un, aS as rn, aT as Y, aU as o, aV as M, aW as sn, aX as on, aY as fn } from "./extractHeadings-CGJexznE.js";
2
2
  function cn(l) {
3
3
  return l.innerRadius;
4
4
  }
@@ -1 +1 @@
1
- "use strict";const n=require("./extractHeadings-DZwpYYZa.cjs");function $(o){return o.innerRadius}function b(o){return o.outerRadius}function k(o){return o.startAngle}function _(o){return o.endAngle}function nn(o){return o&&o.padAngle}function en(o,x,D,P,h,v,S,s){var E=D-o,r=P-x,e=S-h,p=s-v,i=p*E-e*r;if(!(i*i<n.epsilon))return i=(e*(x-v)-p*(o-h))/i,[o+i*E,x+i*r]}function M(o,x,D,P,h,v,S){var s=o-D,E=x-P,r=(S?v:-v)/n.sqrt(s*s+E*E),e=r*E,p=-r*s,i=o+e,u=x+p,c=D+e,f=P+p,j=(i+c)/2,l=(u+f)/2,y=c-i,g=f-u,A=y*y+g*g,R=h-v,T=i*f-c*u,H=(g<0?-1:1)*n.sqrt(n.max(0,R*R*A-T*T)),I=(T*g-y*H)/A,O=(-T*y-g*H)/A,q=(T*g+y*H)/A,d=(-T*y+g*H)/A,m=I-j,a=O-l,t=q-j,z=d-l;return m*m+a*a>t*t+z*z&&(I=q,O=d),{cx:I,cy:O,x01:-e,y01:-p,x11:I*(h/R-1),y11:O*(h/R-1)}}function an(){var o=$,x=b,D=n.constant(0),P=null,h=k,v=_,S=nn,s=null,E=n.withPath(r);function r(){var e,p,i=+o.apply(this,arguments),u=+x.apply(this,arguments),c=h.apply(this,arguments)-n.halfPi,f=v.apply(this,arguments)-n.halfPi,j=n.abs(f-c),l=f>c;if(s||(s=e=E()),u<i&&(p=u,u=i,i=p),!(u>n.epsilon))s.moveTo(0,0);else if(j>n.tau-n.epsilon)s.moveTo(u*n.cos(c),u*n.sin(c)),s.arc(0,0,u,c,f,!l),i>n.epsilon&&(s.moveTo(i*n.cos(f),i*n.sin(f)),s.arc(0,0,i,f,c,l));else{var y=c,g=f,A=c,R=f,T=j,H=j,I=S.apply(this,arguments)/2,O=I>n.epsilon&&(P?+P.apply(this,arguments):n.sqrt(i*i+u*u)),q=n.min(n.abs(u-i)/2,+D.apply(this,arguments)),d=q,m=q,a,t;if(O>n.epsilon){var z=n.asin(O/i*n.sin(I)),F=n.asin(O/u*n.sin(I));(T-=z*2)>n.epsilon?(z*=l?1:-1,A+=z,R-=z):(T=0,A=R=(c+f)/2),(H-=F*2)>n.epsilon?(F*=l?1:-1,y+=F,g-=F):(H=0,y=g=(c+f)/2)}var B=u*n.cos(y),C=u*n.sin(y),G=i*n.cos(R),J=i*n.sin(R);if(q>n.epsilon){var K=u*n.cos(g),L=u*n.sin(g),N=i*n.cos(A),Q=i*n.sin(A),w;if(j<n.pi)if(w=en(B,C,N,Q,K,L,G,J)){var U=B-w[0],V=C-w[1],W=K-w[0],X=L-w[1],Y=1/n.sin(n.acos((U*W+V*X)/(n.sqrt(U*U+V*V)*n.sqrt(W*W+X*X)))/2),Z=n.sqrt(w[0]*w[0]+w[1]*w[1]);d=n.min(q,(i-Z)/(Y-1)),m=n.min(q,(u-Z)/(Y+1))}else d=m=0}H>n.epsilon?m>n.epsilon?(a=M(N,Q,B,C,u,m,l),t=M(K,L,G,J,u,m,l),s.moveTo(a.cx+a.x01,a.cy+a.y01),m<q?s.arc(a.cx,a.cy,m,n.atan2(a.y01,a.x01),n.atan2(t.y01,t.x01),!l):(s.arc(a.cx,a.cy,m,n.atan2(a.y01,a.x01),n.atan2(a.y11,a.x11),!l),s.arc(0,0,u,n.atan2(a.cy+a.y11,a.cx+a.x11),n.atan2(t.cy+t.y11,t.cx+t.x11),!l),s.arc(t.cx,t.cy,m,n.atan2(t.y11,t.x11),n.atan2(t.y01,t.x01),!l))):(s.moveTo(B,C),s.arc(0,0,u,y,g,!l)):s.moveTo(B,C),!(i>n.epsilon)||!(T>n.epsilon)?s.lineTo(G,J):d>n.epsilon?(a=M(G,J,K,L,i,-d,l),t=M(B,C,N,Q,i,-d,l),s.lineTo(a.cx+a.x01,a.cy+a.y01),d<q?s.arc(a.cx,a.cy,d,n.atan2(a.y01,a.x01),n.atan2(t.y01,t.x01),!l):(s.arc(a.cx,a.cy,d,n.atan2(a.y01,a.x01),n.atan2(a.y11,a.x11),!l),s.arc(0,0,i,n.atan2(a.cy+a.y11,a.cx+a.x11),n.atan2(t.cy+t.y11,t.cx+t.x11),l),s.arc(t.cx,t.cy,d,n.atan2(t.y11,t.x11),n.atan2(t.y01,t.x01),!l))):s.arc(0,0,i,R,A,l)}if(s.closePath(),e)return s=null,e+""||null}return r.centroid=function(){var e=(+o.apply(this,arguments)+ +x.apply(this,arguments))/2,p=(+h.apply(this,arguments)+ +v.apply(this,arguments))/2-n.pi/2;return[n.cos(p)*e,n.sin(p)*e]},r.innerRadius=function(e){return arguments.length?(o=typeof e=="function"?e:n.constant(+e),r):o},r.outerRadius=function(e){return arguments.length?(x=typeof e=="function"?e:n.constant(+e),r):x},r.cornerRadius=function(e){return arguments.length?(D=typeof e=="function"?e:n.constant(+e),r):D},r.padRadius=function(e){return arguments.length?(P=e==null?null:typeof e=="function"?e:n.constant(+e),r):P},r.startAngle=function(e){return arguments.length?(h=typeof e=="function"?e:n.constant(+e),r):h},r.endAngle=function(e){return arguments.length?(v=typeof e=="function"?e:n.constant(+e),r):v},r.padAngle=function(e){return arguments.length?(S=typeof e=="function"?e:n.constant(+e),r):S},r.context=function(e){return arguments.length?(s=e??null,r):s},r}exports.d3arc=an;
1
+ "use strict";const n=require("./extractHeadings-lDHB2sBb.cjs");function $(o){return o.innerRadius}function b(o){return o.outerRadius}function k(o){return o.startAngle}function _(o){return o.endAngle}function nn(o){return o&&o.padAngle}function en(o,x,D,P,h,v,S,s){var E=D-o,r=P-x,e=S-h,p=s-v,i=p*E-e*r;if(!(i*i<n.epsilon))return i=(e*(x-v)-p*(o-h))/i,[o+i*E,x+i*r]}function M(o,x,D,P,h,v,S){var s=o-D,E=x-P,r=(S?v:-v)/n.sqrt(s*s+E*E),e=r*E,p=-r*s,i=o+e,u=x+p,c=D+e,f=P+p,j=(i+c)/2,l=(u+f)/2,y=c-i,g=f-u,A=y*y+g*g,R=h-v,T=i*f-c*u,H=(g<0?-1:1)*n.sqrt(n.max(0,R*R*A-T*T)),I=(T*g-y*H)/A,O=(-T*y-g*H)/A,q=(T*g+y*H)/A,d=(-T*y+g*H)/A,m=I-j,a=O-l,t=q-j,z=d-l;return m*m+a*a>t*t+z*z&&(I=q,O=d),{cx:I,cy:O,x01:-e,y01:-p,x11:I*(h/R-1),y11:O*(h/R-1)}}function an(){var o=$,x=b,D=n.constant(0),P=null,h=k,v=_,S=nn,s=null,E=n.withPath(r);function r(){var e,p,i=+o.apply(this,arguments),u=+x.apply(this,arguments),c=h.apply(this,arguments)-n.halfPi,f=v.apply(this,arguments)-n.halfPi,j=n.abs(f-c),l=f>c;if(s||(s=e=E()),u<i&&(p=u,u=i,i=p),!(u>n.epsilon))s.moveTo(0,0);else if(j>n.tau-n.epsilon)s.moveTo(u*n.cos(c),u*n.sin(c)),s.arc(0,0,u,c,f,!l),i>n.epsilon&&(s.moveTo(i*n.cos(f),i*n.sin(f)),s.arc(0,0,i,f,c,l));else{var y=c,g=f,A=c,R=f,T=j,H=j,I=S.apply(this,arguments)/2,O=I>n.epsilon&&(P?+P.apply(this,arguments):n.sqrt(i*i+u*u)),q=n.min(n.abs(u-i)/2,+D.apply(this,arguments)),d=q,m=q,a,t;if(O>n.epsilon){var z=n.asin(O/i*n.sin(I)),F=n.asin(O/u*n.sin(I));(T-=z*2)>n.epsilon?(z*=l?1:-1,A+=z,R-=z):(T=0,A=R=(c+f)/2),(H-=F*2)>n.epsilon?(F*=l?1:-1,y+=F,g-=F):(H=0,y=g=(c+f)/2)}var B=u*n.cos(y),C=u*n.sin(y),G=i*n.cos(R),J=i*n.sin(R);if(q>n.epsilon){var K=u*n.cos(g),L=u*n.sin(g),N=i*n.cos(A),Q=i*n.sin(A),w;if(j<n.pi)if(w=en(B,C,N,Q,K,L,G,J)){var U=B-w[0],V=C-w[1],W=K-w[0],X=L-w[1],Y=1/n.sin(n.acos((U*W+V*X)/(n.sqrt(U*U+V*V)*n.sqrt(W*W+X*X)))/2),Z=n.sqrt(w[0]*w[0]+w[1]*w[1]);d=n.min(q,(i-Z)/(Y-1)),m=n.min(q,(u-Z)/(Y+1))}else d=m=0}H>n.epsilon?m>n.epsilon?(a=M(N,Q,B,C,u,m,l),t=M(K,L,G,J,u,m,l),s.moveTo(a.cx+a.x01,a.cy+a.y01),m<q?s.arc(a.cx,a.cy,m,n.atan2(a.y01,a.x01),n.atan2(t.y01,t.x01),!l):(s.arc(a.cx,a.cy,m,n.atan2(a.y01,a.x01),n.atan2(a.y11,a.x11),!l),s.arc(0,0,u,n.atan2(a.cy+a.y11,a.cx+a.x11),n.atan2(t.cy+t.y11,t.cx+t.x11),!l),s.arc(t.cx,t.cy,m,n.atan2(t.y11,t.x11),n.atan2(t.y01,t.x01),!l))):(s.moveTo(B,C),s.arc(0,0,u,y,g,!l)):s.moveTo(B,C),!(i>n.epsilon)||!(T>n.epsilon)?s.lineTo(G,J):d>n.epsilon?(a=M(G,J,K,L,i,-d,l),t=M(B,C,N,Q,i,-d,l),s.lineTo(a.cx+a.x01,a.cy+a.y01),d<q?s.arc(a.cx,a.cy,d,n.atan2(a.y01,a.x01),n.atan2(t.y01,t.x01),!l):(s.arc(a.cx,a.cy,d,n.atan2(a.y01,a.x01),n.atan2(a.y11,a.x11),!l),s.arc(0,0,i,n.atan2(a.cy+a.y11,a.cx+a.x11),n.atan2(t.cy+t.y11,t.cx+t.x11),l),s.arc(t.cx,t.cy,d,n.atan2(t.y11,t.x11),n.atan2(t.y01,t.x01),!l))):s.arc(0,0,i,R,A,l)}if(s.closePath(),e)return s=null,e+""||null}return r.centroid=function(){var e=(+o.apply(this,arguments)+ +x.apply(this,arguments))/2,p=(+h.apply(this,arguments)+ +v.apply(this,arguments))/2-n.pi/2;return[n.cos(p)*e,n.sin(p)*e]},r.innerRadius=function(e){return arguments.length?(o=typeof e=="function"?e:n.constant(+e),r):o},r.outerRadius=function(e){return arguments.length?(x=typeof e=="function"?e:n.constant(+e),r):x},r.cornerRadius=function(e){return arguments.length?(D=typeof e=="function"?e:n.constant(+e),r):D},r.padRadius=function(e){return arguments.length?(P=e==null?null:typeof e=="function"?e:n.constant(+e),r):P},r.startAngle=function(e){return arguments.length?(h=typeof e=="function"?e:n.constant(+e),r):h},r.endAngle=function(e){return arguments.length?(v=typeof e=="function"?e:n.constant(+e),r):v},r.padAngle=function(e){return arguments.length?(S=typeof e=="function"?e:n.constant(+e),r):S},r.context=function(e){return arguments.length?(s=e??null,r):s},r}exports.d3arc=an;